File tree Expand file tree Collapse file tree 6 files changed +136
-30
lines changed
Tests/OpenSwiftUICoreTests/Data Expand file tree Collapse file tree 6 files changed +136
-30
lines changed Original file line number Diff line number Diff line change 53
53
/* End PBXFileReference section */
54
54
55
55
/* Begin PBXFileSystemSynchronizedRootGroup section */
56
+ 27C4C20C2D8178CF00511552 /* Examples */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Examples; sourceTree = "<group>"; };
56
57
27E6C4F62D2842D80010502F /* Configurations */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); name = Configurations; path = ../Configurations; sourceTree = "<group>"; };
57
58
/* End PBXFileSystemSynchronizedRootGroup section */
58
59
130
131
27D49DF92BA604FB00F6E2E2 /* HostingExample */ = {
131
132
isa = PBXGroup;
132
133
children = (
134
+ 27C4C20C2D8178CF00511552 /* Examples */,
133
135
27D49DFA2BA604FB00F6E2E2 /* AppDelegate.swift */,
134
136
27D49DFC2BA604FB00F6E2E2 /* SceneDelegate.swift */,
135
137
27D49DFE2BA604FB00F6E2E2 /* ViewController.swift */,
186
188
);
187
189
dependencies = (
188
190
);
191
+ fileSystemSynchronizedGroups = (
192
+ 27C4C20C2D8178CF00511552 /* Examples */,
193
+ );
189
194
name = HostingExample;
190
195
packageProductDependencies = (
191
196
27D49E0D2BA60AF600F6E2E2 /* OpenSwiftUI */,
Original file line number Diff line number Diff line change
1
+ //
2
+ // AppearanceActionModifierExample.swift
3
+ // HostingExample
4
+
5
+ #if OPENSWIFTUI
6
+ import OpenSwiftUI
7
+ #else
8
+ import SwiftUI
9
+ #endif
10
+ import Foundation
11
+
12
+ struct AppearanceActionModifierExample : View {
13
+ @State private var first = true
14
+
15
+ var body : some View {
16
+ Color ( uiColor: first ? . red : . blue)
17
+ . onAppear {
18
+ print ( " View appear " )
19
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
20
+ first. toggle ( )
21
+ }
22
+ }
23
+ . onDisappear {
24
+ print ( " View disappear " )
25
+ }
26
+ . id ( first)
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // ConditionalContentExample.swift
3
+ // HostingExample
4
+
5
+ #if OPENSWIFTUI
6
+ import OpenSwiftUI
7
+ #else
8
+ import SwiftUI
9
+ #endif
10
+ import Foundation
11
+
12
+ // FIXME
13
+ struct ConditionalContentExample : View {
14
+ @State private var first = true
15
+
16
+ var body : some View {
17
+ if first {
18
+ Color . red
19
+ . onAppear {
20
+ print ( " Red appear " )
21
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
22
+ first. toggle ( )
23
+ }
24
+ }
25
+ . onDisappear {
26
+ print ( " Red disappear " )
27
+ }
28
+ . id ( first)
29
+ } else {
30
+ Color . blue
31
+ . onAppear {
32
+ print ( " Blue appear " )
33
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
34
+ first. toggle ( )
35
+ }
36
+ }
37
+ . onDisappear {
38
+ print ( " Blue disappear " )
39
+ }
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ //
2
+ // NamespaceExample.swift
3
+ // HostingExample
4
+
5
+ #if OPENSWIFTUI
6
+ import OpenSwiftUI
7
+ #else
8
+ import SwiftUI
9
+ #endif
10
+ import Foundation
11
+
12
+ struct NamespaceExample : View {
13
+ @State private var first = true
14
+ @Namespace private var id
15
+
16
+ var body : some View {
17
+ Color ( uiColor: first ? . red : . blue)
18
+ . onAppear {
19
+ print ( " View appear \( id) " )
20
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
21
+ first. toggle ( )
22
+ }
23
+ }
24
+ . onDisappear {
25
+ print ( " View disappear \( id) " )
26
+ }
27
+ . id ( first)
28
+ }
29
+ }
Original file line number Diff line number Diff line change @@ -39,37 +39,8 @@ final class EntryViewController: UIViewController {
39
39
}
40
40
}
41
41
42
- // TODO: Known issue
43
- // 1. State toggle crash
44
- // 2. pop - UIHostingView deinit crash / onDisappear
45
- // 3. if else builder issue
46
42
struct ContentView : View {
47
- @State private var first = true
48
-
49
43
var body : some View {
50
- // if first {
51
- Color ( uiColor: first ? . red : . blue)
52
- . onAppear {
53
- print ( " View appear " )
54
- DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
55
- first. toggle ( )
56
- }
57
- }
58
- . onDisappear {
59
- print ( " Red disappear " )
60
- }
61
- . id ( first)
62
- // } else {
63
- // Color.blue
64
- // .onAppear {
65
- // print("Blue appear")
66
- // DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
67
- // first.toggle()
68
- // }
69
- // }
70
- // .onDisappear {
71
- // print("Blue disappear")
72
- // }
73
- // }
44
+ AppearanceActionModifierExample ( )
74
45
}
75
46
}
Original file line number Diff line number Diff line change
1
+ //
2
+ // NamespaceTests.swift
3
+ // OpenSwiftUICoreTests
4
+
5
+ import Testing
6
+ import OpenSwiftUICore
7
+ import Foundation
8
+
9
+ struct NamespaceTests {
10
+ @Test
11
+ func example( ) {
12
+ struct ContentView : View {
13
+ @State private var first = false
14
+ @Namespace private var id
15
+
16
+ var body : some View {
17
+ Color ( uiColor: first ? . red : . blue)
18
+ . onAppear {
19
+ print ( " View appear " )
20
+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + 1 ) {
21
+ first. toggle ( )
22
+ }
23
+ }
24
+ . onDisappear {
25
+ print ( " Red disappear " )
26
+ }
27
+ . id ( first)
28
+ }
29
+ }
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments