cleanup widget tree
removes some redundant widgets that aren't displayed or diplicated
This commit is contained in:
parent
26b7f49a8e
commit
ef6c7a2176
|
@ -520,7 +520,9 @@ class Resources {
|
|||
}
|
||||
|
||||
Future<void> setLanguage(
|
||||
BuildContext context, Function(String?)? callback) async {
|
||||
BuildContext context,
|
||||
Function(String?)? callback,
|
||||
) async {
|
||||
final languageColumn = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
|
@ -570,7 +572,7 @@ Bidirectionality getBidirectionality(BuildContext context) {
|
|||
currentLocale.languageCode == "he" ||
|
||||
currentLocale.languageCode == "ps" ||
|
||||
currentLocale.languageCode == "ur") {
|
||||
print("bidirectionality: RTL");
|
||||
debugPrint("bidirectionality: RTL");
|
||||
return Bidirectionality.rightToLeft;
|
||||
} else {
|
||||
return Bidirectionality.leftToRight;
|
||||
|
@ -591,5 +593,5 @@ void setSpecialCountryAndRegion(BuildContext context) {
|
|||
break;
|
||||
}
|
||||
|
||||
print("Set Special Country and Region to $specialCountryAndRegion.");
|
||||
debugPrint("Set Special Country and Region to $specialCountryAndRegion.");
|
||||
}
|
||||
|
|
|
@ -37,42 +37,21 @@ class AboutPage extends StatelessWidget {
|
|||
// String _version = "";
|
||||
final String tag = "[about] ";
|
||||
|
||||
String getMode() {
|
||||
late String ret;
|
||||
String get mode {
|
||||
if (kDebugMode) {
|
||||
ret = "- debug";
|
||||
return "- debug";
|
||||
} else if (kProfileMode) {
|
||||
ret = "- profile";
|
||||
return "- profile";
|
||||
} else if (kReleaseMode) {
|
||||
ret = "";
|
||||
return "";
|
||||
} else {
|
||||
ret = "-test";
|
||||
return "-test";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String mode = getMode();
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.aboutPageBackgroundColor,
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text("${S.of(context).about} ${S.of(context).appName}"),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: children(context, mode),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> children(BuildContext context, String mode) {
|
||||
return <Widget>[
|
||||
final List<Widget> _children = [
|
||||
FutureBuilder<PackageInfo>(
|
||||
future: PackageInfo.fromPlatform(),
|
||||
builder: (_, data) {
|
||||
|
@ -95,19 +74,14 @@ class AboutPage extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).feedback,
|
||||
onTap: _launchFeedback,
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).eula,
|
||||
onTap: () {
|
||||
_launchEULA();
|
||||
},
|
||||
onTap: _launchEULA,
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).license,
|
||||
onTap: () {
|
||||
|
@ -119,43 +93,40 @@ class AboutPage extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).sourceCode,
|
||||
onTap: () {
|
||||
_launchSourceCode();
|
||||
},
|
||||
onTap: _launchSourceCode,
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).privacyPolicy,
|
||||
onTap: () {
|
||||
_launchPrivacyPolicy();
|
||||
},
|
||||
onTap: _launchPrivacyPolicy,
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).ossLicenses,
|
||||
onTap: () {
|
||||
_launchThirdPartyNotices(context);
|
||||
},
|
||||
onTap: () => _launchThirdPartyNotices(context),
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).helpImproveTranslate,
|
||||
onTap: () {
|
||||
_launchHelpImproveTranslate();
|
||||
},
|
||||
onTap: _launchHelpImproveTranslate,
|
||||
),
|
||||
const ListItemDivider(),
|
||||
SettingsListTile(
|
||||
titleString: S.of(context).thanks,
|
||||
onTap: () {
|
||||
_launchThanks();
|
||||
},
|
||||
onTap: _launchThanks,
|
||||
),
|
||||
const ListItemDivider(),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppTheme.aboutPageBackgroundColor,
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text("${S.of(context).about} ${S.of(context).appName}"),
|
||||
),
|
||||
body: ListView.separated(
|
||||
itemBuilder: (_, index) => _children[index],
|
||||
separatorBuilder: (_, __) => const ListItemDivider(),
|
||||
itemCount: _children.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _launchURL(String url) async {
|
||||
|
|
|
@ -46,15 +46,14 @@ class Board extends StatelessWidget {
|
|||
|
||||
buildSquareDescription(context);
|
||||
|
||||
final container = Container(
|
||||
margin: EdgeInsets.zero,
|
||||
child: GridView(
|
||||
final grid = GridView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 7,
|
||||
),
|
||||
children: List.generate(7 * 7, (index) {
|
||||
return Center(
|
||||
children: List.generate(
|
||||
7 * 7,
|
||||
(index) => Center(
|
||||
child: Text(
|
||||
squareDesc[index],
|
||||
style: TextStyle(
|
||||
|
@ -62,8 +61,7 @@ class Board extends StatelessWidget {
|
|||
color: Config.developerMode ? Colors.red : Colors.transparent,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -76,7 +74,7 @@ class Board extends StatelessWidget {
|
|||
blurIndex: Game.instance.blurIndex,
|
||||
animationValue: animationValue,
|
||||
),
|
||||
child: container,
|
||||
child: grid,
|
||||
);
|
||||
|
||||
final boardContainer = Container(
|
||||
|
@ -128,7 +126,7 @@ class Board extends StatelessWidget {
|
|||
final List<String> coordinates = [];
|
||||
final List<String> pieceDesc = [];
|
||||
|
||||
final map = [
|
||||
const map = [
|
||||
/* 1 */
|
||||
1,
|
||||
8,
|
||||
|
@ -187,7 +185,7 @@ class Board extends StatelessWidget {
|
|||
49
|
||||
];
|
||||
|
||||
final checkPoints = [
|
||||
const checkPoints = [
|
||||
/* 1 */
|
||||
1,
|
||||
0,
|
||||
|
@ -266,14 +264,27 @@ class Board extends StatelessWidget {
|
|||
for (var i = 0; i < 7 * 7; i++) {
|
||||
if (checkPoints[i] == 0) {
|
||||
pieceDesc.add(S.of(context).noPoint);
|
||||
} else if (Game.instance.position.pieceOnGrid(i) == PieceColor.white) {
|
||||
} else {
|
||||
switch (Game.instance.position.pieceOnGrid(i)) {
|
||||
case PieceColor.white:
|
||||
pieceDesc.add(S.of(context).whitePiece);
|
||||
} else if (Game.instance.position.pieceOnGrid(i) == PieceColor.black) {
|
||||
|
||||
break;
|
||||
case PieceColor.black:
|
||||
pieceDesc.add(S.of(context).blackPiece);
|
||||
} else if (Game.instance.position.pieceOnGrid(i) == PieceColor.ban) {
|
||||
|
||||
break;
|
||||
case PieceColor.ban:
|
||||
pieceDesc.add(S.of(context).banPoint);
|
||||
} else if (Game.instance.position.pieceOnGrid(i) == PieceColor.none) {
|
||||
|
||||
break;
|
||||
case PieceColor.none:
|
||||
pieceDesc.add(S.of(context).emptyPoint);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,23 +39,14 @@ class EnvironmentVariablesPage extends StatelessWidget {
|
|||
title: Text(S.of(context).environmentVariables),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
_data,
|
||||
style: const TextStyle(fontFamily: 'Monospace', fontSize: 12),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1515,7 +1515,7 @@ class _GamePageState extends State<GamePage>
|
|||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text(
|
||||
_tip!,
|
||||
|
|
|
@ -20,7 +20,6 @@ class HelpScreen extends StatelessWidget {
|
|||
),
|
||||
backgroundColor: Color(Config.darkBackgroundColor),
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
S.of(context).helpContent,
|
||||
|
@ -30,7 +29,6 @@ class HelpScreen extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,9 +135,7 @@ class HomeDrawer extends StatelessWidget {
|
|||
|
||||
final animatedBuilder = AnimatedBuilder(
|
||||
animation: iconAnimationController!,
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return scaleTransition;
|
||||
},
|
||||
builder: (_, __) => scaleTransition,
|
||||
);
|
||||
|
||||
final animatedTextsColors = [
|
||||
|
@ -181,10 +179,7 @@ class HomeDrawer extends StatelessWidget {
|
|||
},
|
||||
);
|
||||
|
||||
final drawerHeader = Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.zero,
|
||||
child: Container(
|
||||
final drawerHeader = Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -196,7 +191,6 @@ class HomeDrawer extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/*
|
||||
|
@ -233,9 +227,9 @@ class HomeDrawer extends StatelessWidget {
|
|||
);
|
||||
*/
|
||||
|
||||
final scaffold = Scaffold(
|
||||
backgroundColor: Color(Config.drawerBackgroundColor),
|
||||
body: Column(
|
||||
final drawer = Material(
|
||||
color: Color(Config.drawerBackgroundColor),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
drawerHeader,
|
||||
|
@ -244,7 +238,6 @@ class HomeDrawer extends StatelessWidget {
|
|||
Expanded(
|
||||
child: ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: drawerList.length,
|
||||
itemBuilder: (BuildContext context, int index) =>
|
||||
buildInkwell(context, drawerList[index]),
|
||||
|
@ -256,7 +249,7 @@ class HomeDrawer extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
|
||||
return scaffold;
|
||||
return drawer;
|
||||
}
|
||||
|
||||
Future<void> navigationToScreen(DrawerIndex? index) async {
|
||||
|
@ -278,7 +271,7 @@ class HomeDrawer extends StatelessWidget {
|
|||
0.0,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.75 - 64,
|
||||
height: 46,
|
||||
|
@ -306,8 +299,8 @@ class HomeDrawer extends StatelessWidget {
|
|||
|
||||
final stack = Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
const SizedBox(width: 6.0, height: 46.0),
|
||||
|
|
|
@ -35,24 +35,18 @@ class LicenseAgreementPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(S.of(context).license), centerTitle: true),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 16,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
appBar: AppBar(
|
||||
title: Text(S.of(context).license),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
_data,
|
||||
style: const TextStyle(fontFamily: 'Monospace', fontSize: 12),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:sanmill/style/app_theme.dart';
|
||||
|
||||
// TODO: replace with Divider();
|
||||
class ListItemDivider extends StatelessWidget {
|
||||
const ListItemDivider({
|
||||
Key? key,
|
||||
|
@ -27,10 +26,10 @@ class ListItemDivider extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16),
|
||||
width: double.infinity,
|
||||
height: 1.0,
|
||||
return const Divider(
|
||||
indent: 16,
|
||||
endIndent: 16,
|
||||
thickness: 1.0,
|
||||
color: AppTheme.listItemDividerColor,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import 'package:sanmill/common/constants.dart';
|
|||
import 'package:sanmill/engine/engine.dart';
|
||||
import 'package:sanmill/mill/game.dart';
|
||||
import 'package:sanmill/style/app_theme.dart';
|
||||
import 'package:sanmill/style/colors.dart';
|
||||
import 'package:sanmill/widgets/about_page.dart';
|
||||
import 'package:sanmill/widgets/drawer_user_controller.dart';
|
||||
import 'package:sanmill/widgets/help_screen.dart';
|
||||
|
@ -58,14 +57,9 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: UIColors.nearlyWhite,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Scaffold(
|
||||
backgroundColor: AppTheme.navigationHomeScreenBackgroundColor,
|
||||
body: DrawerUserController(
|
||||
return Material(
|
||||
color: AppTheme.navigationHomeScreenBackgroundColor,
|
||||
child: DrawerUserController(
|
||||
screenIndex: drawerIndex,
|
||||
drawerWidth: MediaQuery.of(context).size.width * 0.75,
|
||||
onDrawerCall: (DrawerIndex index) {
|
||||
|
@ -77,8 +71,6 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
|||
// we need on navigate starting screens
|
||||
screenView: screenView,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -95,6 +87,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
|
|||
|
||||
drawerIndex = index;
|
||||
|
||||
// TODO: use switch case
|
||||
final engineType = drawerMap[drawerIndex!];
|
||||
if (engineType != null) {
|
||||
setState(() {
|
||||
|
|
|
@ -37,14 +37,15 @@ class FlutterLicense extends LicenseEntry {
|
|||
class OssLicensesPage extends StatelessWidget {
|
||||
static Future<List<String>> loadLicenses() async {
|
||||
Stream<LicenseEntry> licenses() async* {
|
||||
yield FlutterLicense([
|
||||
'Sound Effects'
|
||||
], [
|
||||
yield FlutterLicense(
|
||||
['Sound Effects'],
|
||||
[
|
||||
const LicenseParagraph(
|
||||
'CC-0\nhttps://freesound.org/people/unfa/sounds/243749/',
|
||||
0,
|
||||
)
|
||||
]);
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
LicenseRegistry.addLicense(licenses);
|
||||
|
@ -67,17 +68,14 @@ class OssLicensesPage extends StatelessWidget {
|
|||
return ossKeys..sort();
|
||||
}
|
||||
|
||||
static final _licenses = loadLicenses();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(S.of(context).ossLicenses),
|
||||
),
|
||||
body: FutureBuilder<List<String>>(
|
||||
future: _licenses,
|
||||
future: loadLicenses(),
|
||||
builder: (context, snapshot) => ListView.separated(
|
||||
padding: EdgeInsets.zero,
|
||||
itemCount: snapshot.data?.length ?? 0,
|
||||
itemBuilder: (context, index) {
|
||||
final key = snapshot.data![index];
|
||||
|
@ -85,13 +83,12 @@ class OssLicensesPage extends StatelessWidget {
|
|||
final version = ossl['version'];
|
||||
final desc = ossl['description'] as String?;
|
||||
return ListTile(
|
||||
title: Text('$key ${version ?? ''}'),
|
||||
title: Text('$key $version'),
|
||||
subtitle: desc != null ? Text(desc) : null,
|
||||
trailing: const Icon(FluentIcons.chevron_right_24_regular),
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
MiscOssLicenseSingle(name: key, json: ossl),
|
||||
builder: (_) => MiscOssLicenseSingle(name: key, json: ossl),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -106,14 +103,17 @@ class MiscOssLicenseSingle extends StatelessWidget {
|
|||
final String name;
|
||||
final Map<String, dynamic> json;
|
||||
|
||||
const MiscOssLicenseSingle({
|
||||
required this.name,
|
||||
required this.json,
|
||||
});
|
||||
|
||||
String get version => json['version'] as String? ?? "";
|
||||
String? get description => json['description'] as String?;
|
||||
String get licenseText => json['license'] as String;
|
||||
String? get homepage => json['homepage'] as String?;
|
||||
|
||||
const MiscOssLicenseSingle({required this.name, required this.json});
|
||||
|
||||
String _bodyText() => licenseText.split('\n').map((line) {
|
||||
String get _bodyText => licenseText.split('\n').map((line) {
|
||||
if (line.startsWith('//')) line = line.substring(2);
|
||||
return line.trim();
|
||||
}).join('\n');
|
||||
|
@ -121,9 +121,8 @@ class MiscOssLicenseSingle extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(title: Text('$name $version')),
|
||||
body: Container(
|
||||
color: Theme.of(context).canvasColor,
|
||||
child: ListView(
|
||||
backgroundColor: Theme.of(context).canvasColor,
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
if (description != null)
|
||||
Padding(
|
||||
|
@ -160,15 +159,17 @@ class MiscOssLicenseSingle extends StatelessWidget {
|
|||
),
|
||||
if (description != null || homepage != null) const Divider(),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 12.0, left: 12.0, right: 12.0),
|
||||
padding: const EdgeInsets.only(
|
||||
top: 12.0,
|
||||
left: 12.0,
|
||||
right: 12.0,
|
||||
),
|
||||
child: Text(
|
||||
_bodyText(),
|
||||
_bodyText,
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue