Skip to content

Commit 2ba4bad

Browse files
committed
Improve SamplesSwiftUI
1 parent 913cd1b commit 2ba4bad

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

Examples/SamplesSwiftUI/SamplesSwiftUI/UseCases/MainView.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,19 @@ struct MainView: View {
5858
case .list:
5959
ContentView(proxy: proxy)
6060
case .detail:
61-
VStack {
62-
Text("off")
63-
.padding(.top, 32)
61+
HStack {
62+
Spacer()
63+
VStack {
64+
Text("Detail content")
65+
.padding(.top, 32)
66+
Spacer()
67+
}
6468
Spacer()
6569
}
70+
.padding()
71+
.background {
72+
BackgroundView()
73+
}
6674
}
6775
}
6876
.floatingPanelSurfaceAppearance(.transparent())
@@ -127,4 +135,3 @@ class MyFloatingPanelLayout: FloatingPanelLayout {
127135
#Preview("MainView") {
128136
MainView()
129137
}
130-
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import SwiftUI
2+
3+
struct BackgroundView: View {
4+
var body: some View {
5+
GeometryReader { geometry in
6+
Rectangle()
7+
.fill(.clear)
8+
.frame(height: geometry.size.height * 2)
9+
.backgroundEffect()
10+
}
11+
}
12+
}
13+
14+
extension View {
15+
@ViewBuilder
16+
fileprivate func backgroundEffect() -> some View {
17+
if #available(iOS 26, *) {
18+
self.glassEffect(.regular, in: .rect)
19+
} else {
20+
self.background(.regularMaterial)
21+
}
22+
}
23+
}

Examples/SamplesSwiftUI/SamplesSwiftUI/Views/ContentView.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct ContentView: View {
1515
.frame(maxWidth: .infinity, alignment: .leading)
1616
.frame(height: 60)
1717
.background(.clear)
18+
.padding(.horizontal)
1819
}
1920
}
2021
}
@@ -28,6 +29,7 @@ struct ContentView: View {
2829
.frame(maxWidth: .infinity, alignment: .leading)
2930
.frame(height: 60)
3031
.background(.clear)
32+
.padding(.horizontal)
3133
}
3234
}
3335
}
@@ -38,12 +40,7 @@ struct ContentView: View {
3840
}
3941
// Prevent revealing underlying content at the bottom of the panel when the panel is moving beyond its fully‑expanded position.
4042
.background {
41-
GeometryReader { geometry in
42-
Rectangle()
43-
.fill(.clear)
44-
.frame(height: geometry.size.height * 2)
45-
.background(.regularMaterial)
46-
}
43+
BackgroundView()
4744
}
4845
}
4946
}

0 commit comments

Comments
 (0)