From 3e3be7b1b3ebcccbb96c307ca9bb9b2002e6c551 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 8 Nov 2020 15:37:40 +0800 Subject: [PATCH] =?UTF-8?q?flutter:=20color=5Fconst=20=E6=94=B9=E5=90=8D?= =?UTF-8?q?=E4=B8=BA=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/flutter/lib/board/board_painter.dart | 4 +-- src/ui/flutter/lib/board/board_widget.dart | 4 +-- src/ui/flutter/lib/board/pieces_painter.dart | 14 ++++---- src/ui/flutter/lib/board/words_on_board.dart | 4 +-- .../common/{color.dart => properties.dart} | 2 +- src/ui/flutter/lib/routes/battle_page.dart | 32 ++++++++--------- src/ui/flutter/lib/routes/edit_page.dart | 8 ++--- src/ui/flutter/lib/routes/main_menu.dart | 8 ++--- src/ui/flutter/lib/routes/settings_page.dart | 36 +++++++++---------- 9 files changed, 56 insertions(+), 56 deletions(-) rename src/ui/flutter/lib/common/{color.dart => properties.dart} (98%) diff --git a/src/ui/flutter/lib/board/board_painter.dart b/src/ui/flutter/lib/board/board_painter.dart index 044dd1d7..b7643bb2 100644 --- a/src/ui/flutter/lib/board/board_painter.dart +++ b/src/ui/flutter/lib/board/board_painter.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import '../board/painter_base.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; import 'board_widget.dart'; class BoardPainter extends PainterBase { @@ -35,7 +35,7 @@ class BoardPainter extends PainterBase { double offsetY, }) { // - paint.color = ColorConst.boardLineColor; + paint.color = Properties.boardLineColor; paint.style = PaintingStyle.stroke; const double borderLineWidth = 2.0; diff --git a/src/ui/flutter/lib/board/board_widget.dart b/src/ui/flutter/lib/board/board_widget.dart index 71f11e5e..aea02b01 100644 --- a/src/ui/flutter/lib/board/board_widget.dart +++ b/src/ui/flutter/lib/board/board_widget.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; import '../game/battle.dart'; import 'board_painter.dart'; import 'pieces_painter.dart'; @@ -28,7 +28,7 @@ class BoardWidget extends StatelessWidget { height: height, decoration: BoxDecoration( borderRadius: BorderRadius.circular(boardBorderRadius), - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, ), child: CustomPaint( painter: BoardPainter(width: width), diff --git a/src/ui/flutter/lib/board/pieces_painter.dart b/src/ui/flutter/lib/board/pieces_painter.dart index aa33e938..46c4595c 100644 --- a/src/ui/flutter/lib/board/pieces_painter.dart +++ b/src/ui/flutter/lib/board/pieces_painter.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import '../board/painter_base.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; import '../mill/mill.dart'; import '../mill/position.dart'; import 'board_widget.dart'; @@ -110,8 +110,8 @@ class PiecesPainter extends PainterBase { // 绘制棋子边界 paint.color = Piece.isWhite(pps.piece) - ? ColorConst.whitePieceBorderColor - : ColorConst.blackPieceBorderColor; + ? Properties.whitePieceBorderColor + : Properties.blackPieceBorderColor; canvas.drawCircle(pps.pos, pieceRadius, paint); // 临时调试用 @@ -119,8 +119,8 @@ class PiecesPainter extends PainterBase { // 棋子颜色 paint.color = Piece.isWhite(pps.piece) - ? ColorConst.whitePieceColor - : ColorConst.blackPieceColor; + ? Properties.whitePieceColor + : Properties.blackPieceColor; //paint.color = ColorConst.WhitePieceColor; canvas.drawCircle(pps.pos, pieceInnerRadius, paint); @@ -149,7 +149,7 @@ class PiecesPainter extends PainterBase { // final int row = focusIndex ~/ 7, column = focusIndex % 7; - paint.color = ColorConst.focusPositionColor; + paint.color = Properties.focusPositionColor; paint.style = PaintingStyle.stroke; paint.strokeWidth = 2; @@ -164,7 +164,7 @@ class PiecesPainter extends PainterBase { // final row = blurIndex ~/ 7, column = blurIndex % 7; - paint.color = ColorConst.blurPositionColor; + paint.color = Properties.blurPositionColor; paint.style = PaintingStyle.fill; canvas.drawCircle( diff --git a/src/ui/flutter/lib/board/words_on_board.dart b/src/ui/flutter/lib/board/words_on_board.dart index a4f4ceaf..5732b048 100644 --- a/src/ui/flutter/lib/board/words_on_board.dart +++ b/src/ui/flutter/lib/board/words_on_board.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; class WordsOnBoard extends StatelessWidget { // @@ -26,7 +26,7 @@ class WordsOnBoard extends StatelessWidget { Row(children: rChildren), ], ), - style: TextStyle(color: ColorConst.boardTipsColor), + style: TextStyle(color: Properties.boardTipsColor), ); } } diff --git a/src/ui/flutter/lib/common/color.dart b/src/ui/flutter/lib/common/properties.dart similarity index 98% rename from src/ui/flutter/lib/common/color.dart rename to src/ui/flutter/lib/common/properties.dart index 0ee37d0d..d8b0e0f8 100644 --- a/src/ui/flutter/lib/common/color.dart +++ b/src/ui/flutter/lib/common/properties.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -class ColorConst { +class Properties { // static const logoColor = Color(0xFF6D000D); diff --git a/src/ui/flutter/lib/routes/battle_page.dart b/src/ui/flutter/lib/routes/battle_page.dart index bbd5ed18..6307210c 100644 --- a/src/ui/flutter/lib/routes/battle_page.dart +++ b/src/ui/flutter/lib/routes/battle_page.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import '../board/board_widget.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; import '../common/toast.dart'; import '../engine/analysis.dart'; import '../engine/engine.dart'; @@ -153,7 +153,7 @@ class _BattlePageState extends State { builder: (BuildContext context) { return AlertDialog( title: - Text('放弃对局?', style: TextStyle(color: ColorConst.primaryColor)), + Text('放弃对局?', style: TextStyle(color: Properties.primaryColor)), content: SingleChildScrollView(child: Text('你确定要放弃当前的对局吗?')), actions: [ FlatButton(child: Text('确定'), onPressed: confirm), @@ -219,7 +219,7 @@ class _BattlePageState extends State { barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( - title: Text('赢了', style: TextStyle(color: ColorConst.primaryColor)), + title: Text('赢了', style: TextStyle(color: Properties.primaryColor)), content: Text('恭喜您取得了伟大的胜利!'), actions: [ FlatButton(child: Text('再来一盘'), onPressed: newGame), @@ -247,7 +247,7 @@ class _BattlePageState extends State { barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( - title: Text('输了', style: TextStyle(color: ColorConst.primaryColor)), + title: Text('输了', style: TextStyle(color: Properties.primaryColor)), content: Text('勇士!坚定战斗,虽败犹荣!'), actions: [ FlatButton(child: Text('再来一盘'), onPressed: newGame), @@ -269,7 +269,7 @@ class _BattlePageState extends State { barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( - title: Text('和���', style: TextStyle(color: ColorConst.primaryColor)), + title: Text('和���', style: TextStyle(color: Properties.primaryColor)), content: Text('您用自己的力量捍卫了和平!'), actions: [ FlatButton(child: Text('再来一盘'), onPressed: newGame), @@ -298,9 +298,9 @@ class _BattlePageState extends State { Widget createPageHeader() { // final titleStyle = - TextStyle(fontSize: 28, color: ColorConst.darkTextPrimaryColor); + TextStyle(fontSize: 28, color: Properties.darkTextPrimaryColor); final subTitleStyle = - TextStyle(fontSize: 16, color: ColorConst.darkTextSecondaryColor); + TextStyle(fontSize: 16, color: Properties.darkTextSecondaryColor); return Container( margin: EdgeInsets.only(top: SanmillApp.StatusBarHeight), @@ -310,7 +310,7 @@ class _BattlePageState extends State { children: [ IconButton( icon: Icon(Icons.arrow_back, - color: ColorConst.darkTextPrimaryColor), + color: Properties.darkTextPrimaryColor), onPressed: () => Navigator.of(context).pop(), ), Expanded(child: SizedBox()), @@ -321,7 +321,7 @@ class _BattlePageState extends State { Expanded(child: SizedBox()), IconButton( icon: Icon(Icons.settings, - color: ColorConst.darkTextPrimaryColor), + color: Properties.darkTextPrimaryColor), onPressed: () => Navigator.of(context).push( MaterialPageRoute(builder: (context) => SettingsPage()), ), @@ -333,7 +333,7 @@ class _BattlePageState extends State { width: 180, margin: EdgeInsets.only(bottom: 10), decoration: BoxDecoration( - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, borderRadius: BorderRadius.circular(2), ), ), @@ -363,12 +363,12 @@ class _BattlePageState extends State { Widget createOperatorBar() { // - final buttonStyle = TextStyle(color: ColorConst.primaryColor, fontSize: 20); + final buttonStyle = TextStyle(color: Properties.primaryColor, fontSize: 20); return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, ), margin: EdgeInsets.symmetric(horizontal: BattlePage.screenPaddingH), padding: EdgeInsets.symmetric(vertical: 2), @@ -410,7 +410,7 @@ class _BattlePageState extends State { // final manualStyle = TextStyle( fontSize: 18, - color: ColorConst.darkTextSecondaryColor, + color: Properties.darkTextSecondaryColor, height: 1.5, ); @@ -428,14 +428,14 @@ class _BattlePageState extends State { return Expanded( child: IconButton( - icon: Icon(Icons.expand_less, color: ColorConst.darkTextPrimaryColor), + icon: Icon(Icons.expand_less, color: Properties.darkTextPrimaryColor), onPressed: () => showDialog( context: context, barrierDismissible: false, builder: (BuildContext context) { return AlertDialog( title: - Text('棋谱', style: TextStyle(color: ColorConst.primaryColor)), + Text('棋谱', style: TextStyle(color: Properties.primaryColor)), content: SingleChildScrollView(child: Text(text, style: manualStyle)), actions: [ @@ -462,7 +462,7 @@ class _BattlePageState extends State { final footer = buildFooter(); return Scaffold( - backgroundColor: ColorConst.darkBackgroundColor, + backgroundColor: Properties.darkBackgroundColor, body: Column(children: [header, board, operatorBar, footer]), ); } diff --git a/src/ui/flutter/lib/routes/edit_page.dart b/src/ui/flutter/lib/routes/edit_page.dart index 4566da4b..2d687b84 100644 --- a/src/ui/flutter/lib/routes/edit_page.dart +++ b/src/ui/flutter/lib/routes/edit_page.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; class EditPage extends StatefulWidget { // @@ -39,7 +39,7 @@ class _EditPageState extends State { // final inputBorder = OutlineInputBorder( borderRadius: BorderRadius.circular(25), - borderSide: BorderSide(color: ColorConst.secondaryColor), + borderSide: BorderSide(color: Properties.secondaryColor), ); return Scaffold( @@ -53,7 +53,7 @@ class _EditPageState extends State { ) ], ), - backgroundColor: ColorConst.lightBackgroundColor, + backgroundColor: Properties.lightBackgroundColor, body: Container( margin: EdgeInsets.all(16), child: Column( @@ -67,7 +67,7 @@ class _EditPageState extends State { focusedBorder: inputBorder, ), style: TextStyle( - color: ColorConst.primaryColor, fontSize: 16, fontFamily: ''), + color: Properties.primaryColor, fontSize: 16, fontFamily: ''), onSubmitted: (input) => onSubmit(input), focusNode: _commentFocus, ), diff --git a/src/ui/flutter/lib/routes/main_menu.dart b/src/ui/flutter/lib/routes/main_menu.dart index a5f1c1ca..7c77edd7 100644 --- a/src/ui/flutter/lib/routes/main_menu.dart +++ b/src/ui/flutter/lib/routes/main_menu.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../common/color.dart'; +import '../common/properties.dart'; import '../engine/engine.dart'; import '../main.dart'; import 'battle_page.dart'; @@ -89,7 +89,7 @@ class _MainMenuState extends State with TickerProviderStateMixin { ); final menuItemStyle = TextStyle( fontSize: 28, - color: ColorConst.primaryColor, + color: Properties.primaryColor, shadows: [menuItemShadow], ); @@ -115,7 +115,7 @@ class _MainMenuState extends State with TickerProviderStateMixin { ); return Scaffold( - backgroundColor: ColorConst.lightBackgroundColor, + backgroundColor: Properties.lightBackgroundColor, body: Stack( children: [ menuItems, @@ -123,7 +123,7 @@ class _MainMenuState extends State with TickerProviderStateMixin { top: SanmillApp.StatusBarHeight, left: 10, child: IconButton( - icon: Icon(Icons.settings, color: ColorConst.primaryColor), + icon: Icon(Icons.settings, color: Properties.primaryColor), onPressed: () => Navigator.of(context).push( MaterialPageRoute(builder: (context) => SettingsPage()), ), diff --git a/src/ui/flutter/lib/routes/settings_page.dart b/src/ui/flutter/lib/routes/settings_page.dart index f27dee42..3c80e328 100644 --- a/src/ui/flutter/lib/routes/settings_page.dart +++ b/src/ui/flutter/lib/routes/settings_page.dart @@ -2,8 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:package_info/package_info.dart'; -import '../common/color.dart'; import '../common/config.dart'; +import '../common/properties.dart'; import '../common/toast.dart'; import '../services/audios.dart'; import '../services/player.dart'; @@ -52,7 +52,7 @@ class _SettingsPageState extends State { children: [ SizedBox(height: 10), RadioListTile( - activeColor: ColorConst.primaryColor, + activeColor: Properties.primaryColor, title: Text('初级'), groupValue: Config.stepTime, value: 5000, @@ -60,7 +60,7 @@ class _SettingsPageState extends State { ), Divider(), RadioListTile( - activeColor: ColorConst.primaryColor, + activeColor: Properties.primaryColor, title: Text('中级'), groupValue: Config.stepTime, value: 15000, @@ -68,7 +68,7 @@ class _SettingsPageState extends State { ), Divider(), RadioListTile( - activeColor: ColorConst.primaryColor, + activeColor: Properties.primaryColor, title: Text('高级'), groupValue: Config.stepTime, value: 30000, @@ -132,7 +132,7 @@ class _SettingsPageState extends State { barrierDismissible: false, builder: (context) => AlertDialog( title: - Text('关于「直棋 」', style: TextStyle(color: ColorConst.primaryColor)), + Text('关于「直棋 」', style: TextStyle(color: Properties.primaryColor)), content: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -168,11 +168,11 @@ class _SettingsPageState extends State { Widget build(BuildContext context) { // final TextStyle headerStyle = - TextStyle(color: ColorConst.secondaryColor, fontSize: 20.0); - final TextStyle itemStyle = TextStyle(color: ColorConst.primaryColor); + TextStyle(color: Properties.secondaryColor, fontSize: 20.0); + final TextStyle itemStyle = TextStyle(color: Properties.primaryColor); return Scaffold( - backgroundColor: ColorConst.lightBackgroundColor, + backgroundColor: Properties.lightBackgroundColor, appBar: AppBar(title: Text('设置')), body: SingleChildScrollView( padding: const EdgeInsets.all(16), @@ -183,7 +183,7 @@ class _SettingsPageState extends State { Text("人机难度", style: headerStyle), const SizedBox(height: 10.0), Card( - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, elevation: 0.5, margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 0), child: Column( @@ -196,7 +196,7 @@ class _SettingsPageState extends State { ? '初级' : Config.stepTime <= 15000 ? '中级' : '高级'), Icon(Icons.keyboard_arrow_right, - color: ColorConst.secondaryColor), + color: Properties.secondaryColor), ]), onTap: changeDifficult, ), @@ -206,19 +206,19 @@ class _SettingsPageState extends State { const SizedBox(height: 16), Text("声音", style: headerStyle), Card( - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, margin: const EdgeInsets.symmetric(vertical: 10), child: Column( children: [ SwitchListTile( - activeColor: ColorConst.primaryColor, + activeColor: Properties.primaryColor, value: Config.bgmEnabled, title: Text("背景音乐", style: itemStyle), onChanged: switchMusic, ), _buildDivider(), SwitchListTile( - activeColor: ColorConst.primaryColor, + activeColor: Properties.primaryColor, value: Config.toneEnabled, title: Text("提示音效", style: itemStyle), onChanged: switchTone, @@ -229,7 +229,7 @@ class _SettingsPageState extends State { const SizedBox(height: 16), Text("排行榜", style: headerStyle), Card( - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, margin: const EdgeInsets.symmetric(vertical: 10), child: Column( children: [ @@ -239,7 +239,7 @@ class _SettingsPageState extends State { Row(mainAxisSize: MainAxisSize.min, children: [ Text(Player.shared.name), Icon(Icons.keyboard_arrow_right, - color: ColorConst.secondaryColor), + color: Properties.secondaryColor), ]), onTap: changeName, ), @@ -249,7 +249,7 @@ class _SettingsPageState extends State { const SizedBox(height: 16), Text("关于", style: headerStyle), Card( - color: ColorConst.boardBackgroundColor, + color: Properties.boardBackgroundColor, margin: const EdgeInsets.symmetric(vertical: 10), child: Column( children: [ @@ -259,7 +259,7 @@ class _SettingsPageState extends State { Row(mainAxisSize: MainAxisSize.min, children: [ Text(_version ?? ''), Icon(Icons.keyboard_arrow_right, - color: ColorConst.secondaryColor), + color: Properties.secondaryColor), ]), onTap: showAbout, ), @@ -278,7 +278,7 @@ class _SettingsPageState extends State { margin: const EdgeInsets.symmetric(horizontal: 16), width: double.infinity, height: 1.0, - color: ColorConst.lightLineColor, + color: Properties.lightLineColor, ); } }