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';
|
2020-01-27 07:43:10 +01:00
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/code.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';
|
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';
|
2020-01-27 07:43:10 +01:00
|
|
|
import 'package:launch_review/launch_review.dart';
|
|
|
|
import 'package:package_info/package_info.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
|
|
|
|
2020-01-27 07:43:10 +01:00
|
|
|
class SettingsScreen extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_SettingsScreenState createState() => _SettingsScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettingsScreenState extends State<SettingsScreen> {
|
|
|
|
var _version = '';
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
PackageInfo.fromPlatform().then((info) {
|
|
|
|
setState(() {
|
|
|
|
_version = info.version;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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);
|
2020-01-27 07:43:10 +01:00
|
|
|
final auth = Provider.of<AuthModel>(context);
|
|
|
|
final code = Provider.of<CodeModel>(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-27 07:43:10 +01:00
|
|
|
TableView(headerText: 'accounts', items: [
|
|
|
|
TableViewItem(
|
|
|
|
text: Text('Switch Accounts'),
|
|
|
|
url: '/login',
|
|
|
|
rightWidget: Text(auth.activeAccount.login),
|
|
|
|
),
|
2020-01-27 07:53:37 +01:00
|
|
|
TableViewItem(
|
|
|
|
text: Text('Review Permissions'),
|
|
|
|
url:
|
|
|
|
'https://github.com/settings/connections/applications/$clientId',
|
|
|
|
rightWidget: Text(auth.activeAccount.login),
|
|
|
|
),
|
2020-01-27 07:43:10 +01:00
|
|
|
]),
|
2019-10-02 10:09:54 +02:00
|
|
|
CommonStyle.verticalGap,
|
2020-01-27 07:43:10 +01:00
|
|
|
TableView(headerText: 'theme', items: [
|
2020-01-24 16:11:43 +01:00
|
|
|
TableViewItem(
|
2020-01-27 07:43:10 +01:00
|
|
|
text: Text('Brightness'),
|
|
|
|
rightWidget: Text(theme.brighnessValue == AppBrightnessType.light
|
|
|
|
? 'Light'
|
|
|
|
: theme.brighnessValue == AppBrightnessType.dark
|
|
|
|
? 'Dark'
|
|
|
|
: 'Follow system'),
|
2020-01-24 16:11:43 +01:00
|
|
|
onTap: () {
|
|
|
|
theme.showActions(context, [
|
|
|
|
for (var t in [
|
2020-01-27 07:43:10 +01:00
|
|
|
Tuple2('Follow System', AppBrightnessType.followSystem),
|
|
|
|
Tuple2('Light', AppBrightnessType.light),
|
|
|
|
Tuple2('Dark', AppBrightnessType.dark),
|
2020-01-24 16:11:43 +01:00
|
|
|
])
|
|
|
|
ActionItem(
|
|
|
|
text: t.item1,
|
|
|
|
onTap: (_) {
|
2020-01-27 07:43:10 +01:00
|
|
|
if (theme.brighnessValue != t.item2)
|
|
|
|
theme.setBrightness(t.item2);
|
2020-01-24 16:11:43 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
TableViewItem(
|
2020-01-27 07:43:10 +01:00
|
|
|
text: Text('Scaffold Theme'),
|
|
|
|
rightWidget: Text(theme.theme == AppThemeType.cupertino
|
|
|
|
? 'Cupertino'
|
|
|
|
: 'Material'),
|
2020-01-24 16:11:43 +01:00
|
|
|
onTap: () {
|
|
|
|
theme.showActions(context, [
|
|
|
|
for (var t in [
|
2020-01-27 07:43:10 +01:00
|
|
|
Tuple2('Material', AppThemeType.material),
|
|
|
|
Tuple2('Cupertino', AppThemeType.cupertino),
|
2020-01-24 16:11:43 +01:00
|
|
|
])
|
|
|
|
ActionItem(
|
|
|
|
text: t.item1,
|
|
|
|
onTap: (_) {
|
2020-01-27 07:43:10 +01:00
|
|
|
if (theme.theme != t.item2) {
|
|
|
|
theme.setTheme(t.item2);
|
|
|
|
}
|
2020-01-24 16:11:43 +01:00
|
|
|
},
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
),
|
2020-01-27 03:47:34 +01:00
|
|
|
TableViewItem(
|
|
|
|
text: Text('Code Theme'),
|
|
|
|
url: '/choose-code-theme',
|
2020-01-27 07:43:10 +01:00
|
|
|
rightWidget: Text('${code.fontFamily}, ${code.fontSize}pt'),
|
2020-01-27 03:47:34 +01:00
|
|
|
),
|
2020-01-24 16:11:43 +01:00
|
|
|
]),
|
2020-01-27 07:43:10 +01:00
|
|
|
CommonStyle.verticalGap,
|
|
|
|
TableView(headerText: 'feedback', items: [
|
|
|
|
TableViewItem(
|
|
|
|
text: Text('Submit an issue'),
|
|
|
|
rightWidget: Text('pd4d10/git-touch'),
|
|
|
|
url: '/pd4d10/git-touch/issues/new',
|
|
|
|
),
|
|
|
|
TableViewItem(
|
|
|
|
text: Text('Rate This App'),
|
|
|
|
onTap: () {
|
|
|
|
LaunchReview.launch(
|
|
|
|
androidAppId: 'io.github.pd4d10.gittouch',
|
|
|
|
iOSAppId: '1452042346',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
TableViewItem(
|
|
|
|
text: Text('Email'),
|
|
|
|
rightWidget: Text('pd4d10@gmail.com'),
|
|
|
|
hideRightChevron: true,
|
|
|
|
url: 'mailto:pd4d10@gmail.com',
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
CommonStyle.verticalGap,
|
|
|
|
TableView(headerText: 'about', items: [
|
|
|
|
TableViewItem(text: Text('Version'), rightWidget: Text(_version)),
|
|
|
|
TableViewItem(
|
|
|
|
text: Text('Source Code'),
|
|
|
|
rightWidget: Text('pd4d10/git-touch'),
|
|
|
|
url: '/pd4d10/git-touch',
|
|
|
|
),
|
|
|
|
])
|
2019-09-25 08:24:20 +02:00
|
|
|
],
|
|
|
|
),
|
2019-02-08 12:34:07 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|