Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauritz8 committed May 15, 2024
1 parent 885630d commit 151020a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 24 deletions.
9 changes: 7 additions & 2 deletions lib/src/model/clock/clock_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class ClockController extends _$ClockController {
void updateOptions(TimeIncrement timeIncrement) =>
state = ClockState.fromTimeIncrement(timeIncrement);

void updateOptionsCustom(TimeIncrement playerTop, TimeIncrement playerBottom) =>
void updateOptionsCustom(
TimeIncrement playerTop,
TimeIncrement playerBottom,
) =>
state = ClockState.fromSeparateTimeIncrements(playerTop, playerBottom);

void setLoser(ClockPlayerType playerType) =>
Expand Down Expand Up @@ -120,7 +123,9 @@ class ClockState with _$ClockState {
}

factory ClockState.fromSeparateTimeIncrements(
TimeIncrement playerTop, TimeIncrement playerBottom,) {
TimeIncrement playerTop,
TimeIncrement playerBottom,
) {
final options = ClockOptions(
timePlayerTop: Duration(seconds: playerTop.time),
timePlayerBottom: Duration(seconds: playerBottom.time),
Expand Down
5 changes: 4 additions & 1 deletion lib/src/view/clock/clock_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class ClockSettings extends ConsumerWidget {
controller.updateOptions(choice);
},
onSelectedCustom: (playerTop, playerBottom) {
controller.updateOptionsCustom(playerTop, playerBottom);
controller.updateOptionsCustom(
playerTop,
playerBottom,
);
},
);
},
Expand Down
26 changes: 20 additions & 6 deletions lib/src/view/play/create_custom_time_control_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import 'package:lichess_mobile/src/widgets/non_linear_slider.dart';
import 'package:lichess_mobile/src/widgets/platform.dart';

class CreateCustomTimeControlScreen extends StatelessWidget {
final void Function(TimeIncrement playerTop, TimeIncrement playerBottom) onSubmit;
final void Function(TimeIncrement playerTop, TimeIncrement playerBottom)
onSubmit;
final TimeIncrement topPlayer;
final TimeIncrement bottomPlayer;

Expand All @@ -31,20 +32,31 @@ class CreateCustomTimeControlScreen extends StatelessWidget {
Widget _androidBuilder(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(context.l10n.custom)),
body: _Body(onSubmit: onSubmit, topPlayer: topPlayer, bottomPlayer: bottomPlayer),
body: _Body(
onSubmit: onSubmit,
topPlayer: topPlayer,
bottomPlayer: bottomPlayer,
),
);
}

Widget _iosBuilder(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(),
child: _Body(onSubmit: onSubmit, topPlayer: topPlayer, bottomPlayer: bottomPlayer),
child: _Body(
onSubmit: onSubmit,
topPlayer: topPlayer,
bottomPlayer: bottomPlayer,
),
);
}
}

class _Body extends StatefulWidget {
final void Function(TimeIncrement timeTopPlayer, TimeIncrement timeBottomPlayer) onSubmit;
final void Function(
TimeIncrement timeTopPlayer,
TimeIncrement timeBottomPlayer,
) onSubmit;
final TimeIncrement topPlayer;
final TimeIncrement bottomPlayer;

Expand Down Expand Up @@ -90,14 +102,16 @@ class _BodyState extends State<_Body> {
timeSec: timeTopPlayer,
incrementSec: incrementTopPlayer,
updateTime: (int time) => setState(() => timeTopPlayer = time),
updateIncrement: (int increment) => setState(() => incrementTopPlayer = increment),
updateIncrement: (int increment) =>
setState(() => incrementTopPlayer = increment),
),
_PlayerTimeSlider(
playerNr: 2,
timeSec: timeBottomPlayer,
incrementSec: incrementBottomPlayer,
updateTime: (int time) => setState(() => timeBottomPlayer = time),
updateIncrement: (int increment) => setState(() => incrementBottomPlayer = increment),
updateIncrement: (int increment) =>
setState(() => incrementBottomPlayer = increment),
),
FatButton(
semanticsLabel: context.l10n.apply,
Expand Down
36 changes: 21 additions & 15 deletions lib/src/view/play/time_control_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import 'package:lichess_mobile/src/widgets/buttons.dart';

class TimeControlModal extends ConsumerWidget {
final ValueSetter<TimeIncrement> onSelected;
final void Function(TimeIncrement playerTop, TimeIncrement playerBottom)? onSelectedCustom;
final void Function(TimeIncrement playerTop, TimeIncrement playerBottom)?
onSelectedCustom;
final TimeIncrement topPlayer;
final TimeIncrement bottomPlayer;
final bool excludeUltraBullet;
Expand Down Expand Up @@ -45,22 +46,27 @@ class TimeControlModal extends ConsumerWidget {
),
const SizedBox(height: 26.0),
if (onSelectedCustom != null)
FatButton(
semanticsLabel: context.l10n.custom,
onPressed: () => {
pushPlatformRoute(
context,
title: context.l10n.custom,
builder: (_) => CreateCustomTimeControlScreen(
onSubmit: onSelectedCustom!,
topPlayer: topPlayer,
bottomPlayer: bottomPlayer,
),
ListView(
shrinkWrap: true,
children: [
FatButton(
semanticsLabel: context.l10n.custom,
onPressed: () => {
pushPlatformRoute(
context,
title: context.l10n.custom,
builder: (_) => CreateCustomTimeControlScreen(
onSubmit: onSelectedCustom!,
topPlayer: topPlayer,
bottomPlayer: bottomPlayer,
),
),
},
child: Text(context.l10n.custom),
),
},
child: Text(context.l10n.custom),
const SizedBox(height: 20.0),
],
),
const SizedBox(height: 20.0),
_SectionChoices(
topPlayer,
choices: [
Expand Down

0 comments on commit 151020a

Please sign in to comment.