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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 262 additions and 308 deletions

View File

@ -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<SettingsViewModel>.reactive(
@ -31,133 +34,140 @@ class SettingsView extends StatelessWidget {
),
),
),
SliverPadding(
padding: const EdgeInsets.all(20.0),
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
SettingsSection(
title: 'settingsView.appearanceSectionTitle',
children: <Widget>[
CustomSwitchTile(
title: I18nText(
'settingsView.darkThemeLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
SettingsSection(
title: 'settingsView.appearanceSectionTitle',
children: <Widget>[
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<int>(
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<int>(
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: <Widget>[
SettingsTileDialog(
title: 'settingsView.sourcesLabel',
subtitle: 'settingsView.sourcesLabelHint',
onTap: () => model.showSourcesDialog(context),
),
],
),
const Divider(thickness: 1.0),
SettingsSection(
title: 'settingsView.teamSectionTitle',
children: <Widget>[
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: <Widget>[
SettingsTileDialog(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
title: 'settingsView.sourcesLabel',
subtitle: 'settingsView.sourcesLabelHint',
onTap: () => model.showSourcesDialog(context),
),
],
),
_settingsDivider,
SettingsSection(
title: 'settingsView.teamSectionTitle',
children: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <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';
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<AboutWidget> createState() => _AboutWidgetState();
@ -13,28 +15,15 @@ class AboutWidget extends StatefulWidget {
class _AboutWidgetState extends State<AboutWidget> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
I18nText(
'settingsView.aboutLabel',
child: const Text(
'',
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: () {
return FutureBuilder<Map<String, dynamic>>(
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<AboutWidget> {
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: <Widget>[
Text(
@ -90,15 +91,11 @@ class _AboutWidgetState extends State<AboutWidget> {
),
),
],
),
);
} else {
return Container();
}
},
)
: const SizedBox(),
),
],
),
);
},
);
}
}

View File

@ -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,

View File

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

View File

@ -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(

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_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: <Widget>[
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 <Widget>[
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(),
);
}
}