Change download style, you can cancel downlaod when paused.
This commit is contained in:
parent
63e587d089
commit
be00383966
|
@ -11,6 +11,7 @@ import 'package:provider/provider.dart';
|
|||
import '../state/audio_state.dart';
|
||||
import '../state/download_state.dart';
|
||||
import '../state/setting_state.dart';
|
||||
import '../type/episode_task.dart';
|
||||
import '../type/episodebrief.dart';
|
||||
import '../util/custom_widget.dart';
|
||||
import '../util/extension_helper.dart';
|
||||
|
@ -167,8 +168,8 @@ class _DownloadButtonState extends State<DownloadButton> {
|
|||
builder: (_, data, __) => _buttonOnMenu(
|
||||
Center(
|
||||
child: SizedBox(
|
||||
height: 18,
|
||||
width: 18,
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CustomPaint(
|
||||
painter: DownloadPainter(
|
||||
color: Colors.grey[700],
|
||||
|
@ -196,11 +197,11 @@ class _DownloadButtonState extends State<DownloadButton> {
|
|||
duration: Duration(milliseconds: 1000),
|
||||
tween: Tween(begin: 0.0, end: 1.0),
|
||||
builder: (context, fraction, child) => SizedBox(
|
||||
height: 18,
|
||||
width: 18,
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CustomPaint(
|
||||
painter: DownloadPainter(
|
||||
color: Colors.grey[700],
|
||||
color: context.accentColor,
|
||||
fraction: fraction,
|
||||
progressColor: context.accentColor,
|
||||
progress: task.progress / 100),
|
||||
|
@ -226,11 +227,11 @@ class _DownloadButtonState extends State<DownloadButton> {
|
|||
duration: Duration(milliseconds: 500),
|
||||
tween: Tween(begin: 0.0, end: 1.0),
|
||||
builder: (context, fraction, child) => SizedBox(
|
||||
height: 18,
|
||||
width: 18,
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CustomPaint(
|
||||
painter: DownloadPainter(
|
||||
color: Colors.grey[700],
|
||||
color: context.accentColor,
|
||||
fraction: 1,
|
||||
progressColor: context.accentColor,
|
||||
progress: task.progress / 100,
|
||||
|
@ -245,13 +246,31 @@ class _DownloadButtonState extends State<DownloadButton> {
|
|||
case 3:
|
||||
Provider.of<AudioPlayerNotifier>(context, listen: false)
|
||||
.updateMediaItem(task.episode);
|
||||
return _buttonOnMenu(
|
||||
Icon(
|
||||
Icons.done_all,
|
||||
color: Theme.of(context).accentColor,
|
||||
), () {
|
||||
_deleteDownload(task.episode);
|
||||
});
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
_deleteDownload(task.episode);
|
||||
},
|
||||
child: Container(
|
||||
height: 50.0,
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(horizontal: 18),
|
||||
child: SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CustomPaint(
|
||||
painter: DownloadPainter(
|
||||
color: context.accentColor,
|
||||
fraction: 1,
|
||||
progressColor: context.accentColor,
|
||||
progress: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 4:
|
||||
return _buttonOnMenu(Icon(Icons.refresh, color: Colors.red),
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
|||
|
||||
import '../episodes/episode_detail.dart';
|
||||
import '../state/download_state.dart';
|
||||
import '../type/episode_task.dart';
|
||||
import '../util/pageroute.dart';
|
||||
|
||||
class DownloadList extends StatefulWidget {
|
||||
|
@ -17,11 +18,20 @@ Widget _downloadButton(EpisodeTask task, BuildContext context) {
|
|||
var downloader = Provider.of<DownloadState>(context, listen: false);
|
||||
switch (task.status.value) {
|
||||
case 2:
|
||||
return IconButton(
|
||||
icon: Icon(
|
||||
Icons.pause_circle_filled,
|
||||
),
|
||||
onPressed: () => downloader.pauseTask(task.episode),
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.pause_circle_filled,
|
||||
),
|
||||
onPressed: () => downloader.pauseTask(task.episode),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () => downloader.delTask(task.episode),
|
||||
),
|
||||
],
|
||||
);
|
||||
case 4:
|
||||
return Row(
|
||||
|
@ -38,10 +48,16 @@ Widget _downloadButton(EpisodeTask task, BuildContext context) {
|
|||
],
|
||||
);
|
||||
case 6:
|
||||
return IconButton(
|
||||
icon: Icon(Icons.play_circle_filled),
|
||||
onPressed: () => downloader.resumeTask(task.episode),
|
||||
);
|
||||
return Row(mainAxisSize: MainAxisSize.min, children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.play_circle_filled),
|
||||
onPressed: () => downloader.resumeTask(task.episode),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close),
|
||||
onPressed: () => downloader.delTask(task.episode),
|
||||
),
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
return Center();
|
||||
|
@ -54,12 +70,12 @@ class _DownloadListState extends State<DownloadList> {
|
|||
return SliverPadding(
|
||||
padding: EdgeInsets.zero,
|
||||
sliver: Consumer<DownloadState>(builder: (_, downloader, __) {
|
||||
var tasks = downloader.episodeTasks
|
||||
final tasks = downloader.episodeTasks
|
||||
.where((task) => task.status.value != 3)
|
||||
.toList();
|
||||
return tasks.length > 0
|
||||
? SliverPadding(
|
||||
padding: EdgeInsets.all(5.0),
|
||||
padding: EdgeInsets.symmetric(vertical: 5.0),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
|
|
Loading…
Reference in New Issue