flutter: Do not show rollback button if move list is empty

This commit is contained in:
Calcitem 2021-06-05 17:12:32 +08:00
parent f6d4bd03aa
commit cb0dfa659b
1 changed files with 21 additions and 17 deletions
src/ui/flutter_app/lib/widgets

View File

@ -833,7 +833,7 @@ class _GamePageState extends State<GamePage>
onMoveListButtonPressed() {
final moveHistoryText = Game.instance.position.moveHistoryText;
var end = Game.instance.moveHistory.length - 1;
Navigator.of(context).pop();
showDialog(
@ -851,23 +851,27 @@ class _GamePageState extends State<GamePage>
child:
Text(moveHistoryText, style: AppTheme.moveHistoryTextStyle)),
actions: <Widget>[
TextButton(
child: Text(S.of(context).rollback,
style: AppTheme.moveHistoryTextStyle),
onPressed: () async {
int selectValue = await showPickerNumber(
context,
1,
Game.instance.moveHistory.length - 1,
1,
S.of(context).moves,
);
end > 0
? TextButton(
child: Text(S.of(context).rollback,
style: AppTheme.moveHistoryTextStyle),
onPressed: () async {
int selectValue = await showPickerNumber(
context,
1,
end,
1,
S.of(context).moves,
);
if (selectValue != 0) {
onTakeBackNButtonPressed(selectValue);
}
},
),
if (selectValue != 0) {
onTakeBackNButtonPressed(selectValue);
}
},
)
: TextButton(
child: Text(""),
onPressed: () => Navigator.of(context).pop()),
TextButton(
child: Text(S.of(context).copy,
style: AppTheme.moveHistoryTextStyle),