From e373aef2d9812e25c4b9687a3d1f50736d1ba06a Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Fri, 19 Aug 2022 18:34:40 +0530 Subject: [PATCH] feat: about info card and flutter convention style --- lib/constants.dart | 12 +++++- lib/ui/views/settings/settings_view.dart | 39 +++++++++++------ lib/ui/widgets/about_info_widget.dart | 54 ++++++++++++++++++++++++ lib/ui/widgets/app_selector_card.dart | 4 +- lib/ui/widgets/application_item.dart | 6 +-- lib/ui/widgets/installed_app_item.dart | 2 +- lib/ui/widgets/latest_commit_card.dart | 4 +- lib/ui/widgets/patch_selector_card.dart | 6 +-- lib/ui/widgets/patch_text_button.dart | 2 +- lib/utils/about_info.dart | 17 ++++++++ pubspec.yaml | 1 + 11 files changed, 119 insertions(+), 28 deletions(-) create mode 100644 lib/ui/widgets/about_info_widget.dart create mode 100644 lib/utils/about_info.dart diff --git a/lib/constants.dart b/lib/constants.dart index 6170cd1a..668449d6 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -8,8 +8,16 @@ const purple40 = Color(0xFF6650a4); const purpleGrey40 = Color(0xFF625b71); const pink40 = Color(0xFF7D5260); -final interTextStyle = GoogleFonts.inter(); -final robotoTextStyle = GoogleFonts.roboto(); +final kInterTextStyle = GoogleFonts.inter(); +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 patchesRepo = 'revanced-patches'; diff --git a/lib/ui/views/settings/settings_view.dart b/lib/ui/views/settings/settings_view.dart index b2cfac58..60e4616c 100644 --- a/lib/ui/views/settings/settings_view.dart +++ b/lib/ui/views/settings/settings_view.dart @@ -1,7 +1,10 @@ import 'package:flutter/material.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/ui/views/settings/settings_viewmodel.dart'; +import 'package:revanced_manager/ui/widgets/about_info_widget.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_themes/stacked_themes.dart'; @@ -15,18 +18,30 @@ class SettingsView extends StatelessWidget { builder: (context, SettingsViewModel model, child) => Scaffold( body: SafeArea( child: Padding( - padding: const EdgeInsets.all(8.0), - child: ListView( + padding: const EdgeInsets.all(12.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ + const SizedBox(height: 12), I18nText( 'settingsView.widgetTitle', child: Text( '', - style: Theme.of(context).textTheme.headline5, + style: GoogleFonts.inter( + fontSize: 28, + fontWeight: FontWeight.w500, + ), ), ), + const SizedBox(height: 12), ListTile( - title: I18nText('settingsView.themeLabel'), + title: I18nText( + 'settingsView.themeLabel', + child: Text( + '', + style: kSettingItemTextStyle, + ), + ), subtitle: I18nText('settingsView.themeHint'), trailing: Switch( value: isDark, @@ -46,12 +61,7 @@ class SettingsView extends StatelessWidget { children: [ I18nText( 'settingsView.languageLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 16, - ), - ), + child: Text('', style: kSettingItemTextStyle), ), DropdownButton( value: 'en', @@ -73,12 +83,13 @@ class SettingsView extends StatelessWidget { ), ), ListTile( - title: I18nText('settingsView.aboutLabel'), - ), - ListTile( - title: I18nText('settingsView.contributorsLabel'), + title: I18nText( + 'settingsView.contributorsLabel', + child: Text('', style: kSettingItemTextStyle), + ), onTap: model.navigateToContributors, ), + const AboutWidget(), ], ), ), diff --git a/lib/ui/widgets/about_info_widget.dart b/lib/ui/widgets/about_info_widget.dart new file mode 100644 index 00000000..2d35239c --- /dev/null +++ b/lib/ui/widgets/about_info_widget.dart @@ -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 createState() => _AboutWidgetState(); +} + +class _AboutWidgetState extends State { + @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>( + 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(); + } + }, + ), + ], + ), + ); + } +} diff --git a/lib/ui/widgets/app_selector_card.dart b/lib/ui/widgets/app_selector_card.dart index 74333307..dc5eac2e 100644 --- a/lib/ui/widgets/app_selector_card.dart +++ b/lib/ui/widgets/app_selector_card.dart @@ -49,7 +49,7 @@ class AppSelectorCard extends StatelessWidget { 'appSelectorCard.widgetSubtitle', child: Text( '', - style: robotoTextStyle, + style: kRobotoTextStyle, ), ) : Row( @@ -68,7 +68,7 @@ class AppSelectorCard extends StatelessWidget { const SizedBox(width: 4), Text( _getAppSelection(), - style: robotoTextStyle, + style: kRobotoTextStyle, ), ], ), diff --git a/lib/ui/widgets/application_item.dart b/lib/ui/widgets/application_item.dart index 55830a33..d37c4d01 100644 --- a/lib/ui/widgets/application_item.dart +++ b/lib/ui/widgets/application_item.dart @@ -67,7 +67,7 @@ class ApplicationItem extends StatelessWidget { ), Text( format(patchDate, locale: 'en_short'), - style: robotoTextStyle.copyWith( + style: kRobotoTextStyle.copyWith( color: Theme.of(context).colorScheme.tertiary, ), ), @@ -100,12 +100,12 @@ class ApplicationItem extends StatelessWidget { 'applicationItem.changelogLabel', child: Text( '', - style: robotoTextStyle.copyWith(fontWeight: FontWeight.w700), + style: kRobotoTextStyle.copyWith(fontWeight: FontWeight.w700), ), ), Text( changelog, - style: robotoTextStyle, + style: kRobotoTextStyle, ), ], ), diff --git a/lib/ui/widgets/installed_app_item.dart b/lib/ui/widgets/installed_app_item.dart index 0ecce773..4278a950 100644 --- a/lib/ui/widgets/installed_app_item.dart +++ b/lib/ui/widgets/installed_app_item.dart @@ -60,7 +60,7 @@ class _InstalledAppItemState extends State { const SizedBox(height: 4), Text( widget.pkgName, - style: robotoTextStyle, + style: kRobotoTextStyle, ), ], ), diff --git a/lib/ui/widgets/latest_commit_card.dart b/lib/ui/widgets/latest_commit_card.dart index 16407e36..b5681b02 100644 --- a/lib/ui/widgets/latest_commit_card.dart +++ b/lib/ui/widgets/latest_commit_card.dart @@ -61,7 +61,7 @@ class _LatestCommitCardState extends State { context, 'latestCommitCard.loadingLabel', ), - style: robotoTextStyle, + style: kRobotoTextStyle, ), ), ], @@ -91,7 +91,7 @@ class _LatestCommitCardState extends State { context, 'latestCommitCard.loadingLabel', ), - style: robotoTextStyle, + style: kRobotoTextStyle, ), ), ], diff --git a/lib/ui/widgets/patch_selector_card.dart b/lib/ui/widgets/patch_selector_card.dart index a70ae7d9..42339b56 100644 --- a/lib/ui/widgets/patch_selector_card.dart +++ b/lib/ui/widgets/patch_selector_card.dart @@ -48,7 +48,7 @@ class PatchSelectorCard extends StatelessWidget { 'patchSelectorCard.widgetSubtitle', child: Text( '', - style: robotoTextStyle, + style: kRobotoTextStyle, ), ) : locator().selectedPatches.isEmpty @@ -56,12 +56,12 @@ class PatchSelectorCard extends StatelessWidget { 'patchSelectorCard.widgetEmptySubtitle', child: Text( '', - style: robotoTextStyle, + style: kRobotoTextStyle, ), ) : Text( _getPatchesSelection(), - style: robotoTextStyle, + style: kRobotoTextStyle, ), ], ), diff --git a/lib/ui/widgets/patch_text_button.dart b/lib/ui/widgets/patch_text_button.dart index e042093a..b81da000 100644 --- a/lib/ui/widgets/patch_text_button.dart +++ b/lib/ui/widgets/patch_text_button.dart @@ -37,7 +37,7 @@ class PatchTextButton extends StatelessWidget { child: I18nText(text, child: Text( '', - style: interTextStyle.copyWith( + style: kInterTextStyle.copyWith( color: backgroundColor == Colors.transparent ? const Color.fromRGBO(119, 146, 186, 1) : isDark diff --git a/lib/utils/about_info.dart b/lib/utils/about_info.dart new file mode 100644 index 00000000..47af6203 --- /dev/null +++ b/lib/utils/about_info.dart @@ -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> 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 + }; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 6b63b18c..f0e7afd1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: git: url: https://github.com/ponces/flutter_plugin_device_apps ref: appinfo-from-storage + device_info_plus: ^4.1.2 expandable: ^5.0.1 file_picker: ^5.0.1 flutter: