@@ -14,17 +14,36 @@ public struct PokitBottomButton: View {
1414 private let labelText : String
1515 private let state : PokitButtonStyle . State
1616 private let size : PokitButtonStyle . Size = . large
17+ private let isGradient : Bool
18+ private let isKeyboardVisible : Bool
1719 private let action : ( ) -> Void
1820
19- public init (
21+ private init (
2022 _ labelText: String ,
2123 state: PokitButtonStyle . State ,
22- isLoading: Binding < Bool > = . constant( false ) ,
24+ isLoading: Binding < Bool > ,
25+ isGradient: Bool ,
26+ isKeyboardVisible: Bool ,
2327 action: @escaping ( ) -> Void
2428 ) {
2529 self . labelText = labelText
2630 self . state = state
2731 self . _isLoading = isLoading
32+ self . isGradient = isGradient
33+ self . isKeyboardVisible = isKeyboardVisible
34+ self . action = action
35+ }
36+
37+ public init (
38+ _ labelText: String ,
39+ state: PokitButtonStyle . State ,
40+ action: @escaping ( ) -> Void
41+ ) {
42+ self . labelText = labelText
43+ self . state = state
44+ self . _isLoading = . constant( false )
45+ self . isGradient = false
46+ self . isKeyboardVisible = false
2847 self . action = action
2948 }
3049
@@ -37,7 +56,17 @@ public struct PokitBottomButton: View {
3756 }
3857 . disabled ( state == . disable)
3958 . padding ( . top, 16 )
40- // .padding(.bottom, 36)
59+ . padding ( . bottom, isKeyboardVisible ? 10 : 36 )
60+ . background ( if: isGradient) {
61+ LinearGradient (
62+ stops: [
63+ Gradient . Stop ( color: . pokit( . bg( . base) ) . opacity ( 0 ) , location: 0.00 ) ,
64+ Gradient . Stop ( color: . pokit( . bg( . base) ) , location: 0.20 ) ,
65+ ] ,
66+ startPoint: UnitPoint ( x: 0.5 , y: 0 ) ,
67+ endPoint: UnitPoint ( x: 0.5 , y: 1 )
68+ )
69+ }
4170 }
4271
4372 private var label : some View {
@@ -71,7 +100,41 @@ public struct PokitBottomButton: View {
71100 . stroke ( self . state. backgroundStrokeColor, lineWidth: 1 )
72101 }
73102 }
103+ . padding ( . horizontal, isGradient ? 20 : 0 )
74104 . animation ( . pokitDissolve, value: self . state)
75105 }
106+
107+ public func keyboardAnchor( _ isKeyboardVisible: Bool ) -> Self {
108+ PokitBottomButton (
109+ self . labelText,
110+ state: self . state,
111+ isLoading: self . $isLoading,
112+ isGradient: self . isGradient,
113+ isKeyboardVisible: isKeyboardVisible,
114+ action: self . action
115+ )
116+ }
117+
118+ public func gradientBackground( ) -> Self {
119+ PokitBottomButton (
120+ self . labelText,
121+ state: self . state,
122+ isLoading: self . $isLoading,
123+ isGradient: true ,
124+ isKeyboardVisible: self . isKeyboardVisible,
125+ action: self . action
126+ )
127+ }
128+
129+ public func loading( _ isLoading: Binding < Bool > ) -> Self {
130+ PokitBottomButton (
131+ self . labelText,
132+ state: self . state,
133+ isLoading: isLoading,
134+ isGradient: self . isGradient,
135+ isKeyboardVisible: self . isKeyboardVisible,
136+ action: self . action
137+ )
138+ }
76139}
77140
0 commit comments