fix some stuff

- remove unnecessary containers
- bump linting version in pubspec.yml
- make `isLargeScreen` and `isSmallScreen` a geter
- add decimal points to double values
- remove unused SizedBox
- use const constructor where possible
- remove residual code
- fix help_screen AppBar
- Fix historyNavToolbar padding

fix styling of drawer
- fix the padding of the drawer elements.


cleanup settings
- removes unused properties
- fixes ListItemDivider height
This commit is contained in:
Leptopoda 2021-10-10 11:16:01 +02:00
parent 418d1cfb44
commit 961aa6241b
No known key found for this signature in database
GPG Key ID: 661B059EDE309F11
17 changed files with 142 additions and 246 deletions

View File

@ -96,7 +96,7 @@ Future<void> main() async {
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown],
);
if (Platform.isAndroid && isLargeScreen()) {
if (Platform.isAndroid && isLargeScreen) {
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
@ -108,7 +108,7 @@ Future<void> main() async {
);
}
if (isSmallScreen()) {
if (isSmallScreen) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
}
}

View File

@ -34,7 +34,6 @@ import 'list_item_divider.dart';
import 'oss_license_page.dart';
class AboutPage extends StatelessWidget {
// String _version = "";
final String tag = "[about] ";
String get mode {

View File

@ -49,12 +49,9 @@ import 'game_settings_page.dart';
double boardWidth = 0.0;
class GamePage extends StatefulWidget {
static double boardMargin = AppTheme.boardMargin;
static double screenPaddingH = AppTheme.boardScreenPaddingH;
final EngineType engineType;
const GamePage(this.engineType);
const GamePage(this.engineType, {Key? key}) : super(key: key);
@override
_GamePageState createState() => _GamePageState();
@ -64,6 +61,9 @@ class _GamePageState extends State<GamePage>
with RouteAware, SingleTickerProviderStateMixin {
final Engine _engine = NativeEngine();
double screenPaddingH = AppTheme.boardScreenPaddingH;
final double boardMargin = AppTheme.boardMargin;
String? _tip = '';
bool isReady = false;
bool isGoingToHistory = false;
@ -77,26 +77,9 @@ class _GamePageState extends State<GamePage>
late AnimationController _animationController;
late Animation<double> animation;
bool disposed = false;
bool ltr = true;
late final bool ltr;
final String tag = "[game_page]";
@override
void initState() {
debugPrint("$tag Engine type: ${widget.engineType}");
gameInstance.setWhoIsAi(widget.engineType);
super.initState();
gameInstance.init();
_engine.startup();
timer = Timer.periodic(const Duration(microseconds: 100), (Timer t) {
_setReadyState();
});
_initAnimation();
}
Future<void> _setReadyState() async {
debugPrint("$tag Check if need to set Ready state...");
if (!isReady && mounted && Config.settingsLoaded) {
@ -124,9 +107,7 @@ class _GamePageState extends State<GamePage>
begin: 1.27, // sqrt(1.618) = 1.272
end: 1.0,
).animate(_animationController)
..addListener(() {
setState(() {});
});
..addListener(() => setState(() {}));
_animationController.addStatusListener((state) {
if (state == AnimationStatus.completed ||
@ -904,6 +885,44 @@ class _GamePageState extends State<GamePage>
}
void onMoveButtonPressed() {
final List<Widget> _historyNavigation = [
SimpleDialogOption(
onPressed: onTakeBackButtonPressed,
child: Text(
S.of(context).takeBack,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
const SizedBox(height: AppTheme.sizedBoxHeight),
SimpleDialogOption(
onPressed: onStepForwardButtonPressed,
child: Text(
S.of(context).stepForward,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
const SizedBox(height: AppTheme.sizedBoxHeight),
SimpleDialogOption(
onPressed: onTakeBackAllButtonPressed,
child: Text(
S.of(context).takeBackAll,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
const SizedBox(height: AppTheme.sizedBoxHeight),
SimpleDialogOption(
onPressed: onStepForwardAllButtonPressed,
child: Text(
S.of(context).stepForwardAll,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
const SizedBox(height: AppTheme.sizedBoxHeight),
];
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
@ -912,50 +931,7 @@ class _GamePageState extends State<GamePage>
child: SimpleDialog(
backgroundColor: Colors.transparent,
children: <Widget>[
if (!Config.isHistoryNavigationToolbarShown)
SimpleDialogOption(
onPressed: onTakeBackButtonPressed,
child: Text(
S.of(context).takeBack,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
if (!Config.isHistoryNavigationToolbarShown)
const SizedBox(height: AppTheme.sizedBoxHeight),
if (!Config.isHistoryNavigationToolbarShown)
SimpleDialogOption(
onPressed: onStepForwardButtonPressed,
child: Text(
S.of(context).stepForward,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
if (!Config.isHistoryNavigationToolbarShown)
const SizedBox(height: AppTheme.sizedBoxHeight),
if (!Config.isHistoryNavigationToolbarShown)
SimpleDialogOption(
onPressed: onTakeBackAllButtonPressed,
child: Text(
S.of(context).takeBackAll,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
if (!Config.isHistoryNavigationToolbarShown)
const SizedBox(height: AppTheme.sizedBoxHeight),
if (!Config.isHistoryNavigationToolbarShown)
SimpleDialogOption(
onPressed: onStepForwardAllButtonPressed,
child: Text(
S.of(context).stepForwardAll,
style: AppTheme.simpleDialogOptionTextStyle,
textAlign: TextAlign.center,
),
),
if (!Config.isHistoryNavigationToolbarShown)
const SizedBox(height: AppTheme.sizedBoxHeight),
if (!Config.isHistoryNavigationToolbarShown) ..._historyNavigation,
SimpleDialogOption(
onPressed: onMoveListButtonPressed,
child: Text(
@ -1430,21 +1406,23 @@ class _GamePageState extends State<GamePage>
}
}
void calcScreenPaddingH() {
double get _screenPaddingH {
//
// when screen's height/width rate is less than 16/9, limit width of board
final windowSize = MediaQuery.of(context).size;
final double height = windowSize.height;
double width = windowSize.width;
// TODO: maybe use windowSize.aspectratio
if (height / width < 16.0 / 9.0) {
width = height * 9 / 16;
GamePage.screenPaddingH =
(windowSize.width - width) / 2 - AppTheme.boardMargin;
return (windowSize.width - width) / 2 - AppTheme.boardMargin;
} else {
return AppTheme.boardScreenPaddingH;
}
}
Widget createPageHeader() {
Widget get header {
final Map<EngineType, IconData> engineTypeToIconLeft = {
EngineType.humanVsAi: Config.aiMovesFirst
? FluentIcons.bot_24_filled
@ -1467,17 +1445,14 @@ class _GamePageState extends State<GamePage>
EngineType.testViaLAN: FluentIcons.wifi_1_24_filled,
};
final IconData iconArrow = getIconArrow();
final iconColor = Color(Config.messageColor);
final iconRow = Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Expanded(child: SizedBox()),
Icon(engineTypeToIconLeft[widget.engineType], color: iconColor),
Icon(iconArrow, color: iconColor),
Icon(engineTypeToIconRight[widget.engineType], color: iconColor),
const Expanded(child: SizedBox()),
],
);
@ -1511,7 +1486,7 @@ class _GamePageState extends State<GamePage>
);
}
IconData getIconArrow() {
IconData get iconArrow {
IconData iconArrow = FluentIcons.code_24_regular;
if (gameInstance.position.phase == Phase.gameOver) {
@ -1547,15 +1522,11 @@ class _GamePageState extends State<GamePage>
return iconArrow;
}
Widget createBoard() {
boardWidth =
MediaQuery.of(context).size.width - GamePage.screenPaddingH * 2;
Widget get board {
boardWidth = MediaQuery.of(context).size.width - screenPaddingH * 2;
return Container(
margin: EdgeInsets.symmetric(
horizontal: GamePage.screenPaddingH,
vertical: GamePage.boardMargin,
),
margin: EdgeInsets.symmetric(vertical: boardMargin),
child: Board(
width: boardWidth,
onBoardTap: onBoardTap,
@ -1630,7 +1601,7 @@ class _GamePageState extends State<GamePage>
return ret;
}
Widget createToolbar() {
Widget get toolbar {
final gameButton = TextButton(
onPressed: onGameButtonPressed,
child: Column(
@ -1704,94 +1675,70 @@ class _GamePageState extends State<GamePage>
borderRadius: BorderRadius.circular(5),
color: Color(Config.mainToolbarBackgroundColor),
),
margin: EdgeInsets.symmetric(horizontal: GamePage.screenPaddingH),
margin: EdgeInsets.symmetric(horizontal: screenPaddingH),
padding: const EdgeInsets.symmetric(vertical: 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
textDirection: TextDirection.ltr,
children: <Widget>[
const Expanded(child: SizedBox()),
gameButton,
const Expanded(child: SizedBox()),
optionsButton,
const Expanded(child: SizedBox()),
moveButton,
const Expanded(child: SizedBox()), //dashboard_outlined
infoButton,
const Expanded(child: SizedBox()),
],
),
);
}
Widget createHistoryNavigationToolbar() {
Widget get historyNavToolbar {
final takeBackAllButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Semantics(
label: S.of(context).takeBackAll,
child: Icon(
ltr
? FluentIcons.arrow_previous_24_regular
: FluentIcons.arrow_next_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
],
child: Semantics(
label: S.of(context).takeBackAll,
child: Icon(
ltr
? FluentIcons.arrow_previous_24_regular
: FluentIcons.arrow_next_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
onPressed: () => onTakeBackAllButtonPressed(pop: false),
);
final takeBackButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Semantics(
label: S.of(context).takeBack,
child: Icon(
ltr
? FluentIcons.chevron_left_24_regular
: FluentIcons.chevron_right_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
],
child: Semantics(
label: S.of(context).takeBack,
child: Icon(
ltr
? FluentIcons.chevron_left_24_regular
: FluentIcons.chevron_right_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
onPressed: () => onTakeBackButtonPressed(pop: false),
);
final stepForwardButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Semantics(
label: S.of(context).stepForward,
child: Icon(
ltr
? FluentIcons.chevron_right_24_regular
: FluentIcons.chevron_left_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
],
child: Semantics(
label: S.of(context).stepForward,
child: Icon(
ltr
? FluentIcons.chevron_right_24_regular
: FluentIcons.chevron_left_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
onPressed: () => onStepForwardButtonPressed(pop: false),
);
final stepForwardAllButton = TextButton(
child: Column(
// Replace with a Row for horizontal icon + text
children: <Widget>[
Semantics(
label: S.of(context).stepForwardAll,
child: Icon(
ltr
? FluentIcons.arrow_next_24_regular
: FluentIcons.arrow_previous_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
],
child: Semantics(
label: S.of(context).stepForwardAll,
child: Icon(
ltr
? FluentIcons.arrow_next_24_regular
: FluentIcons.arrow_previous_24_regular,
color: Color(Config.navigationToolbarIconColor),
),
),
onPressed: () => onStepForwardAllButtonPressed(pop: false),
);
@ -1801,25 +1748,41 @@ class _GamePageState extends State<GamePage>
borderRadius: BorderRadius.circular(5),
color: Color(Config.navigationToolbarBackgroundColor),
),
margin: EdgeInsets.symmetric(horizontal: GamePage.screenPaddingH),
margin: EdgeInsets.symmetric(
horizontal: screenPaddingH,
vertical: 1,
),
padding: const EdgeInsets.symmetric(vertical: 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
textDirection: TextDirection.ltr,
children: <Widget>[
const Expanded(child: SizedBox()),
takeBackAllButton,
const Expanded(child: SizedBox()),
takeBackButton,
const Expanded(child: SizedBox()),
stepForwardButton,
const Expanded(child: SizedBox()), //dashboard_outlined
stepForwardAllButton,
const Expanded(child: SizedBox()),
],
),
);
}
@override
void initState() {
debugPrint("$tag Engine type: ${widget.engineType}");
gameInstance.setWhoIsAi(widget.engineType);
super.initState();
gameInstance.init();
_engine.startup();
timer = Timer.periodic(const Duration(microseconds: 100), (Timer t) {
_setReadyState();
});
_initAnimation();
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
@ -1827,23 +1790,16 @@ class _GamePageState extends State<GamePage>
this,
ModalRoute.of(context)! as PageRoute<dynamic>,
);
screenPaddingH = _screenPaddingH;
ltr = getBidirectionality(context) == Bidirectionality.leftToRight;
}
@override
Widget build(BuildContext context) {
ltr = getBidirectionality(context) == Bidirectionality.leftToRight;
if (_tip == '') {
_tip = S.of(context).welcome;
}
calcScreenPaddingH();
final header = createPageHeader();
final board = createBoard();
final toolbar = createToolbar();
final historyNavToolbar = createHistoryNavigationToolbar();
return Scaffold(
backgroundColor: Color(Config.darkBackgroundColor),
body: Column(

View File

@ -194,10 +194,8 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
return <Widget>[
Text(S.of(context).whoMovesFirst, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: !Config.aiMovesFirst,
onChanged: setWhoMovesFirst,
titleString:
@ -208,7 +206,6 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).difficulty, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsListTile(
titleString: S.of(context).skillLevel,
@ -224,7 +221,6 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).aisPlayStyle, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsListTile(
titleString: S.of(context).algorithm,
@ -232,66 +228,50 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
onTap: setAlgorithm,
),
SettingsSwitchListTile(
context: context,
value: Config.drawOnHumanExperience,
onChanged: setDrawOnHumanExperience,
titleString: S.of(context).drawOnHumanExperience,
),
SettingsSwitchListTile(
context: context,
value: Config.considerMobility,
onChanged: setConsiderMobility,
titleString: S.of(context).considerMobility,
),
SettingsSwitchListTile(
context: context,
value: Config.aiIsLazy,
onChanged: setAiIsLazy,
titleString: S.of(context).passive,
),
SettingsSwitchListTile(
context: context,
value: Config.shufflingEnabled,
onChanged: setShufflingEnabled,
titleString: S.of(context).shufflingEnabled,
),
],
),
if (!Platform.isWindows) const SizedBox(height: AppTheme.sizedBoxHeight),
if (!Platform.isWindows)
const SizedBox(height: AppTheme.sizedBoxHeight)
else
const SizedBox(height: 0.0, width: 0.0),
if (!Platform.isWindows)
Text(S.of(context).playSounds, style: AppTheme.settingsHeaderStyle)
else
const SizedBox(height: 0.0, width: 0.0),
Text(S.of(context).playSounds, style: AppTheme.settingsHeaderStyle),
if (!Platform.isWindows)
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.toneEnabled,
onChanged: setTone,
titleString: S.of(context).playSoundsInTheGame,
),
SettingsSwitchListTile(
context: context,
value: Config.keepMuteWhenTakingBack,
onChanged: setKeepMuteWhenTakingBack,
titleString: S.of(context).keepMuteWhenTakingBack,
),
],
)
else
const SizedBox(height: 0.0, width: 0.0),
),
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).accessibility, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.screenReaderSupport,
onChanged: setScreenReaderSupport,
titleString: S.of(context).screenReaderSupport,
@ -301,7 +281,6 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).restore, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsListTile(
titleString: S.of(context).restoreDefaultSettings,
@ -317,22 +296,18 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
if (Developer.developerModeEnabled)
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.developerMode,
onChanged: setDeveloperMode,
titleString: S.of(context).developerMode,
),
SettingsSwitchListTile(
context: context,
value: Config.experimentsEnabled,
onChanged: setExperimentsEnabled,
titleString: S.of(context).experiments,
),
SettingsSwitchListTile(
context: context,
value: Config.isAutoRestart,
onChanged: setIsAutoRestart,
titleString: S.of(context).isAutoRestart,

View File

@ -8,12 +8,12 @@ class HelpScreen extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0.0,
backgroundColor: Color(Config.darkBackgroundColor),
centerTitle: true,
title: Text(
S.of(context).howToPlay,
style: TextStyle(
fontSize: Config.fontSize + 4,
fontWeight: FontWeight.bold,
color: AppTheme.helpTextColor,
),
),

View File

@ -186,7 +186,7 @@ class HomeDrawer extends StatelessWidget {
children: <Widget>[
animatedBuilder,
Padding(
padding: EdgeInsets.only(top: isLargeScreen() ? 30 : 8, left: 4),
padding: EdgeInsets.only(top: isLargeScreen ? 30 : 8, left: 4),
child: ExcludeSemantics(child: animatedTextKit),
),
],
@ -269,7 +269,7 @@ class HomeDrawer extends StatelessWidget {
0.0,
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Container(
width: MediaQuery.of(context).size.width * 0.75 - 64,
height: 46,
@ -298,7 +298,7 @@ class HomeDrawer extends StatelessWidget {
final stack = Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Row(
children: <Widget>[
const SizedBox(height: 46.0, width: 6.0),
@ -326,7 +326,7 @@ class HomeDrawer extends StatelessWidget {
],
),
),
if (screenIndex == listItem.index) animatedBuilder else const SizedBox()
if (screenIndex == listItem.index) animatedBuilder,
],
);
@ -336,9 +336,7 @@ class HomeDrawer extends StatelessWidget {
child: InkWell(
splashColor: AppTheme.drawerSplashColor,
highlightColor: AppTheme.drawerHighlightColor,
onTap: () {
navigationToScreen(listItem.index);
},
onTap: () => navigationToScreen(listItem.index),
child: stack,
),
);

View File

@ -29,6 +29,7 @@ class ListItemDivider extends StatelessWidget {
return Divider(
indent: 16,
endIndent: 16,
height: 1.0,
thickness: 1.0,
color: AppTheme.listItemDividerColor,
);

View File

@ -387,7 +387,6 @@ class _PersonalizationSettingsPageState
return <Widget>[
Text(S.of(context).display, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsListTile(
titleString: S.of(context).language,
@ -398,19 +397,16 @@ class _PersonalizationSettingsPageState
onTap: () => setLanguage(context, langCallback),
),
SettingsSwitchListTile(
context: context,
value: Config.isPieceCountInHandShown,
onChanged: setIsPieceCountInHandShown,
titleString: S.of(context).isPieceCountInHandShown,
),
SettingsSwitchListTile(
context: context,
value: Config.isNotationsShown,
onChanged: setIsNotationsShown,
titleString: S.of(context).isNotationsShown,
),
SettingsSwitchListTile(
context: context,
value: Config.isHistoryNavigationToolbarShown,
onChanged: setIsHistoryNavigationToolbarShown,
titleString: S.of(context).isHistoryNavigationToolbarShown,
@ -440,7 +436,6 @@ class _PersonalizationSettingsPageState
onTap: setAnimationDuration,
),
SettingsSwitchListTile(
context: context,
value: Config.standardNotationEnabled,
onChanged: setStandardNotationEnabled,
titleString: S.of(context).standardNotation,
@ -450,7 +445,6 @@ class _PersonalizationSettingsPageState
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).color, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsListTile(
titleString: S.of(context).boardColor,

View File

@ -54,7 +54,6 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
return <Widget>[
Text(S.of(context).general, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsListTile(
titleString: S.of(context).piecesCount,
@ -63,7 +62,6 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
onTap: setNTotalPiecesEachSide,
),
SettingsSwitchListTile(
context: context,
value: Config.hasDiagonalLines,
onChanged: setHasDiagonalLines,
titleString: S.of(context).hasDiagonalLines,
@ -82,7 +80,6 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
onTap: setEndgameNMoveRule,
),
SettingsSwitchListTile(
context: context,
value: Config.threefoldRepetitionRule,
onChanged: setThreefoldRepetitionRule,
titleString: S.of(context).threefoldRepetitionRule,
@ -93,17 +90,14 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).placing, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.hasBannedLocations,
onChanged: setHasBannedLocations,
titleString: S.of(context).hasBannedLocations,
subtitleString: S.of(context).hasBannedLocations_Detail,
),
SettingsSwitchListTile(
context: context,
value: Config.isWhiteLoseButNotDrawWhenBoardFull,
onChanged: setIsWhiteLoseButNotDrawWhenBoardFull,
titleString: S.of(context).isWhiteLoseButNotDrawWhenBoardFull,
@ -111,7 +105,6 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
S.of(context).isWhiteLoseButNotDrawWhenBoardFull_Detail,
),
SettingsSwitchListTile(
context: context,
value: Config.mayOnlyRemoveUnplacedPieceInPlacingPhase,
onChanged: setMayOnlyRemoveUnplacedPieceInPlacingPhase,
titleString: S.of(context).removeUnplacedPiece,
@ -122,11 +115,9 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).moving, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
if (Config.experimentsEnabled)
SettingsSwitchListTile(
context: context,
value: Config.mayMoveInPlacingPhase,
onChanged: setMayMoveInPlacingPhase,
titleString: S.of(context).mayMoveInPlacingPhase,
@ -134,14 +125,12 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
)
else
SettingsSwitchListTile(
context: context,
value: Config.isDefenderMoveFirst,
onChanged: setIsDefenderMoveFirst,
titleString: S.of(context).isDefenderMoveFirst,
subtitleString: S.of(context).isDefenderMoveFirst_Detail,
),
SettingsSwitchListTile(
context: context,
value: Config.isLoseButNotChangeSideWhenNoWay,
onChanged: setIsLoseButNotChangeSideWhenNoWay,
titleString: S.of(context).isLoseButNotChangeSideWhenNoWay,
@ -153,10 +142,8 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).mayFly, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.mayFly,
onChanged: setAllowFlyingAllowed,
titleString: S.of(context).mayFly,
@ -173,17 +160,14 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
const SizedBox(height: AppTheme.sizedBoxHeight),
Text(S.of(context).removing, style: AppTheme.settingsHeaderStyle),
SettingsCard(
context: context,
children: <Widget>[
SettingsSwitchListTile(
context: context,
value: Config.mayRemoveFromMillsAlways,
onChanged: setAllowRemovePieceInMill,
titleString: S.of(context).mayRemoveFromMillsAlways,
subtitleString: S.of(context).mayRemoveFromMillsAlways_Detail,
),
SettingsSwitchListTile(
context: context,
value: Config.mayRemoveMultiple,
onChanged: setAllowRemoveMultiPiecesWhenCloseMultiMill,
titleString: S.of(context).mayRemoveMultiple,

View File

@ -23,11 +23,9 @@ import 'package:sanmill/shared/theme/app_theme.dart';
class SettingsCard extends StatelessWidget {
const SettingsCard({
Key? key,
required this.context,
required this.children,
}) : super(key: key);
final BuildContext context;
final List<Widget> children;
@override

View File

@ -63,9 +63,7 @@ class SettingsListTile extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(
trailingColor == null
? (trailingString == null ? "" : trailingString!)
: trailingColor!.toRadixString(16),
trailingColor?.toRadixString(16) ?? trailingString ?? '',
style: TextStyle(
fontSize: Config.fontSize,
backgroundColor:

View File

@ -23,14 +23,12 @@ import 'package:sanmill/shared/theme/app_theme.dart';
class SettingsSwitchListTile extends StatelessWidget {
const SettingsSwitchListTile({
Key? key,
required this.context,
required this.value,
required this.onChanged,
required this.titleString,
this.subtitleString,
}) : super(key: key);
final BuildContext context;
final bool value;
final String titleString;
final String? subtitleString;

View File

@ -60,7 +60,7 @@ class Config {
static double boardInnerLineWidth = 2.0;
static double pieceWidth = 0.9;
static double fontSize = 16.0;
static double boardTop = isLargeScreen() ? 75.0 : 36.0;
static double boardTop = isLargeScreen ? 75.0 : 36.0;
static double animationDuration = 0.0;
// Color
@ -146,14 +146,14 @@ class Config {
Config.isHistoryNavigationToolbarShown =
settings['IsHistoryNavigationToolbarShown'] as bool? ?? false;
Config.boardBorderLineWidth =
settings['BoardBorderLineWidth'] as double? ?? 2;
settings['BoardBorderLineWidth'] as double? ?? 2.0;
Config.boardInnerLineWidth =
settings['BoardInnerLineWidth'] as double? ?? 2;
settings['BoardInnerLineWidth'] as double? ?? 2.0;
Config.pieceWidth = settings['PieceWidth'] as double? ?? 0.9;
Config.fontSize = settings['FontSize'] as double? ?? 16.0;
Config.boardTop =
settings['BoardTop'] as double? ?? (isLargeScreen() ? 75 : 36);
Config.animationDuration = settings['AnimationDuration'] as double? ?? 0;
settings['BoardTop'] as double? ?? (isLargeScreen ? 75.0 : 36.0);
Config.animationDuration = settings['AnimationDuration'] as double? ?? 0.0;
// Color
Config.boardLineColor =

View File

@ -78,10 +78,6 @@ class Constants {
static final windowAspectRatio = windowHeight / windowWidth;
}
bool isSmallScreen() {
return Constants.windowHeight <= 800;
}
bool get isSmallScreen => Constants.windowHeight <= 800;
bool isLargeScreen() {
return !isSmallScreen();
}
bool get isLargeScreen => !isSmallScreen;

View File

@ -189,9 +189,7 @@ Future<void> showPrivacyDialog(
setPrivacyPolicyAccepted(false);
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
},
)
else
const SizedBox(height: 0.0, width: 0.0),
),
],
),
);

View File

@ -4,7 +4,8 @@ import 'package:sanmill/shared/common/constants.dart';
import 'package:sanmill/shared/theme/colors.dart';
class AppTheme {
AppTheme._();
const AppTheme._();
// TODO: restructure theming. Some theme Elements should be accessed via Theme.of(context)
// Theme data
static final lightThemeData = ThemeData(
@ -121,7 +122,7 @@ class AppTheme {
color: moveHistoryTextColor,
);
static double boardTop = isLargeScreen() ? 75.0 : 36.0;
static double boardTop = isLargeScreen ? 75.0 : 36.0;
static double boardMargin = 10.0;
static double boardScreenPaddingH = 10.0;
static double boardBorderRadius = 5.0;

View File

@ -39,7 +39,7 @@ dev_dependencies:
flutter_oss_licenses: ^1.0.1
flutter_test:
sdk: flutter
lint: ^1.0.0
lint: ^1.7.2
msix: ^2.1.3
flutter: