2
2
![ Platform: iOS 13+] ( https://img.shields.io/badge/platform-iOS%2013%2B-blue?style=flat&logo=apple )
3
3
![ SwiftPM compatible] ( https://img.shields.io/badge/SPM-compatible-brightgreen?style=flat&logo=swift )
4
4
[ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-lightgrey?style=flat )] ( https://github.com/aaronLab/SweetCardScanner/blob/main/LICENSE )
5
- [ ![ Release version] ( https://img.shields.io/badge/release-v1.0.0.beta.2 -blue )] ( https://github.com/aaronLab/SweetCardScanner/releases )
5
+ [ ![ Release version] ( https://img.shields.io/badge/release-v1.0.0-blue )] ( https://github.com/aaronLab/SweetCardScanner/releases )
6
6
7
7
# Unlocker
8
8
@@ -74,10 +74,10 @@ https://github.com/aaronLab/Unlocker
74
74
- ` threshold: Float = 50.0 ` :
75
75
76
76
- The default value is ` 50.0 `
77
- - This is the ` threshold ` where ` the completion would start ` .
77
+ - This is the ` threshold ` where ` the completion would start ` .
78
78
- Also this will make your ` slider disabled ` to ` prevent the slider works multiple times during the process ` .
79
79
- When the user swipe the slider more than the percentage of this value in the screen, the action closure will be triggered.
80
-
80
+
81
81
- ` duration: Double = 0.3 ` :
82
82
83
83
- The default value is ` 0.3 `
@@ -100,68 +100,68 @@ import SwiftUI
100
100
import Unlocker
101
101
102
102
struct CapsuleShape : View {
103
-
103
+
104
104
@State private var disabled: Bool = false
105
105
@State private var percentage: Float = 0.0
106
-
106
+
107
107
var body: some View {
108
-
108
+
109
109
ZStack {
110
-
110
+
111
111
Color.gray
112
-
112
+
113
113
// Background
114
114
HStack {
115
115
Spacer (minLength : 0 )
116
116
Text (" Slide to Unlock" )
117
117
Image (systemName : " chevron.right.2" )
118
118
} //: H
119
119
.padding (.trailing )
120
-
120
+
121
121
// Slider
122
122
Unlocker (disabled : $disabled, percentage : $percentage, minPercentage : 25 , threshold : 50.0 ) { sliderWidth in
123
123
ZStack {
124
-
124
+
125
125
// Slider Background
126
126
Rectangle ()
127
127
.foregroundColor (.primary )
128
-
128
+
129
129
/*
130
130
You can choose when you are going to show your content
131
131
with the escaping parameter(CGFloat), which is the slider's width.
132
132
*/
133
133
if sliderWidth > UIScreen.main.bounds.width / 3.0 {
134
-
134
+
135
135
// Slider Content
136
136
HStack {
137
-
137
+
138
138
Text (" Slide to Unlock" )
139
139
.foregroundColor (.blue )
140
140
.lineLimit (1 )
141
141
.padding (.leading )
142
-
142
+
143
143
Image (systemName : " chevron.right.2" )
144
144
.foregroundColor (.blue )
145
-
145
+
146
146
Spacer (minLength : 0 )
147
-
147
+
148
148
} //: H
149
-
149
+
150
150
} else {
151
-
151
+
152
152
/*
153
153
Placeholder Image before slide
154
154
*/
155
155
Image (systemName : " chevron.right.2" )
156
156
.foregroundColor (.blue )
157
-
157
+
158
158
}
159
-
159
+
160
160
}
161
161
} completion : {
162
162
// Your task here
163
163
print (" CapsuleShape Process Started" )
164
-
164
+
165
165
/*
166
166
Since the slider will be "disabled" after fully swiped,
167
167
you will need to toggle "disabled" parameter at the end of your process,
@@ -176,8 +176,8 @@ struct CapsuleShape: View {
176
176
disabled.toggle ()
177
177
}
178
178
}
179
-
180
-
179
+
180
+
181
181
} //: Z
182
182
.font (.system (size : 12 ))
183
183
.frame (height : 60 )
@@ -187,9 +187,9 @@ struct CapsuleShape: View {
187
187
*/
188
188
.clipShape (Capsule ())
189
189
.padding ()
190
-
190
+
191
191
}
192
-
192
+
193
193
}
194
194
```
195
195
0 commit comments