2020-03-19 20:58:30 +01:00
|
|
|
import 'dart:io';
|
2020-04-25 15:50:27 +02:00
|
|
|
import 'dart:math' as math;
|
2020-03-19 20:58:30 +01:00
|
|
|
|
2020-03-01 13:17:06 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
2020-03-19 20:58:30 +01:00
|
|
|
import 'package:path/path.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'package:line_icons/line_icons.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2020-03-19 20:58:30 +01:00
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../util/ompl_build.dart';
|
|
|
|
import '../util/context_extension.dart';
|
|
|
|
import '../intro_slider/app_intro.dart';
|
|
|
|
import '../type/podcastlocal.dart';
|
|
|
|
import '../local_storage/sqflite_localpodcast.dart';
|
2020-03-19 20:58:30 +01:00
|
|
|
import 'theme.dart';
|
|
|
|
import 'storage.dart';
|
|
|
|
import 'history.dart';
|
|
|
|
import 'syncing.dart';
|
2020-03-14 04:14:24 +01:00
|
|
|
import 'libries.dart';
|
2020-04-22 20:10:57 +02:00
|
|
|
import 'play_setting.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-03-19 20:58:30 +01:00
|
|
|
_exportOmpl() async {
|
|
|
|
var dbHelper = DBHelper();
|
|
|
|
List<PodcastLocal> podcastList = await dbHelper.getPodcastLocalAll();
|
2020-04-18 06:48:02 +02:00
|
|
|
var ompl = omplBuilder(podcastList.reversed.toList());
|
2020-03-19 20:58:30 +01:00
|
|
|
var tempdir = await getTemporaryDirectory();
|
|
|
|
var file = File(join(tempdir.path, 'tsacdop_ompl.xml'));
|
|
|
|
print(file.path);
|
|
|
|
await file.writeAsString(ompl.toString());
|
|
|
|
final params = SaveFileDialogParams(sourceFilePath: file.path);
|
|
|
|
final filePath = await FlutterFileDialog.saveFile(params: params);
|
|
|
|
print(filePath);
|
|
|
|
print(ompl.toString());
|
|
|
|
}
|
|
|
|
|
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),
|
|
|
|
),
|
|
|
|
Text(name)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2020-03-01 13:17:06 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
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(
|
|
|
|
title: Text('Settings'),
|
|
|
|
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,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 80),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text('Prefrence',
|
|
|
|
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-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.adjust_solid),
|
|
|
|
title: Text('Appearance'),
|
|
|
|
subtitle: Text('Colors and themes'),
|
|
|
|
),
|
|
|
|
Divider(height: 2),
|
|
|
|
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-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.play_circle),
|
2020-04-22 20:10:57 +02:00
|
|
|
title: Text('Play'),
|
|
|
|
subtitle: Text('Playlist and player'),
|
2020-04-25 15:50:27 +02:00
|
|
|
// trailing: Selector<AudioPlayerNotifier, bool>(
|
|
|
|
// selector: (_, audio) => audio.autoPlay,
|
|
|
|
// builder: (_, data, __) => Switch(
|
|
|
|
// value: data,
|
|
|
|
// onChanged: (boo) => audio.autoPlaySwitch = boo),
|
|
|
|
// ),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
|
|
|
ListTile(
|
2020-03-19 20:58:30 +01:00
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => SyncingSetting())),
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.cloud_download_alt_solid),
|
2020-03-19 20:58:30 +01:00
|
|
|
title: Text('Syncing'),
|
|
|
|
subtitle: Text('Refresh podcasts in the background'),
|
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-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.save),
|
|
|
|
title: Text('Storage'),
|
|
|
|
subtitle: Text('Manage cache and download storage'),
|
|
|
|
),
|
|
|
|
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-03-14 04:14:24 +01:00
|
|
|
leading: Icon(Icons.update),
|
|
|
|
title: Text('History'),
|
|
|
|
subtitle: Text('Listen data'),
|
|
|
|
),
|
|
|
|
Divider(height: 2),
|
2020-03-19 20:58:30 +01:00
|
|
|
ListTile(
|
|
|
|
onTap: () {
|
|
|
|
_exportOmpl();
|
|
|
|
},
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-03-19 20:58:30 +01:00
|
|
|
leading: Icon(LineIcons.file_code_solid),
|
|
|
|
title: Text('Export'),
|
2020-04-22 20:10:57 +02:00
|
|
|
subtitle: Text('Export ompl file of all podcasts'),
|
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,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 80),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text('Info',
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.bodyText1
|
|
|
|
.copyWith(color: Theme.of(context).accentColor)),
|
|
|
|
),
|
|
|
|
ListView(
|
|
|
|
physics: ClampingScrollPhysics(),
|
|
|
|
shrinkWrap: true,
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
children: <Widget>[
|
|
|
|
ListTile(
|
|
|
|
onTap: () => _launchUrl(
|
|
|
|
'https://github.com/stonega/tsacdop/releases'),
|
2020-03-21 17:14:10 +01:00
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.map_signs_solid),
|
|
|
|
title: Text('Changelog'),
|
2020-04-02 11:52:26 +02:00
|
|
|
subtitle: Text('List of changes'),
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
|
|
|
Divider(height: 2),
|
|
|
|
ListTile(
|
2020-03-21 17:14:10 +01:00
|
|
|
onTap: () => Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (context) => Libries())),
|
|
|
|
contentPadding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 25.0),
|
2020-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.book_open_solid),
|
|
|
|
title: Text('Libraries'),
|
2020-03-21 17:14:10 +01:00
|
|
|
subtitle:
|
|
|
|
Text('Open source libraries in application'),
|
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-03-14 04:14:24 +01:00
|
|
|
leading: Icon(LineIcons.bug_solid),
|
|
|
|
title: Text('Feedback'),
|
2020-04-25 15:50:27 +02:00
|
|
|
subtitle: Text('Bugs and feature request'),
|
|
|
|
trailing: Transform.rotate(
|
|
|
|
angle: math.pi * _value,
|
|
|
|
child: Icon(Icons.keyboard_arrow_down),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
_showFeedback
|
|
|
|
? Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceEvenly,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.github,
|
|
|
|
'Submit issue',
|
|
|
|
'https://github.com/stonega/tsacdop/issues'),
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.telegram,
|
|
|
|
'Join group',
|
|
|
|
'https://t.me/joinchat/Bk3LkRpTHy40QYC78PK7Qg'),
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.envelope_open_text_solid,
|
|
|
|
'Write to me',
|
|
|
|
'mailto:<tsacdop.app@gmail.com>?subject=Tsacdop Feedback'),
|
|
|
|
_feedbackItem(
|
|
|
|
LineIcons.google_play,
|
|
|
|
'Rate on Play',
|
|
|
|
'https://play.google.com/store/apps/details?id=com.stonegate.tsacdop')
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: Center(),
|
|
|
|
Divider(
|
|
|
|
height: 2,
|
2020-03-14 04:14:24 +01:00
|
|
|
),
|
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-04-06 14:30:44 +02:00
|
|
|
leading: Icon(LineIcons.columns_solid),
|
2020-04-06 14:18:08 +02:00
|
|
|
title: Text('App Intro'),
|
|
|
|
),
|
|
|
|
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
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|