@@ -19,8 +19,7 @@ class BoardSettingsScreen extends StatelessWidget {
1919
2020 @override
2121 Widget build (BuildContext context) {
22- return PlatformWidget (
23- androidBuilder: _androidBuilder, iosBuilder: _iosBuilder);
22+ return PlatformWidget (androidBuilder: _androidBuilder, iosBuilder: _iosBuilder);
2423 }
2524
2625 Widget _androidBuilder (BuildContext context) {
@@ -31,8 +30,7 @@ class BoardSettingsScreen extends StatelessWidget {
3130 }
3231
3332 Widget _iosBuilder (BuildContext context) {
34- return const CupertinoPageScaffold (
35- navigationBar: CupertinoNavigationBar (), child: _Body ());
33+ return const CupertinoPageScaffold (navigationBar: CupertinoNavigationBar (), child: _Body ());
3634 }
3735}
3836
@@ -53,8 +51,7 @@ class _Body extends ConsumerWidget {
5351 children: [
5452 SettingsListTile (
5553 settingsLabel: Text (context.l10n.preferencesHowDoYouMovePieces),
56- settingsValue:
57- pieceShiftMethodl10n (context, boardPrefs.pieceShiftMethod),
54+ settingsValue: pieceShiftMethodl10n (context, boardPrefs.pieceShiftMethod),
5855 showCupertinoTrailingValue: false ,
5956 onTap: () {
6057 if (Theme .of (context).platform == TargetPlatform .android) {
@@ -66,24 +63,21 @@ class _Body extends ConsumerWidget {
6663 onSelectedItemChanged: (PieceShiftMethod ? value) {
6764 ref
6865 .read (boardPreferencesProvider.notifier)
69- .setPieceShiftMethod (
70- value ?? PieceShiftMethod .either);
66+ .setPieceShiftMethod (value ?? PieceShiftMethod .either);
7167 },
7268 );
7369 } else {
7470 pushPlatformRoute (
7571 context,
7672 title: context.l10n.preferencesHowDoYouMovePieces,
77- builder: (context) =>
78- const PieceShiftMethodSettingsScreen (),
73+ builder: (context) => const PieceShiftMethodSettingsScreen (),
7974 );
8075 }
8176 },
8277 ),
8378 SettingsListTile (
8479 settingsLabel: Text (
85- context.l10n
86- .preferencesCastleByMovingTheKingTwoSquaresOrOntoTheRook,
80+ context.l10n.preferencesCastleByMovingTheKingTwoSquaresOrOntoTheRook,
8781 ),
8882 settingsValue: boardPrefs.castlingMethod.name,
8983 showCupertinoTrailingValue: false ,
@@ -103,8 +97,7 @@ class _Body extends ConsumerWidget {
10397 } else {
10498 pushPlatformRoute (
10599 context,
106- title: context.l10n
107- .preferencesCastleByMovingTheKingTwoSquaresOrOntoTheRook,
100+ title: context.l10n.preferencesCastleByMovingTheKingTwoSquaresOrOntoTheRook,
108101 builder: (context) => const CastlingMethodSettingsScreen (),
109102 );
110103 }
@@ -114,9 +107,7 @@ class _Body extends ConsumerWidget {
114107 title: Text (context.l10n.mobilePrefMagnifyDraggedPiece),
115108 value: boardPrefs.magnifyDraggedPiece,
116109 onChanged: (value) {
117- ref
118- .read (boardPreferencesProvider.notifier)
119- .toggleMagnifyDraggedPiece ();
110+ ref.read (boardPreferencesProvider.notifier).toggleMagnifyDraggedPiece ();
120111 },
121112 ),
122113 SettingsListTile (
@@ -158,38 +149,35 @@ class _Body extends ConsumerWidget {
158149 maxLines: 5 ,
159150 ),
160151 onChanged: (value) {
161- ref
162- .read (boardPreferencesProvider.notifier)
163- .toggleHapticFeedback ();
152+ ref.read (boardPreferencesProvider.notifier).toggleHapticFeedback ();
164153 },
165154 ),
166155 SwitchSettingTile (
167156 title: Text (context.l10n.preferencesPieceAnimation),
168157 value: boardPrefs.pieceAnimation,
169158 onChanged: (value) {
170- ref
171- .read (boardPreferencesProvider.notifier)
172- .togglePieceAnimation ();
159+ ref.read (boardPreferencesProvider.notifier).togglePieceAnimation ();
173160 },
174161 ),
175- if (Theme .of (context).platform == TargetPlatform .android &&
176- ! isTabletOrLarger (context))
162+ if (Theme .of (context).platform == TargetPlatform .android && ! isTabletOrLarger (context))
177163 androidVersionAsync.maybeWhen (
178- data: (version) => version != null && version.sdkInt >= 29
179- ? SwitchSettingTile (
180- title: Text (context.l10n.mobileSettingsImmersiveMode),
181- subtitle: Text (
182- context.l10n.mobileSettingsImmersiveModeSubtitle,
183- maxLines: 5 ,
184- ),
185- value: boardPrefs.immersiveModeWhilePlaying ?? false ,
186- onChanged: (value) {
187- ref
188- .read (boardPreferencesProvider.notifier)
189- .toggleImmersiveModeWhilePlaying ();
190- },
191- )
192- : const SizedBox .shrink (),
164+ data:
165+ (version) =>
166+ version != null && version.sdkInt >= 29
167+ ? SwitchSettingTile (
168+ title: Text (context.l10n.mobileSettingsImmersiveMode),
169+ subtitle: Text (
170+ context.l10n.mobileSettingsImmersiveModeSubtitle,
171+ maxLines: 5 ,
172+ ),
173+ value: boardPrefs.immersiveModeWhilePlaying ?? false ,
174+ onChanged: (value) {
175+ ref
176+ .read (boardPreferencesProvider.notifier)
177+ .toggleImmersiveModeWhilePlaying ();
178+ },
179+ )
180+ : const SizedBox .shrink (),
193181 orElse: () => const SizedBox .shrink (),
194182 ),
195183 SettingsListTile (
@@ -203,9 +191,10 @@ class _Body extends ConsumerWidget {
203191 choices: ClockPosition .values,
204192 selectedItem: boardPrefs.clockPosition,
205193 labelBuilder: (t) => Text (t.label),
206- onSelectedItemChanged: (ClockPosition ? value) => ref
207- .read (boardPreferencesProvider.notifier)
208- .setClockPosition (value ?? ClockPosition .right),
194+ onSelectedItemChanged:
195+ (ClockPosition ? value) => ref
196+ .read (boardPreferencesProvider.notifier)
197+ .setClockPosition (value ?? ClockPosition .right),
209198 );
210199 } else {
211200 pushPlatformRoute (
@@ -220,45 +209,38 @@ class _Body extends ConsumerWidget {
220209 title: Text (context.l10n.preferencesPieceDestinations),
221210 value: boardPrefs.showLegalMoves,
222211 onChanged: (value) {
223- ref
224- .read (boardPreferencesProvider.notifier)
225- .toggleShowLegalMoves ();
212+ ref.read (boardPreferencesProvider.notifier).toggleShowLegalMoves ();
226213 },
227214 ),
228215 SwitchSettingTile (
229216 title: Text (context.l10n.preferencesBoardHighlights),
230217 value: boardPrefs.boardHighlights,
231218 onChanged: (value) {
232- ref
233- .read (boardPreferencesProvider.notifier)
234- .toggleBoardHighlights ();
219+ ref.read (boardPreferencesProvider.notifier).toggleBoardHighlights ();
235220 },
236221 ),
237222 SettingsListTile (
238223 settingsLabel: const Text ('Material' ), //TODO: l10n
239- settingsValue: boardPrefs.materialDifferenceFormat
240- .l10n (AppLocalizations .of (context)),
224+ settingsValue: boardPrefs.materialDifferenceFormat.l10n (AppLocalizations .of (context)),
241225 onTap: () {
242226 if (Theme .of (context).platform == TargetPlatform .android) {
243227 showChoicePicker (
244228 context,
245229 choices: MaterialDifferenceFormat .values,
246230 selectedItem: boardPrefs.materialDifferenceFormat,
247231 labelBuilder: (t) => Text (t.label),
248- onSelectedItemChanged: ( MaterialDifferenceFormat ? value) =>
249- ref
232+ onSelectedItemChanged:
233+ ( MaterialDifferenceFormat ? value) => ref
250234 .read (boardPreferencesProvider.notifier)
251235 .setMaterialDifferenceFormat (
252- value ??
253- MaterialDifferenceFormat .materialDifference,
236+ value ?? MaterialDifferenceFormat .materialDifference,
254237 ),
255238 );
256239 } else {
257240 pushPlatformRoute (
258241 context,
259242 title: 'Material' ,
260- builder: (context) =>
261- const MaterialDifferenceFormatScreen (),
243+ builder: (context) => const MaterialDifferenceFormatScreen (),
262244 );
263245 }
264246 },
@@ -273,9 +255,7 @@ class _Body extends ConsumerWidget {
273255 ),
274256 value: boardPrefs.enableShapeDrawings,
275257 onChanged: (value) {
276- ref
277- .read (boardPreferencesProvider.notifier)
278- .toggleEnableShapeDrawings ();
258+ ref.read (boardPreferencesProvider.notifier).toggleEnableShapeDrawings ();
279259 },
280260 ),
281261 ],
@@ -329,9 +309,7 @@ class CastlingMethodSettingsScreen extends ConsumerWidget {
329309 );
330310
331311 void onChanged (CastlingMethod ? value) {
332- ref
333- .read (boardPreferencesProvider.notifier)
334- .setCastlingMethod (value ?? CastlingMethod .either);
312+ ref.read (boardPreferencesProvider.notifier).setCastlingMethod (value ?? CastlingMethod .either);
335313 }
336314
337315 return CupertinoPageScaffold (
@@ -361,9 +339,8 @@ class BoardClockPositionScreen extends ConsumerWidget {
361339 final clockPosition = ref.watch (
362340 boardPreferencesProvider.select ((state) => state.clockPosition),
363341 );
364- void onChanged (ClockPosition ? value) => ref
365- .read (boardPreferencesProvider.notifier)
366- .setClockPosition (value ?? ClockPosition .right);
342+ void onChanged (ClockPosition ? value) =>
343+ ref.read (boardPreferencesProvider.notifier).setClockPosition (value ?? ClockPosition .right);
367344 return CupertinoPageScaffold (
368345 navigationBar: const CupertinoNavigationBar (),
369346 child: SafeArea (
@@ -388,12 +365,11 @@ class MaterialDifferenceFormatScreen extends ConsumerWidget {
388365 @override
389366 Widget build (BuildContext context, WidgetRef ref) {
390367 final materialDifferenceFormat = ref.watch (
391- boardPreferencesProvider
392- .select ((state) => state.materialDifferenceFormat),
368+ boardPreferencesProvider.select ((state) => state.materialDifferenceFormat),
393369 );
394- void onChanged (MaterialDifferenceFormat ? value) =>
395- ref .read (boardPreferencesProvider.notifier). setMaterialDifferenceFormat (
396- value ?? MaterialDifferenceFormat .materialDifference);
370+ void onChanged (MaterialDifferenceFormat ? value) => ref
371+ .read (boardPreferencesProvider.notifier)
372+ . setMaterialDifferenceFormat ( value ?? MaterialDifferenceFormat .materialDifference);
397373 return CupertinoPageScaffold (
398374 navigationBar: const CupertinoNavigationBar (),
399375 child: ListView (
@@ -420,9 +396,7 @@ class DragTargetKindSettingsScreen extends ConsumerWidget {
420396 );
421397
422398 void onChanged (DragTargetKind ? value) {
423- ref
424- .read (boardPreferencesProvider.notifier)
425- .setDragTargetKind (value ?? DragTargetKind .circle);
399+ ref.read (boardPreferencesProvider.notifier).setDragTargetKind (value ?? DragTargetKind .circle);
426400 }
427401
428402 return CupertinoPageScaffold (
@@ -431,10 +405,8 @@ class DragTargetKindSettingsScreen extends ConsumerWidget {
431405 child: ListView (
432406 children: [
433407 Padding (
434- padding:
435- Styles .horizontalBodyPadding.add (Styles .sectionTopPadding),
436- child: const Text (
437- 'How the target square is highlighted when dragging a piece.' ),
408+ padding: Styles .horizontalBodyPadding.add (Styles .sectionTopPadding),
409+ child: const Text ('How the target square is highlighted when dragging a piece.' ),
438410 ),
439411 ChoicePicker (
440412 notchedTile: true ,
@@ -450,22 +422,18 @@ class DragTargetKindSettingsScreen extends ConsumerWidget {
450422 }
451423}
452424
453- String pieceShiftMethodl10n (
454- BuildContext context, PieceShiftMethod pieceShiftMethod) =>
425+ String pieceShiftMethodl10n (BuildContext context, PieceShiftMethod pieceShiftMethod) =>
455426 switch (pieceShiftMethod) {
456427 // TODO add this to mobile translations
457428 PieceShiftMethod .either => 'Either tap or drag' ,
458429 PieceShiftMethod .drag => context.l10n.preferencesDragPiece,
459430 PieceShiftMethod .tapTwoSquares => 'Tap two squares' ,
460431 };
461432
462- String castlingMethodl10n (
463- BuildContext context, CastlingMethod castlingMethod) =>
433+ String castlingMethodl10n (BuildContext context, CastlingMethod castlingMethod) =>
464434 switch (castlingMethod) {
465435 // TODO add this to mobile translations
466- CastlingMethod .kingOverRook =>
467- context.l10n.preferencesCastleByMovingOntoTheRook,
468- CastlingMethod .kingTwoSquares =>
469- context.l10n.preferencesCastleByMovingTwoSquares,
436+ CastlingMethod .kingOverRook => context.l10n.preferencesCastleByMovingOntoTheRook,
437+ CastlingMethod .kingTwoSquares => context.l10n.preferencesCastleByMovingTwoSquares,
470438 CastlingMethod .either => 'Either' ,
471439 };
0 commit comments