feat: about info card and flutter convention style

This commit is contained in:
Aunali321 2022-08-19 18:34:40 +05:30
parent 614a694a77
commit e373aef2d9
11 changed files with 119 additions and 28 deletions

View File

@ -8,8 +8,16 @@ const purple40 = Color(0xFF6650a4);
const purpleGrey40 = Color(0xFF625b71); const purpleGrey40 = Color(0xFF625b71);
const pink40 = Color(0xFF7D5260); const pink40 = Color(0xFF7D5260);
final interTextStyle = GoogleFonts.inter(); final kInterTextStyle = GoogleFonts.inter();
final robotoTextStyle = GoogleFonts.roboto(); final kRobotoTextStyle = GoogleFonts.roboto();
final kSettingItemTextStyle = GoogleFonts.roboto(
fontSize: 20,
fontWeight: FontWeight.w500,
);
final kSettingItemSubtitleTextStyle = GoogleFonts.roboto(
fontSize: 13,
fontWeight: FontWeight.w300,
);
const ghOrg = 'revanced'; const ghOrg = 'revanced';
const patchesRepo = 'revanced-patches'; const patchesRepo = 'revanced-patches';

View File

@ -1,7 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/constants.dart';
import 'package:revanced_manager/theme.dart'; import 'package:revanced_manager/theme.dart';
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/about_info_widget.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:stacked_themes/stacked_themes.dart'; import 'package:stacked_themes/stacked_themes.dart';
@ -15,18 +18,30 @@ class SettingsView extends StatelessWidget {
builder: (context, SettingsViewModel model, child) => Scaffold( builder: (context, SettingsViewModel model, child) => Scaffold(
body: SafeArea( body: SafeArea(
child: Padding( child: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(12.0),
child: ListView( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
const SizedBox(height: 12),
I18nText( I18nText(
'settingsView.widgetTitle', 'settingsView.widgetTitle',
child: Text( child: Text(
'', '',
style: Theme.of(context).textTheme.headline5, style: GoogleFonts.inter(
fontSize: 28,
fontWeight: FontWeight.w500,
), ),
), ),
),
const SizedBox(height: 12),
ListTile( ListTile(
title: I18nText('settingsView.themeLabel'), title: I18nText(
'settingsView.themeLabel',
child: Text(
'',
style: kSettingItemTextStyle,
),
),
subtitle: I18nText('settingsView.themeHint'), subtitle: I18nText('settingsView.themeHint'),
trailing: Switch( trailing: Switch(
value: isDark, value: isDark,
@ -46,12 +61,7 @@ class SettingsView extends StatelessWidget {
children: [ children: [
I18nText( I18nText(
'settingsView.languageLabel', 'settingsView.languageLabel',
child: const Text( child: Text('', style: kSettingItemTextStyle),
'',
style: TextStyle(
fontSize: 16,
),
),
), ),
DropdownButton( DropdownButton(
value: 'en', value: 'en',
@ -73,12 +83,13 @@ class SettingsView extends StatelessWidget {
), ),
), ),
ListTile( ListTile(
title: I18nText('settingsView.aboutLabel'), title: I18nText(
'settingsView.contributorsLabel',
child: Text('', style: kSettingItemTextStyle),
), ),
ListTile(
title: I18nText('settingsView.contributorsLabel'),
onTap: model.navigateToContributors, onTap: model.navigateToContributors,
), ),
const AboutWidget(),
], ],
), ),
), ),

View File

@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/widgets/I18nText.dart';
import 'package:revanced_manager/constants.dart';
import 'package:revanced_manager/utils/about_info.dart';
class AboutWidget extends StatefulWidget {
const AboutWidget({Key? key}) : super(key: key);
@override
State<AboutWidget> createState() => _AboutWidgetState();
}
class _AboutWidgetState extends State<AboutWidget> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
I18nText(
'settingsView.aboutLabel',
child: Text('', style: kSettingItemTextStyle),
),
const SizedBox(height: 4),
FutureBuilder<Map<String, dynamic>>(
future: AboutInfo.getInfo(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Version: ${snapshot.data!['version']}',
style: kSettingItemSubtitleTextStyle),
Text('Build: ${snapshot.data!['buildNumber']}',
style: kSettingItemSubtitleTextStyle),
Text('Model: ${snapshot.data!['model']}',
style: kSettingItemSubtitleTextStyle),
Text('Android Version: ${snapshot.data!['androidVersion']}',
style: kSettingItemSubtitleTextStyle),
Text('Arch: ${snapshot.data!['arch']}',
style: kSettingItemSubtitleTextStyle),
],
);
} else {
return Container();
}
},
),
],
),
);
}
}

