Change setting menu, remove playlist.
This commit is contained in:
parent
dc40803a79
commit
26353bb67b
|
@ -2,6 +2,7 @@ import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:tsacdop/widgets/general_dialog.dart';
|
||||||
|
|
||||||
import '../state/audio_state.dart';
|
import '../state/audio_state.dart';
|
||||||
import '../type/episodebrief.dart';
|
import '../type/episodebrief.dart';
|
||||||
|
@ -19,10 +20,11 @@ class PlaylistDetail extends StatefulWidget {
|
||||||
class _PlaylistDetailState extends State<PlaylistDetail> {
|
class _PlaylistDetailState extends State<PlaylistDetail> {
|
||||||
final List<EpisodeBrief> _selectedEpisodes = [];
|
final List<EpisodeBrief> _selectedEpisodes = [];
|
||||||
bool _resetSelected;
|
bool _resetSelected;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void setState(fn) {
|
void initState() {
|
||||||
_resetSelected = false;
|
_resetSelected = false;
|
||||||
super.setState(fn);
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -42,15 +44,16 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
|
||||||
? widget.playlist.name
|
? widget.playlist.name
|
||||||
: '${_selectedEpisodes.length} selected'),
|
: '${_selectedEpisodes.length} selected'),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
if (_selectedEpisodes.isNotEmpty)
|
||||||
splashRadius: 20,
|
IconButton(
|
||||||
icon: Icon(Icons.delete_outline_rounded),
|
splashRadius: 20,
|
||||||
onPressed: () {
|
icon: Icon(Icons.delete_outline_rounded),
|
||||||
context.read<AudioPlayerNotifier>().removeEpisodeFromPlaylist(
|
onPressed: () {
|
||||||
widget.playlist,
|
context.read<AudioPlayerNotifier>().removeEpisodeFromPlaylist(
|
||||||
episodes: _selectedEpisodes);
|
widget.playlist,
|
||||||
setState(_selectedEpisodes.clear);
|
episodes: _selectedEpisodes);
|
||||||
}),
|
setState(_selectedEpisodes.clear);
|
||||||
|
}),
|
||||||
if (_selectedEpisodes.isNotEmpty)
|
if (_selectedEpisodes.isNotEmpty)
|
||||||
IconButton(
|
IconButton(
|
||||||
splashRadius: 20,
|
splashRadius: 20,
|
||||||
|
@ -61,35 +64,51 @@ class _PlaylistDetailState extends State<PlaylistDetail> {
|
||||||
_resetSelected = !_resetSelected;
|
_resetSelected = !_resetSelected;
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
SizedBox(
|
IconButton(
|
||||||
height: 40,
|
splashRadius: 20,
|
||||||
width: 40,
|
icon: Icon(Icons.more_vert),
|
||||||
child: Material(
|
onPressed: () => generalSheet(context,
|
||||||
color: Colors.transparent,
|
title: widget.playlist.name,
|
||||||
borderRadius: BorderRadius.circular(100),
|
child: _PlaylistSetting(widget.playlist))
|
||||||
clipBehavior: Clip.hardEdge,
|
.then((value) {
|
||||||
child: SizedBox(
|
if (!context
|
||||||
height: 40,
|
.read<AudioPlayerNotifier>()
|
||||||
width: 40,
|
.playlists
|
||||||
child: PopupMenuButton<int>(
|
.contains(widget.playlist)) {
|
||||||
icon: Icon(Icons.more_vert),
|
Navigator.pop(context);
|
||||||
shape: RoundedRectangleBorder(
|
}
|
||||||
borderRadius: BorderRadius.circular(10)),
|
setState(() {});
|
||||||
elevation: 1,
|
}),
|
||||||
tooltip: s.menu,
|
),
|
||||||
itemBuilder: (context) => [
|
//SizedBox(
|
||||||
PopupMenuItem(value: 1, child: Text('Clear all')),
|
// height: 40,
|
||||||
],
|
// width: 40,
|
||||||
onSelected: (value) {
|
// child: Material(
|
||||||
if (value == 1) {
|
// color: Colors.transparent,
|
||||||
context
|
// borderRadius: BorderRadius.circular(100),
|
||||||
.read<AudioPlayerNotifier>()
|
// clipBehavior: Clip.hardEdge,
|
||||||
.clearPlaylist(widget.playlist);
|
// child: SizedBox(
|
||||||
}
|
// height: 40,
|
||||||
}),
|
// width: 40,
|
||||||
),
|
// child: PopupMenuButton<int>(
|
||||||
),
|
// icon: Icon(Icons.more_vert),
|
||||||
)
|
// shape: RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(10)),
|
||||||
|
// elevation: 1,
|
||||||
|
// tooltip: s.menu,
|
||||||
|
// itemBuilder: (context) => [
|
||||||
|
// PopupMenuItem(value: 1, child: Text('Clear all')),
|
||||||
|
// ],
|
||||||
|
// onSelected: (value) {
|
||||||
|
// if (value == 1) {
|
||||||
|
// context
|
||||||
|
// .read<AudioPlayerNotifier>()
|
||||||
|
// .clearPlaylist(widget.playlist);
|
||||||
|
// }
|
||||||
|
// }),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Selector<AudioPlayerNotifier, List<Playlist>>(
|
body: Selector<AudioPlayerNotifier, List<Playlist>>(
|
||||||
|
@ -287,3 +306,116 @@ class __PlaylistItemState extends State<_PlaylistItem>
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _PlaylistSetting extends StatefulWidget {
|
||||||
|
final Playlist playlist;
|
||||||
|
_PlaylistSetting(this.playlist, {Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
__PlaylistSettingState createState() => __PlaylistSettingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class __PlaylistSettingState extends State<_PlaylistSetting> {
|
||||||
|
bool _clearConfirm;
|
||||||
|
bool _removeConfirm;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_clearConfirm = false;
|
||||||
|
_removeConfirm = false;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = context.s;
|
||||||
|
final textStyle = context.textTheme.bodyText2;
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
ListTile(
|
||||||
|
onTap: () {
|
||||||
|
setState(() => _clearConfirm = true);
|
||||||
|
},
|
||||||
|
dense: true,
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.highlight_off, size: 18),
|
||||||
|
SizedBox(width: 20),
|
||||||
|
Text('Clear all', style: textStyle),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_clearConfirm)
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: context.primaryColorDark,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () => setState(() {
|
||||||
|
_clearConfirm = false;
|
||||||
|
}),
|
||||||
|
child:
|
||||||
|
Text(s.cancel, style: TextStyle(color: Colors.grey[600])),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
splashColor: Colors.red.withAlpha(70),
|
||||||
|
onPressed: () async {
|
||||||
|
context
|
||||||
|
.read<AudioPlayerNotifier>()
|
||||||
|
.clearPlaylist(widget.playlist);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child:
|
||||||
|
Text(s.confirm, style: TextStyle(color: Colors.red))),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.playlist.name != 'Queue')
|
||||||
|
ListTile(
|
||||||
|
onTap: () {
|
||||||
|
setState(() => _removeConfirm = true);
|
||||||
|
},
|
||||||
|
dense: true,
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.delete, color: Colors.red, size: 18),
|
||||||
|
SizedBox(width: 20),
|
||||||
|
Text('Remove playlist',
|
||||||
|
style: textStyle.copyWith(
|
||||||
|
color: Colors.red, fontWeight: FontWeight.bold)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_removeConfirm)
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: context.primaryColorDark,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
FlatButton(
|
||||||
|
onPressed: () => setState(() {
|
||||||
|
_removeConfirm = false;
|
||||||
|
}),
|
||||||
|
child:
|
||||||
|
Text(s.cancel, style: TextStyle(color: Colors.grey[600])),
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
splashColor: Colors.red.withAlpha(70),
|
||||||
|
onPressed: () async {
|
||||||
|
context
|
||||||
|
.read<AudioPlayerNotifier>()
|
||||||
|
.deletePlaylist(widget.playlist);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child:
|
||||||
|
Text(s.confirm, style: TextStyle(color: Colors.red))),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue