Skip to content

Commit

Permalink
Fix timer picker intitial duration
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanSarwar45 committed Sep 17, 2024
1 parent 4c771e9 commit 3d3460e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/timer/widgets/duration_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Future<TimeDuration?> showDurationPicker(
BuildContext context, {
TimeDuration initialTimeDuration =
const TimeDuration(hours: 0, minutes: 5, seconds: 0),
const TimeDuration(hours: 0, minutes: 0, seconds: 0),
bool showHours = true,
}) async {
final theme = Theme.of(context);
Expand Down
7 changes: 5 additions & 2 deletions lib/timer/widgets/numpad_duration_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class _NumpadDurationPickerState extends State<NumpadDurationPicker> {
);
} else if (index == 9) {
return TimerButton(
isHighlighted: true,
label: "00",
onTap: () {
_addDigit("0", 2);
Expand All @@ -123,6 +124,7 @@ class _NumpadDurationPickerState extends State<NumpadDurationPicker> {
);
} else {
return TimerButton(
isHighlighted: true,
icon: Icons.backspace_outlined,
onTap: _removeDigit,
);
Expand All @@ -139,9 +141,10 @@ class TimerButton extends StatelessWidget {
final String? label;
final IconData? icon;
final VoidCallback onTap;
final bool isHighlighted;

const TimerButton(
{super.key, this.label, required this.onTap, this.icon});
{super.key, this.label, required this.onTap, this.icon, this.isHighlighted = false});

@override
Widget build(BuildContext context) {
Expand All @@ -153,7 +156,7 @@ class TimerButton extends StatelessWidget {
borderRadius: BorderRadius.circular(100),
child: Container(
decoration: BoxDecoration(
color: colorScheme.onBackground.withOpacity(0.1),
color: isHighlighted ? colorScheme.primary.withOpacity(0.2) : colorScheme.onBackground.withOpacity(0.1),
borderRadius: BorderRadius.circular(100),
),
child: Center(
Expand Down
2 changes: 1 addition & 1 deletion lib/timer/widgets/timer_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<PickerResult<ClockTimer>?> showTimerPicker(
context: context,
builder: (BuildContext context) {
ClockTimer timer = ClockTimer.from(
initialTimer ?? ClockTimer(const TimeDuration(minutes: 5)));
initialTimer ?? ClockTimer(const TimeDuration(minutes: 0)));

TimerPreset? selectedPreset;
List<TimerPreset> presets = loadListSync<TimerPreset>("timer_presets");
Expand Down
2 changes: 1 addition & 1 deletion lib/timer/widgets/timer_preset_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Future<TimerPreset?> showTimerPresetPicker(BuildContext context,
context: context,
builder: (BuildContext context) {
TimerPreset timerPreset = TimerPreset.from(initialTimerPreset ??
TimerPreset("New Preset", const TimeDuration(minutes: 5)));
TimerPreset("New Preset", const TimeDuration(minutes: 0)));

TextEditingController controller = TextEditingController(
text: timerPreset.name,
Expand Down

0 comments on commit 3d3460e

Please sign in to comment.