1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-07 15:18:47 +01:00

99 lines
3.0 KiB
Dart
Raw Normal View History

2019-09-04 22:59:33 +08:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
2019-09-25 17:06:36 +08:00
import 'package:git_touch/scaffolds/single.dart';
2019-09-04 22:59:33 +08:00
import 'package:git_touch/utils/utils.dart';
2019-09-11 19:59:47 +08:00
import 'package:git_touch/widgets/app_bar_title.dart';
2020-01-13 21:07:28 +08:00
import 'package:git_touch/widgets/table_view.dart';
import 'package:provider/provider.dart';
2020-01-13 21:07:28 +08:00
import 'package:tuple/tuple.dart';
2019-12-13 13:13:45 +08:00
final settingsRouter = RouterScreen(
'/settings',
(context, parameters) => SettingsScreen(),
);
2019-09-14 23:48:01 +08:00
class SettingsScreen extends StatelessWidget {
2020-01-13 21:07:28 +08:00
Widget _buildRightWidget(BuildContext context, bool checked) {
final theme = Provider.of<ThemeModel>(context);
2019-09-04 22:59:33 +08:00
if (!checked) return null;
2020-01-14 18:13:07 +08:00
return Icon(Icons.check, color: theme.paletteOf(context).primary, size: 24);
2019-09-04 22:59:33 +08:00
}
@override
Widget build(BuildContext context) {
2020-01-13 21:07:28 +08:00
final theme = Provider.of<ThemeModel>(context);
2019-09-25 17:06:36 +08:00
return SingleScaffold(
2019-09-11 19:59:47 +08:00
title: AppBarTitle('Settings'),
2019-09-25 17:06:36 +08:00
body: Column(
2019-09-25 14:24:20 +08:00
children: <Widget>[
2019-10-02 16:09:54 +08:00
CommonStyle.verticalGap,
2020-01-12 17:13:48 +08:00
TableView(
headerText: 'ACCOUNTS',
items: [
TableViewItem(
text: Text('Switch to another account'),
url: '/login',
),
],
),
2019-10-02 16:09:54 +08:00
CommonStyle.verticalGap,
2020-01-12 17:13:48 +08:00
TableView(
headerText: 'APP THEME',
items: [
2020-01-13 21:07:28 +08:00
Tuple2('Material', AppThemeType.material),
Tuple2('Cupertino', AppThemeType.cupertino),
].map((t) {
return TableViewItem(
2020-01-14 12:34:27 +08:00
text: Text(t.item1),
2020-01-12 17:13:48 +08:00
rightWidget: _buildRightWidget(
2020-01-13 21:07:28 +08:00
context,
2020-01-14 12:34:27 +08:00
theme.theme == t.item2,
2020-01-13 21:07:28 +08:00
),
2020-01-12 17:13:48 +08:00
onTap: () {
2020-01-14 12:34:27 +08:00
if (theme.theme != t.item2) {
theme.setTheme(t.item2);
2020-01-12 17:13:48 +08:00
}
},
hideRightChevron: true,
2020-01-13 21:07:28 +08:00
);
}).toList(),
),
CommonStyle.verticalGap,
TableView(
headerText: 'BRIGHTNESS',
items: [
2020-01-14 18:13:07 +08:00
Tuple2('Follow System', AppBrightnessType.followSystem),
2020-01-13 21:07:28 +08:00
Tuple2('Light', AppBrightnessType.light),
Tuple2('Dark', AppBrightnessType.dark),
].map((t) {
return TableViewItem(
text: Text(t.item1),
2020-01-12 17:13:48 +08:00
rightWidget: _buildRightWidget(
2020-01-13 21:07:28 +08:00
context,
theme.brighnessValue == t.item2,
),
2020-01-12 17:13:48 +08:00
onTap: () {
2020-01-13 21:07:28 +08:00
if (theme.brighnessValue != t.item2)
theme.setBrightness(t.item2);
2020-01-12 17:13:48 +08:00
},
hideRightChevron: true,
2020-01-13 21:07:28 +08:00
);
}).toList(),
2020-01-12 17:13:48 +08:00
),
CommonStyle.verticalGap,
TableView(
headerText: 'CODE VIEW',
items: [
TableViewItem(
text: Text('Code settings'),
url: '/choose-code-theme',
),
],
),
2019-09-25 14:24:20 +08:00
],
),
);
}
}