forked from lichess-org/mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuzzle_settings_screen.dart
More file actions
48 lines (46 loc) · 1.85 KB
/
puzzle_settings_screen.dart
File metadata and controls
48 lines (46 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_preferences.dart';
import 'package:lichess_mobile/src/utils/l10n_context.dart';
import 'package:lichess_mobile/src/view/settings/board_settings_screen.dart';
import 'package:lichess_mobile/src/widgets/adaptive_bottom_sheet.dart';
import 'package:lichess_mobile/src/widgets/list.dart';
import 'package:lichess_mobile/src/widgets/settings.dart';
class PuzzleSettingsScreen extends ConsumerWidget {
const PuzzleSettingsScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final signedIn = ref.watch(authSessionProvider)?.user.id != null;
final autoNext = ref.watch(puzzlePreferencesProvider.select((value) => value.autoNext));
final rated = ref.watch(puzzlePreferencesProvider.select((value) => value.rated));
return BottomSheetScrollableContainer(
children: [
SwitchSettingTile(
title: Text(context.l10n.puzzleJumpToNextPuzzleImmediately),
value: autoNext,
onChanged: (value) {
ref.read(puzzlePreferencesProvider.notifier).setAutoNext(value);
},
),
if (signedIn)
SwitchSettingTile(
title: Text(context.l10n.rated),
value: rated,
onChanged: (value) {
ref.read(puzzlePreferencesProvider.notifier).setRated(value);
},
),
PlatformListTile(
title: const Text('Board settings'),
trailing: const Icon(CupertinoIcons.chevron_right),
onTap: () {
Navigator.of(
context,
).push(BoardSettingsScreen.buildRoute(context, fullscreenDialog: true));
},
),
],
);
}
}