2020-08-31 16:17:39 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
2020-09-02 01:35:30 +02:00
|
|
|
import '../stores/accounts_store.dart';
|
2020-08-31 16:17:39 +02:00
|
|
|
import '../stores/config_store.dart';
|
|
|
|
|
2020-09-03 14:33:17 +02:00
|
|
|
class SettingsPage extends StatelessWidget {
|
2020-08-31 16:17:39 +02:00
|
|
|
@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'),
|
2020-09-02 01:35:30 +02:00
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context)
|
|
|
|
.push(MaterialPageRoute(builder: (_) => _AccountsConfig()));
|
|
|
|
},
|
2020-08-31 16:17:39 +02:00
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
leading: Icon(Icons.color_lens),
|
|
|
|
title: Text('Appearance'),
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).push(
|
2020-08-31 21:04:17 +02:00
|
|
|
MaterialPageRoute(builder: (_) => _AppearanceConfig()));
|
2020-08-31 16:17:39 +02:00
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 21:04:17 +02:00
|
|
|
class _AppearanceConfig extends StatelessWidget {
|
2020-08-31 16:17:39 +02:00
|
|
|
@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(
|
2020-09-03 22:20:32 +02:00
|
|
|
builder: (ctx) => ListView(
|
2020-08-31 16:17:39 +02:00
|
|
|
children: [
|
2020-09-03 22:20:32 +02:00
|
|
|
Center(
|
|
|
|
child: Text(
|
|
|
|
'Theme',
|
|
|
|
style: theme.textTheme.headline6,
|
|
|
|
),
|
2020-08-31 16:17:39 +02:00
|
|
|
),
|
|
|
|
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;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-09-02 01:35:30 +02:00
|
|
|
|
|
|
|
class _AccountsConfig 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('Accounts', style: theme.textTheme.headline6),
|
|
|
|
centerTitle: true,
|
|
|
|
),
|
|
|
|
body: Observer(
|
|
|
|
builder: (ctx) {
|
|
|
|
var accountsStore = ctx.watch<AccountsStore>();
|
|
|
|
var theme = Theme.of(context);
|
|
|
|
|
2020-09-03 22:20:32 +02:00
|
|
|
return ListView(
|
2020-09-02 01:35:30 +02:00
|
|
|
children: [
|
|
|
|
for (var entry in accountsStore.users.entries) ...[
|
2020-09-03 22:20:32 +02:00
|
|
|
Center(
|
|
|
|
child: Text(
|
|
|
|
entry.key,
|
|
|
|
style: theme.textTheme.subtitle2,
|
|
|
|
),
|
2020-09-02 01:35:30 +02:00
|
|
|
),
|
|
|
|
for (var username in entry.value.keys) ...[
|
|
|
|
ListTile(
|
|
|
|
trailing:
|
|
|
|
username == accountsStore.defaultUserFor(entry.key).name
|
|
|
|
? Icon(Icons.check_circle_outline)
|
|
|
|
: null,
|
|
|
|
selected: username ==
|
|
|
|
accountsStore.defaultUserFor(entry.key).name,
|
|
|
|
title: Text(username),
|
|
|
|
onLongPress: () {
|
|
|
|
accountsStore.setDefaultAccountFor(entry.key, username);
|
|
|
|
},
|
|
|
|
onTap: () {}, // TODO: go to managing account
|
|
|
|
),
|
|
|
|
],
|
|
|
|
Divider(),
|
|
|
|
]
|
|
|
|
]..removeLast(), // removes trailing Divider
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|