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