Add sleep timer settings.
This commit is contained in:
parent
ad754cfcd9
commit
9ac4790e44
|
@ -5,7 +5,9 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
![CircleCI](https://img.shields.io/circleci/build/github/stonega/tsacdop?token=efe1331861e017144f2abb363acd95197e436dad)
|
![CircleCI](https://img.shields.io/circleci/build/github/stonega/tsacdop?token=efe1331861e017144f2abb363acd95197e436dad)
|
||||||
|
|
||||||
![GitHub release (latest by date)](https://img.shields.io/github/v/release/stonega/tsacdop)
|
![GitHub release (latest by date)](https://img.shields.io/github/v/release/stonega/tsacdop)
|
||||||
|
|
||||||
[![GooglePlay](https://img.shields.io/badge/Google-PlayStore-%2323CCC6)](https://play.google.com/store/apps/details?id=com.stonegate.tsacdop)
|
[![GooglePlay](https://img.shields.io/badge/Google-PlayStore-%2323CCC6)](https://play.google.com/store/apps/details?id=com.stonegate.tsacdop)
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
@ -28,7 +30,7 @@ The podcasts search engine is powered by [ListenNotes](https://listennotes.com).
|
||||||
* Listen and subscribe history record
|
* Listen and subscribe history record
|
||||||
* Dark mode / Accent color
|
* Dark mode / Accent color
|
||||||
* Download for offline playing
|
* Download for offline playing
|
||||||
* Share clip(video format) on twitter
|
* Auto download new episodes / Auto delete outdated downloads
|
||||||
|
|
||||||
More to come...
|
More to come...
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ Share_key is used for generate clip.
|
||||||
|
|
||||||
## Known Issue
|
## Known Issue
|
||||||
|
|
||||||
- Playlist unstable
|
* Playlist unstable
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import 'package:line_icons/line_icons.dart';
|
||||||
import '../type/episodebrief.dart';
|
import '../type/episodebrief.dart';
|
||||||
import '../state/audiostate.dart';
|
import '../state/audiostate.dart';
|
||||||
import '../local_storage/sqflite_localpodcast.dart';
|
import '../local_storage/sqflite_localpodcast.dart';
|
||||||
|
import '../local_storage/key_value_storage.dart';
|
||||||
import '../util/pageroute.dart';
|
import '../util/pageroute.dart';
|
||||||
import '../util/colorize.dart';
|
import '../util/colorize.dart';
|
||||||
import '../util/context_extension.dart';
|
import '../util/context_extension.dart';
|
||||||
|
@ -42,6 +43,9 @@ String _stringForSeconds(double seconds) {
|
||||||
return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}';
|
return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const List minsToSelect = [10, 15, 20, 25, 30, 45, 60, 70, 80, 90, 99];
|
||||||
|
const List speedToSelect = [0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0];
|
||||||
|
|
||||||
class PlayerWidget extends StatefulWidget {
|
class PlayerWidget extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_PlayerWidgetState createState() => _PlayerWidgetState();
|
_PlayerWidgetState createState() => _PlayerWidgetState();
|
||||||
|
@ -788,13 +792,21 @@ class SleepMode extends StatefulWidget {
|
||||||
class SleepModeState extends State<SleepMode>
|
class SleepModeState extends State<SleepMode>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
int _minSelected;
|
int _minSelected;
|
||||||
List minsToSelect = [10, 15, 20, 25, 30, 45, 60, 70, 80, 90, 99];
|
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
Animation<double> _animation;
|
Animation<double> _animation;
|
||||||
|
|
||||||
|
Future _getDefaultTime() async {
|
||||||
|
KeyValueStorage defaultSleepTimerStorage =
|
||||||
|
KeyValueStorage(defaultSleepTimerKey);
|
||||||
|
int defaultTime = await defaultSleepTimerStorage.getInt(defaultValue: 30);
|
||||||
|
setState(() => _minSelected = defaultTime);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_minSelected = 30;
|
_minSelected = 30;
|
||||||
|
_getDefaultTime();
|
||||||
_controller =
|
_controller =
|
||||||
AnimationController(vsync: this, duration: Duration(milliseconds: 400));
|
AnimationController(vsync: this, duration: Duration(milliseconds: 400));
|
||||||
_animation = Tween<double>(begin: 0.0, end: 1.0).animate(_controller)
|
_animation = Tween<double>(begin: 0.0, end: 1.0).animate(_controller)
|
||||||
|
@ -1085,7 +1097,6 @@ class ControlPanel extends StatefulWidget {
|
||||||
|
|
||||||
class _ControlPanelState extends State<ControlPanel>
|
class _ControlPanelState extends State<ControlPanel>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
final _speedToSelect = [0.5, 0.6, 0.8, 1.0, 1.2, 1.5, 2.0];
|
|
||||||
double _speedSelected;
|
double _speedSelected;
|
||||||
double _setSpeed;
|
double _setSpeed;
|
||||||
AnimationController _controller;
|
AnimationController _controller;
|
||||||
|
@ -1363,7 +1374,8 @@ class _ControlPanelState extends State<ControlPanel>
|
||||||
velocity: 50.0,
|
velocity: 50.0,
|
||||||
pauseAfterRound: Duration.zero,
|
pauseAfterRound: Duration.zero,
|
||||||
startPadding: 30.0,
|
startPadding: 30.0,
|
||||||
accelerationDuration: Duration(milliseconds: 100),
|
accelerationDuration:
|
||||||
|
Duration(milliseconds: 100),
|
||||||
accelerationCurve: Curves.linear,
|
accelerationCurve: Curves.linear,
|
||||||
decelerationDuration:
|
decelerationDuration:
|
||||||
Duration(milliseconds: 100),
|
Duration(milliseconds: 100),
|
||||||
|
@ -1459,7 +1471,7 @@ class _ControlPanelState extends State<ControlPanel>
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: EdgeInsets.all(10.0),
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: _speedToSelect
|
children: speedToSelect
|
||||||
.map<Widget>((e) => InkWell(
|
.map<Widget>((e) => InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (_setSpeed == 1) {
|
if (_setSpeed == 1) {
|
||||||
|
|
|
@ -179,7 +179,9 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15,
|
height: 15,
|
||||||
child: WaveLoader(color: context.accentColor,)),
|
child: WaveLoader(
|
||||||
|
color: context.accentColor,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -211,7 +213,9 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15,
|
height: 15,
|
||||||
child: WaveLoader(color: context.accentColor,)),
|
child: WaveLoader(
|
||||||
|
color: context.accentColor,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -307,7 +311,7 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
|
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
|
||||||
Color _c = (Theme.of(context).brightness == Brightness.light)
|
Color _c = (Theme.of(context).brightness == Brightness.light)
|
||||||
? widget.episode.primaryColor.colorizedark()
|
? widget.episode.primaryColor.colorizedark()
|
||||||
: widget.episode.primaryColor.colorizeLight();
|
: widget.episode.primaryColor.colorizeLight();
|
||||||
return AnimatedContainer(
|
return AnimatedContainer(
|
||||||
|
@ -363,6 +367,7 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
||||||
gravity: ToastGravity.BOTTOM,
|
gravity: ToastGravity.BOTTOM,
|
||||||
);
|
);
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
backgroundColor: Colors.grey[800],
|
backgroundColor: Colors.grey[800],
|
||||||
content: Text('Episode removed',
|
content: Text('Episode removed',
|
||||||
style: TextStyle(color: Colors.white)),
|
style: TextStyle(color: Colors.white)),
|
||||||
|
|
|
@ -6,13 +6,13 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import '../state/podcast_group.dart';
|
import '../state/podcast_group.dart';
|
||||||
|
|
||||||
const String autoPlayKey = 'autoPlay';
|
const String autoPlayKey = 'autoPlay';
|
||||||
const String autoAddKey = 'autoAdd';
|
//const String autoAddKey = 'autoAdd';
|
||||||
const String audioPositionKey = 'audioposition';
|
const String audioPositionKey = 'audioposition';
|
||||||
const String lastWorkKey = 'lastWork';
|
const String lastWorkKey = 'lastWork';
|
||||||
const String refreshdateKey = 'refreshdate';
|
const String refreshdateKey = 'refreshdate';
|
||||||
const String themesKey = 'themes';
|
const String themesKey = 'themes';
|
||||||
const String accentsKey = 'accents';
|
const String accentsKey = 'accents';
|
||||||
const String autoUpdateKey = 'autoupdate';
|
const String autoUpdateKey = 'autoAdd';
|
||||||
const String updateIntervalKey = 'updateInterval';
|
const String updateIntervalKey = 'updateInterval';
|
||||||
const String downloadUsingDataKey = 'downloadUsingData';
|
const String downloadUsingDataKey = 'downloadUsingData';
|
||||||
const String introKey = 'intro';
|
const String introKey = 'intro';
|
||||||
|
@ -25,6 +25,12 @@ const String downloadLayoutKey = 'downloadLayoutKey';
|
||||||
const String autoDownloadNetworkKey = 'autoDownloadNetwork';
|
const String autoDownloadNetworkKey = 'autoDownloadNetwork';
|
||||||
const String episodePopupMenuKey = 'episodePopupMenuKey';
|
const String episodePopupMenuKey = 'episodePopupMenuKey';
|
||||||
const String autoDeleteKey = 'autoDeleteKey';
|
const String autoDeleteKey = 'autoDeleteKey';
|
||||||
|
//SleepTImer
|
||||||
|
const String autoSleepTimerKey = 'autoSleepTimerKey';
|
||||||
|
const String autoSleepTimerStartKey = 'autoSleepTimerStartKey';
|
||||||
|
const String autoSleepTimerEndKey = 'autoSleepTimerEndKey';
|
||||||
|
const String defaultSleepTimerKey = 'defaultSleepTimerKey';
|
||||||
|
const String autoSleepTimerModeKey = 'autoSleepTimerModeKey';
|
||||||
|
|
||||||
class KeyValueStorage {
|
class KeyValueStorage {
|
||||||
final String key;
|
final String key;
|
||||||
|
@ -60,9 +66,9 @@ class KeyValueStorage {
|
||||||
return prefs.setInt(key, setting);
|
return prefs.setInt(key, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getInt() async {
|
Future<int> getInt({int defaultValue = 0}) async {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
if (prefs.getInt(key) == null) await prefs.setInt(key, 0);
|
if (prefs.getInt(key) == null) await prefs.setInt(key, defaultValue);
|
||||||
return prefs.getInt(key);
|
return prefs.getInt(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@ class _LayoutSettingState extends State<LayoutSetting> {
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
KeyValueStorage storage = KeyValueStorage(key);
|
KeyValueStorage storage = KeyValueStorage(key);
|
||||||
await storage.saveInt(option.index);
|
await storage.saveInt(option.index);
|
||||||
print(option.index);
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: AnimatedContainer(
|
||||||
|
duration: Duration(milliseconds: 400),
|
||||||
height: 30,
|
height: 30,
|
||||||
width: 50,
|
width: 50,
|
||||||
color: layout == option
|
color: layout == option
|
||||||
|
|
|
@ -1,13 +1,212 @@
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
import 'package:flutter_time_picker_spinner/flutter_time_picker_spinner.dart';
|
||||||
|
|
||||||
import '../state/audiostate.dart';
|
import '../state/settingstate.dart';
|
||||||
|
import '../home/audioplayer.dart';
|
||||||
|
import '../util/general_dialog.dart';
|
||||||
|
import '../util/context_extension.dart';
|
||||||
|
|
||||||
|
String stringForMins(int mins) {
|
||||||
|
if (mins == null) return null;
|
||||||
|
return '${(mins ~/ 60)}:${(mins.truncate() % 60).toString().padLeft(2, '0')}';
|
||||||
|
}
|
||||||
|
|
||||||
class PlaySetting extends StatelessWidget {
|
class PlaySetting extends StatelessWidget {
|
||||||
|
Widget _modeWidget(BuildContext context) {
|
||||||
|
var settings = Provider.of<SettingState>(context, listen: false);
|
||||||
|
return Selector<SettingState, Tuple2<int, int>>(
|
||||||
|
selector: (_, settings) =>
|
||||||
|
Tuple2(settings.autoSleepTimerMode, settings.defaultSleepTimer),
|
||||||
|
builder: (_, data, __) => Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () => settings.setAutoSleepTimerMode = 0,
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: Duration(milliseconds: 400),
|
||||||
|
color: data.item1 == 0
|
||||||
|
? context.accentColor
|
||||||
|
: context.primaryColorDark,
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text('End of Episode',
|
||||||
|
style: TextStyle(
|
||||||
|
color: data.item1 == 0 ? Colors.white : null)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () => settings.setAutoSleepTimerMode = 1,
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: Duration(milliseconds: 400),
|
||||||
|
color: data.item1 == 1
|
||||||
|
? context.accentColor
|
||||||
|
: context.primaryColorDark,
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(data.item2.toString() + 'mins',
|
||||||
|
style: TextStyle(
|
||||||
|
color: data.item1 == 1 ? Colors.white : null)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _scheduleWidget(BuildContext context) {
|
||||||
|
var settings = Provider.of<SettingState>(context, listen: false);
|
||||||
|
return Selector<SettingState, Tuple2<int, int>>(
|
||||||
|
selector: (_, settings) =>
|
||||||
|
Tuple2(settings.autoSleepTimerStart, settings.autoSleepTimerEnd),
|
||||||
|
builder: (_, data, __) => Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
int startTime = data.item1;
|
||||||
|
generalDialog(
|
||||||
|
context,
|
||||||
|
content: TimePickerSpinner(
|
||||||
|
minutesInterval: 15,
|
||||||
|
time: DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
data.item1 * 60 * 1000,
|
||||||
|
isUtc: true),
|
||||||
|
isForce2Digits: true,
|
||||||
|
is24HourMode: false,
|
||||||
|
highlightedTextStyle: GoogleFonts.teko(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 40, color: context.accentColor)),
|
||||||
|
normalTextStyle: GoogleFonts.teko(
|
||||||
|
textStyle:
|
||||||
|
TextStyle(fontSize: 40, color: Colors.black38)),
|
||||||
|
onTimeChange: (DateTime time) {
|
||||||
|
startTime = time.hour * 60 + time.minute;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: Text(
|
||||||
|
'CANCEL',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (startTime != data.item2) {
|
||||||
|
settings.setAutoSleepTimerStart = startTime;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
} else {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: 'Time is equal to end time',
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'CONFIRM',
|
||||||
|
style: TextStyle(color: context.accentColor),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Container(
|
||||||
|
color: context.primaryColorDark,
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text('From ' + stringForMins(data.item1)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
int endTime;
|
||||||
|
generalDialog(
|
||||||
|
context,
|
||||||
|
content: TimePickerSpinner(
|
||||||
|
minutesInterval: 15,
|
||||||
|
time: DateTime.fromMillisecondsSinceEpoch(
|
||||||
|
data.item2 * 60 * 1000,
|
||||||
|
isUtc: true),
|
||||||
|
isForce2Digits: true,
|
||||||
|
highlightedTextStyle: GoogleFonts.teko(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 40, color: context.accentColor)),
|
||||||
|
normalTextStyle: GoogleFonts.teko(
|
||||||
|
textStyle:
|
||||||
|
TextStyle(fontSize: 40, color: Colors.black38)),
|
||||||
|
is24HourMode: false,
|
||||||
|
onTimeChange: (DateTime time) {
|
||||||
|
endTime = time.hour * 60 + time.minute;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: Text(
|
||||||
|
'CANCEL',
|
||||||
|
style: TextStyle(color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (endTime != data.item1) {
|
||||||
|
settings.setAutoSleepTimerEnd = endTime;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
} else {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: 'Time is equal to start time',
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'CONFIRM',
|
||||||
|
style: TextStyle(color: context.accentColor),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
color: Colors.black54,
|
||||||
|
child: Text('To ' + stringForMins(data.item2),
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
|
var settings = Provider.of<SettingState>(context, listen: false);
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
value: SystemUiOverlayStyle(
|
value: SystemUiOverlayStyle(
|
||||||
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
statusBarIconBrightness: Theme.of(context).accentColorBrightness,
|
||||||
|
@ -32,7 +231,7 @@ class PlaySetting extends StatelessWidget {
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
height: 30.0,
|
height: 30.0,
|
||||||
|
@ -49,36 +248,103 @@ class PlaySetting extends StatelessWidget {
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListTile(
|
Selector<SettingState, bool>(
|
||||||
contentPadding:
|
selector: (_, settings) => settings.autoPlay,
|
||||||
EdgeInsets.only(left: 80.0, right: 20, bottom: 0),
|
builder: (_, data, __) => ListTile(
|
||||||
title: Text('Autoplay'),
|
onTap: () => settings.setAutoPlay = !data,
|
||||||
subtitle: Text('Autoplay next episode in playlist'),
|
contentPadding:
|
||||||
trailing: Selector<AudioPlayerNotifier, bool>(
|
EdgeInsets.only(left: 80.0, right: 20),
|
||||||
selector: (_, audio) => audio.autoPlay,
|
title: Text('Autoplay'),
|
||||||
builder: (_, data, __) => Transform.scale(
|
subtitle: Text('Autoplay next episode in playlist'),
|
||||||
|
trailing: Transform.scale(
|
||||||
scale: 0.9,
|
scale: 0.9,
|
||||||
child: Switch(
|
child: Switch(
|
||||||
value: data,
|
value: data,
|
||||||
onChanged: (boo) => audio.autoPlaySwitch = boo),
|
onChanged: (boo) => settings.setAutoPlay = boo),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(height: 2),
|
Divider(height: 2),
|
||||||
// ListTile(
|
],
|
||||||
// contentPadding:
|
),
|
||||||
// EdgeInsets.only(left: 80.0, right: 20, bottom: 0),
|
Padding(
|
||||||
// title: Text('Autoadd'),
|
padding: const EdgeInsets.all(10.0),
|
||||||
// subtitle:
|
),
|
||||||
// Text('Autoadd new updated episodes to playlist'),
|
Container(
|
||||||
// trailing: Selector<AudioPlayerNotifier, bool>(
|
height: 30.0,
|
||||||
// selector: (_, audio) => audio.autoAdd,
|
padding: EdgeInsets.symmetric(horizontal: 70),
|
||||||
// builder: (_, data, __) => Switch(
|
alignment: Alignment.centerLeft,
|
||||||
// value: data,
|
child: Text('Sleep timer',
|
||||||
// onChanged: (boo) => audio.autoAddSwitch = boo),
|
style: Theme.of(context)
|
||||||
// ),
|
.textTheme
|
||||||
// ),
|
.bodyText1
|
||||||
// Divider(height: 2),
|
.copyWith(color: Theme.of(context).accentColor)),
|
||||||
|
),
|
||||||
|
ListView(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.only(left: 80.0, right: 20),
|
||||||
|
title: Text('Default time'),
|
||||||
|
subtitle: Text('Default time for sleep timer.'),
|
||||||
|
trailing: Selector<SettingState, int>(
|
||||||
|
selector: (_, settings) => settings.defaultSleepTimer,
|
||||||
|
builder: (_, data, __) => DropdownButton(
|
||||||
|
hint: Text(data.toString() + 'mins'),
|
||||||
|
underline: Center(),
|
||||||
|
elevation: 1,
|
||||||
|
isDense: true,
|
||||||
|
value: data,
|
||||||
|
onChanged: (int value) =>
|
||||||
|
settings.setDefaultSleepTimer = value,
|
||||||
|
items:
|
||||||
|
minsToSelect.map<DropdownMenuItem<int>>((e) {
|
||||||
|
return DropdownMenuItem<int>(
|
||||||
|
value: e,
|
||||||
|
child: Text(e.toString() + ' mins'));
|
||||||
|
}).toList()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Selector<SettingState, bool>(
|
||||||
|
selector: (_, settings) => settings.autoSleepTimer,
|
||||||
|
builder: (_, data, __) => ListTile(
|
||||||
|
onTap: () => settings.setAutoSleepTimer = !data,
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
left: 80.0, right: 20.0, bottom: 10.0, top: 10.0),
|
||||||
|
title: Text('Auto turn on sleep timer'),
|
||||||
|
subtitle:
|
||||||
|
Text('Auto start sleep timer at scheduled time.'),
|
||||||
|
trailing: Transform.scale(
|
||||||
|
scale: 0.9,
|
||||||
|
child: Switch(
|
||||||
|
value: data,
|
||||||
|
onChanged: (boo) =>
|
||||||
|
settings.setAutoSleepTimer = boo),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
left: 80.0, right: 20.0, bottom: 10.0, top: 10.0),
|
||||||
|
title: Text('Auto sleep timer mode'),
|
||||||
|
subtitle:
|
||||||
|
context.width > 360 ? null : _modeWidget(context),
|
||||||
|
trailing: context.width > 360
|
||||||
|
? _modeWidget(context)
|
||||||
|
: null),
|
||||||
|
ListTile(
|
||||||
|
contentPadding:
|
||||||
|
EdgeInsets.only(left: 80.0, right: 20),
|
||||||
|
title: Text('Schedule'),
|
||||||
|
subtitle: context.width > 360
|
||||||
|
? null
|
||||||
|
: _scheduleWidget(context),
|
||||||
|
trailing: context.width > 360
|
||||||
|
? _scheduleWidget(context)
|
||||||
|
: null),
|
||||||
|
Divider(height: 2)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -88,40 +88,40 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
backgroundColor: context.primaryColor,
|
backgroundColor: context.primaryColor,
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: Column(
|
||||||
child: Column(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
children: [
|
||||||
children: [
|
Container(
|
||||||
Container(
|
color: context.primaryColor,
|
||||||
color: context.primaryColor,
|
height: 200,
|
||||||
height: 200,
|
// color: Colors.red,
|
||||||
// color: Colors.red,
|
child: FlareActor(
|
||||||
child: FlareActor(
|
'assets/longtap.flr',
|
||||||
'assets/longtap.flr',
|
alignment: Alignment.center,
|
||||||
alignment: Alignment.center,
|
animation: 'longtap',
|
||||||
animation: 'longtap',
|
fit: BoxFit.cover,
|
||||||
fit: BoxFit.cover,
|
)),
|
||||||
)),
|
Divider(height: 2),
|
||||||
Divider(height: 2),
|
Padding(
|
||||||
Padding(
|
padding: EdgeInsets.symmetric(vertical: 10),
|
||||||
padding: EdgeInsets.symmetric(vertical: 10),
|
),
|
||||||
),
|
Container(
|
||||||
Container(
|
height: 30.0,
|
||||||
height: 30.0,
|
padding: EdgeInsets.symmetric(horizontal: 80),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 80),
|
alignment: Alignment.centerLeft,
|
||||||
alignment: Alignment.centerLeft,
|
child: Text('Episode popup menu',
|
||||||
child: Text('Episode popup menu',
|
style: Theme.of(context)
|
||||||
style: Theme.of(context)
|
.textTheme
|
||||||
.textTheme
|
.bodyText1
|
||||||
.bodyText1
|
.copyWith(color: Theme.of(context).accentColor)),
|
||||||
.copyWith(color: Theme.of(context).accentColor)),
|
),
|
||||||
),
|
FutureBuilder<List<int>>(
|
||||||
FutureBuilder<List<int>>(
|
future: _getEpisodeMenu(),
|
||||||
future: _getEpisodeMenu(),
|
initialData: [0, 1, 12, 13, 14],
|
||||||
initialData: [0, 1, 12, 13, 14],
|
builder: (context, snapshot) {
|
||||||
builder: (context, snapshot) {
|
List<int> menu = snapshot.data;
|
||||||
List<int> menu = snapshot.data;
|
return Expanded(
|
||||||
return ListView(
|
child: ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
children: menu.map<Widget>((int e) {
|
children: menu.map<Widget>((int e) {
|
||||||
int i = e % 10;
|
int i = e % 10;
|
||||||
|
@ -163,7 +163,6 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
|
||||||
text: 'Mark Listened',
|
text: 'Mark Listened',
|
||||||
description: 'Mark episode as listened');
|
description: 'Mark episode as listened');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return _popupMenuItem(menu, e,
|
return _popupMenuItem(menu, e,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
|
@ -178,10 +177,10 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
),
|
||||||
}),
|
);
|
||||||
],
|
}),
|
||||||
),
|
],
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,18 +115,19 @@ class ThemeSetting extends StatelessWidget {
|
||||||
title: Text('Theme'),
|
title: Text('Theme'),
|
||||||
subtitle: Text('System default'),
|
subtitle: Text('System default'),
|
||||||
),
|
),
|
||||||
ListTile(
|
Selector<SettingState, bool>(
|
||||||
contentPadding:
|
selector: (_, setting) => setting.realDark,
|
||||||
EdgeInsets.only(left: 80.0, right: 20, bottom: 10),
|
builder: (_, data, __) => ListTile(
|
||||||
// leading: Icon(Icons.colorize),
|
onTap: () => settings.setRealDark = !data,
|
||||||
title: Text(
|
contentPadding: const EdgeInsets.only(
|
||||||
'Real Dark',
|
left: 80.0, right: 20, bottom: 10, top: 10),
|
||||||
),
|
// leading: Icon(Icons.colorize),
|
||||||
subtitle:
|
title: Text(
|
||||||
Text('Turn on if you think the night is not dark enough'),
|
'Real Dark',
|
||||||
trailing: Selector<SettingState, bool>(
|
),
|
||||||
selector: (_, setting) => setting.realDark,
|
subtitle: Text(
|
||||||
builder: (_, data, __) => Transform.scale(
|
'Turn on if you think the night is not dark enough'),
|
||||||
|
trailing: Transform.scale(
|
||||||
scale: 0.9,
|
scale: 0.9,
|
||||||
child: Switch(
|
child: Switch(
|
||||||
value: data,
|
value: data,
|
||||||
|
|
|
@ -128,7 +128,15 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
DBHelper dbHelper = DBHelper();
|
DBHelper dbHelper = DBHelper();
|
||||||
KeyValueStorage positionStorage = KeyValueStorage(audioPositionKey);
|
KeyValueStorage positionStorage = KeyValueStorage(audioPositionKey);
|
||||||
KeyValueStorage autoPlayStorage = KeyValueStorage(autoPlayKey);
|
KeyValueStorage autoPlayStorage = KeyValueStorage(autoPlayKey);
|
||||||
KeyValueStorage autoAddStorage = KeyValueStorage(autoAddKey);
|
KeyValueStorage autoSleepTimerStorage = KeyValueStorage(autoSleepTimerKey);
|
||||||
|
KeyValueStorage defaultSleepTimerStorage =
|
||||||
|
KeyValueStorage(defaultSleepTimerKey);
|
||||||
|
KeyValueStorage autoSleepTimerModeStorage =
|
||||||
|
KeyValueStorage(autoSleepTimerModeKey);
|
||||||
|
KeyValueStorage autoSleepTimerStartStorage =
|
||||||
|
KeyValueStorage(autoSleepTimerStartKey);
|
||||||
|
KeyValueStorage autoSleepTimerEndStorage =
|
||||||
|
KeyValueStorage(autoSleepTimerEndKey);
|
||||||
|
|
||||||
EpisodeBrief _episode;
|
EpisodeBrief _episode;
|
||||||
Playlist _queue = Playlist();
|
Playlist _queue = Playlist();
|
||||||
|
@ -148,12 +156,13 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
bool _startSleepTimer = false;
|
bool _startSleepTimer = false;
|
||||||
double _switchValue = 0;
|
double _switchValue = 0;
|
||||||
SleepTimerMode _sleepTimerMode = SleepTimerMode.undefined;
|
SleepTimerMode _sleepTimerMode = SleepTimerMode.undefined;
|
||||||
|
//Auto stop at the end of episode when you start play at scheduled time.
|
||||||
|
bool _autoSleepTimer;
|
||||||
|
//Default sleep timer time.
|
||||||
ShareStatus _shareStatus = ShareStatus.undefined;
|
ShareStatus _shareStatus = ShareStatus.undefined;
|
||||||
String _shareFile = '';
|
String _shareFile = '';
|
||||||
//set autoplay episode in playlist
|
//set autoplay episode in playlist
|
||||||
bool _autoPlay = true;
|
bool _autoPlay;
|
||||||
//TODO Set auto add episodes to playlist
|
|
||||||
//bool _autoAdd = false;
|
|
||||||
DateTime _current;
|
DateTime _current;
|
||||||
int _currentPosition;
|
int _currentPosition;
|
||||||
double _currentSpeed = 1;
|
double _currentSpeed = 1;
|
||||||
|
@ -177,23 +186,18 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
SleepTimerMode get sleepTimerMode => _sleepTimerMode;
|
SleepTimerMode get sleepTimerMode => _sleepTimerMode;
|
||||||
ShareStatus get shareStatus => _shareStatus;
|
ShareStatus get shareStatus => _shareStatus;
|
||||||
String get shareFile => _shareFile;
|
String get shareFile => _shareFile;
|
||||||
bool get autoPlay => _autoPlay;
|
//bool get autoPlay => _autoPlay;
|
||||||
int get timeLeft => _timeLeft;
|
int get timeLeft => _timeLeft;
|
||||||
double get switchValue => _switchValue;
|
double get switchValue => _switchValue;
|
||||||
double get currentSpeed => _currentSpeed;
|
double get currentSpeed => _currentSpeed;
|
||||||
bool get episodeState => _episodeState;
|
bool get episodeState => _episodeState;
|
||||||
|
bool get autoSleepTimer => _autoSleepTimer;
|
||||||
|
|
||||||
set setSwitchValue(double value) {
|
set setSwitchValue(double value) {
|
||||||
_switchValue = value;
|
_switchValue = value;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
set autoPlaySwitch(bool boo) {
|
|
||||||
_autoPlay = boo;
|
|
||||||
notifyListeners();
|
|
||||||
_setAutoPlay();
|
|
||||||
}
|
|
||||||
|
|
||||||
set setShareStatue(ShareStatus status) {
|
set setShareStatue(ShareStatus status) {
|
||||||
_shareStatus = status;
|
_shareStatus = status;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
@ -206,11 +210,12 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
|
|
||||||
Future _getAutoPlay() async {
|
Future _getAutoPlay() async {
|
||||||
int i = await autoPlayStorage.getInt();
|
int i = await autoPlayStorage.getInt();
|
||||||
_autoPlay = i == 0 ? true : false;
|
_autoPlay = i == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future _setAutoPlay() async {
|
Future _getAutoSleepTimer() async {
|
||||||
await autoPlayStorage.saveInt(_autoPlay ? 1 : 0);
|
int i = await autoSleepTimerStorage.getInt();
|
||||||
|
_autoSleepTimer = i == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
set setSleepTimerMode(SleepTimerMode timer) {
|
set setSleepTimerMode(SleepTimerMode timer) {
|
||||||
|
@ -222,6 +227,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
void addListener(VoidCallback listener) async {
|
void addListener(VoidCallback listener) async {
|
||||||
super.addListener(listener);
|
super.addListener(listener);
|
||||||
_queueUpdate = false;
|
_queueUpdate = false;
|
||||||
|
await _getAutoSleepTimer();
|
||||||
await AudioService.connect();
|
await AudioService.connect();
|
||||||
bool running = AudioService.running;
|
bool running = AudioService.running;
|
||||||
if (running) {}
|
if (running) {}
|
||||||
|
@ -285,7 +291,6 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
if (!AudioService.connected) {
|
if (!AudioService.connected) {
|
||||||
await AudioService.connect();
|
await AudioService.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
await AudioService.start(
|
await AudioService.start(
|
||||||
backgroundTaskEntrypoint: _audioPlayerTaskEntrypoint,
|
backgroundTaskEntrypoint: _audioPlayerTaskEntrypoint,
|
||||||
androidNotificationChannelName: 'Tsacdop',
|
androidNotificationChannelName: 'Tsacdop',
|
||||||
|
@ -294,6 +299,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
enableQueue: true,
|
enableQueue: true,
|
||||||
androidStopOnRemoveTask: true,
|
androidStopOnRemoveTask: true,
|
||||||
androidStopForegroundOnPause: true);
|
androidStopForegroundOnPause: true);
|
||||||
|
await _getAutoPlay();
|
||||||
if (_autoPlay) {
|
if (_autoPlay) {
|
||||||
await Future.forEach(_queue.playlist, (episode) async {
|
await Future.forEach(_queue.playlist, (episode) async {
|
||||||
await AudioService.addQueueItem(episode.toMediaItem());
|
await AudioService.addQueueItem(episode.toMediaItem());
|
||||||
|
@ -301,6 +307,23 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
||||||
} else {
|
} else {
|
||||||
await AudioService.addQueueItem(_queue.playlist.first.toMediaItem());
|
await AudioService.addQueueItem(_queue.playlist.first.toMediaItem());
|
||||||
}
|
}
|
||||||
|
await _getAutoSleepTimer();
|
||||||
|
if (_autoSleepTimer) {
|
||||||
|
int startTime =
|
||||||
|
await autoSleepTimerStartStorage.getInt(defaultValue: 1380);
|
||||||
|
int endTime = await autoSleepTimerEndStorage.getInt(defaultValue: 360);
|
||||||
|
int currentTime = DateTime.now().hour * 60 + DateTime.now().minute;
|
||||||
|
if ((startTime > endTime &&
|
||||||
|
(currentTime > startTime || currentTime > endTime)) ||
|
||||||
|
((startTime < endTime) &&
|
||||||
|
(currentTime > startTime && currentTime < endTime))) {
|
||||||
|
int mode = await autoSleepTimerModeStorage.getInt();
|
||||||
|
_sleepTimerMode = SleepTimerMode.values[mode];
|
||||||
|
int defaultTimer =
|
||||||
|
await defaultSleepTimerStorage.getInt(defaultValue: 30);
|
||||||
|
sleepTimer(defaultTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
_playerRunning = true;
|
_playerRunning = true;
|
||||||
await AudioService.play();
|
await AudioService.play();
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ class DownloadState extends ChangeNotifier {
|
||||||
FlutterDownloader.remove(taskId: task.taskId);
|
FlutterDownloader.remove(taskId: task.taskId);
|
||||||
var dbHelper = DBHelper();
|
var dbHelper = DBHelper();
|
||||||
_episodeTasks.insert(index, EpisodeTask(episode, newTaskId));
|
_episodeTasks.insert(index, EpisodeTask(episode, newTaskId));
|
||||||
await dbHelper.saveDownloaded(newTaskId, episode.enclosureUrl);
|
await dbHelper.saveDownloaded(episode.enclosureUrl, newTaskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future retryTask(EpisodeBrief episode) async {
|
Future retryTask(EpisodeBrief episode) async {
|
||||||
|
@ -298,7 +298,7 @@ class DownloadState extends ChangeNotifier {
|
||||||
_removeTask(episode);
|
_removeTask(episode);
|
||||||
var dbHelper = DBHelper();
|
var dbHelper = DBHelper();
|
||||||
_episodeTasks.insert(index, EpisodeTask(episode, newTaskId));
|
_episodeTasks.insert(index, EpisodeTask(episode, newTaskId));
|
||||||
await dbHelper.saveDownloaded(newTaskId, episode.enclosureUrl);
|
await dbHelper.saveDownloaded(episode.enclosureUrl, newTaskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future removeTask(EpisodeBrief episode) async {
|
Future removeTask(EpisodeBrief episode) async {
|
||||||
|
@ -322,6 +322,7 @@ class DownloadState extends ChangeNotifier {
|
||||||
|
|
||||||
_removeTask(EpisodeBrief episode) {
|
_removeTask(EpisodeBrief episode) {
|
||||||
_episodeTasks.removeWhere((element) => element.episode == episode);
|
_episodeTasks.removeWhere((element) => element.episode == episode);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
_autoDelete() async {
|
_autoDelete() async {
|
||||||
|
|
|
@ -78,12 +78,22 @@ ThemeData lightTheme = ThemeData(
|
||||||
class SettingState extends ChangeNotifier {
|
class SettingState extends ChangeNotifier {
|
||||||
KeyValueStorage themeStorage = KeyValueStorage(themesKey);
|
KeyValueStorage themeStorage = KeyValueStorage(themesKey);
|
||||||
KeyValueStorage accentStorage = KeyValueStorage(accentsKey);
|
KeyValueStorage accentStorage = KeyValueStorage(accentsKey);
|
||||||
KeyValueStorage autoupdateStorage = KeyValueStorage(autoAddKey);
|
KeyValueStorage autoupdateStorage = KeyValueStorage(autoUpdateKey);
|
||||||
KeyValueStorage intervalStorage = KeyValueStorage(updateIntervalKey);
|
KeyValueStorage intervalStorage = KeyValueStorage(updateIntervalKey);
|
||||||
KeyValueStorage downloadUsingDataStorage =
|
KeyValueStorage downloadUsingDataStorage =
|
||||||
KeyValueStorage(downloadUsingDataKey);
|
KeyValueStorage(downloadUsingDataKey);
|
||||||
KeyValueStorage introStorage = KeyValueStorage(introKey);
|
KeyValueStorage introStorage = KeyValueStorage(introKey);
|
||||||
KeyValueStorage realDarkStorage = KeyValueStorage(realDarkKey);
|
KeyValueStorage realDarkStorage = KeyValueStorage(realDarkKey);
|
||||||
|
KeyValueStorage autoPlayStorage = KeyValueStorage(autoPlayKey);
|
||||||
|
KeyValueStorage defaultSleepTimerStorage =
|
||||||
|
KeyValueStorage(defaultSleepTimerKey);
|
||||||
|
KeyValueStorage autoSleepTimerStorage = KeyValueStorage(autoSleepTimerKey);
|
||||||
|
KeyValueStorage autoSleepTimerModeStorage =
|
||||||
|
KeyValueStorage(autoSleepTimerModeKey);
|
||||||
|
KeyValueStorage autoSleepTimerStartStorage =
|
||||||
|
KeyValueStorage(autoSleepTimerStartKey);
|
||||||
|
KeyValueStorage autoSleepTimerEndStorage =
|
||||||
|
KeyValueStorage(autoSleepTimerEndKey);
|
||||||
|
|
||||||
Future initData() async {
|
Future initData() async {
|
||||||
await _getTheme();
|
await _getTheme();
|
||||||
|
@ -164,11 +174,60 @@ class SettingState extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _defaultSleepTimer;
|
||||||
|
int get defaultSleepTimer => _defaultSleepTimer;
|
||||||
|
set setDefaultSleepTimer(int i) {
|
||||||
|
_defaultSleepTimer = i;
|
||||||
|
_setDefaultSleepTimer();
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _autoPlay;
|
||||||
|
bool get autoPlay => _autoPlay;
|
||||||
|
set setAutoPlay(bool boo) {
|
||||||
|
_autoPlay = boo;
|
||||||
|
notifyListeners();
|
||||||
|
_saveAutoPlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _autoSleepTimer;
|
||||||
|
bool get autoSleepTimer => _autoSleepTimer;
|
||||||
|
set setAutoSleepTimer(bool boo) {
|
||||||
|
_autoSleepTimer = boo;
|
||||||
|
notifyListeners();
|
||||||
|
_saveAutoSleepTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _autoSleepTimerMode;
|
||||||
|
int get autoSleepTimerMode => _autoSleepTimerMode;
|
||||||
|
set setAutoSleepTimerMode(int mode) {
|
||||||
|
_autoSleepTimerMode = mode;
|
||||||
|
notifyListeners();
|
||||||
|
_saveAutoSleepTimerMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _autoSleepTimerStart;
|
||||||
|
int get autoSleepTimerStart => _autoSleepTimerStart;
|
||||||
|
set setAutoSleepTimerStart(int start) {
|
||||||
|
_autoSleepTimerStart = start;
|
||||||
|
notifyListeners();
|
||||||
|
_saveAutoSleepTimerStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
int _autoSleepTimerEnd;
|
||||||
|
int get autoSleepTimerEnd => _autoSleepTimerEnd;
|
||||||
|
set setAutoSleepTimerEnd(int end) {
|
||||||
|
_autoSleepTimerEnd = end;
|
||||||
|
notifyListeners();
|
||||||
|
_saveAutoSleepTimerEnd();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void addListener(VoidCallback listener) {
|
void addListener(VoidCallback listener) {
|
||||||
super.addListener(listener);
|
super.addListener(listener);
|
||||||
_getAutoUpdate();
|
_getAutoUpdate();
|
||||||
_getDownloadUsingData();
|
_getDownloadUsingData();
|
||||||
|
_getSleepTimerData();
|
||||||
_getUpdateInterval().then((value) async {
|
_getUpdateInterval().then((value) async {
|
||||||
if (_initUpdateTag == 0)
|
if (_initUpdateTag == 0)
|
||||||
setWorkManager(24);
|
setWorkManager(24);
|
||||||
|
@ -250,4 +309,42 @@ class SettingState extends ChangeNotifier {
|
||||||
Future _setRealDark() async {
|
Future _setRealDark() async {
|
||||||
await realDarkStorage.saveInt(_realDark ? 1 : 0);
|
await realDarkStorage.saveInt(_realDark ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future _getSleepTimerData() async {
|
||||||
|
_defaultSleepTimer =
|
||||||
|
await defaultSleepTimerStorage.getInt(defaultValue: 30);
|
||||||
|
int i = await autoSleepTimerStorage.getInt();
|
||||||
|
_autoSleepTimer = i == 1;
|
||||||
|
_autoSleepTimerStart =
|
||||||
|
await autoSleepTimerStartStorage.getInt(defaultValue: 1380);
|
||||||
|
_autoSleepTimerEnd =
|
||||||
|
await autoSleepTimerEndStorage.getInt(defaultValue: 360);
|
||||||
|
int a = await autoPlayStorage.getInt();
|
||||||
|
_autoPlay = a == 0;
|
||||||
|
_autoSleepTimerMode = await autoSleepTimerModeStorage.getInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _saveAutoPlay() async {
|
||||||
|
await autoPlayStorage.saveInt(_autoPlay ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _setDefaultSleepTimer() async {
|
||||||
|
await defaultSleepTimerStorage.saveInt(_defaultSleepTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _saveAutoSleepTimer() async {
|
||||||
|
await autoSleepTimerStorage.saveInt(_autoSleepTimer ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _saveAutoSleepTimerMode() async {
|
||||||
|
await autoSleepTimerModeStorage.saveInt(_autoSleepTimerMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _saveAutoSleepTimerStart() async {
|
||||||
|
await autoSleepTimerStartStorage.saveInt(_autoSleepTimerStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _saveAutoSleepTimerEnd() async {
|
||||||
|
await autoSleepTimerEndStorage.saveInt(_autoSleepTimerEnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ dependencies:
|
||||||
auto_animated: ^2.1.0
|
auto_animated: ^2.1.0
|
||||||
feature_discovery: ^0.10.0
|
feature_discovery: ^0.10.0
|
||||||
flutter_isolate: ^1.0.0+14
|
flutter_isolate: ^1.0.0+14
|
||||||
|
flutter_time_picker_spinner: ^1.0.6+1
|
||||||
just_audio:
|
just_audio:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/stonega/just_audio.git
|
url: https://github.com/stonega/just_audio.git
|
||||||
|
|
Loading…
Reference in New Issue