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

99 lines
3.2 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-04 16:59:33 +02:00
import 'package:git_touch/utils/utils.dart';
import 'package:provider/provider.dart';
2019-02-08 16:20:28 +01:00
import 'package:url_launcher/url_launcher.dart';
2019-03-10 06:13:40 +01:00
import 'package:launch_review/launch_review.dart';
import '../scaffolds/simple.dart';
2019-02-08 16:20:28 +01:00
import '../widgets/table_view.dart';
import '../screens/repo.dart';
import '../screens/login.dart';
class SettingsScreen extends StatefulWidget {
@override
_SettingsScreenState createState() => _SettingsScreenState();
}
class _SettingsScreenState extends State<SettingsScreen> {
2019-09-04 16:59:33 +02:00
Widget _buildRightWidget(bool checked) {
if (!checked) return null;
return Icon(Octicons.check, color: CupertinoColors.activeBlue, size: 20);
}
@override
Widget build(BuildContext context) {
var themeProvider = Provider.of<ThemeModel>(context);
2019-02-08 16:20:28 +01:00
return SimpleScaffold(
title: Text('Settings'),
bodyBuilder: () {
2019-02-08 16:20:28 +01:00
return Column(
children: <Widget>[
2019-09-04 16:37:22 +02:00
TableViewSeperator(),
TableView(headerText: 'ACCOUNTS', items: [
TableViewItem(
2019-09-04 16:59:33 +02:00
text: Text('Switch to another account'),
2019-09-04 16:37:22 +02:00
screenBuilder: (_) => LoginScreen(),
),
]),
TableViewSeperator(),
TableView(headerText: 'THEME', items: [
TableViewItem(
2019-09-04 16:59:33 +02:00
text: Text('material'),
rightWidget:
_buildRightWidget(themeProvider.theme == ThemeMap.material),
2019-09-04 16:37:22 +02:00
onTap: () {
if (themeProvider.theme != ThemeMap.material) {
themeProvider.setTheme(ThemeMap.material);
}
},
),
TableViewItem(
2019-09-04 16:59:33 +02:00
text: Text('cupertino'),
rightWidget: _buildRightWidget(
themeProvider.theme == ThemeMap.cupertino),
2019-09-04 16:37:22 +02:00
onTap: () {
if (themeProvider.theme != ThemeMap.cupertino) {
themeProvider.setTheme(ThemeMap.cupertino);
}
},
),
]),
TableViewSeperator(),
TableView(headerText: 'REVIEW', items: [
TableViewItem(
2019-09-04 16:59:33 +02:00
text: Text('Review'),
2019-09-04 16:37:22 +02:00
onTap: () {
LaunchReview.launch(
androidAppId: 'io.github.pd4d10.gittouch',
iOSAppId: '1452042346',
);
},
)
]),
TableViewSeperator(),
TableView(headerText: 'SOURCE CODE', items: [
TableViewItem(
2019-09-04 16:59:33 +02:00
text: Text('pd4d10/git-touch'),
2019-09-04 16:37:22 +02:00
screenBuilder: (_) => RepoScreen('pd4d10', 'git-touch'),
)
]),
TableViewSeperator(),
TableView(headerText: 'LICENSE', items: [
TableViewItem(
2019-09-04 16:59:33 +02:00
text: Text('MIT'),
2019-09-04 16:37:22 +02:00
onTap: () {
launch(
'https://github.com/pd4d10/git-touch/blob/master/LICENSE');
},
)
]),
TableViewSeperator(),
2019-02-08 16:20:28 +01:00
],
);
},
);
}
}