From d6dde3e23bdaea99b238b19bdd9e8011e9813e4b Mon Sep 17 00:00:00 2001 From: Unknown <55922348+55nknown@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:39:25 +0200 Subject: [PATCH] fix: (settings) remove padding from inkwells (#194) --- lib/ui/views/settings/settings_view.dart | 236 +++++++++--------- lib/ui/widgets/settingsView/about_widget.dart | 63 +++-- .../settingsView/custom_switch_tile.dart | 5 +- .../settingsView/settings_section.dart | 2 +- .../settingsView/settings_tile_dialog.dart | 4 +- .../settingsView/social_media_item.dart | 52 ++++ .../settingsView/social_media_widget.dart | 208 ++++----------- 7 files changed, 262 insertions(+), 308 deletions(-) create mode 100644 lib/ui/widgets/settingsView/social_media_item.dart diff --git a/lib/ui/views/settings/settings_view.dart b/lib/ui/views/settings/settings_view.dart index 4d7f1a1b..6a657111 100644 --- a/lib/ui/views/settings/settings_view.dart +++ b/lib/ui/views/settings/settings_view.dart @@ -13,6 +13,9 @@ import 'package:stacked/stacked.dart'; class SettingsView extends StatelessWidget { const SettingsView({Key? key}) : super(key: key); + static const _settingsDivider = + Divider(thickness: 1.0, indent: 20.0, endIndent: 20.0); + @override Widget build(BuildContext context) { return ViewModelBuilder.reactive( @@ -31,133 +34,140 @@ class SettingsView extends StatelessWidget { ), ), ), - SliverPadding( - padding: const EdgeInsets.all(20.0), - sliver: SliverList( - delegate: SliverChildListDelegate.fixed( - [ - SettingsSection( - title: 'settingsView.appearanceSectionTitle', - children: [ - CustomSwitchTile( - title: I18nText( - 'settingsView.darkThemeLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), + SliverList( + delegate: SliverChildListDelegate.fixed( + [ + SettingsSection( + title: 'settingsView.appearanceSectionTitle', + children: [ + CustomSwitchTile( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + title: I18nText( + 'settingsView.darkThemeLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, ), ), - subtitle: I18nText('settingsView.darkThemeHint'), - value: model.getDarkThemeStatus(), - onTap: (value) => model.setUseDarkTheme( - context, - value, - ), ), - FutureBuilder( - future: model.getSdkVersion(), - builder: (context, snapshot) => Visibility( - visible: snapshot.hasData && - snapshot.data! >= ANDROID_12_SDK_VERSION, - child: CustomSwitchTile( - title: I18nText( - 'settingsView.dynamicThemeLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), + subtitle: I18nText('settingsView.darkThemeHint'), + value: model.getDarkThemeStatus(), + onTap: (value) => model.setUseDarkTheme( + context, + value, + ), + ), + FutureBuilder( + future: model.getSdkVersion(), + builder: (context, snapshot) => Visibility( + visible: snapshot.hasData && + snapshot.data! >= ANDROID_12_SDK_VERSION, + child: CustomSwitchTile( + padding: + const EdgeInsets.symmetric(horizontal: 20.0), + title: I18nText( + 'settingsView.dynamicThemeLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, ), ), - subtitle: - I18nText('settingsView.dynamicThemeHint'), - value: model.getDynamicThemeStatus(), - onTap: (value) => model.setUseDynamicTheme( - context, - value, - ), + ), + subtitle: I18nText('settingsView.dynamicThemeHint'), + value: model.getDynamicThemeStatus(), + onTap: (value) => model.setUseDynamicTheme( + context, + value, ), ), ), - ], - ), - SettingsTileDialog( - title: 'settingsView.languageLabel', - subtitle: 'English', - onTap: () => model.showLanguagesDialog(context), - ), - const Divider(thickness: 1.0), - SettingsSection( - title: 'settingsView.patcherSectionTitle', - children: [ - SettingsTileDialog( - title: 'settingsView.sourcesLabel', - subtitle: 'settingsView.sourcesLabelHint', - onTap: () => model.showSourcesDialog(context), - ), - ], - ), - const Divider(thickness: 1.0), - SettingsSection( - title: 'settingsView.teamSectionTitle', - children: [ - ListTile( - contentPadding: EdgeInsets.zero, - title: I18nText( - 'settingsView.contributorsLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), + ), + ], + ), + SettingsTileDialog( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + title: 'settingsView.languageLabel', + subtitle: 'English', + onTap: () => model.showLanguagesDialog(context), + ), + SettingsSection( + title: 'settingsView.patcherSectionTitle', + children: [ + SettingsTileDialog( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + title: 'settingsView.sourcesLabel', + subtitle: 'settingsView.sourcesLabelHint', + onTap: () => model.showSourcesDialog(context), + ), + ], + ), + _settingsDivider, + SettingsSection( + title: 'settingsView.teamSectionTitle', + children: [ + ListTile( + contentPadding: + const EdgeInsets.symmetric(horizontal: 20.0), + title: I18nText( + 'settingsView.contributorsLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, ), ), - subtitle: I18nText('settingsView.contributorsHint'), - onTap: () => model.navigateToContributors(), ), - const SocialMediaWidget(), - ], - ), - const Divider(thickness: 1.0), - SettingsSection( - title: 'settingsView.infoSectionTitle', - children: [ - ListTile( - contentPadding: EdgeInsets.zero, - title: I18nText( - 'settingsView.logsLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), + subtitle: I18nText('settingsView.contributorsHint'), + onTap: () => model.navigateToContributors(), + ), + const SocialMediaWidget( + padding: EdgeInsets.symmetric(horizontal: 20.0), + ), + ], + ), + _settingsDivider, + SettingsSection( + title: 'settingsView.infoSectionTitle', + children: [ + ListTile( + contentPadding: + const EdgeInsets.symmetric(horizontal: 20.0), + title: I18nText( + 'settingsView.logsLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, ), ), - subtitle: I18nText('settingsView.logsHint'), - onTap: () => model.exportLogcatLogs(), ), - const AboutWidget(), - ], - ), - const Divider(thickness: 1.0), - SettingsSection( - title: 'settingsView.advancedSectionTitle', - children: [ - SettingsTileDialog( - title: 'settingsView.apiURLLabel', - subtitle: 'settingsView.apiURLHint', - onTap: () => model.showApiUrlDialog(context), - ), - ], - ), - ], - ), + subtitle: I18nText('settingsView.logsHint'), + onTap: () => model.exportLogcatLogs(), + ), + const AboutWidget( + padding: EdgeInsets.symmetric(horizontal: 20.0), + ), + ], + ), + _settingsDivider, + SettingsSection( + title: 'settingsView.advancedSectionTitle', + children: [ + SettingsTileDialog( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + title: 'settingsView.apiURLLabel', + subtitle: 'settingsView.apiURLHint', + onTap: () => model.showApiUrlDialog(context), + ), + ], + ), + ], ), ), ], diff --git a/lib/ui/widgets/settingsView/about_widget.dart b/lib/ui/widgets/settingsView/about_widget.dart index c7b5add6..1f6d9325 100644 --- a/lib/ui/widgets/settingsView/about_widget.dart +++ b/lib/ui/widgets/settingsView/about_widget.dart @@ -4,7 +4,9 @@ import 'package:revanced_manager/utils/about_info.dart'; import 'package:flutter/services.dart'; class AboutWidget extends StatefulWidget { - const AboutWidget({Key? key}) : super(key: key); + const AboutWidget({Key? key, this.padding}) : super(key: key); + + final EdgeInsetsGeometry? padding; @override State createState() => _AboutWidgetState(); @@ -13,28 +15,15 @@ class AboutWidget extends StatefulWidget { class _AboutWidgetState extends State { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - I18nText( - 'settingsView.aboutLabel', - child: const Text( - '', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w500, - ), - ), - ), - const SizedBox(height: 4), - FutureBuilder>( - future: AboutInfo.getInfo(), - builder: (context, snapshot) { - if (snapshot.hasData) { - return GestureDetector( - onLongPress: () { + return FutureBuilder>( + future: AboutInfo.getInfo(), + builder: (context, snapshot) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: ListTile( + contentPadding: widget.padding ?? EdgeInsets.zero, + onLongPress: snapshot.hasData + ? () { Clipboard.setData( ClipboardData( text: 'Version: ${snapshot.data!['version']}\n' @@ -50,8 +39,20 @@ class _AboutWidgetState extends State { Theme.of(context).colorScheme.secondary, ), ); - }, - child: Column( + } + : null, + title: I18nText( + 'settingsView.aboutLabel', + child: const Text( + '', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w500, + ), + ), + ), + subtitle: snapshot.hasData + ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( @@ -90,15 +91,11 @@ class _AboutWidgetState extends State { ), ), ], - ), - ); - } else { - return Container(); - } - }, + ) + : const SizedBox(), ), - ], - ), + ); + }, ); } } diff --git a/lib/ui/widgets/settingsView/custom_switch_tile.dart b/lib/ui/widgets/settingsView/custom_switch_tile.dart index 348e1440..77521cbc 100644 --- a/lib/ui/widgets/settingsView/custom_switch_tile.dart +++ b/lib/ui/widgets/settingsView/custom_switch_tile.dart @@ -6,6 +6,7 @@ class CustomSwitchTile extends StatelessWidget { final Widget subtitle; final bool value; final Function(bool) onTap; + final EdgeInsetsGeometry? padding; const CustomSwitchTile({ Key? key, @@ -13,14 +14,16 @@ class CustomSwitchTile extends StatelessWidget { required this.subtitle, required this.value, required this.onTap, + this.padding, }) : super(key: key); @override Widget build(BuildContext context) { return ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: padding ?? EdgeInsets.zero, title: title, subtitle: subtitle, + onTap: () => onTap(!value), trailing: CustomSwitch( value: value, onChanged: onTap, diff --git a/lib/ui/widgets/settingsView/settings_section.dart b/lib/ui/widgets/settingsView/settings_section.dart index 02343e2c..402e2e55 100644 --- a/lib/ui/widgets/settingsView/settings_section.dart +++ b/lib/ui/widgets/settingsView/settings_section.dart @@ -17,7 +17,7 @@ class SettingsSection extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: const EdgeInsets.only(top: 16.0, bottom: 10.0), + padding: const EdgeInsets.only(top: 16.0, bottom: 10.0, left: 20.0), child: I18nText( title, child: Text( diff --git a/lib/ui/widgets/settingsView/settings_tile_dialog.dart b/lib/ui/widgets/settingsView/settings_tile_dialog.dart index 565fb670..f4353cdd 100644 --- a/lib/ui/widgets/settingsView/settings_tile_dialog.dart +++ b/lib/ui/widgets/settingsView/settings_tile_dialog.dart @@ -5,18 +5,20 @@ class SettingsTileDialog extends StatelessWidget { final String title; final String subtitle; final Function()? onTap; + final EdgeInsetsGeometry? padding; const SettingsTileDialog({ Key? key, required this.title, required this.subtitle, required this.onTap, + this.padding, }) : super(key: key); @override Widget build(BuildContext context) { return ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: padding ?? EdgeInsets.zero, title: I18nText( title, child: const Text( diff --git a/lib/ui/widgets/settingsView/social_media_item.dart b/lib/ui/widgets/settingsView/social_media_item.dart new file mode 100644 index 00000000..3bc28cde --- /dev/null +++ b/lib/ui/widgets/settingsView/social_media_item.dart @@ -0,0 +1,52 @@ + +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class SocialMediaItem extends StatelessWidget { + final Widget? icon; + final Widget title; + final Widget? subtitle; + final String? url; + + const SocialMediaItem({ + Key? key, + this.icon, + required this.title, + this.subtitle, + this.url, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return ListTile( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)), + contentPadding: EdgeInsets.zero, + leading: SizedBox( + width: 48.0, + child: Center( + child: icon, + ), + ), + title: DefaultTextStyle( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.onSecondaryContainer, + ), + child: title, + ), + subtitle: subtitle != null + ? DefaultTextStyle( + style: Theme.of(context).textTheme.bodyMedium!.copyWith( + color: Theme.of(context).colorScheme.primary, + ), + child: subtitle!, + ) + : null, + onTap: () => url != null + ? launchUrl( + Uri.parse(url!), + mode: LaunchMode.externalApplication, + ) + : null, + ); + } +} diff --git a/lib/ui/widgets/settingsView/social_media_widget.dart b/lib/ui/widgets/settingsView/social_media_widget.dart index 003f170c..37bfd08e 100644 --- a/lib/ui/widgets/settingsView/social_media_widget.dart +++ b/lib/ui/widgets/settingsView/social_media_widget.dart @@ -2,11 +2,16 @@ import 'package:expandable/expandable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:revanced_manager/ui/widgets/settingsView/social_media_item.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_card.dart'; -import 'package:url_launcher/url_launcher.dart'; class SocialMediaWidget extends StatelessWidget { - const SocialMediaWidget({Key? key}) : super(key: key); + final EdgeInsetsGeometry? padding; + + const SocialMediaWidget({ + Key? key, + this.padding, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -14,11 +19,13 @@ class SocialMediaWidget extends StatelessWidget { theme: ExpandableThemeData( hasIcon: true, iconColor: Theme.of(context).iconTheme.color, - iconPadding: const EdgeInsets.symmetric(vertical: 16.0), + iconPadding: const EdgeInsets.symmetric(vertical: 16.0) + .add(padding ?? EdgeInsets.zero) + .resolve(Directionality.of(context)), animationDuration: const Duration(milliseconds: 400), ), header: ListTile( - contentPadding: EdgeInsets.zero, + contentPadding: padding ?? EdgeInsets.zero, title: I18nText( 'socialMediaCard.widgetTitle', child: const Text( @@ -31,169 +38,52 @@ class SocialMediaWidget extends StatelessWidget { ), subtitle: I18nText('socialMediaCard.widgetSubtitle'), ), - expanded: CustomCard( - child: Column( - children: [ - ListTile( - contentPadding: EdgeInsets.zero, - leading: Padding( - padding: const EdgeInsets.all(8.0), - child: FaIcon( - FontAwesomeIcons.github, - color: Theme.of(context).colorScheme.secondary, - ), + expanded: Padding( + padding: padding ?? EdgeInsets.zero, + child: CustomCard( + child: Column( + children: const [ + SocialMediaItem( + icon: FaIcon(FontAwesomeIcons.github), + title: Text('GitHub'), + subtitle: Text('github.com/revanced'), + url: 'https://github.com/revanced', ), - title: Text( - 'GitHub', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), + SocialMediaItem( + icon: FaIcon(FontAwesomeIcons.discord), + title: Text('Discord'), + subtitle: Text('discord.gg/revanced'), + url: 'https://discord.gg/rF2YcEjcrT', ), - subtitle: Text( - 'github.com/revanced', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), + SocialMediaItem( + icon: FaIcon(FontAwesomeIcons.telegram), + title: Text('Telegram'), + subtitle: Text('t.me/app_revanced'), + url: 'https://t.me/app_revanced', ), - onTap: () => launchUrl( - Uri.parse('https://github.com/revanced'), - mode: LaunchMode.externalApplication, + SocialMediaItem( + icon: FaIcon(FontAwesomeIcons.reddit), + title: Text('Reddit'), + subtitle: Text('r/revancedapp'), + url: 'https://reddit.com/r/revancedapp', ), - ), - ListTile( - contentPadding: EdgeInsets.zero, - leading: Padding( - padding: const EdgeInsets.all(8.0).copyWith(left: 5), - child: FaIcon( - FontAwesomeIcons.discord, - color: Theme.of(context).colorScheme.secondary, - ), + SocialMediaItem( + icon: FaIcon(FontAwesomeIcons.twitter), + title: Text('Twitter'), + subtitle: Text('@revancedapp'), + url: 'https://twitter.com/revancedapp', ), - title: Text( - 'Discord', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), + SocialMediaItem( + icon: FaIcon(FontAwesomeIcons.youtube), + title: Text('YouTube'), + subtitle: Text('youtube.com/revanced'), + url: 'https://youtube.com/revanced', ), - subtitle: Text( - 'discord.gg/revanced', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - onTap: () => launchUrl( - Uri.parse('https://discord.gg/rF2YcEjcrT'), - mode: LaunchMode.externalApplication, - ), - ), - ListTile( - contentPadding: EdgeInsets.zero, - leading: Padding( - padding: const EdgeInsets.all(8.0), - child: FaIcon( - FontAwesomeIcons.telegram, - color: Theme.of(context).colorScheme.secondary, - ), - ), - title: Text( - 'Telegram', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - subtitle: Text( - 't.me/app_revanced', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - onTap: () => launchUrl( - Uri.parse('https://t.me/app_revanced'), - mode: LaunchMode.externalApplication, - ), - ), - ListTile( - contentPadding: EdgeInsets.zero, - leading: Padding( - padding: const EdgeInsets.all(8.0), - child: FaIcon( - FontAwesomeIcons.reddit, - color: Theme.of(context).colorScheme.secondary, - ), - ), - title: Text( - 'Reddit', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - subtitle: Text( - 'r/revancedapp', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - onTap: () => launchUrl( - Uri.parse('https://reddit.com/r/revancedapp'), - mode: LaunchMode.externalApplication, - ), - ), - ListTile( - contentPadding: EdgeInsets.zero, - leading: Padding( - padding: const EdgeInsets.all(8.0), - child: FaIcon( - FontAwesomeIcons.twitter, - color: Theme.of(context).colorScheme.secondary, - ), - ), - title: Text( - 'Twitter', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - subtitle: Text( - '@revancedapp', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - onTap: () => launchUrl( - Uri.parse('https://twitter.com/revancedapp'), - mode: LaunchMode.externalApplication, - ), - ), - ListTile( - contentPadding: EdgeInsets.zero, - leading: Padding( - padding: const EdgeInsets.all(8.0), - child: FaIcon( - FontAwesomeIcons.youtube, - color: Theme.of(context).colorScheme.secondary, - ), - ), - title: Text( - 'YouTube', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - subtitle: Text( - 'youtube.com/revanced', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - ), - ), - onTap: () => launchUrl( - Uri.parse('https://youtube.com/revanced'), - mode: LaunchMode.externalApplication, - ), - ), - ], + ], + ), ), ), - collapsed: Container(), + collapsed: const SizedBox(), ); } }