@@ -12,14 +12,10 @@ import SwiftUI
12
12
struct ModalViewPresenterViewModifier < PresentationState: ModalPresentationState > : ViewModifier {
13
13
@EnvironmentObject var modalViewRouter : ModalViewRouter < PresentationState >
14
14
15
- @ Binding private var options : [ BottomSheet . Options ]
15
+ private let options : [ BottomSheet . Options ]
16
16
17
17
init ( options: [ BottomSheet . Options ] = [ ] ) {
18
- self . _options = . constant( options)
19
- }
20
-
21
- init ( options: Binding < [ BottomSheet . Options ] > ) {
22
- self . _options = options
18
+ self . options = options
23
19
}
24
20
25
21
public func body( content: Content ) -> some View {
@@ -48,26 +44,8 @@ public extension View {
48
44
/// Works with the implementation of the `ModalPresentationState` protocol that represents all modals that can be shown with this presenter.
49
45
/// Need to set an environmentObject of `ModalViewRouter<S: ModalPresentationState>` before using this modifier otherwise an error will occur.
50
46
///
51
- /// - parameters:
52
- /// - presentationStateType: A type that represent possible states to show
53
- /// - options: Modal view options to customise it
54
- ///
55
- func modalViewPresenter< PresentationState: ModalPresentationState > ( presentationStateType: PresentationState . Type ,
56
- options: [ BottomSheet . Options ] = [ ] ) -> some View {
57
- self . modifier ( ModalViewPresenterViewModifier < PresentationState > ( options: options) )
58
- }
59
-
60
- /// A view modifier to present modal views from any view.
61
- ///
62
- /// Works with the implementation of the `ModalPresentationState` protocol that represents all modals that can be shown with this presenter.
63
- /// Need to set an environmentObject of `ModalViewRouter<S: ModalPresentationState>` before using this modifier otherwise an error will occur.
64
- ///
65
- /// - parameters:
66
- /// - presentationStateType: A type that represent possible states to show
67
- /// - options: A options binding to allow to change the modal options
68
- ///
69
47
func modalViewPresenter< PresentationState: ModalPresentationState > ( presentationStateType: PresentationState . Type ,
70
- options: Binding < [ BottomSheet . Options ] > ) -> some View {
48
+ options: [ BottomSheet . Options ] ) -> some View {
71
49
self . modifier ( ModalViewPresenterViewModifier < PresentationState > ( options: options) )
72
50
}
73
51
}
@@ -83,7 +61,6 @@ struct ModalViewPresenterViewModifier_Previews: PreviewProvider {
83
61
@StateObject private var testModalViewRouter = TestModalViewRouter ( )
84
62
85
63
@State var color : Color = . red
86
- @State var options : [ BottomSheet . Options ] = [ . disableSwipeToDismiss, . tapToDismiss]
87
64
88
65
var body : some View {
89
66
ZStack {
@@ -93,13 +70,12 @@ struct ModalViewPresenterViewModifier_Previews: PreviewProvider {
93
70
testModalViewRouter. setModal ( state: . text( " Hello World! " ) ,
94
71
type: . customSheet) {
95
72
color = [ Color . red, . purple, . blue, . yellow, . green] . randomElement ( ) ?? . orange
96
-
97
- options = [ . tapToDismiss]
98
73
}
99
74
}
100
75
}
101
76
. modalViewPresenter ( presentationStateType: TestModalPresentationState . self,
102
- options: $options)
77
+ options: [ . tapToDismiss,
78
+ . maxHeight( 500 ) ] )
103
79
. environmentObject ( testModalViewRouter)
104
80
}
105
81
}
0 commit comments