1
0
mirror of https://github.com/stonega/tsacdop synced 2025-02-17 20:10:37 +01:00

💄 Update episode detail menu bar

This commit is contained in:
stonegate 2020-06-06 17:05:38 +08:00
parent 643ec50b1d
commit 62256c7c93
9 changed files with 231 additions and 188 deletions

View File

@ -5,9 +5,7 @@
</p>
![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)
[![GooglePlay](https://img.shields.io/badge/Google-PlayStore-%2323CCC6)](https://play.google.com/store/apps/details?id=com.stonegate.tsacdop)
## About

View File

@ -2,7 +2,7 @@ arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
connection.project.dir=app
eclipse.preferences.version=1
gradle.user.home=
java.home=C\:/Program Files/Java/jdk1.8.0_171

View File

@ -1,2 +1,13 @@
connection.project.dir=..
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=C\:/Program Files/Java/jdk1.8.0_171
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true

View File

@ -9,6 +9,7 @@ import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.pathprovider.PathProviderPlugin;
import com.tekartik.sqflite.SqflitePlugin;
import io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin;
import vn.hunghd.flutterdownloader.FlutterDownloaderPlugin;
/**
* Generated file. Do not edit. This file is generated by the Flutter tool based
@ -24,6 +25,7 @@ public final class IsolatePluginRegistrant {
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
SqflitePlugin.registerWith(registry.registrarFor("com.tekartik.sqflite.SqflitePlugin"));
SharedPreferencesPlugin.registerWith(registry.registrarFor("io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin"));
FlutterDownloaderPlugin.registerWith(registry.registrarFor("vn.hunghd.flutterdownloader.FlutterDownloaderPlugin"));
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {

View File

@ -469,186 +469,207 @@ class _MenuBarState extends State<MenuBar> {
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Hero(
tag: widget.episodeItem.enclosureUrl + widget.heroTag,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Container(
height: 30.0,
width: 30.0,
color: Theme.of(context).scaffoldBackgroundColor,
child: widget.hide
? Center()
: CircleAvatar(
backgroundImage:
FileImage(File("${widget.episodeItem.imagePath}"))),
children: [
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Hero(
tag: widget.episodeItem.enclosureUrl + widget.heroTag,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: Container(
height: 30.0,
width: 30.0,
color: Theme.of(context).scaffoldBackgroundColor,
child: widget.hide
? Center()
: CircleAvatar(
backgroundImage: FileImage(
File("${widget.episodeItem.imagePath}"))),
),
),
),
FutureBuilder<bool>(
future: _isLiked(widget.episodeItem),
initialData: false,
builder: (BuildContext context, AsyncSnapshot snapshot) {
return (!snapshot.data && !_liked)
? _buttonOnMenu(
Icon(
Icons.favorite_border,
color: Colors.grey[700],
), () async {
await saveLiked(widget.episodeItem.enclosureUrl);
OverlayEntry _overlayEntry;
_overlayEntry = _createOverlayEntry();
Overlay.of(context).insert(_overlayEntry);
await Future.delayed(Duration(seconds: 2));
_overlayEntry?.remove();
})
: (snapshot.data && !_liked)
? _buttonOnMenu(
Icon(
Icons.favorite,
color: Colors.red,
),
() => setUnliked(
widget.episodeItem.enclosureUrl))
: _buttonOnMenu(
Icon(
Icons.favorite,
color: Colors.red,
),
() {
setUnliked(widget.episodeItem.enclosureUrl);
},
);
},
),
DownloadButton(episode: widget.episodeItem),
Selector<AudioPlayerNotifier, List<String>>(
selector: (_, audio) => audio.queue.playlist
.map((e) => e.enclosureUrl)
.toList(),
builder: (_, data, __) {
return data.contains(widget.episodeItem.enclosureUrl)
? _buttonOnMenu(
Icon(Icons.playlist_add_check,
color: Theme.of(context).accentColor), () {
audio.delFromPlaylist(widget.episodeItem);
Fluttertoast.showToast(
msg: 'Removed from playlist',
gravity: ToastGravity.BOTTOM,
);
})
: _buttonOnMenu(
Icon(Icons.playlist_add, color: Colors.grey[700]),
() {
Fluttertoast.showToast(
msg: 'Added to playlist',
gravity: ToastGravity.BOTTOM,
);
audio.addToPlaylist(widget.episodeItem);
});
},
),
FutureBuilder<PlayHistory>(
future: getPosition(widget.episodeItem),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return snapshot.hasData
? snapshot.data.seekValue > 0.95
? Container(
height: 25,
padding:
EdgeInsets.symmetric(horizontal: 15),
child: SizedBox(
width: 25,
height: 25,
child: CustomPaint(
painter: ListenedAllPainter(
context.accentColor,
stroke: 2.0),
),
),
)
: snapshot.data.seconds < 0.1
// ? Material(
// color: Colors.transparent,
// child: InkWell(
// onTap: () async {
// await _markListened(widget.episodeItem);
// setState(() {});
// Fluttertoast.showToast(
// msg: 'Mark as listened',
// gravity: ToastGravity.BOTTOM,
// );
// },
// child: Container(
// height: 50,
// padding: EdgeInsets.only(
// left: 15,
// right: 15,
// top: 12,
// bottom: 12),
// child: SizedBox(
// width: 22,
// height: 22,
// child: CustomPaint(
// painter: MarkListenedPainter(
// Colors.grey[700],
// stroke: 2.0),
// ),
// ),
// ),
// ),
// )
? SizedBox(
width: 1,
)
: Material(
color: Colors.transparent,
child: InkWell(
onTap: () => audio.episodeLoad(
widget.episodeItem,
startPosition:
(snapshot.data.seconds * 1000)
.toInt()),
child: Container(
height: 50,
padding: EdgeInsets.symmetric(
horizontal: 15),
child: Row(
children: <Widget>[
SizedBox(
width: 20,
height: 20,
child: CustomPaint(
painter: ListenedPainter(
context.accentColor,
stroke: 2.0),
),
),
Padding(
padding:
EdgeInsets.symmetric(
horizontal: 2)),
Container(
height: 20,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: 5),
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(
Radius.circular(
10.0)),
color: context.accentColor,
),
child: Text(
_stringForSeconds(
snapshot.data.seconds),
style: TextStyle(
color: Colors.white),
),
),
],
),
),
),
)
: Center();
}),
],
),
),
),
FutureBuilder<bool>(
future: _isLiked(widget.episodeItem),
initialData: false,
builder: (BuildContext context, AsyncSnapshot snapshot) {
return (!snapshot.data && !_liked)
? _buttonOnMenu(
Icon(
Icons.favorite_border,
color: Colors.grey[700],
), () async {
await saveLiked(widget.episodeItem.enclosureUrl);
OverlayEntry _overlayEntry;
_overlayEntry = _createOverlayEntry();
Overlay.of(context).insert(_overlayEntry);
await Future.delayed(Duration(seconds: 2));
_overlayEntry?.remove();
})
: (snapshot.data && !_liked)
? _buttonOnMenu(
Icon(
Icons.favorite,
color: Colors.red,
),
() => setUnliked(widget.episodeItem.enclosureUrl))
: _buttonOnMenu(
Icon(
Icons.favorite,
color: Colors.red,
),
() {
setUnliked(widget.episodeItem.enclosureUrl);
},
);
},
),
DownloadButton(episode: widget.episodeItem),
Selector<AudioPlayerNotifier, List<String>>(
selector: (_, audio) =>
audio.queue.playlist.map((e) => e.enclosureUrl).toList(),
builder: (_, data, __) {
return data.contains(widget.episodeItem.enclosureUrl)
? _buttonOnMenu(
Icon(Icons.playlist_add_check,
color: Theme.of(context).accentColor), () {
audio.delFromPlaylist(widget.episodeItem);
Fluttertoast.showToast(
msg: 'Removed from playlist',
gravity: ToastGravity.BOTTOM,
);
})
: _buttonOnMenu(
Icon(Icons.playlist_add, color: Colors.grey[700]), () {
Fluttertoast.showToast(
msg: 'Added to playlist',
gravity: ToastGravity.BOTTOM,
);
audio.addToPlaylist(widget.episodeItem);
});
},
),
FutureBuilder<PlayHistory>(
future: getPosition(widget.episodeItem),
builder: (context, snapshot) {
if (snapshot.hasError) print(snapshot.error);
return snapshot.hasData
? snapshot.data.seekValue > 0.95
? Container(
height: 25,
padding: EdgeInsets.symmetric(horizontal: 15),
child: SizedBox(
width: 25,
height: 25,
child: CustomPaint(
painter: ListenedAllPainter(context.accentColor,
stroke: 2.0),
),
),
)
: snapshot.data.seconds < 0.1
// ? Material(
// color: Colors.transparent,
// child: InkWell(
// onTap: () async {
// await _markListened(widget.episodeItem);
// setState(() {});
// Fluttertoast.showToast(
// msg: 'Mark as listened',
// gravity: ToastGravity.BOTTOM,
// );
// },
// child: Container(
// height: 50,
// padding: EdgeInsets.only(
// left: 15,
// right: 15,
// top: 12,
// bottom: 12),
// child: SizedBox(
// width: 22,
// height: 22,
// child: CustomPaint(
// painter: MarkListenedPainter(
// Colors.grey[700],
// stroke: 2.0),
// ),
// ),
// ),
// ),
// )
? Center()
: Material(
color: Colors.transparent,
child: InkWell(
onTap: () => audio.episodeLoad(
widget.episodeItem,
startPosition:
(snapshot.data.seconds * 1000)
.toInt()),
child: Container(
height: 50,
padding:
EdgeInsets.symmetric(horizontal: 15),
child: Row(
children: <Widget>[
SizedBox(
width: 20,
height: 20,
child: CustomPaint(
painter: ListenedPainter(
context.accentColor,
stroke: 2.0),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: 2)),
Container(
height: 20,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(
horizontal: 5),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(10.0)),
color: context.accentColor,
),
child: Text(
_stringForSeconds(
snapshot.data.seconds),
style:
TextStyle(color: Colors.white),
),
),
],
),
),
),
)
: Center();
}),
Spacer(),
Selector<AudioPlayerNotifier, Tuple2<EpisodeBrief, bool>>(
selector: (_, audio) => Tuple2(audio.episode, audio.playerRunning),
selector: (_, audio) =>
Tuple2(audio.episode, audio.playerRunning),
builder: (_, data, __) {
return (widget.episodeItem.title == data.item1?.title &&
data.item2)

View File

@ -11,12 +11,12 @@ class AudioPanel extends StatefulWidget {
class _AudioPanelState extends State<AudioPanel>
with SingleTickerProviderStateMixin {
double initSize;
double minSize = 60;
double maxSize = 300;
final double minSize = 60;
final double maxSize = 300;
double _startdy;
double _move = 0;
AnimationController _controller;
var _animation;
Animation _animation;
@override
void initState() {
@ -138,7 +138,8 @@ class _AudioPanelState extends State<AudioPanel>
_end() {
if (_animation.value >= (maxSize + minSize) / 4 &&
_animation.value < maxSize) {
_animation.value < maxSize ||
(_move - _startdy > 20)) {
setState(() {
_animation = Tween<double>(begin: _animation.value, end: maxSize)
.animate(_controller);
@ -157,7 +158,7 @@ class _AudioPanelState extends State<AudioPanel>
setState(() {
initSize = maxSize;
});
} else if (_animation.value <= minSize) {
} else if (_animation.value < minSize) {
setState(() {
initSize = minSize;
});

View File

@ -512,6 +512,7 @@ class DBHelper {
url,
]);
});
}
}
int countUpdate = Sqflite.firstIntValue(await dbClient.rawQuery(

View File

@ -4,6 +4,7 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:intl/intl.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as path;
@ -131,8 +132,17 @@ class DownloadState extends ChangeNotifier {
if (!hasExisted) {
saveDir.create();
}
DateTime now = DateTime.now();
String datePlus = now.year.toString() +
now.month.toString() +
now.day.toString() +
now.second.toString();
String fileName = episode.title +
datePlus +
'.' +
episode.enclosureUrl.split('/').last.split('.').last;
String taskId = await FlutterDownloader.enqueue(
fileName: episode.enclosureUrl.split('/').last,
fileName: fileName,
url: episode.enclosureUrl,
savedDir: localPath,
showNotification: true,

View File

@ -77,8 +77,7 @@ Future<void> refreshIsolateEntryPoint(SendPort sendPort) async {
await dbHelper.updatePodcastRss(podcastLocal);
print('Refresh ' + podcastLocal.title);
});
// KeyValueStorage refreshcountstorage = KeyValueStorage('refreshcount');
// await refreshcountstorage.saveInt(i);
// await refreshcountstorage.saveInt(i);
sendPort.send("done");
}