Skip to content

Commit

Permalink
Add more actions to timer popup
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Apr 18, 2024
1 parent cbed855 commit 9bfcd9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
13 changes: 8 additions & 5 deletions lib/timer/screens/timer_fullscreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ class _TimerFullscreenState extends State<TimerFullscreen> {
),
),
const SizedBox(height: 32),
TimerProgressBar(timer: timer, size: orientation == Orientation.portrait ? width : height),
TimerProgressBar(
timer: timer,
size: orientation == Orientation.portrait ? width : height),
const SizedBox(height: 32),
Padding(
padding: const EdgeInsets.only(left: 20.0, right:20.0, bottom:20.0),
padding:
const EdgeInsets.only(left: 20.0, right: 20.0, bottom: 20.0),
child: Flex(
direction: orientation == Orientation.portrait
? Axis.horizontal
Expand All @@ -127,7 +130,6 @@ class _TimerFullscreenState extends State<TimerFullscreen> {
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.replay_rounded,

color: colorScheme.primary,
size: 32,
// size: 64,
Expand Down Expand Up @@ -175,8 +177,9 @@ class _TimerFullscreenState extends State<TimerFullscreen> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('+${timer.addLength.floor()}:00',
style:
orientation == Orientation.portrait ? textTheme.displaySmall: textTheme.titleSmall)),
style: orientation == Orientation.portrait
? textTheme.displaySmall
: textTheme.titleSmall)),
onTap: () async {
await widget.onAddTime(timer);
updateTimer();
Expand Down
2 changes: 2 additions & 0 deletions lib/timer/screens/timer_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class _TimerScreenState extends State<TimerScreen> {
onToggleState: () => _handleToggleState(timer),
onPressDelete: () => _listController.deleteItem(timer),
onPressDuplicate: () => _listController.duplicateItem(timer),
onPressReset: ()=> _handleResetTimer(timer),
onPressAddTime: ()=> _handleAddTimeToTimer(timer),
),
onTapItem: (timer, index) async {
await Navigator.push(
Expand Down
43 changes: 21 additions & 22 deletions lib/timer/widgets/timer_card.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';

import 'package:clock_app/common/types/popup_action.dart';
import 'package:clock_app/common/utils/popup_action.dart';
import 'package:clock_app/common/widgets/card_edit_menu.dart';
import 'package:clock_app/common/widgets/circular_progress_bar.dart';
import 'package:clock_app/timer/types/time_duration.dart';
import 'package:clock_app/timer/types/timer.dart';
import 'package:clock_app/timer/widgets/timer_progress_bar.dart';
Expand All @@ -15,12 +15,15 @@ class TimerCard extends StatefulWidget {
required this.onToggleState,
required this.onPressDelete,
required this.onPressDuplicate,
required this.onPressReset, required this.onPressAddTime,
});

final ClockTimer timer;
final VoidCallback onToggleState;
final VoidCallback onPressDelete;
final VoidCallback onPressDuplicate;
final VoidCallback onPressReset;
final VoidCallback onPressAddTime;

@override
State<TimerCard> createState() => _TimerCardState();
Expand All @@ -44,11 +47,9 @@ class _TimerCardState extends State<TimerCard> {
});
}
valueNotifier.value = widget.timer.remainingSeconds.toDouble();
// remainingSeconds = widget.timer.remainingSeconds;
});
}

// update value notifier every second
@override
void initState() {
super.initState();
Expand All @@ -59,7 +60,6 @@ class _TimerCardState extends State<TimerCard> {
valueNotifier = ValueNotifier(widget.timer.remainingSeconds.toDouble());
remainingSeconds = widget.timer.remainingSeconds;
valueNotifier.addListener(() {
// print("valueNotifier: ${valueNotifier.value}");
setState(() {
remainingSeconds = valueNotifier.value.toInt();
});
Expand Down Expand Up @@ -91,10 +91,12 @@ class _TimerCardState extends State<TimerCard> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TimerProgressBar(timer: widget.timer, size: 50,centerWidget:GestureDetector(
TimerProgressBar(
timer: widget.timer,
size: 50,
centerWidget: GestureDetector(
onTap: () {
widget.onToggleState();
// print("================toglle");
updateTimer();
},
child: widget.timer.isRunning
Expand All @@ -108,22 +110,7 @@ class _TimerCardState extends State<TimerCard> {
color: colorScheme.onSurface.withOpacity(0.6),
size: 32,
),
)
),

// CircularProgressBar(
// size: 50,
// valueNotifier: valueNotifier,
// progressStrokeWidth: 8,
// backStrokeWidth: 8,
// maxValue: widget.timer.currentDuration.inSeconds.toDouble(),
// mergeMode: true,
// animationDuration: 0,
// onGetCenterWidget: (value) {
// return },
// progressColors: [colorScheme.primary],
// backColor: Colors.black.withOpacity(0.15),
// ),
)),
const SizedBox(width: 16),
Expanded(
flex: 999,
Expand Down Expand Up @@ -152,6 +139,18 @@ class _TimerCardState extends State<TimerCard> {
CardEditMenu(actions: [
getDeletePopupAction(context, widget.onPressDelete),
getDuplicatePopupAction(widget.onPressDuplicate),
if (!widget.timer.isStopped)
PopupAction(
"Reset",
widget.onPressReset,
Icons.replay_rounded,
),
if (!widget.timer.isStopped)
PopupAction(
'+${widget.timer.addLength.floor()}:00',
widget.onPressAddTime,
Icons.add_rounded,
)
]),
],
));
Expand Down

0 comments on commit 9bfcd9c

Please sign in to comment.