From 09baa8fa18bfe30e3625e881057928609c7dc048 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 28 Mar 2021 11:33:06 +0800 Subject: [PATCH] flutter: Add list_item_divider.dart --- .../flutter_app/lib/widgets/about_page.dart | 26 +++++--------- .../lib/widgets/game_settings_page.dart | 27 ++++++-------- .../lib/widgets/list_item_divider.dart | 36 +++++++++++++++++++ .../lib/widgets/rule_settings_page.dart | 33 +++++++---------- 4 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 src/ui/flutter_app/lib/widgets/list_item_divider.dart diff --git a/src/ui/flutter_app/lib/widgets/about_page.dart b/src/ui/flutter_app/lib/widgets/about_page.dart index 667ec7bd..7632928d 100644 --- a/src/ui/flutter_app/lib/widgets/about_page.dart +++ b/src/ui/flutter_app/lib/widgets/about_page.dart @@ -26,6 +26,7 @@ import 'package:sanmill/style/colors.dart'; import 'package:url_launcher/url_launcher.dart'; import 'license_page.dart'; +import 'list_item_divider.dart'; class AboutPage extends StatefulWidget { @override @@ -72,7 +73,7 @@ class _AboutPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onTap: _showVersionInfo, ), - _buildDivider(), + ListItemDivider(), /* ListTile( title: @@ -80,14 +81,14 @@ class _AboutPageState extends State { onTap: () => _launchURL( 'https://play.google.com/store/apps/details?id=com.calcitem.sanmill'), ), - _buildDivider(), + ListItemDivider(), */ ListTile( title: Text(S.of(context).feedback, style: itemStyle), onTap: () => _launchURL('https://github.com/calcitem/Sanmill/issues'), ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).license, style: itemStyle), onTap: () { @@ -98,45 +99,36 @@ class _AboutPageState extends State { ), ); }), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).sourceCode, style: itemStyle), onTap: () => _launchURL('https://github.com/calcitem/Sanmill'), ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).privacyPolicy, style: itemStyle), onTap: () => _launchURL( 'https://github.com/calcitem/Sanmill/wiki/privacy_policy'), ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).thirdPartyNotices, style: itemStyle), onTap: () => _launchURL( 'https://github.com/calcitem/Sanmill/wiki/third-party_notices'), ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).thanks, style: itemStyle), onTap: () => _launchURL('https://github.com/calcitem/Sanmill/wiki/thanks'), ), - _buildDivider(), + ListItemDivider(), ], ), ), ); } - Container _buildDivider() { - return Container( - margin: const EdgeInsets.symmetric(horizontal: 16), - width: double.infinity, - height: 1.0, - color: UIColors.lightLineColor, - ); - } - _loadVersionInfo() async { if (Platform.isWindows) { setState(() { diff --git a/src/ui/flutter_app/lib/widgets/game_settings_page.dart b/src/ui/flutter_app/lib/widgets/game_settings_page.dart index 8fcdc8bd..e7aebef8 100644 --- a/src/ui/flutter_app/lib/widgets/game_settings_page.dart +++ b/src/ui/flutter_app/lib/widgets/game_settings_page.dart @@ -25,6 +25,8 @@ import 'package:sanmill/common/settings.dart'; import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/style/colors.dart'; +import 'list_item_divider.dart'; + class GameSettingsPage extends StatefulWidget { @override _GameSettingsPageState createState() => _GameSettingsPageState(); @@ -573,7 +575,7 @@ class _GameSettingsPageState extends State { title: Text(S.of(context).passive, style: itemStyle), onChanged: setAiIsLazy, ), - _buildDivider(), + ListItemDivider(), SwitchListTile( activeColor: UIColors.primaryColor, value: Config.shufflingEnabled, @@ -651,7 +653,7 @@ class _GameSettingsPageState extends State { style: itemStyle), onChanged: setIsPieceCountInHandShown, ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).boardBorderLineWidth, style: itemStyle), @@ -663,7 +665,7 @@ class _GameSettingsPageState extends State { ]), onTap: setBoardBorderLineWidth, ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).boardInnerLineWidth, style: itemStyle), @@ -698,7 +700,7 @@ class _GameSettingsPageState extends State { ]), onTap: showBoardColorDialog, ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).backgroudColor, style: itemStyle), trailing: @@ -712,7 +714,7 @@ class _GameSettingsPageState extends State { ]), onTap: showBackgroundColorDialog, ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).lineColor, style: itemStyle), trailing: @@ -725,7 +727,7 @@ class _GameSettingsPageState extends State { ]), onTap: showBoardLineColorDialog, ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).blackPieceColor, style: itemStyle), @@ -739,7 +741,7 @@ class _GameSettingsPageState extends State { ]), onTap: showBlackPieceColorDialog, ), - _buildDivider(), + ListItemDivider(), ListTile( title: Text(S.of(context).whitePieceColor, style: itemStyle), @@ -773,7 +775,7 @@ class _GameSettingsPageState extends State { ]), onTap: restoreFactoryDefaultSettings, ), - _buildDivider(), + ListItemDivider(), ], ), ), @@ -782,13 +784,4 @@ class _GameSettingsPageState extends State { ), ); } - - Container _buildDivider() { - return Container( - margin: const EdgeInsets.symmetric(horizontal: 16), - width: double.infinity, - height: 1.0, - color: UIColors.lightLineColor, - ); - } } diff --git a/src/ui/flutter_app/lib/widgets/list_item_divider.dart b/src/ui/flutter_app/lib/widgets/list_item_divider.dart new file mode 100644 index 00000000..973a020c --- /dev/null +++ b/src/ui/flutter_app/lib/widgets/list_item_divider.dart @@ -0,0 +1,36 @@ +/* + This file is part of Sanmill. + Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file) + + Sanmill is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Sanmill is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +import 'package:flutter/material.dart'; +import 'package:sanmill/style/colors.dart'; + +class ListItemDivider extends StatelessWidget { + const ListItemDivider({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + width: double.infinity, + height: 1.0, + color: UIColors.lightLineColor, + ); + } +} diff --git a/src/ui/flutter_app/lib/widgets/rule_settings_page.dart b/src/ui/flutter_app/lib/widgets/rule_settings_page.dart index c46d0331..d82a15bc 100644 --- a/src/ui/flutter_app/lib/widgets/rule_settings_page.dart +++ b/src/ui/flutter_app/lib/widgets/rule_settings_page.dart @@ -22,6 +22,8 @@ import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/mill/rule.dart'; import 'package:sanmill/style/colors.dart'; +import 'list_item_divider.dart'; + class RuleSettingsPage extends StatefulWidget { @override _RuleSettingsPageState createState() => _RuleSettingsPageState(); @@ -60,7 +62,7 @@ class _RuleSettingsPageState extends State { value: 6, onChanged: callback, ), - Divider(), + ListItemDivider(), RadioListTile( activeColor: UIColors.primaryColor, title: Text('9'), @@ -68,7 +70,7 @@ class _RuleSettingsPageState extends State { value: 9, onChanged: callback, ), - Divider(), + ListItemDivider(), RadioListTile( activeColor: UIColors.primaryColor, title: Text('12'), @@ -76,7 +78,7 @@ class _RuleSettingsPageState extends State { value: 12, onChanged: callback, ), - Divider(), + ListItemDivider(), SizedBox(height: 56), ], ), @@ -213,7 +215,7 @@ class _RuleSettingsPageState extends State { ]), onTap: setNTotalPiecesEachSide, ), - _buildDivider(), + ListItemDivider(), SwitchListTile( activeColor: UIColors.primaryColor, value: Config.hasDiagonalLines, @@ -223,7 +225,7 @@ class _RuleSettingsPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onChanged: setHasDiagonalLines, ), - _buildDivider(), + ListItemDivider(), SwitchListTile( activeColor: UIColors.primaryColor, value: Config.mayFly, @@ -232,7 +234,7 @@ class _RuleSettingsPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onChanged: setAllowFlyingAllowed, ), - _buildDivider(), + ListItemDivider(), /* SwitchListTile( @@ -242,7 +244,7 @@ class _RuleSettingsPageState extends State { Text(S.of(context).maxStepsLedToDraw, style: itemStyle), onChanged: setMaxStepsLedToDraw, ), - _buildDivider(), + ListItemDivider(), */ ], ), @@ -262,7 +264,7 @@ class _RuleSettingsPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onChanged: setHasBannedLocations, ), - _buildDivider(), + ListItemDivider(), SwitchListTile( activeColor: UIColors.primaryColor, value: Config.isBlackLoseButNotDrawWhenBoardFull, @@ -289,7 +291,7 @@ class _RuleSettingsPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onChanged: setIsDefenderMoveFirst, ), - _buildDivider(), + ListItemDivider(), SwitchListTile( activeColor: UIColors.primaryColor, value: Config.isLoseButNotChangeSideWhenNoWay, @@ -316,7 +318,7 @@ class _RuleSettingsPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onChanged: setAllowRemovePieceInMill, ), - _buildDivider(), + ListItemDivider(), SwitchListTile( activeColor: UIColors.primaryColor, value: Config.mayRemoveMultiple, @@ -326,7 +328,7 @@ class _RuleSettingsPageState extends State { style: TextStyle(color: UIColors.secondaryColor)), onChanged: setAllowRemoveMultiPiecesWhenCloseMultiMill, ), - _buildDivider(), + ListItemDivider(), ]), ), ], @@ -334,13 +336,4 @@ class _RuleSettingsPageState extends State { ), ); } - - Container _buildDivider() { - return Container( - margin: const EdgeInsets.symmetric(horizontal: 16), - width: double.infinity, - height: 1.0, - color: UIColors.lightLineColor, - ); - } }