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