mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 17:29:50 +08:00
Settings: Use SwitchListTile instead of our custom widget
I didn't know this widget existed.
This commit is contained in:
@ -115,10 +115,10 @@ class SettingsListState extends State<SettingsList> {
|
||||
|
||||
return ListView(children: [
|
||||
SettingsHeader('Display Settings'),
|
||||
BoolPreference(
|
||||
title: "Dark Theme",
|
||||
defaultValue: brightness == Brightness.dark,
|
||||
onChange: (bool newVal) {
|
||||
SwitchListTile(
|
||||
title: const Text("Dark Theme"),
|
||||
value: brightness == Brightness.dark,
|
||||
onChanged: (bool newVal) {
|
||||
var b = newVal ? Brightness.dark : Brightness.light;
|
||||
var dynamicTheme = DynamicTheme.of(context);
|
||||
dynamicTheme.setBrightness(b);
|
||||
@ -159,19 +159,19 @@ class SettingsListState extends State<SettingsList> {
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
SettingsHeader("Analytics"),
|
||||
BoolPreference(
|
||||
title: "Collect Anonymous Usage Statistics",
|
||||
defaultValue: Settings.instance.collectUsageStatistics,
|
||||
onChange: (bool val) {
|
||||
SwitchListTile(
|
||||
title: const Text("Collect Anonymous Usage Statistics"),
|
||||
value: Settings.instance.collectUsageStatistics,
|
||||
onChanged: (bool val) {
|
||||
Settings.instance.collectUsageStatistics = val;
|
||||
Settings.instance.save();
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
BoolPreference(
|
||||
title: "Collect Anonymous Crash Reports",
|
||||
defaultValue: Settings.instance.collectUsageStatistics,
|
||||
onChange: (bool val) {
|
||||
SwitchListTile(
|
||||
title: const Text("Collect Anonymous Crash Reports"),
|
||||
value: Settings.instance.collectCrashReports,
|
||||
onChanged: (bool val) {
|
||||
Settings.instance.collectCrashReports = val;
|
||||
Settings.instance.save();
|
||||
setState(() {});
|
||||
|
@ -63,27 +63,3 @@ class ListPreference extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BoolPreference extends StatelessWidget {
|
||||
final String title;
|
||||
final bool defaultValue;
|
||||
final Function(bool) onChange;
|
||||
|
||||
BoolPreference({
|
||||
@required this.title,
|
||||
@required this.defaultValue,
|
||||
@required this.onChange,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text(title),
|
||||
trailing: Switch(
|
||||
value: defaultValue,
|
||||
onChanged: onChange,
|
||||
),
|
||||
onTap: () => onChange(!defaultValue),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user