flutter: Add list_item_divider.dart

This commit is contained in:
Calcitem 2021-03-28 11:33:06 +08:00
parent 33abfab7a5
commit 09baa8fa18
4 changed files with 68 additions and 54 deletions

View File

@ -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<AboutPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onTap: _showVersionInfo,
),
_buildDivider(),
ListItemDivider(),
/*
ListTile(
title:
@ -80,14 +81,14 @@ class _AboutPageState extends State<AboutPage> {
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<AboutPage> {
),
);
}),
_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(() {

View File

@ -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<GameSettingsPage> {
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<GameSettingsPage> {
style: itemStyle),
onChanged: setIsPieceCountInHandShown,
),
_buildDivider(),
ListItemDivider(),
ListTile(
title: Text(S.of(context).boardBorderLineWidth,
style: itemStyle),
@ -663,7 +665,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]),
onTap: setBoardBorderLineWidth,
),
_buildDivider(),
ListItemDivider(),
ListTile(
title: Text(S.of(context).boardInnerLineWidth,
style: itemStyle),
@ -698,7 +700,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]),
onTap: showBoardColorDialog,
),
_buildDivider(),
ListItemDivider(),
ListTile(
title: Text(S.of(context).backgroudColor, style: itemStyle),
trailing:
@ -712,7 +714,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]),
onTap: showBackgroundColorDialog,
),
_buildDivider(),
ListItemDivider(),
ListTile(
title: Text(S.of(context).lineColor, style: itemStyle),
trailing:
@ -725,7 +727,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]),
onTap: showBoardLineColorDialog,
),
_buildDivider(),
ListItemDivider(),
ListTile(
title:
Text(S.of(context).blackPieceColor, style: itemStyle),
@ -739,7 +741,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]),
onTap: showBlackPieceColorDialog,
),
_buildDivider(),
ListItemDivider(),
ListTile(
title:
Text(S.of(context).whitePieceColor, style: itemStyle),
@ -773,7 +775,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]),
onTap: restoreFactoryDefaultSettings,
),
_buildDivider(),
ListItemDivider(),
],
),
),
@ -782,13 +784,4 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
);
}
Container _buildDivider() {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
height: 1.0,
color: UIColors.lightLineColor,
);
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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,
);
}
}

View File

@ -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<RuleSettingsPage> {
value: 6,
onChanged: callback,
),
Divider(),
ListItemDivider(),
RadioListTile(
activeColor: UIColors.primaryColor,
title: Text('9'),
@ -68,7 +70,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
value: 9,
onChanged: callback,
),
Divider(),
ListItemDivider(),
RadioListTile(
activeColor: UIColors.primaryColor,
title: Text('12'),
@ -76,7 +78,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
value: 12,
onChanged: callback,
),
Divider(),
ListItemDivider(),
SizedBox(height: 56),
],
),
@ -213,7 +215,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
]),
onTap: setNTotalPiecesEachSide,
),
_buildDivider(),
ListItemDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.hasDiagonalLines,
@ -223,7 +225,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setHasDiagonalLines,
),
_buildDivider(),
ListItemDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.mayFly,
@ -232,7 +234,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setAllowFlyingAllowed,
),
_buildDivider(),
ListItemDivider(),
/*
SwitchListTile(
@ -242,7 +244,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
Text(S.of(context).maxStepsLedToDraw, style: itemStyle),
onChanged: setMaxStepsLedToDraw,
),
_buildDivider(),
ListItemDivider(),
*/
],
),
@ -262,7 +264,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setHasBannedLocations,
),
_buildDivider(),
ListItemDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.isBlackLoseButNotDrawWhenBoardFull,
@ -289,7 +291,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setIsDefenderMoveFirst,
),
_buildDivider(),
ListItemDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.isLoseButNotChangeSideWhenNoWay,
@ -316,7 +318,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setAllowRemovePieceInMill,
),
_buildDivider(),
ListItemDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.mayRemoveMultiple,
@ -326,7 +328,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setAllowRemoveMultiPiecesWhenCloseMultiMill,
),
_buildDivider(),
ListItemDivider(),
]),
),
],
@ -334,13 +336,4 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
),
);
}
Container _buildDivider() {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
height: 1.0,
color: UIColors.lightLineColor,
);
}
}