fix: (settings) remove padding from inkwells (#194)

This commit is contained in:
Unknown
2022-09-19 10:39:25 +02:00
committed by GitHub
parent fc5414c788
commit d6dde3e23b
7 changed files with 262 additions and 308 deletions

View File

@ -13,6 +13,9 @@ import 'package:stacked/stacked.dart';
class SettingsView extends StatelessWidget { class SettingsView extends StatelessWidget {
const SettingsView({Key? key}) : super(key: key); const SettingsView({Key? key}) : super(key: key);
static const _settingsDivider =
Divider(thickness: 1.0, indent: 20.0, endIndent: 20.0);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ViewModelBuilder<SettingsViewModel>.reactive( return ViewModelBuilder<SettingsViewModel>.reactive(
@ -31,133 +34,140 @@ class SettingsView extends StatelessWidget {
), ),
), ),
), ),
SliverPadding( SliverList(
padding: const EdgeInsets.all(20.0), delegate: SliverChildListDelegate.fixed(
sliver: SliverList( <Widget>[
delegate: SliverChildListDelegate.fixed( SettingsSection(
<Widget>[ title: 'settingsView.appearanceSectionTitle',
SettingsSection( children: <Widget>[
title: 'settingsView.appearanceSectionTitle', CustomSwitchTile(
children: <Widget>[ padding: const EdgeInsets.symmetric(horizontal: 20.0),
CustomSwitchTile( title: I18nText(
title: I18nText( 'settingsView.darkThemeLabel',
'settingsView.darkThemeLabel', child: const Text(
child: const Text( '',
'', style: TextStyle(
style: TextStyle( fontSize: 20,
fontSize: 20, fontWeight: FontWeight.w500,
fontWeight: FontWeight.w500,
),
), ),
), ),
subtitle: I18nText('settingsView.darkThemeHint'),
value: model.getDarkThemeStatus(),
onTap: (value) => model.setUseDarkTheme(
context,
value,
),
), ),
FutureBuilder<int>( subtitle: I18nText('settingsView.darkThemeHint'),
future: model.getSdkVersion(), value: model.getDarkThemeStatus(),
builder: (context, snapshot) => Visibility( onTap: (value) => model.setUseDarkTheme(
visible: snapshot.hasData && context,
snapshot.data! >= ANDROID_12_SDK_VERSION, value,
child: CustomSwitchTile( ),
title: I18nText( ),
'settingsView.dynamicThemeLabel', FutureBuilder<int>(
child: const Text( future: model.getSdkVersion(),
'', builder: (context, snapshot) => Visibility(
style: TextStyle( visible: snapshot.hasData &&
fontSize: 20, snapshot.data! >= ANDROID_12_SDK_VERSION,
fontWeight: FontWeight.w500, 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'), subtitle: I18nText('settingsView.dynamicThemeHint'),
value: model.getDynamicThemeStatus(), value: model.getDynamicThemeStatus(),
onTap: (value) => model.setUseDynamicTheme( onTap: (value) => model.setUseDynamicTheme(
context, context,
value, value,
),
), ),
), ),
), ),
], ),
), ],
SettingsTileDialog( ),
title: 'settingsView.languageLabel', SettingsTileDialog(
subtitle: 'English', padding: const EdgeInsets.symmetric(horizontal: 20.0),
onTap: () => model.showLanguagesDialog(context), title: 'settingsView.languageLabel',
), subtitle: 'English',
const Divider(thickness: 1.0), onTap: () => model.showLanguagesDialog(context),
SettingsSection( ),
title: 'settingsView.patcherSectionTitle', SettingsSection(
children: <Widget>[ title: 'settingsView.patcherSectionTitle',
SettingsTileDialog( children: <Widget>[
title: 'settingsView.sourcesLabel', SettingsTileDialog(
subtitle: 'settingsView.sourcesLabelHint', padding: const EdgeInsets.symmetric(horizontal: 20.0),
onTap: () => model.showSourcesDialog(context), title: 'settingsView.sourcesLabel',
), subtitle: 'settingsView.sourcesLabelHint',
], onTap: () => model.showSourcesDialog(context),
), ),
const Divider(thickness: 1.0), ],
SettingsSection( ),
title: 'settingsView.teamSectionTitle', _settingsDivider,
children: <Widget>[ SettingsSection(
ListTile( title: 'settingsView.teamSectionTitle',
contentPadding: EdgeInsets.zero, children: <Widget>[
title: I18nText( ListTile(
'settingsView.contributorsLabel', contentPadding:
child: const Text( const EdgeInsets.symmetric(horizontal: 20.0),
'', title: I18nText(
style: TextStyle( 'settingsView.contributorsLabel',
fontSize: 20, child: const Text(
fontWeight: FontWeight.w500, '',
), style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
), ),
), ),
subtitle: I18nText('settingsView.contributorsHint'),
onTap: () => model.navigateToContributors(),
), ),
const SocialMediaWidget(), subtitle: I18nText('settingsView.contributorsHint'),
], onTap: () => model.navigateToContributors(),
), ),
const Divider(thickness: 1.0), const SocialMediaWidget(
SettingsSection( padding: EdgeInsets.symmetric(horizontal: 20.0),
title: 'settingsView.infoSectionTitle', ),
children: <Widget>[ ],
ListTile( ),
contentPadding: EdgeInsets.zero, _settingsDivider,
title: I18nText( SettingsSection(
'settingsView.logsLabel', title: 'settingsView.infoSectionTitle',
child: const Text( children: <Widget>[
'', ListTile(
style: TextStyle( contentPadding:
fontSize: 20, const EdgeInsets.symmetric(horizontal: 20.0),
fontWeight: FontWeight.w500, title: I18nText(
), 'settingsView.logsLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
), ),
), ),
subtitle: I18nText('settingsView.logsHint'),
onTap: () => model.exportLogcatLogs(),
), ),
const AboutWidget(), subtitle: I18nText('settingsView.logsHint'),
], onTap: () => model.exportLogcatLogs(),
), ),
const Divider(thickness: 1.0), const AboutWidget(
SettingsSection( padding: EdgeInsets.symmetric(horizontal: 20.0),
title: 'settingsView.advancedSectionTitle', ),
children: <Widget>[ ],
SettingsTileDialog( ),
title: 'settingsView.apiURLLabel', _settingsDivider,
subtitle: 'settingsView.apiURLHint', SettingsSection(
onTap: () => model.showApiUrlDialog(context), title: 'settingsView.advancedSectionTitle',
), children: <Widget>[
], SettingsTileDialog(
), padding: const EdgeInsets.symmetric(horizontal: 20.0),
], title: 'settingsView.apiURLLabel',
), subtitle: 'settingsView.apiURLHint',
onTap: () => model.showApiUrlDialog(context),
),
],
),
],
), ),
), ),
], ],

