2020-04-25 15:50:27 +02:00
|
|
|
import 'dart:math' as math;
|
2020-03-19 20:58:30 +01:00
|
|
|
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'package:feature_discovery/feature_discovery.dart';
|
2020-03-01 13:17:06 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'package:line_icons/line_icons.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
2020-06-07 14:47:28 +02:00
|
|
|
import '../home/home.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import '../intro_slider/app_intro.dart';
|
2020-07-07 17:29:21 +02:00
|
|
|
import '../podcasts/podcast_manage.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import '../util/extension_helper.dart';
|
|
|
|
import 'data_backup.dart';
|
2020-03-19 20:58:30 +01:00
|
|
|
import 'history.dart';
|
2020-07-07 17:29:21 +02:00
|
|
|
import 'languages.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'layouts.dart';
|
|
|
|
import 'libries.dart';
|
2020-04-22 20:10:57 +02:00
|
|
|
import 'play_setting.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'storage.dart';
|
|
|
|
import 'syncing.dart';
|
|
|
|
import 'theme.dart';
|
2020-03-01 13:17:06 +01:00
|
|
|
|
2020-04-25 15:50:27 +02:00
|
|
|
class Settings extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_SettingsState createState() => _SettingsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SettingsState extends State<Settings>
|
|
|
|
with SingleTickerProviderStateMixin {
|
2020-03-14 04:14:24 +01:00
|
|
|
_launchUrl(String url) async {
|
|
|
|
if (await canLaunch(url)) {
|
|
|
|
await launch(url);
|
|
|
|
} else {
|
|
|
|
throw 'Could not launch $url';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-25 15:50:27 +02:00
|
|
|
bool _showFeedback;
|
|
|
|
Animation _animation;
|
|
|
|
AnimationController _controller;
|
|
|
|
double _value;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_showFeedback = false;
|
|
|
|
_value = 0;
|
|
|
|
_controller =
|
|
|
|
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
|
|
|
|
_animation = Tween<double>(begin: 0.0, end: 1.0).animate(_controller)
|
|
|
|
..addListener(() {
|
|
|
|
setState(() {
|
|
|
|
_value = _animation.value;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _feedbackItem(IconData icon, String name, String url) => Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () => _launchUrl(url),
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
icon,
|
|
|
|
size: 20 * _value,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 5),
|
|
|
|
),
|
2020-06-02 16:05:49 +02:00
|
|
|
Text(
|
|
|
|
name,
|
|
|
|
maxLines: 2,
|
|
|
|
)
|
2020-04-25 15:50:27 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2020-03-01 13:17:06 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-07-02 14:58:55 +02:00
|
|
|
final s = context.s;
|
2020-03-01 13:17:06 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
|
|
|
systemNavigationBarColor: Theme.of(context).primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
systemNavigationBarIconBrightness:
|
|
|
|
Theme.of(context).accentColorBrightness,
|
2020-03-01 13:17:06 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
2020-07-15 21:42:52 +02:00
|
|
|
title: Text(s.settings),
|
2020-03-19 20:58:30 +01:00
|
|
|
elevation: 0,
|
2020-03-31 18:36:20 +02:00
|
|
|
backgroundColor: context.primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
body: SafeArea(
|
2020-03-21 17:14:10 +01:00
|
|
|
child: SingleChildScrollView(
|
|
|
|
//physics: const AlwaysScrollableScrollPhysics(),
|
2020-03-14 04:14:24 +01:00
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 30.0,
|
2020-06-12 19:56:13 +02:00
|
|
|
padding: EdgeInsets.symmetric(horizontal: 70),
|
2020-03-14 04:14:24 +01:00
|
|
|
alignment: Alignment.centerLeft,
|
2020-07-02 14:58:55 +02:00
|
|
|
child: Text(s.settingsPrefrence,
|
2020-03-14 04:14:24 +01:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.bodyText1
|
2020-03-31 18:36:20 +02:00
|
|
|
.copyWith(color: context.accentColor)),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
ListView(
|
|
|
|
physics: ClampingScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => ThemeSetting())),
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.adjust_solid,
|
|
|
|
color: context.accentColor),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsAppearance),
|
|
|
|
subtitle: Text(s.settingsAppearanceDes),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-06-03 14:39:15 +02:00
|
|
|
ListTile(
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => LayoutSetting())),
|
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.stop_circle_solid,
|
|
|
|
color: Colors.blueAccent),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsLayout),
|
|
|
|
subtitle: Text(s.settingsLayoutDes),
|
2020-06-03 14:39:15 +02:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-03-14 04:14:24 +01:00
|
|
|
ListTile(
|
2020-04-22 20:10:57 +02:00
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => PlaySetting())),
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.play_circle,
|
|
|
|
color: Colors.redAccent),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.play),
|
|
|
|
subtitle: Text(s.settingsPlayDes),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
|
|
|
ListTile(
|
2020-07-02 14:58:55 +02:00
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => SyncingSetting())),
|
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.cloud_download_alt_solid,
|
|
|
|
color: Colors.yellow[700]),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsSyncing),
|
|
|
|
subtitle: Text(s.settingsSyncingDes)),
|
2020-03-14 04:14:24 +01:00
|
|
|
Divider(height: 2),
|
|
|
|
ListTile(
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => StorageSetting())),
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading:
|
|
|
|
Icon(LineIcons.save, color: Colors.green[700]),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingStorage),
|
|
|
|
subtitle: Text(s.settingsStorageDes),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
|
|
|
ListTile(
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => PlayedHistory())),
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading:
|
|
|
|
Icon(Icons.update, color: Colors.indigo[700]),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsHistory),
|
|
|
|
subtitle: Text(s.settingsHistoryDes),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-07-07 17:29:21 +02:00
|
|
|
ListTile(
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => LanguagesSetting())),
|
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.language_solid,
|
|
|
|
color: Colors.purpleAccent),
|
2020-07-07 17:29:21 +02:00
|
|
|
title: Text(s.settingsLanguages),
|
|
|
|
subtitle: Text(s.settingsLanguagesDes),
|
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-03-19 20:58:30 +01:00
|
|
|
ListTile(
|
|
|
|
onTap: () {
|
2020-07-14 17:45:45 +02:00
|
|
|
//_exportOmpl(context);
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => DataBackup()));
|
2020-03-19 20:58:30 +01:00
|
|
|
},
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.file_code_solid,
|
|
|
|
color: Colors.lightGreen[700]),
|
2020-07-14 17:45:45 +02:00
|
|
|
title: Text(s.settingsBackup),
|
|
|
|
subtitle: Text(s.settingsBackupDes),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-03-14 04:14:24 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
height: 30.0,
|
2020-06-12 19:56:13 +02:00
|
|
|
padding: EdgeInsets.symmetric(horizontal: 70),
|
2020-03-14 04:14:24 +01:00
|
|
|
alignment: Alignment.centerLeft,
|
2020-07-02 14:58:55 +02:00
|
|
|
child: Text(s.settingsInfo,
|
2020-03-14 04:14:24 +01:00
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.bodyText1
|
|
|
|
.copyWith(color: Theme.of(context).accentColor)),
|
|
|
|
),
|
|
|
|
ListView(
|
|
|
|
physics: ClampingScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
2020-03-21 17:14:10 +01:00
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => Libries())),
|
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.book_open_solid,
|
|
|
|
color: Colors.purple[700]),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsLibraries),
|
|
|
|
subtitle: Text(s.settingsLibrariesDes),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
|
|
|
ListTile(
|
2020-04-27 19:26:33 +02:00
|
|
|
onTap: () async {
|
|
|
|
if (_value == 0) {
|
|
|
|
_showFeedback = !_showFeedback;
|
2020-04-25 15:50:27 +02:00
|
|
|
_controller.forward();
|
2020-04-27 19:26:33 +02:00
|
|
|
} else {
|
|
|
|
await _controller.reverse();
|
|
|
|
_showFeedback = !_showFeedback;
|
|
|
|
}
|
2020-04-25 15:50:27 +02:00
|
|
|
},
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.bug_solid,
|
|
|
|
color: Colors.pink[700]),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsFeedback),
|
|
|
|
subtitle: Text(s.settingsFeedbackDes),
|
2020-04-25 15:50:27 +02:00
|
|
|
trailing: Transform.rotate(
|
|
|
|
angle: math.pi * _value,
|
|
|
|
child: Icon(Icons.keyboard_arrow_down),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_showFeedback
|
2020-06-02 16:05:49 +02:00
|
|
|
? SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
2020-07-07 19:36:40 +02:00
|
|
|
SizedBox(width: 45),
|
2020-06-02 16:05:49 +02:00
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.github,
|
2020-07-02 14:58:55 +02:00
|
|
|
s.feedbackGithub,
|
2020-06-02 16:05:49 +02:00
|
|
|
'https://github.com/stonega/tsacdop/issues'),
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.telegram,
|
2020-07-02 14:58:55 +02:00
|
|
|
s.feedbackTelegram,
|
2020-06-02 16:05:49 +02:00
|
|
|
'https://t.me/joinchat/Bk3LkRpTHy40QYC78PK7Qg'),
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.envelope_open_text_solid,
|
2020-07-02 14:58:55 +02:00
|
|
|
s.feedbackEmail,
|
2020-06-02 16:05:49 +02:00
|
|
|
'mailto:<tsacdop.app@gmail.com>?subject=Tsacdop Feedback'),
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.google_play,
|
2020-07-02 14:58:55 +02:00
|
|
|
s.feedbackPlay,
|
2020-06-02 16:05:49 +02:00
|
|
|
'https://play.google.com/store/apps/details?id=com.stonegate.tsacdop')
|
|
|
|
],
|
|
|
|
),
|
2020-04-25 15:50:27 +02:00
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
Divider(
|
|
|
|
height: 2,
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
2020-06-07 14:47:28 +02:00
|
|
|
ListTile(
|
|
|
|
onTap: () {
|
|
|
|
FeatureDiscovery.clearPreferences(
|
|
|
|
context, const <String>{
|
|
|
|
addFeature,
|
|
|
|
menuFeature,
|
|
|
|
playlistFeature,
|
|
|
|
groupsFeature,
|
|
|
|
addGroupFeature,
|
|
|
|
configureGroup,
|
|
|
|
configurePodcast,
|
|
|
|
podcastFeature
|
|
|
|
});
|
|
|
|
Fluttertoast.showToast(
|
2020-07-06 11:50:20 +02:00
|
|
|
msg: s.toastDiscovery,
|
2020-06-07 14:47:28 +02:00
|
|
|
gravity: ToastGravity.BOTTOM,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.capsules_solid,
|
|
|
|
color: Colors.pinkAccent),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsDiscovery),
|
2020-06-07 14:47:28 +02:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-04-06 14:18:08 +02:00
|
|
|
ListTile(
|
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
2020-04-18 06:48:02 +02:00
|
|
|
builder: (context) =>
|
|
|
|
SlideIntro(goto: Goto.settings))),
|
2020-04-06 14:18:08 +02:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-07-08 18:34:42 +02:00
|
|
|
leading: Icon(LineIcons.columns_solid,
|
|
|
|
color: Colors.blueGrey),
|
2020-07-02 14:58:55 +02:00
|
|
|
title: Text(s.settingsAppIntro),
|
2020-04-06 14:18:08 +02:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-03-14 04:14:24 +01:00
|
|
|
],
|
|
|
|
),
|
2020-04-25 15:50:27 +02:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(10.0),
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-03-01 13:17:06 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|