@@ -52,68 +52,55 @@ private struct AttachUIViewControllerCoordinator<Route, Coordinator: UIViewContr
52
52
let onConnect : ( ) -> Void
53
53
54
54
func body( content: Content ) -> some View {
55
- PassthroughView {
56
- if coordinator. rootViewController == nil {
57
- ZeroSizeView ( )
58
- } else {
59
- content. environment ( coordinator. environmentInsertions)
55
+ content
56
+ . environment ( coordinator. environmentInsertions)
57
+ . environmentObject ( coordinator)
58
+ . environmentObject ( AnyViewCoordinator ( coordinator) )
59
+ . onAppKitOrUIKitViewControllerResolution { viewController in
60
+ DispatchQueue . main. async {
61
+ coordinator. rootViewController = viewController
62
+
63
+ onConnect ( )
64
+ }
60
65
}
61
- }
62
- . environmentObject ( coordinator)
63
- . environmentObject ( AnyViewCoordinator ( coordinator) )
64
- . onAppKitOrUIKitViewControllerResolution { viewController in
65
- DispatchQueue . main. async {
66
- coordinator. rootViewController = viewController
67
-
68
- onConnect ( )
69
- }
70
- }
71
66
}
72
67
}
73
68
74
69
private struct AttachAppKitOrUIKitWindowCoordinator < Route, Coordinator: AppKitOrUIKitWindowCoordinator < Route > > : ViewModifier {
75
70
@ObservedObject var coordinator : Coordinator
76
71
77
72
let onConnect : ( ) -> Void
78
-
73
+
79
74
func body( content: Content ) -> some View {
80
- PassthroughView {
81
- if coordinator. window == nil {
82
- ZeroSizeView ( )
83
- } else {
84
- content
75
+ content
76
+ . environmentObject ( coordinator)
77
+ . environmentObject ( AnyViewCoordinator ( coordinator) )
78
+ . onAppKitOrUIKitViewControllerResolution { viewController in
79
+ DispatchQueue . main. async {
80
+ coordinator. window = viewController. view. window
81
+
82
+ onConnect ( )
83
+ }
85
84
}
86
- }
87
- . environmentObject ( coordinator)
88
- . environmentObject ( AnyViewCoordinator ( coordinator) )
89
- . onAppKitOrUIKitViewControllerResolution { viewController in
90
- DispatchQueue . main. async {
91
- coordinator. window = viewController. view. window
92
-
93
- onConnect ( )
94
- }
95
- }
96
85
}
97
86
}
98
87
99
88
private struct AttachViewCoordinator < Coordinator: ViewCoordinator > : ViewModifier {
100
89
@ObservedObject var coordinator : Coordinator
101
90
102
91
let onConnect : ( ) -> Void
103
-
92
+
104
93
func body( content: Content ) -> some View {
105
- PassthroughView {
106
- content
107
- }
108
- . environmentObject ( coordinator)
109
- . environmentObject ( ( coordinator as? AnyViewCoordinator < Coordinator . Route > ) ?? AnyViewCoordinator ( coordinator) )
110
- . onAppKitOrUIKitViewControllerResolution { viewController in
111
- DispatchQueue . main. async {
112
- AnyViewCoordinator ( coordinator) . _setViewController ( viewController)
113
-
114
- onConnect ( )
94
+ content
95
+ . environmentObject ( coordinator)
96
+ . environmentObject ( ( coordinator as? AnyViewCoordinator < Coordinator . Route > ) ?? AnyViewCoordinator ( coordinator) )
97
+ . onAppKitOrUIKitViewControllerResolution { viewController in
98
+ DispatchQueue . main. async {
99
+ AnyViewCoordinator ( coordinator) . _setViewController ( viewController)
100
+
101
+ onConnect ( )
102
+ }
115
103
}
116
- }
117
104
}
118
105
}
119
106
#endif
0 commit comments