flutter: color_const 改名为 properties

This commit is contained in:
Calcitem 2020-11-08 15:37:40 +08:00
parent fa428f8332
commit 3e3be7b1b3
9 changed files with 56 additions and 56 deletions

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../board/painter_base.dart'; import '../board/painter_base.dart';
import '../common/color.dart'; import '../common/properties.dart';
import 'board_widget.dart'; import 'board_widget.dart';
class BoardPainter extends PainterBase { class BoardPainter extends PainterBase {
@ -35,7 +35,7 @@ class BoardPainter extends PainterBase {
double offsetY, double offsetY,
}) { }) {
// //
paint.color = ColorConst.boardLineColor; paint.color = Properties.boardLineColor;
paint.style = PaintingStyle.stroke; paint.style = PaintingStyle.stroke;
const double borderLineWidth = 2.0; const double borderLineWidth = 2.0;

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../common/color.dart'; import '../common/properties.dart';
import '../game/battle.dart'; import '../game/battle.dart';
import 'board_painter.dart'; import 'board_painter.dart';
import 'pieces_painter.dart'; import 'pieces_painter.dart';
@ -28,7 +28,7 @@ class BoardWidget extends StatelessWidget {
height: height, height: height,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(boardBorderRadius), borderRadius: BorderRadius.circular(boardBorderRadius),
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
), ),
child: CustomPaint( child: CustomPaint(
painter: BoardPainter(width: width), painter: BoardPainter(width: width),

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../board/painter_base.dart'; import '../board/painter_base.dart';
import '../common/color.dart'; import '../common/properties.dart';
import '../mill/mill.dart'; import '../mill/mill.dart';
import '../mill/position.dart'; import '../mill/position.dart';
import 'board_widget.dart'; import 'board_widget.dart';
@ -110,8 +110,8 @@ class PiecesPainter extends PainterBase {
// //
paint.color = Piece.isWhite(pps.piece) paint.color = Piece.isWhite(pps.piece)
? ColorConst.whitePieceBorderColor ? Properties.whitePieceBorderColor
: ColorConst.blackPieceBorderColor; : Properties.blackPieceBorderColor;
canvas.drawCircle(pps.pos, pieceRadius, paint); // canvas.drawCircle(pps.pos, pieceRadius, paint); //
@ -119,8 +119,8 @@ class PiecesPainter extends PainterBase {
// //
paint.color = Piece.isWhite(pps.piece) paint.color = Piece.isWhite(pps.piece)
? ColorConst.whitePieceColor ? Properties.whitePieceColor
: ColorConst.blackPieceColor; : Properties.blackPieceColor;
//paint.color = ColorConst.WhitePieceColor; //paint.color = ColorConst.WhitePieceColor;
canvas.drawCircle(pps.pos, pieceInnerRadius, paint); canvas.drawCircle(pps.pos, pieceInnerRadius, paint);
@ -149,7 +149,7 @@ class PiecesPainter extends PainterBase {
// //
final int row = focusIndex ~/ 7, column = focusIndex % 7; final int row = focusIndex ~/ 7, column = focusIndex % 7;
paint.color = ColorConst.focusPositionColor; paint.color = Properties.focusPositionColor;
paint.style = PaintingStyle.stroke; paint.style = PaintingStyle.stroke;
paint.strokeWidth = 2; paint.strokeWidth = 2;
@ -164,7 +164,7 @@ class PiecesPainter extends PainterBase {
// //
final row = blurIndex ~/ 7, column = blurIndex % 7; final row = blurIndex ~/ 7, column = blurIndex % 7;
paint.color = ColorConst.blurPositionColor; paint.color = Properties.blurPositionColor;
paint.style = PaintingStyle.fill; paint.style = PaintingStyle.fill;
canvas.drawCircle( canvas.drawCircle(

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../common/color.dart'; import '../common/properties.dart';
class WordsOnBoard extends StatelessWidget { class WordsOnBoard extends StatelessWidget {
// //
@ -26,7 +26,7 @@ class WordsOnBoard extends StatelessWidget {
Row(children: rChildren), Row(children: rChildren),
], ],
), ),
style: TextStyle(color: ColorConst.boardTipsColor), style: TextStyle(color: Properties.boardTipsColor),
); );
} }
} }

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ColorConst { class Properties {
// //
static const logoColor = Color(0xFF6D000D); static const logoColor = Color(0xFF6D000D);

View File

@ -1,7 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../board/board_widget.dart'; import '../board/board_widget.dart';
import '../common/color.dart'; import '../common/properties.dart';
import '../common/toast.dart'; import '../common/toast.dart';
import '../engine/analysis.dart'; import '../engine/analysis.dart';
import '../engine/engine.dart'; import '../engine/engine.dart';
@ -153,7 +153,7 @@ class _BattlePageState extends State<BattlePage> {
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: title:
Text('放弃对局?', style: TextStyle(color: ColorConst.primaryColor)), Text('放弃对局?', style: TextStyle(color: Properties.primaryColor)),
content: SingleChildScrollView(child: Text('你确定要放弃当前的对局吗?')), content: SingleChildScrollView(child: Text('你确定要放弃当前的对局吗?')),
actions: <Widget>[ actions: <Widget>[
FlatButton(child: Text('确定'), onPressed: confirm), FlatButton(child: Text('确定'), onPressed: confirm),
@ -219,7 +219,7 @@ class _BattlePageState extends State<BattlePage> {
barrierDismissible: false, barrierDismissible: false,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: Text('赢了', style: TextStyle(color: ColorConst.primaryColor)), title: Text('赢了', style: TextStyle(color: Properties.primaryColor)),
content: Text('恭喜您取得了伟大的胜利!'), content: Text('恭喜您取得了伟大的胜利!'),
actions: <Widget>[ actions: <Widget>[
FlatButton(child: Text('再来一盘'), onPressed: newGame), FlatButton(child: Text('再来一盘'), onPressed: newGame),
@ -247,7 +247,7 @@ class _BattlePageState extends State<BattlePage> {
barrierDismissible: false, barrierDismissible: false,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: Text('输了', style: TextStyle(color: ColorConst.primaryColor)), title: Text('输了', style: TextStyle(color: Properties.primaryColor)),
content: Text('勇士!坚定战斗,虽败犹荣!'), content: Text('勇士!坚定战斗,虽败犹荣!'),
actions: <Widget>[ actions: <Widget>[
FlatButton(child: Text('再来一盘'), onPressed: newGame), FlatButton(child: Text('再来一盘'), onPressed: newGame),
@ -269,7 +269,7 @@ class _BattlePageState extends State<BattlePage> {
barrierDismissible: false, barrierDismissible: false,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: Text('<EFBFBD><EFBFBD><EFBFBD>', style: TextStyle(color: ColorConst.primaryColor)), title: Text('<EFBFBD><EFBFBD><EFBFBD>', style: TextStyle(color: Properties.primaryColor)),
content: Text('您用自己的力量捍卫了和平!'), content: Text('您用自己的力量捍卫了和平!'),
actions: <Widget>[ actions: <Widget>[
FlatButton(child: Text('再来一盘'), onPressed: newGame), FlatButton(child: Text('再来一盘'), onPressed: newGame),
@ -298,9 +298,9 @@ class _BattlePageState extends State<BattlePage> {
Widget createPageHeader() { Widget createPageHeader() {
// //
final titleStyle = final titleStyle =
TextStyle(fontSize: 28, color: ColorConst.darkTextPrimaryColor); TextStyle(fontSize: 28, color: Properties.darkTextPrimaryColor);
final subTitleStyle = final subTitleStyle =
TextStyle(fontSize: 16, color: ColorConst.darkTextSecondaryColor); TextStyle(fontSize: 16, color: Properties.darkTextSecondaryColor);
return Container( return Container(
margin: EdgeInsets.only(top: SanmillApp.StatusBarHeight), margin: EdgeInsets.only(top: SanmillApp.StatusBarHeight),
@ -310,7 +310,7 @@ class _BattlePageState extends State<BattlePage> {
children: <Widget>[ children: <Widget>[
IconButton( IconButton(
icon: Icon(Icons.arrow_back, icon: Icon(Icons.arrow_back,
color: ColorConst.darkTextPrimaryColor), color: Properties.darkTextPrimaryColor),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
Expanded(child: SizedBox()), Expanded(child: SizedBox()),
@ -321,7 +321,7 @@ class _BattlePageState extends State<BattlePage> {
Expanded(child: SizedBox()), Expanded(child: SizedBox()),
IconButton( IconButton(
icon: Icon(Icons.settings, icon: Icon(Icons.settings,
color: ColorConst.darkTextPrimaryColor), color: Properties.darkTextPrimaryColor),
onPressed: () => Navigator.of(context).push( onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SettingsPage()), MaterialPageRoute(builder: (context) => SettingsPage()),
), ),
@ -333,7 +333,7 @@ class _BattlePageState extends State<BattlePage> {
width: 180, width: 180,
margin: EdgeInsets.only(bottom: 10), margin: EdgeInsets.only(bottom: 10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
), ),
), ),
@ -363,12 +363,12 @@ class _BattlePageState extends State<BattlePage> {
Widget createOperatorBar() { Widget createOperatorBar() {
// //
final buttonStyle = TextStyle(color: ColorConst.primaryColor, fontSize: 20); final buttonStyle = TextStyle(color: Properties.primaryColor, fontSize: 20);
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
), ),
margin: EdgeInsets.symmetric(horizontal: BattlePage.screenPaddingH), margin: EdgeInsets.symmetric(horizontal: BattlePage.screenPaddingH),
padding: EdgeInsets.symmetric(vertical: 2), padding: EdgeInsets.symmetric(vertical: 2),
@ -410,7 +410,7 @@ class _BattlePageState extends State<BattlePage> {
// //
final manualStyle = TextStyle( final manualStyle = TextStyle(
fontSize: 18, fontSize: 18,
color: ColorConst.darkTextSecondaryColor, color: Properties.darkTextSecondaryColor,
height: 1.5, height: 1.5,
); );
@ -428,14 +428,14 @@ class _BattlePageState extends State<BattlePage> {
return Expanded( return Expanded(
child: IconButton( child: IconButton(
icon: Icon(Icons.expand_less, color: ColorConst.darkTextPrimaryColor), icon: Icon(Icons.expand_less, color: Properties.darkTextPrimaryColor),
onPressed: () => showDialog( onPressed: () => showDialog(
context: context, context: context,
barrierDismissible: false, barrierDismissible: false,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: title:
Text('棋谱', style: TextStyle(color: ColorConst.primaryColor)), Text('棋谱', style: TextStyle(color: Properties.primaryColor)),
content: content:
SingleChildScrollView(child: Text(text, style: manualStyle)), SingleChildScrollView(child: Text(text, style: manualStyle)),
actions: <Widget>[ actions: <Widget>[
@ -462,7 +462,7 @@ class _BattlePageState extends State<BattlePage> {
final footer = buildFooter(); final footer = buildFooter();
return Scaffold( return Scaffold(
backgroundColor: ColorConst.darkBackgroundColor, backgroundColor: Properties.darkBackgroundColor,
body: Column(children: <Widget>[header, board, operatorBar, footer]), body: Column(children: <Widget>[header, board, operatorBar, footer]),
); );
} }

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../common/color.dart'; import '../common/properties.dart';
class EditPage extends StatefulWidget { class EditPage extends StatefulWidget {
// //
@ -39,7 +39,7 @@ class _EditPageState extends State<EditPage> {
// //
final inputBorder = OutlineInputBorder( final inputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(25), borderRadius: BorderRadius.circular(25),
borderSide: BorderSide(color: ColorConst.secondaryColor), borderSide: BorderSide(color: Properties.secondaryColor),
); );
return Scaffold( return Scaffold(
@ -53,7 +53,7 @@ class _EditPageState extends State<EditPage> {
) )
], ],
), ),
backgroundColor: ColorConst.lightBackgroundColor, backgroundColor: Properties.lightBackgroundColor,
body: Container( body: Container(
margin: EdgeInsets.all(16), margin: EdgeInsets.all(16),
child: Column( child: Column(
@ -67,7 +67,7 @@ class _EditPageState extends State<EditPage> {
focusedBorder: inputBorder, focusedBorder: inputBorder,
), ),
style: TextStyle( style: TextStyle(
color: ColorConst.primaryColor, fontSize: 16, fontFamily: ''), color: Properties.primaryColor, fontSize: 16, fontFamily: ''),
onSubmitted: (input) => onSubmit(input), onSubmitted: (input) => onSubmit(input),
focusNode: _commentFocus, focusNode: _commentFocus,
), ),

View File

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../common/color.dart'; import '../common/properties.dart';
import '../engine/engine.dart'; import '../engine/engine.dart';
import '../main.dart'; import '../main.dart';
import 'battle_page.dart'; import 'battle_page.dart';
@ -89,7 +89,7 @@ class _MainMenuState extends State<MainMenu> with TickerProviderStateMixin {
); );
final menuItemStyle = TextStyle( final menuItemStyle = TextStyle(
fontSize: 28, fontSize: 28,
color: ColorConst.primaryColor, color: Properties.primaryColor,
shadows: [menuItemShadow], shadows: [menuItemShadow],
); );
@ -115,7 +115,7 @@ class _MainMenuState extends State<MainMenu> with TickerProviderStateMixin {
); );
return Scaffold( return Scaffold(
backgroundColor: ColorConst.lightBackgroundColor, backgroundColor: Properties.lightBackgroundColor,
body: Stack( body: Stack(
children: <Widget>[ children: <Widget>[
menuItems, menuItems,
@ -123,7 +123,7 @@ class _MainMenuState extends State<MainMenu> with TickerProviderStateMixin {
top: SanmillApp.StatusBarHeight, top: SanmillApp.StatusBarHeight,
left: 10, left: 10,
child: IconButton( child: IconButton(
icon: Icon(Icons.settings, color: ColorConst.primaryColor), icon: Icon(Icons.settings, color: Properties.primaryColor),
onPressed: () => Navigator.of(context).push( onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => SettingsPage()), MaterialPageRoute(builder: (context) => SettingsPage()),
), ),

View File

@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
import '../common/color.dart';
import '../common/config.dart'; import '../common/config.dart';
import '../common/properties.dart';
import '../common/toast.dart'; import '../common/toast.dart';
import '../services/audios.dart'; import '../services/audios.dart';
import '../services/player.dart'; import '../services/player.dart';
@ -52,7 +52,7 @@ class _SettingsPageState extends State<SettingsPage> {
children: <Widget>[ children: <Widget>[
SizedBox(height: 10), SizedBox(height: 10),
RadioListTile( RadioListTile(
activeColor: ColorConst.primaryColor, activeColor: Properties.primaryColor,
title: Text('初级'), title: Text('初级'),
groupValue: Config.stepTime, groupValue: Config.stepTime,
value: 5000, value: 5000,
@ -60,7 +60,7 @@ class _SettingsPageState extends State<SettingsPage> {
), ),
Divider(), Divider(),
RadioListTile( RadioListTile(
activeColor: ColorConst.primaryColor, activeColor: Properties.primaryColor,
title: Text('中级'), title: Text('中级'),
groupValue: Config.stepTime, groupValue: Config.stepTime,
value: 15000, value: 15000,
@ -68,7 +68,7 @@ class _SettingsPageState extends State<SettingsPage> {
), ),
Divider(), Divider(),
RadioListTile( RadioListTile(
activeColor: ColorConst.primaryColor, activeColor: Properties.primaryColor,
title: Text('高级'), title: Text('高级'),
groupValue: Config.stepTime, groupValue: Config.stepTime,
value: 30000, value: 30000,
@ -132,7 +132,7 @@ class _SettingsPageState extends State<SettingsPage> {
barrierDismissible: false, barrierDismissible: false,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: title:
Text('关于「直棋 」', style: TextStyle(color: ColorConst.primaryColor)), Text('关于「直棋 」', style: TextStyle(color: Properties.primaryColor)),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -168,11 +168,11 @@ class _SettingsPageState extends State<SettingsPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
// //
final TextStyle headerStyle = final TextStyle headerStyle =
TextStyle(color: ColorConst.secondaryColor, fontSize: 20.0); TextStyle(color: Properties.secondaryColor, fontSize: 20.0);
final TextStyle itemStyle = TextStyle(color: ColorConst.primaryColor); final TextStyle itemStyle = TextStyle(color: Properties.primaryColor);
return Scaffold( return Scaffold(
backgroundColor: ColorConst.lightBackgroundColor, backgroundColor: Properties.lightBackgroundColor,
appBar: AppBar(title: Text('设置')), appBar: AppBar(title: Text('设置')),
body: SingleChildScrollView( body: SingleChildScrollView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
@ -183,7 +183,7 @@ class _SettingsPageState extends State<SettingsPage> {
Text("人机难度", style: headerStyle), Text("人机难度", style: headerStyle),
const SizedBox(height: 10.0), const SizedBox(height: 10.0),
Card( Card(
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
elevation: 0.5, elevation: 0.5,
margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 0), margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 0),
child: Column( child: Column(
@ -196,7 +196,7 @@ class _SettingsPageState extends State<SettingsPage> {
? '初级' ? '初级'
: Config.stepTime <= 15000 ? '中级' : '高级'), : Config.stepTime <= 15000 ? '中级' : '高级'),
Icon(Icons.keyboard_arrow_right, Icon(Icons.keyboard_arrow_right,
color: ColorConst.secondaryColor), color: Properties.secondaryColor),
]), ]),
onTap: changeDifficult, onTap: changeDifficult,
), ),
@ -206,19 +206,19 @@ class _SettingsPageState extends State<SettingsPage> {
const SizedBox(height: 16), const SizedBox(height: 16),
Text("声音", style: headerStyle), Text("声音", style: headerStyle),
Card( Card(
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
margin: const EdgeInsets.symmetric(vertical: 10), margin: const EdgeInsets.symmetric(vertical: 10),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
SwitchListTile( SwitchListTile(
activeColor: ColorConst.primaryColor, activeColor: Properties.primaryColor,
value: Config.bgmEnabled, value: Config.bgmEnabled,
title: Text("背景音乐", style: itemStyle), title: Text("背景音乐", style: itemStyle),
onChanged: switchMusic, onChanged: switchMusic,
), ),
_buildDivider(), _buildDivider(),
SwitchListTile( SwitchListTile(
activeColor: ColorConst.primaryColor, activeColor: Properties.primaryColor,
value: Config.toneEnabled, value: Config.toneEnabled,
title: Text("提示音效", style: itemStyle), title: Text("提示音效", style: itemStyle),
onChanged: switchTone, onChanged: switchTone,
@ -229,7 +229,7 @@ class _SettingsPageState extends State<SettingsPage> {
const SizedBox(height: 16), const SizedBox(height: 16),
Text("排行榜", style: headerStyle), Text("排行榜", style: headerStyle),
Card( Card(
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
margin: const EdgeInsets.symmetric(vertical: 10), margin: const EdgeInsets.symmetric(vertical: 10),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
@ -239,7 +239,7 @@ class _SettingsPageState extends State<SettingsPage> {
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[ Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Player.shared.name), Text(Player.shared.name),
Icon(Icons.keyboard_arrow_right, Icon(Icons.keyboard_arrow_right,
color: ColorConst.secondaryColor), color: Properties.secondaryColor),
]), ]),
onTap: changeName, onTap: changeName,
), ),
@ -249,7 +249,7 @@ class _SettingsPageState extends State<SettingsPage> {
const SizedBox(height: 16), const SizedBox(height: 16),
Text("关于", style: headerStyle), Text("关于", style: headerStyle),
Card( Card(
color: ColorConst.boardBackgroundColor, color: Properties.boardBackgroundColor,
margin: const EdgeInsets.symmetric(vertical: 10), margin: const EdgeInsets.symmetric(vertical: 10),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
@ -259,7 +259,7 @@ class _SettingsPageState extends State<SettingsPage> {
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[ Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(_version ?? ''), Text(_version ?? ''),
Icon(Icons.keyboard_arrow_right, Icon(Icons.keyboard_arrow_right,
color: ColorConst.secondaryColor), color: Properties.secondaryColor),
]), ]),
onTap: showAbout, onTap: showAbout,
), ),
@ -278,7 +278,7 @@ class _SettingsPageState extends State<SettingsPage> {
margin: const EdgeInsets.symmetric(horizontal: 16), margin: const EdgeInsets.symmetric(horizontal: 16),
width: double.infinity, width: double.infinity,
height: 1.0, height: 1.0,
color: ColorConst.lightLineColor, color: Properties.lightLineColor,
); );
} }
} }