git-touch-android-ios-app/lib/screens/settings.dart

99 lines
3.3 KiB
Dart
Raw Normal View History

2019-09-04 16:59:33 +02:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
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';
2020-01-24 16:11:43 +01:00
import 'package:git_touch/widgets/action_button.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';
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-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
}
@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-24 16:11:43 +01:00
TableView(headerText: 'THEME', items: [
TableViewItem(
text: Text('Scaffold'),
rightWidget: Text(theme.theme == AppThemeType.cupertino
? 'Cupertino'
: 'Material'),
onTap: () {
theme.showActions(context, [
for (var t in [
Tuple2('Material', AppThemeType.material),
Tuple2('Cupertino', AppThemeType.cupertino),
])
ActionItem(
text: t.item1,
onTap: (_) {
if (theme.theme != t.item2) {
theme.setTheme(t.item2);
}
},
)
]);
},
),
TableViewItem(
text: Text('Brightness'),
rightWidget: Text(theme.brighnessValue == AppBrightnessType.light
? 'Light'
: theme.brighnessValue == AppBrightnessType.dark
? 'Dark'
: 'Follow system'),
onTap: () {
theme.showActions(context, [
for (var t in [
Tuple2('Follow System', AppBrightnessType.followSystem),
Tuple2('Light', AppBrightnessType.light),
Tuple2('Dark', AppBrightnessType.dark),
])
ActionItem(
text: t.item1,
onTap: (_) {
if (theme.brighnessValue != t.item2)
theme.setBrightness(t.item2);
},
)
]);
},
),
2020-01-27 03:47:34 +01:00
TableViewItem(
text: Text('Code Theme'),
url: '/choose-code-theme',
),
2020-01-24 16:11:43 +01:00
]),
2019-09-25 08:24:20 +02:00
],
),
);
}
}