Skip to content

Commit

Permalink
fix: wait for time before starting
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaoelitiana committed Jan 25, 2022
1 parent 9dcf482 commit a67371b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class _PreferencesRouteState extends State<PreferencesRoute> {
future: _getSharedPreferences(),
builder: (context, AsyncSnapshot<SharedPreferences> snapshot) {
_pomodoroIdTextController = TextEditingController(
text: snapshot.data?.getInt('pomodoro_id').toString());
text: (snapshot.data?.getInt('pomodoro_id') ?? 1)
.toString());
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down
11 changes: 8 additions & 3 deletions lib/models/pomodoro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@ class Pomodoro {
DateTime nextFocusStart = getNextFocusStart();
DateTime nextBreakStart = getNextBreakStart();
int currentLoop = getNextFocusLoop() - 1;
int to = nextFocusStart.isBefore(nextBreakStart)
? nextFocusStart.difference(now).inSeconds
: nextBreakStart.difference(now).inSeconds;
int to = 0;

if (now.isAfter(nextFocusStart) && now.isBefore(nextBreakStart)) {
to = nextFocusStart.isBefore(nextBreakStart)
? nextFocusStart.difference(now).inSeconds
: nextBreakStart.difference(now).inSeconds;
}

Phase phase =
nextFocusStart.isBefore(nextBreakStart) ? Phase.Break : Phase.Focus;

Expand Down

0 comments on commit a67371b

Please sign in to comment.