flutter: Add History Navigation Toolbar
This commit is contained in:
parent
1766e9577d
commit
b0d4f2db42
|
@ -48,6 +48,7 @@ class Config {
|
|||
static bool standardNotationEnabled = true;
|
||||
static bool isPieceCountInHandShown = false;
|
||||
static bool isNotationsShown = false;
|
||||
static bool isHistoryNavigationToolbarShown = false;
|
||||
static double boardBorderLineWidth = 2.0;
|
||||
static double boardInnerLineWidth = 2.0;
|
||||
static double pieceWidth = 0.9;
|
||||
|
@ -109,6 +110,8 @@ class Config {
|
|||
Config.isPieceCountInHandShown =
|
||||
settings['IsPieceCountInHandShown'] ?? false;
|
||||
Config.isNotationsShown = settings['IsNotationsShown'] ?? false;
|
||||
Config.isHistoryNavigationToolbarShown =
|
||||
settings['IsHistoryNavigationToolbarShown'] ?? false;
|
||||
Config.boardBorderLineWidth = settings['BoardBorderLineWidth'] ?? 2;
|
||||
Config.boardInnerLineWidth = settings['BoardInnerLineWidth'] ?? 2;
|
||||
Config.pieceWidth = settings['PieceWidth'] ?? 0.9;
|
||||
|
@ -186,6 +189,8 @@ class Config {
|
|||
settings['StandardNotationEnabled'] = Config.standardNotationEnabled;
|
||||
settings['IsPieceCountInHandShown'] = Config.isPieceCountInHandShown;
|
||||
settings['IsNotationsShown'] = Config.isNotationsShown;
|
||||
settings['IsHistoryNavigationToolbarShown'] =
|
||||
Config.isHistoryNavigationToolbarShown;
|
||||
settings['BoardBorderLineWidth'] = Config.boardBorderLineWidth;
|
||||
settings['BoardInnerLineWidth'] = Config.boardInnerLineWidth;
|
||||
settings['PieceWidth'] = Config.pieceWidth;
|
||||
|
|
|
@ -644,6 +644,10 @@
|
|||
"@isNotationsShown": {
|
||||
"description": "Show notations on board"
|
||||
},
|
||||
"isHistoryNavigationToolbarShown": "Symbolleiste für die Verlaufsnavigation anzeigen",
|
||||
"@isHistoryNavigationToolbarShown": {
|
||||
"description": "Show history navigation toolbar"
|
||||
},
|
||||
"display": "Darstellung",
|
||||
"@display": {
|
||||
"description": "Display"
|
||||
|
|
|
@ -644,6 +644,10 @@
|
|||
"@isNotationsShown": {
|
||||
"description": "Show notations on board"
|
||||
},
|
||||
"isHistoryNavigationToolbarShown": "Show history navigation toolbar",
|
||||
"@isHistoryNavigationToolbarShown": {
|
||||
"description": "Show history navigation toolbar"
|
||||
},
|
||||
"display": "Display",
|
||||
"@display": {
|
||||
"description": "Display"
|
||||
|
|
|
@ -644,6 +644,10 @@
|
|||
"@isNotationsShown": {
|
||||
"description": "Show notations on board"
|
||||
},
|
||||
"isHistoryNavigationToolbarShown": "نمایش نوار ابزار پیمایش تاریخچه",
|
||||
"@isHistoryNavigationToolbarShown": {
|
||||
"description": "Show history navigation toolbar"
|
||||
},
|
||||
"display": "نمایش دادن",
|
||||
"@display": {
|
||||
"description": "Display"
|
||||
|
|
|
@ -161,6 +161,7 @@
|
|||
"aiIsLazy": "机器领先时懒惰",
|
||||
"isPieceCountInHandShown": "显示手中剩余棋子数",
|
||||
"isNotationsShown": "棋盘边缘显示坐标",
|
||||
"isHistoryNavigationToolbarShown": "显示着法导航工具栏",
|
||||
"display": "显示",
|
||||
"boardBorderLineWidth": "棋盘外框线宽",
|
||||
"boardInnerLineWidth": "棋盘内部线宽",
|
||||
|
|
|
@ -291,7 +291,8 @@ class _GamePageState extends State<GamePage>
|
|||
if (position.phase == Phase.moving &&
|
||||
rule.mayFly &&
|
||||
(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.");
|
||||
if (mounted) {
|
||||
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
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
|
@ -1442,10 +1517,19 @@ class _GamePageState extends State<GamePage>
|
|||
final header = createPageHeader();
|
||||
final board = createBoard();
|
||||
final toolbar = createToolbar();
|
||||
final historyNavToolbar = createHistoryNavigationToolbar();
|
||||
|
||||
return Scaffold(
|
||||
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>[
|
||||
header,
|
||||
|
|
|
@ -511,6 +511,16 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
|||
Config.save();
|
||||
}
|
||||
|
||||
setIsHistoryNavigationToolbarShown(bool value) async {
|
||||
setState(() {
|
||||
Config.isHistoryNavigationToolbarShown = value;
|
||||
});
|
||||
|
||||
print("[config] isHistoryNavigationToolbarShown: $value");
|
||||
|
||||
Config.save();
|
||||
}
|
||||
|
||||
setStandardNotationEnabled(bool value) async {
|
||||
setState(() {
|
||||
Config.standardNotationEnabled = value;
|
||||
|
|
|
@ -351,6 +351,13 @@ class _PersonalizationSettingsPageState
|
|||
titleString: S.of(context).isNotationsShown,
|
||||
),
|
||||
ListItemDivider(),
|
||||
SettingsSwitchListTile(
|
||||
context: context,
|
||||
value: Config.isHistoryNavigationToolbarShown,
|
||||
onChanged: setIsHistoryNavigationToolbarShown,
|
||||
titleString: S.of(context).isHistoryNavigationToolbarShown,
|
||||
),
|
||||
ListItemDivider(),
|
||||
SettingsListTile(
|
||||
context: context,
|
||||
titleString: S.of(context).boardBorderLineWidth,
|
||||
|
@ -463,6 +470,14 @@ class _PersonalizationSettingsPageState
|
|||
Config.save();
|
||||
}
|
||||
|
||||
setIsHistoryNavigationToolbarShown(bool value) async {
|
||||
setState(() {
|
||||
Config.isHistoryNavigationToolbarShown = value;
|
||||
});
|
||||
|
||||
Config.save();
|
||||
}
|
||||
|
||||
setStandardNotationEnabled(bool value) async {
|
||||
setState(() {
|
||||
Config.standardNotationEnabled = value;
|
||||
|
|
Loading…
Reference in New Issue