Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/src/model/over_the_board/over_the_board_clock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ class OverTheBoardClock extends _$OverTheBoardClock {

state = state.copyWith(activeClock: newSideToMove);
}

void giveTime(Duration amount) {
final newTime = state.timeLeft(state.activeClock!)! + amount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the clock can be disabled in which case this method would crash. You should check for that first.


if (state.activeClock == Side.white) {
state = state.copyWith(whiteTimeLeft: newTime);
} else {
state = state.copyWith(blackTimeLeft: newTime);
}
}
}

@freezed
Expand Down
6 changes: 6 additions & 0 deletions lib/src/view/over_the_board/over_the_board_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ class _BottomBar extends ConsumerWidget {
);
},
),
BottomSheetAction(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no clock this button should be hidden.

makeLabel: (context) => const Text('Give 15 seconds.'),
onPressed: () {
ref.read(overTheBoardClockProvider.notifier).giveTime(const Duration(seconds: 15));
},
),
],
);
}
Expand Down