@@ -15,6 +15,7 @@ import 'package:simple_app/provider/current_theme.dart';
15
15
import 'package:simple_app/utils/show_dialog.dart' ;
16
16
import 'package:simple_app/utils/show_toast.dart' ;
17
17
import 'package:vibration/vibration.dart' ;
18
+ import 'package:shimmer/shimmer.dart' ;
18
19
19
20
class CountDownPage extends StatefulWidget {
20
21
const CountDownPage ({Key ? key}) : super (key: key);
@@ -30,7 +31,7 @@ class _CountDownPageState extends State<CountDownPage> {
30
31
// 是否显示倒计时看板
31
32
bool show = false ;
32
33
// 圆形大小背景
33
- double size = ScreenUtil ().setHeight (350 );
34
+ double size = ScreenUtil ().setHeight (326 );
34
35
// 进度条宽高度
35
36
double progressSize = ScreenUtil ().setHeight (350 );
36
37
// 进度条大小
@@ -47,15 +48,14 @@ class _CountDownPageState extends State<CountDownPage> {
47
48
Timer ? timerId;
48
49
// 计数器过渡动画
49
50
final Duration _duration = const Duration (milliseconds: 250 );
50
-
51
51
// 音频字节
52
52
ByteData ? bytes;
53
53
FlutterSoundPlayer ? _myPlayer = FlutterSoundPlayer ();
54
54
void handleStartClick () {
55
55
if (pickerTime.inSeconds < 6 ) return ;
56
56
setState (() => show = true );
57
57
const timeout = Duration (seconds: 1 );
58
- // progressValue = 0;
58
+ progressValue = 0 ;
59
59
int startSecond = 0 ;
60
60
int totalSecond = pickerTime.inSeconds;
61
61
int h = pickerTime.inHours;
@@ -133,9 +133,12 @@ class _CountDownPageState extends State<CountDownPage> {
133
133
}
134
134
135
135
TextStyle textStyle = TextStyle (
136
- height: 1.5 ,
137
- fontSize: ScreenUtil ().setSp (35 ),
138
- textBaseline: TextBaseline .alphabetic);
136
+ fontSize: ScreenUtil ().setSp (50 ),
137
+ foreground: Paint ()
138
+ ..style = PaintingStyle .stroke
139
+ ..strokeWidth = 1
140
+ ..color = Colors .white,
141
+ );
139
142
140
143
@override
141
144
void dispose () {
@@ -172,10 +175,7 @@ class _CountDownPageState extends State<CountDownPage> {
172
175
key: ValueKey <bool >(show),
173
176
child: show
174
177
? ClipOval (
175
- child: AnimatedContainer (
176
- duration: const Duration (milliseconds: 100 ),
177
- width: size,
178
- height: size,
178
+ child: Container (
179
179
child: Stack (
180
180
children: [
181
181
Positioned (
@@ -186,7 +186,7 @@ class _CountDownPageState extends State<CountDownPage> {
186
186
lineWidth: strokeWidth,
187
187
animateFromLastPercent: true ,
188
188
backgroundColor: Colors .grey,
189
- circularStrokeCap: CircularStrokeCap .butt ,
189
+ circularStrokeCap: CircularStrokeCap .round ,
190
190
linearGradient: const LinearGradient (
191
191
colors: [
192
192
Color .fromRGBO (179 , 217 , 200 , 0.7 ),
@@ -198,59 +198,82 @@ class _CountDownPageState extends State<CountDownPage> {
198
198
),
199
199
),
200
200
),
201
- Row (
202
- mainAxisAlignment: MainAxisAlignment .center,
203
- children: [
204
- Visibility (
205
- visible: hour != null ,
206
- child: Center (
207
- child: AnimatedFlipCounter (
208
- value: hour ?? = 0 ,
209
- duration: _duration,
210
- textStyle: textStyle,
211
- ),
212
- )),
213
- Visibility (
214
- visible: hour != 0 ,
215
- child: Text (
216
- ':' ,
217
- style: textStyle,
218
- ),
219
- ),
220
- Visibility (
221
- visible: minutes != null ,
222
- child: Center (
223
- child: AnimatedFlipCounter (
224
- value: minutes ?? = 0 ,
225
- duration: _duration,
226
- textStyle: textStyle,
201
+ Positioned (
202
+ top: strokeWidth,
203
+ left: strokeWidth,
204
+ child: ClipOval (
205
+ child: Shimmer .fromColors (
206
+ child: Container (
207
+ width: size,
208
+ height: size,
209
+ decoration: const BoxDecoration (
210
+ gradient: LinearGradient (
211
+ begin: Alignment .centerLeft,
212
+ end: Alignment .centerRight,
213
+ colors: [
214
+ Color .fromRGBO (
215
+ 152 , 203 , 179 , 0.5 ),
216
+ themeColor
217
+ ]),
218
+ ),
219
+ child: Row (
220
+ mainAxisAlignment:
221
+ MainAxisAlignment .center,
222
+ children: [
223
+ Visibility (
224
+ visible: hour != null ,
225
+ child: Center (
226
+ child: AnimatedFlipCounter (
227
+ value: hour ?? = 0 ,
228
+ duration: _duration,
229
+ textStyle: textStyle,
230
+ ),
231
+ )),
232
+ Visibility (
233
+ visible: hour != 0 ,
234
+ child: Text (
235
+ ':' ,
236
+ style: textStyle,
237
+ ),
238
+ ),
239
+ Visibility (
240
+ visible: minutes != null ,
241
+ child: Center (
242
+ child: AnimatedFlipCounter (
243
+ value: minutes ?? = 0 ,
244
+ duration: _duration,
245
+ textStyle: textStyle,
246
+ ),
247
+ )),
248
+ Visibility (
249
+ visible: hour == 0
250
+ ? minutes != 0
251
+ : true ,
252
+ child: Text (
253
+ ':' ,
254
+ style: textStyle,
255
+ ),
256
+ ),
257
+ Visibility (
258
+ visible: second != null ,
259
+ child: Center (
260
+ child: AnimatedFlipCounter (
261
+ value: second ?? = 0 ,
262
+ duration: _duration,
263
+ textStyle: textStyle,
264
+ ),
265
+ ))
266
+ ],
267
+ ),
227
268
),
228
- )),
229
- Visibility (
230
- visible: minutes != 0 ,
231
- child: Text (
232
- ':' ,
233
- style: textStyle,
234
- ),
235
- ),
236
- Visibility (
237
- visible: second != null ,
238
- child: Center (
239
- child: AnimatedFlipCounter (
240
- value: second ?? = 0 ,
241
- duration: _duration,
242
- textStyle: textStyle,
269
+ baseColor:
270
+ const Color .fromRGBO (179 , 217 , 200 , 0.7 ),
271
+ highlightColor: themeColor,
272
+ period: const Duration (seconds: 1 ),
243
273
),
244
- ))
245
- ],
246
- )
274
+ ))
247
275
],
248
276
),
249
- decoration: const BoxDecoration (
250
- gradient: LinearGradient (
251
- begin: Alignment .topLeft,
252
- end: Alignment .bottomRight,
253
- colors: [Colors .white, themeColor])),
254
277
),
255
278
)
256
279
: Column (
0 commit comments