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 'package:url_launcher/url_launcher.dart';
import 'license_page.dart'; import 'license_page.dart';
import 'list_item_divider.dart';
class AboutPage extends StatefulWidget { class AboutPage extends StatefulWidget {
@override @override
@ -72,7 +73,7 @@ class _AboutPageState extends State<AboutPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onTap: _showVersionInfo, onTap: _showVersionInfo,
), ),
_buildDivider(), ListItemDivider(),
/* /*
ListTile( ListTile(
title: title:
@ -80,14 +81,14 @@ class _AboutPageState extends State<AboutPage> {
onTap: () => _launchURL( onTap: () => _launchURL(
'https://play.google.com/store/apps/details?id=com.calcitem.sanmill'), 'https://play.google.com/store/apps/details?id=com.calcitem.sanmill'),
), ),
_buildDivider(), ListItemDivider(),
*/ */
ListTile( ListTile(
title: Text(S.of(context).feedback, style: itemStyle), title: Text(S.of(context).feedback, style: itemStyle),
onTap: () => onTap: () =>
_launchURL('https://github.com/calcitem/Sanmill/issues'), _launchURL('https://github.com/calcitem/Sanmill/issues'),
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).license, style: itemStyle), title: Text(S.of(context).license, style: itemStyle),
onTap: () { onTap: () {
@ -98,45 +99,36 @@ class _AboutPageState extends State<AboutPage> {
), ),
); );
}), }),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).sourceCode, style: itemStyle), title: Text(S.of(context).sourceCode, style: itemStyle),
onTap: () => _launchURL('https://github.com/calcitem/Sanmill'), onTap: () => _launchURL('https://github.com/calcitem/Sanmill'),
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).privacyPolicy, style: itemStyle), title: Text(S.of(context).privacyPolicy, style: itemStyle),
onTap: () => _launchURL( onTap: () => _launchURL(
'https://github.com/calcitem/Sanmill/wiki/privacy_policy'), 'https://github.com/calcitem/Sanmill/wiki/privacy_policy'),
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).thirdPartyNotices, style: itemStyle), title: Text(S.of(context).thirdPartyNotices, style: itemStyle),
onTap: () => _launchURL( onTap: () => _launchURL(
'https://github.com/calcitem/Sanmill/wiki/third-party_notices'), 'https://github.com/calcitem/Sanmill/wiki/third-party_notices'),
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).thanks, style: itemStyle), title: Text(S.of(context).thanks, style: itemStyle),
onTap: () => onTap: () =>
_launchURL('https://github.com/calcitem/Sanmill/wiki/thanks'), _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 { _loadVersionInfo() async {
if (Platform.isWindows) { if (Platform.isWindows) {
setState(() { setState(() {

View File

@ -25,6 +25,8 @@ import 'package:sanmill/common/settings.dart';
import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/generated/l10n.dart';
import 'package:sanmill/style/colors.dart'; import 'package:sanmill/style/colors.dart';
import 'list_item_divider.dart';
class GameSettingsPage extends StatefulWidget { class GameSettingsPage extends StatefulWidget {
@override @override
_GameSettingsPageState createState() => _GameSettingsPageState(); _GameSettingsPageState createState() => _GameSettingsPageState();
@ -573,7 +575,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
title: Text(S.of(context).passive, style: itemStyle), title: Text(S.of(context).passive, style: itemStyle),
onChanged: setAiIsLazy, onChanged: setAiIsLazy,
), ),
_buildDivider(), ListItemDivider(),
SwitchListTile( SwitchListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
value: Config.shufflingEnabled, value: Config.shufflingEnabled,
@ -651,7 +653,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
style: itemStyle), style: itemStyle),
onChanged: setIsPieceCountInHandShown, onChanged: setIsPieceCountInHandShown,
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).boardBorderLineWidth, title: Text(S.of(context).boardBorderLineWidth,
style: itemStyle), style: itemStyle),
@ -663,7 +665,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]), ]),
onTap: setBoardBorderLineWidth, onTap: setBoardBorderLineWidth,
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).boardInnerLineWidth, title: Text(S.of(context).boardInnerLineWidth,
style: itemStyle), style: itemStyle),
@ -698,7 +700,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]), ]),
onTap: showBoardColorDialog, onTap: showBoardColorDialog,
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).backgroudColor, style: itemStyle), title: Text(S.of(context).backgroudColor, style: itemStyle),
trailing: trailing:
@ -712,7 +714,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]), ]),
onTap: showBackgroundColorDialog, onTap: showBackgroundColorDialog,
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: Text(S.of(context).lineColor, style: itemStyle), title: Text(S.of(context).lineColor, style: itemStyle),
trailing: trailing:
@ -725,7 +727,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]), ]),
onTap: showBoardLineColorDialog, onTap: showBoardLineColorDialog,
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: title:
Text(S.of(context).blackPieceColor, style: itemStyle), Text(S.of(context).blackPieceColor, style: itemStyle),
@ -739,7 +741,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]), ]),
onTap: showBlackPieceColorDialog, onTap: showBlackPieceColorDialog,
), ),
_buildDivider(), ListItemDivider(),
ListTile( ListTile(
title: title:
Text(S.of(context).whitePieceColor, style: itemStyle), Text(S.of(context).whitePieceColor, style: itemStyle),
@ -773,7 +775,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
]), ]),
onTap: restoreFactoryDefaultSettings, 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/mill/rule.dart';
import 'package:sanmill/style/colors.dart'; import 'package:sanmill/style/colors.dart';
import 'list_item_divider.dart';
class RuleSettingsPage extends StatefulWidget { class RuleSettingsPage extends StatefulWidget {
@override @override
_RuleSettingsPageState createState() => _RuleSettingsPageState(); _RuleSettingsPageState createState() => _RuleSettingsPageState();
@ -60,7 +62,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
value: 6, value: 6,
onChanged: callback, onChanged: callback,
), ),
Divider(), ListItemDivider(),
RadioListTile( RadioListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
title: Text('9'), title: Text('9'),
@ -68,7 +70,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
value: 9, value: 9,
onChanged: callback, onChanged: callback,
), ),
Divider(), ListItemDivider(),
RadioListTile( RadioListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
title: Text('12'), title: Text('12'),
@ -76,7 +78,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
value: 12, value: 12,
onChanged: callback, onChanged: callback,
), ),
Divider(), ListItemDivider(),
SizedBox(height: 56), SizedBox(height: 56),
], ],
), ),
@ -213,7 +215,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
]), ]),
onTap: setNTotalPiecesEachSide, onTap: setNTotalPiecesEachSide,
), ),
_buildDivider(), ListItemDivider(),
SwitchListTile( SwitchListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
value: Config.hasDiagonalLines, value: Config.hasDiagonalLines,
@ -223,7 +225,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setHasDiagonalLines, onChanged: setHasDiagonalLines,
), ),
_buildDivider(), ListItemDivider(),
SwitchListTile( SwitchListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
value: Config.mayFly, value: Config.mayFly,
@ -232,7 +234,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setAllowFlyingAllowed, onChanged: setAllowFlyingAllowed,
), ),
_buildDivider(), ListItemDivider(),
/* /*
SwitchListTile( SwitchListTile(
@ -242,7 +244,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
Text(S.of(context).maxStepsLedToDraw, style: itemStyle), Text(S.of(context).maxStepsLedToDraw, style: itemStyle),
onChanged: setMaxStepsLedToDraw, onChanged: setMaxStepsLedToDraw,
), ),
_buildDivider(), ListItemDivider(),
*/ */
], ],
), ),
@ -262,7 +264,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setHasBannedLocations, onChanged: setHasBannedLocations,
), ),
_buildDivider(), ListItemDivider(),
SwitchListTile( SwitchListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
value: Config.isBlackLoseButNotDrawWhenBoardFull, value: Config.isBlackLoseButNotDrawWhenBoardFull,
@ -289,7 +291,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setIsDefenderMoveFirst, onChanged: setIsDefenderMoveFirst,
), ),
_buildDivider(), ListItemDivider(),
SwitchListTile( SwitchListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
value: Config.isLoseButNotChangeSideWhenNoWay, value: Config.isLoseButNotChangeSideWhenNoWay,
@ -316,7 +318,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setAllowRemovePieceInMill, onChanged: setAllowRemovePieceInMill,
), ),
_buildDivider(), ListItemDivider(),
SwitchListTile( SwitchListTile(
activeColor: UIColors.primaryColor, activeColor: UIColors.primaryColor,
value: Config.mayRemoveMultiple, value: Config.mayRemoveMultiple,
@ -326,7 +328,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
style: TextStyle(color: UIColors.secondaryColor)), style: TextStyle(color: UIColors.secondaryColor)),
onChanged: setAllowRemoveMultiPiecesWhenCloseMultiMill, 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,
);
}
} }