flutter: Add History Navigation Toolbar

This commit is contained in:
Calcitem 2021-06-06 11:12:18 +08:00
parent 1766e9577d
commit b0d4f2db42
8 changed files with 129 additions and 2 deletions

View File

@ -48,6 +48,7 @@ class Config {
static bool standardNotationEnabled = true; static bool standardNotationEnabled = true;
static bool isPieceCountInHandShown = false; static bool isPieceCountInHandShown = false;
static bool isNotationsShown = false; static bool isNotationsShown = false;
static bool isHistoryNavigationToolbarShown = false;
static double boardBorderLineWidth = 2.0; static double boardBorderLineWidth = 2.0;
static double boardInnerLineWidth = 2.0; static double boardInnerLineWidth = 2.0;
static double pieceWidth = 0.9; static double pieceWidth = 0.9;
@ -109,6 +110,8 @@ class Config {
Config.isPieceCountInHandShown = Config.isPieceCountInHandShown =
settings['IsPieceCountInHandShown'] ?? false; settings['IsPieceCountInHandShown'] ?? false;
Config.isNotationsShown = settings['IsNotationsShown'] ?? false; Config.isNotationsShown = settings['IsNotationsShown'] ?? false;
Config.isHistoryNavigationToolbarShown =
settings['IsHistoryNavigationToolbarShown'] ?? false;
Config.boardBorderLineWidth = settings['BoardBorderLineWidth'] ?? 2; Config.boardBorderLineWidth = settings['BoardBorderLineWidth'] ?? 2;
Config.boardInnerLineWidth = settings['BoardInnerLineWidth'] ?? 2; Config.boardInnerLineWidth = settings['BoardInnerLineWidth'] ?? 2;
Config.pieceWidth = settings['PieceWidth'] ?? 0.9; Config.pieceWidth = settings['PieceWidth'] ?? 0.9;
@ -186,6 +189,8 @@ class Config {
settings['StandardNotationEnabled'] = Config.standardNotationEnabled; settings['StandardNotationEnabled'] = Config.standardNotationEnabled;
settings['IsPieceCountInHandShown'] = Config.isPieceCountInHandShown; settings['IsPieceCountInHandShown'] = Config.isPieceCountInHandShown;
settings['IsNotationsShown'] = Config.isNotationsShown; settings['IsNotationsShown'] = Config.isNotationsShown;
settings['IsHistoryNavigationToolbarShown'] =
Config.isHistoryNavigationToolbarShown;
settings['BoardBorderLineWidth'] = Config.boardBorderLineWidth; settings['BoardBorderLineWidth'] = Config.boardBorderLineWidth;
settings['BoardInnerLineWidth'] = Config.boardInnerLineWidth; settings['BoardInnerLineWidth'] = Config.boardInnerLineWidth;
settings['PieceWidth'] = Config.pieceWidth; settings['PieceWidth'] = Config.pieceWidth;

View File

@ -644,6 +644,10 @@
"@isNotationsShown": { "@isNotationsShown": {
"description": "Show notations on board" "description": "Show notations on board"
}, },
"isHistoryNavigationToolbarShown": "Symbolleiste für die Verlaufsnavigation anzeigen",
"@isHistoryNavigationToolbarShown": {
"description": "Show history navigation toolbar"
},
"display": "Darstellung", "display": "Darstellung",
"@display": { "@display": {
"description": "Display" "description": "Display"

View File

@ -644,6 +644,10 @@
"@isNotationsShown": { "@isNotationsShown": {
"description": "Show notations on board" "description": "Show notations on board"
}, },
"isHistoryNavigationToolbarShown": "Show history navigation toolbar",
"@isHistoryNavigationToolbarShown": {
"description": "Show history navigation toolbar"
},
"display": "Display", "display": "Display",
"@display": { "@display": {
"description": "Display" "description": "Display"

View File

@ -644,6 +644,10 @@
"@isNotationsShown": { "@isNotationsShown": {
"description": "Show notations on board" "description": "Show notations on board"
}, },
"isHistoryNavigationToolbarShown": "نمایش نوار ابزار پیمایش تاریخچه",
"@isHistoryNavigationToolbarShown": {
"description": "Show history navigation toolbar"
},
"display": "نمایش دادن", "display": "نمایش دادن",
"@display": { "@display": {
"description": "Display" "description": "Display"

View File

@ -161,6 +161,7 @@
"aiIsLazy": "机器领先时懒惰", "aiIsLazy": "机器领先时懒惰",
"isPieceCountInHandShown": "显示手中剩余棋子数", "isPieceCountInHandShown": "显示手中剩余棋子数",
"isNotationsShown": "棋盘边缘显示坐标", "isNotationsShown": "棋盘边缘显示坐标",
"isHistoryNavigationToolbarShown": "显示着法导航工具栏",
"display": "显示", "display": "显示",
"boardBorderLineWidth": "棋盘外框线宽", "boardBorderLineWidth": "棋盘外框线宽",
"boardInnerLineWidth": "棋盘内部线宽", "boardInnerLineWidth": "棋盘内部线宽",

View File

@ -291,7 +291,8 @@ class _GamePageState extends State<GamePage>
if (position.phase == Phase.moving && if (position.phase == Phase.moving &&
rule.mayFly && rule.mayFly &&
(Game.instance.position.pieceOnBoardCount[us] == (Game.instance.position.pieceOnBoardCount[us] ==
Config.flyPieceCount || Game.instance.position.pieceOnBoardCount[us] == 3)) { Config.flyPieceCount ||
Game.instance.position.pieceOnBoardCount[us] == 3)) {
print("[tap] May fly."); print("[tap] May fly.");
if (mounted) { if (mounted) {
showTip(S.of(context).tipCanMoveToAnyPoint); showTip(S.of(context).tipCanMoveToAnyPoint);
@ -1415,6 +1416,80 @@ class _GamePageState extends State<GamePage>
); );
} }
Widget createHistoryNavigationToolbar() {
var takeBackAllButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Icon(
Icons.first_page,
color: AppTheme.toolbarIconColor,
),
],
),
onPressed: () => onTakeBackAllButtonPressed(pop: false),
);
var takeBackButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Icon(
ltr ? Icons.keyboard_arrow_left : Icons.keyboard_arrow_right,
color: AppTheme.toolbarIconColor,
),
],
),
onPressed: () => onTakeBackButtonPressed(pop: false),
);
var stepForwardButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Icon(
ltr ? Icons.keyboard_arrow_right : Icons.keyboard_arrow_left,
color: AppTheme.toolbarIconColor,
),
],
),
onPressed: () => onStepForwardButtonPressed(pop: false),
);
var stepForwardAllButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Icon(
Icons.last_page,
color: AppTheme.toolbarIconColor,
),
],
),
onPressed: () => onStepForwardAllButtonPressed(pop: false),
);
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: Color(Config.boardBackgroundColor),
),
margin: EdgeInsets.symmetric(horizontal: GamePage.screenPaddingH),
padding: EdgeInsets.symmetric(vertical: 2),
child: Row(children: <Widget>[
Expanded(child: SizedBox()),
takeBackAllButton,
Expanded(child: SizedBox()),
takeBackButton,
Expanded(child: SizedBox()),
stepForwardButton,
Expanded(child: SizedBox()), //dashboard_outlined
stepForwardAllButton,
Expanded(child: SizedBox()),
]),
);
}
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
@ -1442,10 +1517,19 @@ class _GamePageState extends State<GamePage>
final header = createPageHeader(); final header = createPageHeader();
final board = createBoard(); final board = createBoard();
final toolbar = createToolbar(); final toolbar = createToolbar();
final historyNavToolbar = createHistoryNavigationToolbar();
return Scaffold( return Scaffold(
backgroundColor: Color(Config.darkBackgroundColor), backgroundColor: Color(Config.darkBackgroundColor),
body: Column(children: <Widget>[header, board, toolbar]), body: Column(children: <Widget>[
header,
board,
Config.isHistoryNavigationToolbarShown
? historyNavToolbar
: SizedBox(height: 0),
SizedBox(height: 1),
toolbar,
]),
/* /*
body: Column(children: <Widget>[ body: Column(children: <Widget>[
header, header,

View File

@ -511,6 +511,16 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
Config.save(); Config.save();
} }
setIsHistoryNavigationToolbarShown(bool value) async {
setState(() {
Config.isHistoryNavigationToolbarShown = value;
});
print("[config] isHistoryNavigationToolbarShown: $value");
Config.save();
}
setStandardNotationEnabled(bool value) async { setStandardNotationEnabled(bool value) async {
setState(() { setState(() {
Config.standardNotationEnabled = value; Config.standardNotationEnabled = value;

View File

@ -351,6 +351,13 @@ class _PersonalizationSettingsPageState
titleString: S.of(context).isNotationsShown, titleString: S.of(context).isNotationsShown,
), ),
ListItemDivider(), ListItemDivider(),
SettingsSwitchListTile(
context: context,
value: Config.isHistoryNavigationToolbarShown,
onChanged: setIsHistoryNavigationToolbarShown,
titleString: S.of(context).isHistoryNavigationToolbarShown,
),
ListItemDivider(),
SettingsListTile( SettingsListTile(
context: context, context: context,
titleString: S.of(context).boardBorderLineWidth, titleString: S.of(context).boardBorderLineWidth,
@ -463,6 +470,14 @@ class _PersonalizationSettingsPageState
Config.save(); Config.save();
} }
setIsHistoryNavigationToolbarShown(bool value) async {
setState(() {
Config.isHistoryNavigationToolbarShown = value;
});
Config.save();
}
setStandardNotationEnabled(bool value) async { setStandardNotationEnabled(bool value) async {
setState(() { setState(() {
Config.standardNotationEnabled = value; Config.standardNotationEnabled = value;