Skip to content

Commit

Permalink
Fix settings UI
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinX8 committed Jan 19, 2023
1 parent 9483029 commit 6aaa683
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 72 deletions.
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ class HourlyDashboard extends ConsumerWidget {
}
}
});
var baseColour = Theme.of(context).scaffoldBackgroundColor;
var settingsBG = baseColour.withRed(baseColour.red - 5).withBlue(baseColour.blue - 5).withGreen(baseColour.green - 5);
return Scaffold(
appBar: AppBar(
title: const Text('Dashboard'),
Expand Down Expand Up @@ -215,6 +217,7 @@ class HourlyDashboard extends ConsumerWidget {
icon: const Icon(Icons.pie_chart)),
PopupMenuButton<String>(
onSelected: handleMenu,
color: settingsBG,
itemBuilder: (context) {
return {'Export', 'Settings', 'Stop and Exit'}
.map((String choice) {
Expand Down
150 changes: 79 additions & 71 deletions lib/ui/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,77 +22,85 @@ class SettingsPage {
if (prefs.data == null) {
return const Text('Loading...');
}
return Column(children: [
Expanded(
child: SettingsList(
lightTheme: theme,
darkTheme: theme,
platform: DevicePlatform.android,
sections: [
SettingsSection(
title: const Text('Theme'),
tiles: <SettingsTile>[
SettingsTile.switchTile(
activeSwitchColor: Theme.of(context).colorScheme.primary,
leading: const Icon(Icons.format_paint),
initialValue: prefs.data?.getBool('dynamic_theme'),
onToggle: (value) => setState(() {
prefs.data?.setBool('dynamic_theme', value);
}),
title: const Text('Use Dynamic Theme')),
],
),
SettingsSection(
title: const Text('DEVELOPER SETTINGS: Sentiment'),
tiles: <SettingsTile>[
SettingsTile.switchTile(
activeSwitchColor: Theme.of(context).colorScheme.primary,
initialValue:
prefs.data?.getBool('average_sentiment'),
onToggle: (value) => setState(() {
prefs.data
?.setBool('average_sentiment', value);
}),
title: const Text('Use Average')),
SettingsTile(
title: const Text('Previous Sentiment Split:')),
],
),
],
)),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: Slider(
min: 0,
max: 100,
divisions: 8,
label: "${_sliderState.toString()}%",
value: prefs.data?.getDouble('multiplier_sentiment') !=
null
? prefs.data!.getDouble('multiplier_sentiment')! * 100
: 75,
onChanged: (double value) {
setState(() {
_sliderState = value.toInt();
prefs.data!
.setDouble('multiplier_sentiment', value / 100);
});
},
)),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: TextFormField(
initialValue: prefs.data!.getString('blacklist'),
onChanged: (regex) {
prefs.data?.setString('blacklist', regex);
},
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'App Blacklist Regex',
),
))),
]);
return SettingsList(
lightTheme: theme,
darkTheme: theme,
platform: DevicePlatform.android,
sections: [
SettingsSection(
title: const Text('Theme'),
tiles: <SettingsTile>[
SettingsTile.switchTile(
activeSwitchColor: Theme
.of(context)
.colorScheme
.primary,
leading: const Icon(Icons.format_paint),
initialValue: prefs.data?.getBool('dynamic_theme'),
onToggle: (value) =>
setState(() {
prefs.data?.setBool('dynamic_theme', value);
}),
title: const Text('Use Dynamic Theme')),
],
),
SettingsSection(
title: const Text('DEVELOPER SETTINGS: Sentiment'),
tiles: <SettingsTile>[
SettingsTile.switchTile(
activeSwitchColor: Theme
.of(context)
.colorScheme
.primary,
initialValue:
prefs.data?.getBool('average_sentiment'),
onToggle: (value) =>
setState(() {
prefs.data
?.setBool('average_sentiment', value);
}),
title: const Text('Use Average')),
SettingsTile(
description: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 25),
child: Slider(
min: 0,
max: 100,
divisions: 8,
label: "${_sliderState.toString()}%",
value: prefs.data?.getDouble(
'multiplier_sentiment') !=
null
? prefs.data!.getDouble(
'multiplier_sentiment')! * 100
: 75,
onChanged: (double value) {
setState(() {
_sliderState = value.toInt();
prefs.data!
.setDouble(
'multiplier_sentiment', value / 100);
});
},
)),
title: const Text('Previous Sentiment Split:')),
SettingsTile(title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: TextFormField(
initialValue: prefs.data!.getString('blacklist'),
onChanged: (regex) {
prefs.data?.setString('blacklist', regex);
},
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'App Blacklist Regex',
),
)))
],
),
],
);
}));
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+5
version: 1.1.0+11

environment:
sdk: '>=2.18.2 <3.0.0'
Expand Down

0 comments on commit 6aaa683

Please sign in to comment.