Skip to content

Commit

Permalink
[BoardEditor] moved settings to top right, added menu
Browse files Browse the repository at this point in the history
  • Loading branch information
anon committed Sep 23, 2024
1 parent a818837 commit 59cafec
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 48 deletions.
66 changes: 50 additions & 16 deletions lib/src/view/board_editor/board_editor_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import 'package:lichess_mobile/src/utils/navigation.dart';
import 'package:lichess_mobile/src/utils/screen.dart';
import 'package:lichess_mobile/src/utils/share.dart';
import 'package:lichess_mobile/src/view/analysis/analysis_screen.dart';
import 'package:lichess_mobile/src/view/board_editor/board_editor_menu.dart';
import 'package:lichess_mobile/src/view/board_editor/board_editor_settings.dart';
import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
import 'package:lichess_mobile/src/widgets/adaptive_bottom_sheet.dart';
import 'package:lichess_mobile/src/widgets/bottom_bar.dart';
import 'package:lichess_mobile/src/widgets/bottom_bar_button.dart';
import 'package:lichess_mobile/src/widgets/buttons.dart';
import 'package:lichess_mobile/src/widgets/platform_scaffold.dart';

class BoardEditorScreen extends StatelessWidget {
Expand All @@ -30,6 +32,21 @@ class BoardEditorScreen extends StatelessWidget {
return PlatformScaffold(
appBar: PlatformAppBar(
title: Text(context.l10n.boardEditor),
actions: [
AppBarIconButton(
onPressed: () => showAdaptiveBottomSheet<void>(
context: context,
isScrollControlled: true,
showDragHandle: true,
isDismissible: true,
builder: (context) => BoardEditorPositionSettings(
initialFen: initialFen,
),
),
semanticsLabel: context.l10n.settingsSettings,
icon: const Icon(Icons.settings),
),
],
),
body: _Body(initialFen),
);
Expand Down Expand Up @@ -306,21 +323,38 @@ class _BottomBar extends ConsumerWidget {
children: [
BottomBarButton(
label: context.l10n.menu,
onTap: () => showAdaptiveBottomSheet<void>(
context: context,
builder: (BuildContext context) => BoardEditorMenu(
initialFen: initialFen,
),
),
icon: Icons.tune,
),
BottomBarButton(
key: const Key('flip-button'),
label: context.l10n.flipBoard,
onTap: ref
.read(boardEditorControllerProvider(initialFen).notifier)
.flipBoard,
icon: CupertinoIcons.arrow_2_squarepath,
onTap: () {
final editorProviderData =
ref.read(boardEditorControllerProvider(initialFen).notifier);
showAdaptiveActionSheet<void>(
context: context,
actions: [
BottomSheetAction(
makeLabel: (context) => Text(context.l10n.startPosition),
onPressed: (context) {
editorProviderData.loadFen(
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq',
loadCastling: true,
loadSideToPlay: true,
);
},
),
BottomSheetAction(
makeLabel: (context) => Text(context.l10n.clearBoard),
onPressed: (context) {
editorProviderData.loadFen('8/8/8/8/8/8/8/8');
},
),
BottomSheetAction(
makeLabel: (context) => Text(context.l10n.flipBoard),
onPressed: (context) {
editorProviderData.flipBoard();
},
),
],
);
},
icon: Icons.menu,
),
BottomBarButton(
label: context.l10n.analysis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:lichess_mobile/src/styles/styles.dart';
import 'package:lichess_mobile/src/utils/l10n_context.dart';
import 'package:lichess_mobile/src/widgets/adaptive_bottom_sheet.dart';

class BoardEditorMenu extends ConsumerWidget {
const BoardEditorMenu({required this.initialFen, super.key});
class BoardEditorPositionSettings extends ConsumerWidget {
const BoardEditorPositionSettings({required this.initialFen, super.key});

final String? initialFen;

Expand All @@ -19,36 +19,6 @@ class BoardEditorMenu extends ConsumerWidget {
return BottomSheetScrollableContainer(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 8.0),
children: [
Padding(
padding: Styles.horizontalBodyPadding,
child: Wrap(
spacing: 8.0,
children: [
ChoiceChip(
onSelected: (_) {
ref.read(editorController.notifier).loadFen(
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq',
loadCastling: true,
loadSideToPlay: true,
);
},
selected: false,
label: const Text('Starting Position'),
),
ChoiceChip(
onSelected: (_) {
ref.read(editorController.notifier).loadFen(
'8/8/8/8/8/8/8/8',
loadCastling: true,
loadSideToPlay: true,
);
},
label: const Text('Clear Board'),
selected: false,
),
],
),
),
Padding(
padding: Styles.horizontalBodyPadding,
child: Wrap(
Expand Down

0 comments on commit 59cafec

Please sign in to comment.