flutter: config: Support setting piece width

This commit is contained in:
Calcitem 2021-05-28 23:48:10 +08:00
parent 247bd81280
commit 2989407d31
6 changed files with 50 additions and 2 deletions

View File

@ -48,6 +48,7 @@ class Config {
static bool isNotationsShown = false;
static double boardBorderLineWidth = 2.0;
static double boardInnerLineWidth = 2.0;
static double pieceWidth = 0.9;
static double boardTop = 36.0;
// Color
@ -102,6 +103,7 @@ class Config {
Config.isNotationsShown = settings['IsNotationsShown'] ?? false;
Config.boardBorderLineWidth = settings['BoardBorderLineWidth'] ?? 2;
Config.boardInnerLineWidth = settings['BoardInnerLineWidth'] ?? 2;
Config.pieceWidth = settings['PieceWidth'] ?? 0.9;
Config.boardTop = settings['BoardTop'] ?? 36;
// Color
@ -171,6 +173,7 @@ class Config {
settings['IsNotationsShown'] = Config.isNotationsShown;
settings['BoardBorderLineWidth'] = Config.boardBorderLineWidth;
settings['BoardInnerLineWidth'] = Config.boardInnerLineWidth;
settings['PieceWidth'] = Config.pieceWidth;
settings['BoardTop'] = Config.boardTop;
// Color

View File

@ -600,6 +600,10 @@
"@boardInnerLineWidth": {
"description": "Board inner line width"
},
"pieceWidth": "Steingröße",
"@pieceWidth": {
"description": "Board inner line width"
},
"standardNotation": "Standardnotation",
"@standardNotation": {
"description": "Standard notation"

View File

@ -600,6 +600,10 @@
"@boardInnerLineWidth": {
"description": "Board inner line width"
},
"pieceWidth": "Piece width",
"@pieceWidth": {
"description": "Piece width"
},
"standardNotation": "Standard notation",
"@standardNotation": {
"description": "Standard notation"

View File

@ -150,6 +150,7 @@
"display": "显示",
"boardBorderLineWidth": "棋盘外框线宽",
"boardInnerLineWidth": "棋盘内部线宽",
"pieceWidth": "棋子大小",
"standardNotation": "标准棋谱格式",
"restore": "重置",
"restoreDefaultSettings": "恢复默认设置",

View File

@ -44,8 +44,7 @@ class PiecesPainter extends PiecesBasePainter {
this.focusIndex = invalidIndex,
this.blurIndex = invalidIndex,
}) : super(width: width) {
//
pieceWidth = squareWidth * 0.9; // size of square
pieceWidth = squareWidth * Config.pieceWidth;
}
@override

View File

@ -171,6 +171,37 @@ class _PersonalizationSettingsPageState
);
}
SliderTheme _pieceWidthSliderTheme(context, setState) {
return SliderTheme(
data: AppTheme.sliderThemeData,
child: Slider(
value: Config.pieceWidth.toDouble(),
min: 0.5,
max: 1.0,
divisions: 50,
label: Config.pieceWidth.toStringAsFixed(1),
onChanged: (value) {
setState(() {
print("[config] pieceWidth value: $value");
Config.pieceWidth = value;
Config.save();
});
},
),
);
}
setPieceWidth() async {
showModalBottomSheet(
context: context,
builder: (BuildContext context) => StatefulBuilder(
builder: (context, setState) {
return _pieceWidthSliderTheme(context, setState);
},
),
);
}
SliderTheme _boardTopSliderTheme(context, setState) {
return SliderTheme(
data: AppTheme.sliderThemeData,
@ -251,6 +282,12 @@ class _PersonalizationSettingsPageState
onTap: setBoardInnerLineWidth,
),
ListItemDivider(),
SettingsListTile(
context: context,
titleString: S.of(context).pieceWidth,
onTap: setPieceWidth,
),
ListItemDivider(),
SettingsListTile(
context: context,
titleString: S.of(context).boardTop,