flutter: Refactor about_page.dart
This commit is contained in:
parent
329b4792d1
commit
b4974d8e20
|
@ -24,6 +24,7 @@ import 'package:package_info/package_info.dart';
|
||||||
import 'package:sanmill/generated/l10n.dart';
|
import 'package:sanmill/generated/l10n.dart';
|
||||||
import 'package:sanmill/style/app_theme.dart';
|
import 'package:sanmill/style/app_theme.dart';
|
||||||
import 'package:sanmill/style/colors.dart';
|
import 'package:sanmill/style/colors.dart';
|
||||||
|
import 'package:sanmill/widgets/settings_list_tile.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import 'license_page.dart';
|
import 'license_page.dart';
|
||||||
|
@ -67,34 +68,39 @@ class _AboutPageState extends State<AboutPage> {
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: children(context, mode),
|
||||||
ListTile(
|
),
|
||||||
title: Text(S.of(context).versionInfo,
|
),
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
);
|
||||||
subtitle: Text("Sanmill " + "$_version" + " " + mode,
|
}
|
||||||
style: TextStyle(color: UIColors.secondaryColor)),
|
|
||||||
|
List<Widget> children(BuildContext context, String mode) {
|
||||||
|
return <Widget>[
|
||||||
|
SettingsListTile(
|
||||||
|
context: context,
|
||||||
|
titleString: S.of(context).versionInfo,
|
||||||
|
subtitleString: "Sanmill " + "$_version" + " " + mode,
|
||||||
onTap: _showVersionInfo,
|
onTap: _showVersionInfo,
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
/*
|
/*
|
||||||
ListTile(
|
ListTile(
|
||||||
title:
|
title: Text(S.of(context).viewInGooglePlayStore,
|
||||||
Text(S.of(context).viewInGooglePlayStore, style: AppTheme.switchListTileTitleStyle),
|
style: AppTheme.switchListTileTitleStyle),
|
||||||
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'),
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
*/
|
*/
|
||||||
ListTile(
|
SettingsListTile(
|
||||||
title: Text(S.of(context).feedback,
|
context: context,
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
titleString: S.of(context).feedback,
|
||||||
onTap: () =>
|
onTap: () => _launchURL('https://github.com/calcitem/Sanmill/issues'),
|
||||||
_launchURL('https://github.com/calcitem/Sanmill/issues'),
|
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
ListTile(
|
SettingsListTile(
|
||||||
title: Text(S.of(context).license,
|
context: context,
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
titleString: S.of(context).license,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
@ -102,39 +108,37 @@ class _AboutPageState extends State<AboutPage> {
|
||||||
builder: (context) => LicenseAgreementPage(),
|
builder: (context) => LicenseAgreementPage(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
ListTile(
|
SettingsListTile(
|
||||||
title: Text(S.of(context).sourceCode,
|
context: context,
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
titleString: S.of(context).sourceCode,
|
||||||
onTap: () => _launchURL('https://github.com/calcitem/Sanmill'),
|
onTap: () => _launchURL('https://github.com/calcitem/Sanmill'),
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
ListTile(
|
SettingsListTile(
|
||||||
title: Text(S.of(context).privacyPolicy,
|
context: context,
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
titleString: S.of(context).privacyPolicy,
|
||||||
onTap: () => _launchURL(
|
onTap: () => _launchURL(
|
||||||
'https://github.com/calcitem/Sanmill/wiki/privacy_policy'),
|
'https://github.com/calcitem/Sanmill/wiki/privacy_policy'),
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
ListTile(
|
SettingsListTile(
|
||||||
title: Text(S.of(context).thirdPartyNotices,
|
context: context,
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
titleString: S.of(context).thirdPartyNotices,
|
||||||
onTap: () => _launchURL(
|
onTap: () => _launchURL(
|
||||||
'https://github.com/calcitem/Sanmill/wiki/third-party_notices'),
|
'https://github.com/calcitem/Sanmill/wiki/third-party_notices'),
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
ListTile(
|
SettingsListTile(
|
||||||
title: Text(S.of(context).thanks,
|
context: context,
|
||||||
style: AppTheme.switchListTileTitleStyle),
|
titleString: S.of(context).thanks,
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
_launchURL('https://github.com/calcitem/Sanmill/wiki/thanks'),
|
_launchURL('https://github.com/calcitem/Sanmill/wiki/thanks'),
|
||||||
),
|
),
|
||||||
ListItemDivider(),
|
ListItemDivider(),
|
||||||
],
|
];
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadVersionInfo() async {
|
_loadVersionInfo() async {
|
||||||
|
@ -158,27 +162,38 @@ class _AboutPageState extends State<AboutPage> {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => alertDialog(context),
|
||||||
title: Text(S.of(context).appName,
|
);
|
||||||
style: TextStyle(color: UIColors.primaryColor)),
|
}
|
||||||
|
|
||||||
|
AlertDialog alertDialog(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(
|
||||||
|
S.of(context).appName,
|
||||||
|
style: TextStyle(color: UIColors.primaryColor),
|
||||||
|
),
|
||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(S.of(context).version + ": $_version",
|
Text(
|
||||||
style: TextStyle(fontFamily: '')),
|
S.of(context).version + ": $_version",
|
||||||
|
style: TextStyle(fontFamily: ''),
|
||||||
|
),
|
||||||
AppTheme.sizedBox,
|
AppTheme.sizedBox,
|
||||||
AppTheme.sizedBox,
|
AppTheme.sizedBox,
|
||||||
Text(S.of(context).copyright,
|
Text(
|
||||||
style: TextStyle(fontFamily: '', fontSize: 12)),
|
S.of(context).copyright,
|
||||||
|
style: TextStyle(fontFamily: '', fontSize: 12),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
TextButton(
|
TextButton(
|
||||||
child: Text(S.of(context).ok),
|
child: Text(S.of(context).ok),
|
||||||
onPressed: () => Navigator.of(context).pop()),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue