File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import SwiftUI
99
1010extension EnvironmentValues {
11-
1211 var safeAreaInsets : EdgeInsets {
1312 self [ SafeAreaInsetsKey . self]
1413 }
1514
15+ var sceneWidth : CGFloat {
16+ self [ SceneWidthKey . self]
17+ }
18+
19+ var sceneHeight : CGFloat {
20+ self [ SceneHeightKey . self]
21+ }
22+
1623 private struct SafeAreaInsetsKey : EnvironmentKey {
1724 static var defaultValue : EdgeInsets {
1825 guard let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene ,
@@ -22,6 +29,24 @@ extension EnvironmentValues {
2229 return window. safeAreaInsets. insets
2330 }
2431 }
32+
33+ private struct SceneWidthKey : EnvironmentKey {
34+ static var defaultValue : CGFloat {
35+ guard let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene else {
36+ return UIScreen . main. bounds. width
37+ }
38+ return windowScene. screen. bounds. width
39+ }
40+ }
41+
42+ private struct SceneHeightKey : EnvironmentKey {
43+ static var defaultValue : CGFloat {
44+ guard let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene else {
45+ return UIScreen . main. bounds. height
46+ }
47+ return windowScene. screen. bounds. height
48+ }
49+ }
2550}
2651
2752extension UIEdgeInsets {
Original file line number Diff line number Diff line change 88import SwiftUI
99
1010extension View {
11- var sceneWidth : CGFloat {
12- guard let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene
13- else { return UIScreen . main. bounds. width }
14-
15- return windowScene. screen. bounds. width
16- }
17-
18- var sceneHeight : CGFloat {
19- guard let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene
20- else { return UIScreen . main. bounds. height }
21-
22- return windowScene. screen. bounds. height
23- }
24-
25- var safeAreaInsets : UIEdgeInsets {
26- guard let windowScene = UIApplication . shared. connectedScenes. first as? UIWindowScene ,
27- let window = windowScene. windows. first
28- else { return UIEdgeInsets . zero }
29-
30- return window. safeAreaInsets
31- }
32-
3311 @ViewBuilder
3412 func adaptiveButtonStyle( _ color: Color ? = nil ) -> some View {
3513 if #available( iOS 26 . 0 , * ) , color == nil {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import SwiftUI
99
1010struct HomeView : View {
1111 @Environment ( \. diContainer) var container : any DIContainer
12+ @Environment ( \. sceneWidth) var sceneWidth : CGFloat
1213 @StateObject private var router = NavigationRouter ( )
1314 @StateObject var viewModel : HomeViewModel
1415
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import SwiftUI
1111
1212struct TodoEditorView : View {
1313 @StateObject var viewModel : TodoEditorViewModel
14+ @Environment ( \. safeAreaInsets) private var safeAreaInsets
1415 @Environment ( \. dismiss) private var dismiss
1516 @FocusState private var field : Field ?
1617 @State private var showDueDatePicker : Bool = false
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import SwiftUI
1010struct LoginView : View {
1111 @StateObject var viewModel : LoginViewModel
1212 @Environment ( \. colorScheme) var colorScheme
13+ @Environment ( \. sceneWidth) var sceneWidth
1314
1415 var body : some View {
1516 ZStack {
You can’t perform that action at this time.
0 commit comments