added settings screen

This commit is contained in:
shilangyu 2020-08-31 16:17:39 +02:00
parent a0850836dd
commit f4bd1eb65b
3 changed files with 88 additions and 2 deletions

View File

@ -3,6 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:lemmy_api_client/lemmy_api_client.dart';
import '../widgets/user_profile.dart';
import 'settings.dart';
class UserProfileTab extends HookWidget {
final User user;
@ -41,7 +42,10 @@ class UserProfileTab extends HookWidget {
icon: Icon(
Icons.settings,
),
onPressed: () {}, // TODO: go to settings
onPressed: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => Settings()));
}, // TODO: go to settings
)
],
),

82
lib/pages/settings.dart Normal file
View File

@ -0,0 +1,82 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:provider/provider.dart';
import '../stores/config_store.dart';
class Settings extends StatelessWidget {
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
backgroundColor: theme.scaffoldBackgroundColor,
shadowColor: Colors.transparent,
iconTheme: theme.iconTheme,
title: Text('Settings', style: theme.textTheme.headline6),
centerTitle: true,
),
body: Container(
child: ListView(
children: [
ListTile(
leading: Icon(Icons.person),
title: Text('Accounts'),
onTap: () {},
),
ListTile(
leading: Icon(Icons.color_lens),
title: Text('Appearance'),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => _appearanceConfig()));
},
)
],
),
),
);
}
}
class _appearanceConfig extends StatelessWidget {
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
backgroundColor: theme.scaffoldBackgroundColor,
shadowColor: Colors.transparent,
iconTheme: theme.iconTheme,
title: Text('Appearance', style: theme.textTheme.headline6),
centerTitle: true,
),
body: Observer(
builder: (ctx) => Column(
children: [
Text(
'Theme',
style: theme.textTheme.headline6,
),
for (final theme in ThemeMode.values)
RadioListTile<ThemeMode>(
value: theme,
title: Text(theme.toString().split('.')[1]),
groupValue: ctx.watch<ConfigStore>().theme,
onChanged: (selected) {
ctx.read<ConfigStore>().theme = selected;
},
),
Text(
'Accent color',
style: theme.textTheme.headline6,
),
// TODO: add accent color picking
],
),
),
);
}
}

View File

@ -12,7 +12,7 @@ abstract class _ConfigStore with Store {
_ConfigStore() {
// persitently save settings each time they are changed
_saveReactionDisposer = reaction((_) => theme, (_) {
_saveReactionDisposer = reaction((_) => [theme], (_) {
save();
});
}