View File

@ -4,7 +4,9 @@ import 'package:revanced_manager/utils/about_info.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
class AboutWidget extends StatefulWidget { class AboutWidget extends StatefulWidget {
const AboutWidget({Key? key}) : super(key: key); const AboutWidget({Key? key, this.padding}) : super(key: key);
final EdgeInsetsGeometry? padding;
@override @override
State<AboutWidget> createState() => _AboutWidgetState(); State<AboutWidget> createState() => _AboutWidgetState();
@ -13,28 +15,15 @@ class AboutWidget extends StatefulWidget {
class _AboutWidgetState extends State<AboutWidget> { class _AboutWidgetState extends State<AboutWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return FutureBuilder<Map<String, dynamic>>(
padding: const EdgeInsets.symmetric(vertical: 8.0), future: AboutInfo.getInfo(),
child: Column( builder: (context, snapshot) {
crossAxisAlignment: CrossAxisAlignment.start, return Padding(
children: <Widget>[ padding: const EdgeInsets.symmetric(vertical: 8.0),
I18nText( child: ListTile(
'settingsView.aboutLabel', contentPadding: widget.padding ?? EdgeInsets.zero,
child: const Text( onLongPress: snapshot.hasData
'', ? () {
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 4),
FutureBuilder<Map<String, dynamic>>(
future: AboutInfo.getInfo(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return GestureDetector(
onLongPress: () {
Clipboard.setData( Clipboard.setData(
ClipboardData( ClipboardData(
text: 'Version: ${snapshot.data!['version']}\n' text: 'Version: ${snapshot.data!['version']}\n'
@ -50,8 +39,20 @@ class _AboutWidgetState extends State<AboutWidget> {
Theme.of(context).colorScheme.secondary, 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, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
@ -90,15 +91,11 @@ class _AboutWidgetState extends State<AboutWidget> {
), ),
), ),
], ],
), )
); : const SizedBox(),
} else {
return Container();
}
},
), ),
], );
), },
); );
} }
} }

View File

