Skip to content

Commit e86d487

Browse files
committed
feat: liquid glass!
1 parent 673695d commit e86d487

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

Giffy/App/MainApp.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct MainApp: App {
1616

1717
init() {
1818
Font.loadAllFonts()
19+
NFX.sharedInstance().start()
1920
}
2021

2122
var body: some Scene {

Modules/CommonUI/CommonUI/Sources/CommonUI/ReusableViews/Blur.swift

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,48 @@
88
import Foundation
99
import SwiftUI
1010

11-
public struct Blur: UIViewRepresentable {
11+
public struct Blur: View {
1212
@State var style: UIBlurEffect.Style = .systemMaterial
13+
var interactive: Bool = false
1314

14-
public init(style: UIBlurEffect.Style) {
15+
public init(style: UIBlurEffect.Style = .systemMaterial, interactive: Bool = true) {
16+
self.style = style
17+
self.interactive = interactive
18+
}
19+
20+
public var body: some View {
21+
if #available(iOS 26.0, *) {
22+
// Use SwiftUI glass effect for iOS 26+
23+
Rectangle()
24+
.fill(.clear)
25+
.glassEffect(interactive ? .clear.interactive() : .clear, in: .rect)
26+
} else {
27+
// Fallback to UIViewRepresentable for older iOS
28+
LegacyBlur(style: style)
29+
}
30+
}
31+
}
32+
33+
// Backward compatible UIViewRepresentable implementation
34+
public struct LegacyBlur: UIViewRepresentable {
35+
@State var style: UIBlurEffect.Style = .systemMaterial
36+
37+
public init(style: UIBlurEffect.Style = .systemMaterial) {
1538
self.style = style
1639
}
1740

1841
public func makeUIView(context: Context) -> UIVisualEffectView {
19-
return UIVisualEffectView(effect: UIBlurEffect(style: style))
42+
let blurEffect = UIBlurEffect(style: style)
43+
let blurView = UIVisualEffectView(effect: blurEffect)
44+
45+
// Enhanced styling for liquid glass appearance on older iOS
46+
blurView.backgroundColor = UIColor.white.withAlphaComponent(0.1)
47+
48+
// Subtle border for glass definition
49+
blurView.layer.borderWidth = 0.5
50+
blurView.layer.borderColor = UIColor.white.withAlphaComponent(0.2).cgColor
51+
52+
return blurView
2053
}
2154

2255
public func updateUIView(_ uiView: UIVisualEffectView, context: Context) {

Modules/CommonUI/CommonUI/Sources/CommonUI/ReusableViews/OneDialog.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import SwiftUI
99

1010
private enum DialogConstants {
11-
static let radius: CGFloat = 26
11+
static let radius: CGFloat = 40
1212
static let indicatorHeight: CGFloat = 6
1313
static let indicatorWidth: CGFloat = 60
1414
static let snapRatio: CGFloat = 0.25
@@ -49,14 +49,9 @@ public struct OneDialog<Content: View>: View {
4949
}
5050
.frame(width: geometry.size.width, alignment: .top)
5151
.background(
52-
Color.black.shadow(
53-
color: Color.black.opacity(0.25),
54-
radius: 4,
55-
x: 0,
56-
y: 4
57-
)
52+
Blur(style: .systemUltraThinMaterialLight, interactive: false)
5853
)
59-
.cornerRadius(DialogConstants.radius)
54+
.clipShape(.rect(cornerRadius: DialogConstants.radius))
6055
.frame(height: geometry.size.height, alignment: .bottom)
6156
.offset(y: max(offset + translation, 0))
6257
.animation(.interactiveSpring(duration: 0.5), value: isOpen)
@@ -92,11 +87,6 @@ struct DialogModifier<DialogContent: View>: ViewModifier {
9287
func body(content: Content) -> some View {
9388
ZStack {
9489
content
95-
.overlay(
96-
Color.black
97-
.opacity(isShown ? 0.5 : 0)
98-
.edgesIgnoringSafeArea(.vertical)
99-
)
10090
.onTapGesture {
10191
if shouldDismissOnTapOutside {
10292
isShown = false

0 commit comments

Comments
 (0)