Skip to content

Commit bf7f733

Browse files
authored
solved (#774)
1 parent 82cd3a5 commit bf7f733

File tree

1 file changed

+44
-140
lines changed

1 file changed

+44
-140
lines changed

lib/app/modules/timer/views/timer_animation.dart

Lines changed: 44 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -179,168 +179,72 @@ class _TimerAnimatedCardState extends State<TimerAnimatedCard>
179179
),
180180
Spacer(),
181181
Padding(
182-
padding:
183-
const EdgeInsets.symmetric(vertical: 10),
182+
padding: const EdgeInsets.symmetric(vertical: 10),
184183
child: Row(
185-
mainAxisAlignment:
186-
MainAxisAlignment.spaceBetween,
184+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
187185
children: [
188186
Obx(
189187
() => AnimatedContainer(
190188
duration: Duration(seconds: 1),
191189
child: Text(
192190
'${Utils.formatMilliseconds(widget.timer.timerValue - widget.timer.timeElapsed)}',
193-
style: Theme.of(
194-
context,
195-
).textTheme.displayLarge!.copyWith(
191+
style: Theme.of(context)
192+
.textTheme
193+
.displayLarge!
194+
.copyWith(
196195
color: themeController.primaryTextColor.value,
197196
fontSize: 44,
198197
),
199198
),
200-
201-
InkWell(
199+
),
200+
),
201+
Row(
202+
children: [
203+
GestureDetector(
202204
onTap: () {
203-
controller
204-
.stopRinger(widget.timer.timerId);
205-
controller
206-
.deleteTimer(widget.timer.timerId);
205+
setState(() {
206+
if (widget.timer.isPaused == 0) {
207+
stopTimer();
208+
} else {
209+
startTimer();
210+
}
211+
widget.timer.isPaused =
212+
widget.timer.isPaused == 0 ? 1 : 0;
213+
IsarDb.updateTimerPauseStatus(widget.timer);
214+
});
215+
if (widget.timer.timeElapsed >=
216+
widget.timer.timerValue) {
217+
controller.stopRinger(widget.timer.timerId);
218+
setState(() {
219+
widget.timer.timeElapsed = 0;
220+
IsarDb.updateTimerTick(widget.timer)
221+
.then((value) =>
222+
IsarDb.updateTimerPauseStatus(
223+
widget.timer));
224+
widget.timer.isPaused = 1;
225+
});
226+
}
207227
},
208228
child: Container(
209229
decoration: BoxDecoration(
210-
color: themeController.primaryBackgroundColor.value,
211-
borderRadius:
212-
BorderRadius.circular(20)),
213-
child: const Padding(
214-
padding: EdgeInsets.all(4.0),
215-
child: Icon(
216-
Icons.close,
217-
size: 18,
218-
),
230+
color: kprimaryColor,
231+
borderRadius: BorderRadius.circular(80)),
232+
width: 80,
233+
height: 80,
234+
child: Icon(
235+
widget.timer.isPaused == 0
236+
? Icons.pause
237+
: Icons.play_arrow,
238+
size: 30,
239+
color: Colors.white,
219240
),
220241
),
221-
)
242+
),
222243
],
223244
),
224-
Padding(
225-
padding:
226-
const EdgeInsets.symmetric(vertical: 20),
227-
child: Row(
228-
mainAxisAlignment:
229-
MainAxisAlignment.spaceBetween,
230-
children: [
231-
Obx(
232-
() => AnimatedContainer(
233-
duration: Duration(seconds: 1),
234-
child: Text(
235-
'${Utils.formatMilliseconds(widget.timer.timerValue - widget.timer.timeElapsed)}',
236-
style: Theme.of(
237-
context,
238-
).textTheme.displayLarge!.copyWith(
239-
color: themeController.primaryTextColor.value,
240-
fontSize: 44,
241-
),
242-
),
243-
),
244-
),
245-
Padding(
246-
padding: EdgeInsets.all(20),
247-
child: GestureDetector(
248-
onTap: () {
249-
setState(() {
250-
widget.timer.isPaused == 0
251-
? stopTimer()
252-
: startTimer();
253-
widget.timer.isPaused =
254-
widget.timer.isPaused == 0
255-
? 1
256-
: 0;
257-
IsarDb.updateTimerPauseStatus(
258-
widget.timer);
259-
});
260-
if (widget.timer.timeElapsed >=
261-
widget.timer.timerValue) {
262-
controller.stopRinger(
263-
widget.timer.timerId);
264-
setState(() {
265-
widget.timer.timeElapsed = 0;
266-
IsarDb.updateTimerTick(
267-
widget.timer)
268-
.then((value) => IsarDb
269-
.updateTimerPauseStatus(
270-
widget.timer));
271-
widget.timer.isPaused = 1;
272-
});
273-
}
274-
},
275-
child: Container(
276-
decoration: BoxDecoration(
277-
color: kprimaryColor,
278-
borderRadius:
279-
BorderRadius.circular(80)),
280-
width: width * 0.14,
281-
height: width * 0.14,
282-
child: Icon(
283-
widget.timer.isPaused == 0
284-
? Icons.pause
285-
: Icons.play_arrow,
286-
size: 30,
287-
color: ksecondaryBackgroundColor,
288-
),
289-
),
290-
))
291-
],
292-
293-
),
294-
),
295-
GestureDetector(
296-
onTap: () {
297-
setState(() {
298-
widget.timer.isPaused == 0
299-
? stopTimer()
300-
: startTimer();
301-
widget.timer.isPaused =
302-
widget.timer.isPaused == 0
303-
? 1
304-
: 0;
305-
IsarDb.updateTimerPauseStatus(
306-
widget.timer);
307-
});
308-
if (widget.timer.timeElapsed >=
309-
widget.timer.timerValue) {
310-
controller.stopRinger(
311-
widget.timer.timerId);
312-
setState(() {
313-
widget.timer.timeElapsed = 0;
314-
IsarDb.updateTimerTick(
315-
widget.timer)
316-
.then((value) => IsarDb
317-
.updateTimerPauseStatus(
318-
widget.timer));
319-
widget.timer.isPaused = 1;
320-
});
321-
}
322-
},
323-
child: Container(
324-
decoration: BoxDecoration(
325-
color: kprimaryColor,
326-
borderRadius:
327-
BorderRadius.circular(80)),
328-
width: 80,
329-
height: 80,
330-
child: Icon(
331-
widget.timer.isPaused == 0
332-
? Icons.pause
333-
: Icons.play_arrow,
334-
size: 30,
335-
color:
336-
Colors.white,
337-
),
338-
),
339-
)
340245
],
341246
),
342247
),
343-
Spacer(),
344248
],
345249
),
346250
),

0 commit comments

Comments
 (0)