@ -6,6 +6,7 @@ class CustomSwitchTile extends StatelessWidget {
final Widget subtitle; final Widget subtitle;
final bool value; final bool value;
final Function(bool) onTap; final Function(bool) onTap;
final EdgeInsetsGeometry? padding;
const CustomSwitchTile({ const CustomSwitchTile({
Key? key, Key? key,
@ -13,14 +14,16 @@ class CustomSwitchTile extends StatelessWidget {
required this.subtitle, required this.subtitle,
required this.value, required this.value,
required this.onTap, required this.onTap,
this.padding,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
contentPadding: EdgeInsets.zero, contentPadding: padding ?? EdgeInsets.zero,
title: title, title: title,
subtitle: subtitle, subtitle: subtitle,
onTap: () => onTap(!value),
trailing: CustomSwitch( trailing: CustomSwitch(
value: value, value: value,
onChanged: onTap, onChanged: onTap,

View File

@ -17,7 +17,7 @@ class SettingsSection extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( 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( child: I18nText(
title, title,
child: Text( child: Text(

View File

@ -5,18 +5,20 @@ class SettingsTileDialog extends StatelessWidget {
final String title; final String title;
final String subtitle; final String subtitle;
final Function()? onTap; final Function()? onTap;
final EdgeInsetsGeometry? padding;
const SettingsTileDialog({ const SettingsTileDialog({
Key? key, Key? key,
required this.title, required this.title,
required this.subtitle, required this.subtitle,
required this.onTap, required this.onTap,
this.padding,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
contentPadding: EdgeInsets.zero, contentPadding: padding ?? EdgeInsets.zero,
title: I18nText( title: I18nText(
title, title,
child: const Text( child: const Text(

View File

@ -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,
);
}
}

View File

@ -2,11 +2,16 @@ import 'package:expandable/expandable.dart';
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:font_awesome_flutter/font_awesome_flutter.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:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:url_launcher/url_launcher.dart';
class SocialMediaWidget extends StatelessWidget { class SocialMediaWidget extends StatelessWidget {
const SocialMediaWidget({Key? key}) : super(key: key); final EdgeInsetsGeometry? padding;
const SocialMediaWidget({
Key? key,
this.padding,
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -14,11 +19,13 @@ class SocialMediaWidget extends StatelessWidget {
theme: ExpandableThemeData( theme: ExpandableThemeData(
hasIcon: true, hasIcon: true,
iconColor: Theme.of(context).iconTheme.color, 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), animationDuration: const Duration(milliseconds: 400),
), ),
header: ListTile( header: ListTile(
contentPadding: EdgeInsets.zero, contentPadding: padding ?? EdgeInsets.zero,
title: I18nText( title: I18nText(
'socialMediaCard.widgetTitle', 'socialMediaCard.widgetTitle',
child: const Text( child: const Text(
@ -31,169 +38,52 @@ class SocialMediaWidget extends StatelessWidget {
), ),
subtitle: I18nText('socialMediaCard.widgetSubtitle'), subtitle: I18nText('socialMediaCard.widgetSubtitle'),
), ),
expanded: CustomCard( expanded: Padding(
child: Column( padding: padding ?? EdgeInsets.zero,
children: <Widget>[ child: CustomCard(
ListTile( child: Column(
contentPadding: EdgeInsets.zero, children: const <Widget>[
leading: Padding( SocialMediaItem(
padding: const EdgeInsets.all(8.0), icon: FaIcon(FontAwesomeIcons.github),
child: FaIcon( title: Text('GitHub'),
FontAwesomeIcons.github, subtitle: Text('github.com/revanced'),
color: Theme.of(context).colorScheme.secondary, url: 'https://github.com/revanced',
),
), ),
title: Text( SocialMediaItem(
'GitHub', icon: FaIcon(FontAwesomeIcons.discord),
style: TextStyle( title: Text('Discord'),
color: Theme.of(context).colorScheme.secondary, subtitle: Text('discord.gg/revanced'),
), url: 'https://discord.gg/rF2YcEjcrT',
), ),
subtitle: Text( SocialMediaItem(
'github.com/revanced', icon: FaIcon(FontAwesomeIcons.telegram),
style: TextStyle( title: Text('Telegram'),
color: Theme.of(context).colorScheme.secondary, subtitle: Text('t.me/app_revanced'),
), url: 'https://t.me/app_revanced',
), ),
onTap: () => launchUrl( SocialMediaItem(
Uri.parse('https://github.com/revanced'), icon: FaIcon(FontAwesomeIcons.reddit),
mode: LaunchMode.externalApplication, title: Text('Reddit'),
subtitle: Text('r/revancedapp'),
url: 'https://reddit.com/r/revancedapp',
), ),
), SocialMediaItem(
ListTile( icon: FaIcon(FontAwesomeIcons.twitter),
contentPadding: EdgeInsets.zero, title: Text('Twitter'),
leading: Padding( subtitle: Text('@revancedapp'),
padding: const EdgeInsets.all(8.0).copyWith(left: 5), url: 'https://twitter.com/revancedapp',
child: FaIcon(
FontAwesomeIcons.discord,
color: Theme.of(context).colorScheme.secondary,
),
), ),
title: Text( SocialMediaItem(
'Discord', icon: FaIcon(FontAwesomeIcons.youtube),
style: TextStyle( title: Text('YouTube'),
color: Theme.of(context).colorScheme.secondary, 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(),
); );
} }
} }