Skip to content

Commit

Permalink
fix: (settings) remove padding from inkwells (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameralis authored Sep 19, 2022
1 parent fc5414c commit d6dde3e
Show file tree
Hide file tree
Showing 7 changed files with 268 additions and 314 deletions.
236 changes: 123 additions & 113 deletions lib/ui/views/settings/settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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),
),
],
),
],
),
),
],
Expand Down
63 changes: 30 additions & 33 deletions lib/ui/widgets/settingsView/about_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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'
Expand All @@ -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(
Expand Down Expand Up @@ -90,15 +91,11 @@ class _AboutWidgetState extends State<AboutWidget> {
),
),
],
),
);
} else {
return Container();
}
},
)
: const SizedBox(),
),
],
),
);
},
);
}
}
5 changes: 4 additions & 1 deletion lib/ui/widgets/settingsView/custom_switch_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@ class CustomSwitchTile extends StatelessWidget {
final Widget subtitle;
final bool value;
final Function(bool) onTap;
final EdgeInsetsGeometry? padding;

const CustomSwitchTile({
Key? key,
required this.title,
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,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/settingsView/settings_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading

0 comments on commit d6dde3e

Please sign in to comment.