flutter: settings: Support choose color
This commit is contained in:
parent
3d975c2a86
commit
6939e916ff
|
@ -395,5 +395,25 @@
|
|||
"ruleSettings": "Rule Settings",
|
||||
"@ruleSettings": {
|
||||
"description": "Rule Settings"
|
||||
},
|
||||
"color": "Color",
|
||||
"@color": {
|
||||
"description": "Color"
|
||||
},
|
||||
"boardColor": "Board Color",
|
||||
"@boardColor": {
|
||||
"description": "Board Color"
|
||||
},
|
||||
"pieceColor": "Piece Color",
|
||||
"@pieceColor": {
|
||||
"description": "Piece Color"
|
||||
},
|
||||
"backgroudColor": "Background Color",
|
||||
"@backgroudColor": {
|
||||
"description": "Background Color"
|
||||
},
|
||||
"lineColor": "Line Color",
|
||||
"@lineColor": {
|
||||
"description": "Line Color"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,5 +98,10 @@
|
|||
"inviteFriend": "邀请",
|
||||
"rateTheApp": "投票",
|
||||
"exit": "退出",
|
||||
"ruleSettings": "规则设置"
|
||||
"ruleSettings": "规则设置",
|
||||
"color": "颜色",
|
||||
"boardColor": "棋盘颜色",
|
||||
"pieceColor": "棋子颜色",
|
||||
"backgroudColor": "背景颜色",
|
||||
"lineColor": "线条颜色"
|
||||
}
|
|
@ -31,15 +31,15 @@ class UIColors {
|
|||
static const primaryColor = Color(0xFF461220);
|
||||
static const secondaryColor = Color(0x99461220);
|
||||
|
||||
static const darkBackgroundColor = crusoeColor;
|
||||
static var darkBackgroundColor = crusoeColor;
|
||||
static const lightBackgroundColor = Color(0xFFEEE0CB);
|
||||
|
||||
static const boardBackgroundColor = burlyWoodColor;
|
||||
static var boardBackgroundColor = burlyWoodColor;
|
||||
|
||||
static const darkTextPrimaryColor = Colors.white;
|
||||
static const darkTextSecondaryColor = Colors.white;
|
||||
|
||||
static const boardLineColor = Color(0x996D000D);
|
||||
static var boardLineColor = Color(0x996D000D);
|
||||
static const boardTipsColor = Color(0x666D000D);
|
||||
|
||||
static const lightLineColor = Color(0x336D000D);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
import 'package:sanmill/common/config.dart';
|
||||
import 'package:sanmill/generated/l10n.dart';
|
||||
import 'package:sanmill/services/audios.dart';
|
||||
|
@ -28,11 +29,116 @@ class GameSettingsPage extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _GameSettingsPageState extends State<GameSettingsPage> {
|
||||
// create some values
|
||||
Color pickerColor = Color(0xff443a49);
|
||||
Color currentColor = Color(0xff443a49);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
// ValueChanged<Color> callback
|
||||
void changeColor(Color color) {
|
||||
setState(() => pickerColor = color);
|
||||
}
|
||||
|
||||
showBoardColorDialog() async {
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: const Text('Pick a color!'),
|
||||
content: SingleChildScrollView(
|
||||
child: ColorPicker(
|
||||
pickerColor: pickerColor,
|
||||
onColorChanged: changeColor,
|
||||
showLabel: true,
|
||||
//pickerAreaHeightPercent: 0.8,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Confirm'),
|
||||
onPressed: () {
|
||||
setState(() => currentColor = pickerColor);
|
||||
UIColors.boardBackgroundColor = pickerColor;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
showBackgroundColorDialog() async {
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: const Text('Pick a color!'),
|
||||
content: SingleChildScrollView(
|
||||
child: ColorPicker(
|
||||
pickerColor: pickerColor,
|
||||
onColorChanged: changeColor,
|
||||
showLabel: true,
|
||||
//pickerAreaHeightPercent: 0.8,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Confirm'),
|
||||
onPressed: () {
|
||||
setState(() => currentColor = pickerColor);
|
||||
UIColors.darkBackgroundColor = pickerColor;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
showBoardLineColorDialog() async {
|
||||
AlertDialog alert = AlertDialog(
|
||||
title: const Text('Pick a color!'),
|
||||
content: SingleChildScrollView(
|
||||
child: ColorPicker(
|
||||
pickerColor: pickerColor,
|
||||
onColorChanged: changeColor,
|
||||
showLabel: true,
|
||||
//pickerAreaHeightPercent: 0.8,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Confirm'),
|
||||
onPressed: () {
|
||||
setState(() => currentColor = pickerColor);
|
||||
UIColors.boardLineColor = pickerColor;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// show the dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
setSkillLevel() async {
|
||||
//
|
||||
callback(int skillLevel) async {
|
||||
|
@ -287,6 +393,50 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
|
|||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(S.of(context).color, style: headerStyle),
|
||||
Card(
|
||||
color: UIColors.boardBackgroundColor,
|
||||
margin: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(S.of(context).boardColor, style: itemStyle),
|
||||
trailing:
|
||||
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
||||
Text(UIColors.boardBackgroundColor
|
||||
.toString()
|
||||
.substring(5)),
|
||||
Icon(Icons.keyboard_arrow_right,
|
||||
color: UIColors.secondaryColor),
|
||||
]),
|
||||
onTap: showBoardColorDialog,
|
||||
),
|
||||
_buildDivider(),
|
||||
ListTile(
|
||||
title: Text(S.of(context).backgroudColor, style: itemStyle),
|
||||
trailing:
|
||||
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
||||
Text(
|
||||
UIColors.darkBackgroundColor.toString().substring(5)),
|
||||
Icon(Icons.keyboard_arrow_right,
|
||||
color: UIColors.secondaryColor),
|
||||
]),
|
||||
onTap: showBackgroundColorDialog,
|
||||
),
|
||||
_buildDivider(),
|
||||
ListTile(
|
||||
title: Text(S.of(context).lineColor, style: itemStyle),
|
||||
trailing:
|
||||
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
||||
Text(UIColors.boardLineColor.toString().substring(5)),
|
||||
Icon(Icons.keyboard_arrow_right,
|
||||
color: UIColors.secondaryColor),
|
||||
]),
|
||||
onTap: showBoardLineColorDialog,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -19,6 +19,7 @@ dependencies:
|
|||
url_launcher: ^5.7.10
|
||||
intl: ^0.17.0
|
||||
flutter_socket_io: ^0.6.0
|
||||
flutter_colorpicker: ^0.3.5
|
||||
catcher: ^0.4.1
|
||||
stack_trace: ^1.9.6
|
||||
# sentry_flutter: ^4.0.4
|
||||
|
|
Loading…
Reference in New Issue