@@ -5,6 +5,7 @@ extension View {
5
5
func animatableFullScreenCover(
6
6
isPresented: Binding < Bool > ,
7
7
duration nanoseconds: UInt64 ,
8
+ delay: UInt64 ? = nil ,
8
9
content: @escaping ( ) -> some View ,
9
10
onAppear: @escaping ( ) -> Void ,
10
11
onDisappear: @escaping ( ) -> Void
@@ -13,6 +14,7 @@ extension View {
13
14
AnimatableFullScreenViewModifier (
14
15
isPresented: isPresented,
15
16
duration: nanoseconds,
17
+ delay: delay,
16
18
fullScreenContent: content,
17
19
onAppear: onAppear,
18
20
onDisappear: onDisappear
@@ -23,6 +25,7 @@ extension View {
23
25
func animatableFullScreenCover< Item: Identifiable & Equatable > (
24
26
item: Binding < Item ? > ,
25
27
duration nanoseconds: UInt64 ,
28
+ delay: UInt64 ? = nil ,
26
29
content: @escaping ( Item ) -> some View ,
27
30
onAppear: @escaping ( ) -> Void ,
28
31
onDisappear: @escaping ( ) -> Void
@@ -31,6 +34,7 @@ extension View {
31
34
AnimatableFullScreenItemViewModifier (
32
35
item: item,
33
36
duration: nanoseconds,
37
+ delay: delay,
34
38
fullScreenContent: content,
35
39
onAppear: onAppear,
36
40
onDisappear: onDisappear
@@ -44,19 +48,22 @@ private struct AnimatableFullScreenItemViewModifier<FullScreenContent: View, Ite
44
48
@State var isActualPresented : Item ?
45
49
46
50
let nanoseconds : UInt64
51
+ let delay : UInt64 ?
47
52
let fullScreenContent : ( Item ) -> ( FullScreenContent )
48
53
let onAppear : ( ) -> Void
49
54
let onDisappear : ( ) -> Void
50
55
51
56
init (
52
57
item: Binding < Item ? > ,
53
58
duration nanoseconds: UInt64 ,
59
+ delay: UInt64 ? ,
54
60
fullScreenContent: @escaping ( Item ) -> FullScreenContent ,
55
61
onAppear: @escaping ( ) -> Void ,
56
62
onDisappear: @escaping ( ) -> Void
57
63
) {
58
64
self . _isUserInstructToPresentItem = item
59
65
self . nanoseconds = nanoseconds
66
+ self . delay = delay
60
67
self . fullScreenContent = fullScreenContent
61
68
self . onAppear = onAppear
62
69
self . onDisappear = onDisappear
@@ -68,7 +75,14 @@ private struct AnimatableFullScreenItemViewModifier<FullScreenContent: View, Ite
68
75
. onChange ( of: isUserInstructToPresentItem) { isUserInstructToPresent in
69
76
UIView . setAnimationsEnabled ( false )
70
77
if isUserInstructToPresent != nil {
71
- isActualPresented = isUserInstructToPresent
78
+ if let delay {
79
+ Task {
80
+ try await Task . sleep ( nanoseconds: delay)
81
+ isActualPresented = isUserInstructToPresent
82
+ }
83
+ } else {
84
+ isActualPresented = isUserInstructToPresent
85
+ }
72
86
} else {
73
87
Task {
74
88
try await Task . sleep ( nanoseconds: nanoseconds)
@@ -100,19 +114,22 @@ private struct AnimatableFullScreenViewModifier<FullScreenContent: View>: ViewMo
100
114
@State var isActualPresented : Bool
101
115
102
116
let nanoseconds : UInt64
117
+ let delay : UInt64 ?
103
118
let fullScreenContent : ( ) -> ( FullScreenContent )
104
119
let onAppear : ( ) -> Void
105
120
let onDisappear : ( ) -> Void
106
121
107
122
init (
108
123
isPresented: Binding < Bool > ,
109
124
duration nanoseconds: UInt64 ,
125
+ delay: UInt64 ? ,
110
126
fullScreenContent: @escaping ( ) -> FullScreenContent ,
111
127
onAppear: @escaping ( ) -> Void ,
112
128
onDisappear: @escaping ( ) -> Void
113
129
) {
114
130
self . _isUserInstructToPresent = isPresented
115
131
self . nanoseconds = nanoseconds
132
+ self . delay = delay
116
133
self . fullScreenContent = fullScreenContent
117
134
self . onAppear = onAppear
118
135
self . onDisappear = onDisappear
@@ -124,7 +141,14 @@ private struct AnimatableFullScreenViewModifier<FullScreenContent: View>: ViewMo
124
141
. onChange ( of: isUserInstructToPresent) { isUserInstructToPresent in
125
142
UIView . setAnimationsEnabled ( false )
126
143
if isUserInstructToPresent {
127
- isActualPresented = isUserInstructToPresent
144
+ if let delay {
145
+ Task {
146
+ try await Task . sleep ( nanoseconds: delay)
147
+ isActualPresented = isUserInstructToPresent
148
+ }
149
+ } else {
150
+ isActualPresented = isUserInstructToPresent
151
+ }
128
152
} else {
129
153
Task {
130
154
try await Task . sleep ( nanoseconds: nanoseconds)
0 commit comments