View File

@ -49,7 +49,7 @@ class AppSelectorCard extends StatelessWidget {
'appSelectorCard.widgetSubtitle', 'appSelectorCard.widgetSubtitle',
child: Text( child: Text(
'', '',
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
) )
: Row( : Row(
@ -68,7 +68,7 @@ class AppSelectorCard extends StatelessWidget {
const SizedBox(width: 4), const SizedBox(width: 4),
Text( Text(
_getAppSelection(), _getAppSelection(),
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
], ],
), ),

View File

@ -67,7 +67,7 @@ class ApplicationItem extends StatelessWidget {
), ),
Text( Text(
format(patchDate, locale: 'en_short'), format(patchDate, locale: 'en_short'),
style: robotoTextStyle.copyWith( style: kRobotoTextStyle.copyWith(
color: Theme.of(context).colorScheme.tertiary, color: Theme.of(context).colorScheme.tertiary,
), ),
), ),
@ -100,12 +100,12 @@ class ApplicationItem extends StatelessWidget {
'applicationItem.changelogLabel', 'applicationItem.changelogLabel',
child: Text( child: Text(
'', '',
style: robotoTextStyle.copyWith(fontWeight: FontWeight.w700), style: kRobotoTextStyle.copyWith(fontWeight: FontWeight.w700),
), ),
), ),
Text( Text(
changelog, changelog,
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
], ],
), ),

View File

@ -60,7 +60,7 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
widget.pkgName, widget.pkgName,
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
], ],
), ),

View File

@ -61,7 +61,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
context, context,
'latestCommitCard.loadingLabel', 'latestCommitCard.loadingLabel',
), ),
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
), ),
], ],
@ -91,7 +91,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
context, context,
'latestCommitCard.loadingLabel', 'latestCommitCard.loadingLabel',
), ),
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
), ),
], ],

View File

@ -48,7 +48,7 @@ class PatchSelectorCard extends StatelessWidget {
'patchSelectorCard.widgetSubtitle', 'patchSelectorCard.widgetSubtitle',
child: Text( child: Text(
'', '',
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
) )
: locator<PatcherViewModel>().selectedPatches.isEmpty : locator<PatcherViewModel>().selectedPatches.isEmpty
@ -56,12 +56,12 @@ class PatchSelectorCard extends StatelessWidget {
'patchSelectorCard.widgetEmptySubtitle', 'patchSelectorCard.widgetEmptySubtitle',
child: Text( child: Text(
'', '',
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
) )
: Text( : Text(
_getPatchesSelection(), _getPatchesSelection(),
style: robotoTextStyle, style: kRobotoTextStyle,
), ),
], ],
), ),

View File

@ -37,7 +37,7 @@ class PatchTextButton extends StatelessWidget {
child: I18nText(text, child: I18nText(text,
child: Text( child: Text(
'', '',
style: interTextStyle.copyWith( style: kInterTextStyle.copyWith(
color: backgroundColor == Colors.transparent color: backgroundColor == Colors.transparent
? const Color.fromRGBO(119, 146, 186, 1) ? const Color.fromRGBO(119, 146, 186, 1)
: isDark : isDark

17
lib/utils/about_info.dart Normal file
View File

@ -0,0 +1,17 @@
import 'package:package_info_plus/package_info_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
class AboutInfo {
static Future<Map<String, dynamic>> getInfo() async {
final packageInfo = await PackageInfo.fromPlatform();
final info = await DeviceInfoPlugin().androidInfo;
return {
'version': packageInfo.version,
'buildNumber': packageInfo.buildNumber,
'model': info.model,
'androidVersion': info.version.release,
'arch': info.supported64BitAbis
};
}
}

View File

@ -16,6 +16,7 @@ dependencies:
git: git:
url: https://github.com/ponces/flutter_plugin_device_apps url: https://github.com/ponces/flutter_plugin_device_apps
ref: appinfo-from-storage ref: appinfo-from-storage
device_info_plus: ^4.1.2
expandable: ^5.0.1 expandable: ^5.0.1
file_picker: ^5.0.1 file_picker: ^5.0.1
flutter: flutter: