mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +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: [
|
return ListView(children: [
|
||||||
SettingsHeader('Display Settings'),
|
SettingsHeader('Display Settings'),
|
||||||
BoolPreference(
|
SwitchListTile(
|
||||||
title: "Dark Theme",
|
title: const Text("Dark Theme"),
|
||||||
defaultValue: brightness == Brightness.dark,
|
value: brightness == Brightness.dark,
|
||||||
onChange: (bool newVal) {
|
onChanged: (bool newVal) {
|
||||||
var b = newVal ? Brightness.dark : Brightness.light;
|
var b = newVal ? Brightness.dark : Brightness.light;
|
||||||
var dynamicTheme = DynamicTheme.of(context);
|
var dynamicTheme = DynamicTheme.of(context);
|
||||||
dynamicTheme.setBrightness(b);
|
dynamicTheme.setBrightness(b);
|
||||||
@ -159,19 +159,19 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16.0),
|
const SizedBox(height: 16.0),
|
||||||
SettingsHeader("Analytics"),
|
SettingsHeader("Analytics"),
|
||||||
BoolPreference(
|
SwitchListTile(
|
||||||
title: "Collect Anonymous Usage Statistics",
|
title: const Text("Collect Anonymous Usage Statistics"),
|
||||||
defaultValue: Settings.instance.collectUsageStatistics,
|
value: Settings.instance.collectUsageStatistics,
|
||||||
onChange: (bool val) {
|
onChanged: (bool val) {
|
||||||
Settings.instance.collectUsageStatistics = val;
|
Settings.instance.collectUsageStatistics = val;
|
||||||
Settings.instance.save();
|
Settings.instance.save();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
BoolPreference(
|
SwitchListTile(
|
||||||
title: "Collect Anonymous Crash Reports",
|
title: const Text("Collect Anonymous Crash Reports"),
|
||||||
defaultValue: Settings.instance.collectUsageStatistics,
|
value: Settings.instance.collectCrashReports,
|
||||||
onChange: (bool val) {
|
onChanged: (bool val) {
|
||||||
Settings.instance.collectCrashReports = val;
|
Settings.instance.collectCrashReports = val;
|
||||||
Settings.instance.save();
|
Settings.instance.save();
|
||||||
setState(() {});
|
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