Change podcast setting ui.

This commit is contained in:
stonega 2021-01-02 22:52:28 +08:00
parent 7cf751fed0
commit b36d9f80be
1 changed files with 249 additions and 258 deletions

View File

@ -173,52 +173,44 @@ class __PodcastCardState extends State<_PodcastCard>
Widget build(BuildContext context) { Widget build(BuildContext context) {
final c = widget.podcastLocal.backgroudColor(context); final c = widget.podcastLocal.backgroudColor(context);
final s = context.s; final s = context.s;
var width = context.width;
var groupList = context.watch<GroupList>(); var groupList = context.watch<GroupList>();
_belongGroups = groupList.getPodcastGroup(widget.podcastLocal.id); _belongGroups = groupList.getPodcastGroup(widget.podcastLocal.id);
return Column(
return Container( mainAxisSize: MainAxisSize.min,
decoration: BoxDecoration( children: <Widget>[
border: Border( Material(
bottom: Divider.createBorderSide(context), color: Colors.transparent,
), child: InkWell(
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
InkWell(
onTap: () => setState(() => _addGroup = !_addGroup), onTap: () => setState(() => _addGroup = !_addGroup),
child: Container( child: SizedBox(
padding: EdgeInsets.symmetric(horizontal: 12),
height: 100, height: 100,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Icon( Icon(
Icons.unfold_more, Icons.unfold_more,
color: c, color: c,
), ),
SizedBox(width: 5),
CircleAvatar( CircleAvatar(
radius: 30, radius: 25,
child: backgroundImage: widget.podcastLocal.avatarImage,
Image.file(File("${widget.podcastLocal.imagePath}")),
), ),
SizedBox(width: 10),
Expanded( Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Container( Text(
alignment: Alignment.centerLeft, widget.podcastLocal.title,
child: Text( maxLines: 2,
widget.podcastLocal.title, overflow: TextOverflow.fade,
maxLines: 2, style: TextStyle(
overflow: TextOverflow.fade, fontWeight: FontWeight.bold, fontSize: 15),
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 15),
),
), ),
Row( Row(
children: _belongGroups.map((group) { children: _belongGroups.map((group) {
@ -246,246 +238,245 @@ class __PodcastCardState extends State<_PodcastCard>
child: PodcastSetting( child: PodcastSetting(
podcastLocal: widget.podcastLocal), podcastLocal: widget.podcastLocal),
).then((value) { ).then((value) {
setState(() {}); if (mounted) setState(() {});
})), })),
SizedBox(width: 10),
]), ]),
), ),
), ),
!_addGroup ),
? Center() !_addGroup
: Container( ? Center()
child: Container( : Container(
decoration: BoxDecoration( child: Container(
color: Theme.of(context).primaryColor, decoration: BoxDecoration(
border: Border( color: context.scaffoldBackgroundColor,
bottom: BorderSide( ),
color: Theme.of(context).primaryColorDark), // border: Border(
top: BorderSide( // bottom: BorderSide(
color: Theme.of(context).primaryColorDark))), // color: Theme.of(context).primaryColorDark),
height: 50, // top: BorderSide(
child: _addGroup // color: Theme.of(context).primaryColorDark))),
? Row( height: 50,
mainAxisAlignment: MainAxisAlignment.start, child: _addGroup
children: <Widget>[ ? Row(
Expanded( mainAxisAlignment: MainAxisAlignment.start,
child: SingleChildScrollView( children: <Widget>[
scrollDirection: Axis.horizontal, Expanded(
child: Row( child: SingleChildScrollView(
children: scrollDirection: Axis.horizontal,
groupList.groups.map<Widget>((group) {
return Container(
padding: EdgeInsets.only(left: 5.0),
child: FilterChip(
key: ValueKey<String>(group.id),
label: Text(group.name),
selected:
_selectedGroups.contains(group),
onSelected: (value) {
setState(() {
if (!value) {
_selectedGroups.remove(group);
} else {
_selectedGroups.add(group);
}
});
},
),
);
}).toList()),
),
),
SizedBox(
width: 100,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, children:
children: <Widget>[ groupList.groups.map<Widget>((group) {
IconButton( return Container(
icon: Icon(Icons.clear), padding: EdgeInsets.only(left: 5.0),
onPressed: () => setState(() { child: FilterChip(
_addGroup = false; key: ValueKey<String>(group.id),
}), label: Text(group.name),
), selected: _selectedGroups.contains(group),
IconButton( onSelected: (value) {
onPressed: () async { setState(() {
if (_selectedGroups.length > 0) { if (!value) {
setState(() { _selectedGroups.remove(group);
_addGroup = false; } else {
}); _selectedGroups.add(group);
await groupList.changeGroup( }
widget.podcastLocal, });
_selectedGroups,
);
Fluttertoast.showToast(
msg: s.toastSettingSaved,
gravity: ToastGravity.BOTTOM,
);
} else {
Fluttertoast.showToast(
msg: s.toastOneGroup,
gravity: ToastGravity.BOTTOM,
);
}
}, },
icon: Icon(Icons.done),
), ),
], );
), }).toList()),
) ),
], ),
) Material(
: Row( color: Colors.transparent,
mainAxisAlignment: MainAxisAlignment.spaceEvenly, child: Row(
children: <Widget>[ mainAxisAlignment: MainAxisAlignment.start,
_buttonOnMenu( mainAxisSize: MainAxisSize.min,
icon: Icon(Icons.add, children: <Widget>[
size: _value == 0 ? 1 : 20 * _value), IconButton(
onTap: () { icon: Icon(Icons.clear),
setState(() { splashRadius: 20,
_addGroup = true; onPressed: () => setState(() {
}); _addGroup = false;
}),
),
IconButton(
icon: Icon(Icons.done),
splashRadius: 20,
onPressed: () async {
if (_selectedGroups.length > 0) {
setState(() {
_addGroup = false;
});
await groupList.changeGroup(
widget.podcastLocal,
_selectedGroups,
);
Fluttertoast.showToast(
msg: s.toastSettingSaved,
gravity: ToastGravity.BOTTOM,
);
} else {
Fluttertoast.showToast(
msg: s.toastOneGroup,
gravity: ToastGravity.BOTTOM,
);
}
},
),
],
),
)
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
_buttonOnMenu(
icon: Icon(Icons.add,
size: _value == 0 ? 1 : 20 * _value),
onTap: () {
setState(() {
_addGroup = true;
});
},
tooltip: s.groups(0)),
FutureBuilder<bool>(
future: _getAutoDownload(widget.podcastLocal.id),
initialData: false,
builder: (context, snapshot) {
return _buttonOnMenu(
icon: Container(
child: Icon(Icons.file_download,
size: _value * 15,
color: snapshot.data
? Colors.white
: null),
height: _value == 0 ? 1 : 20 * _value,
width: _value == 0 ? 1 : 20 * _value,
decoration: BoxDecoration(
border: snapshot.data
? Border.all(
width: 1,
color: snapshot.data
? context.accentColor
: context.textTheme
.subtitle1.color)
: null,
shape: BoxShape.circle,
color: snapshot.data
? context.accentColor
: null),
),
tooltip: s.autoDownload,
onTap: () async {
await _setAutoDownload(
widget.podcastLocal.id, !snapshot.data);
setState(() {});
}, },
tooltip: s.groups(0)), );
FutureBuilder<bool>( },
future: ),
_getAutoDownload(widget.podcastLocal.id), FutureBuilder<int>(
initialData: false, future: _getSkipSecond(widget.podcastLocal.id),
initialData: 0,
builder: (context, snapshot) { builder: (context, snapshot) {
return _buttonOnMenu( return _buttonOnMenu(
icon: Container( icon: Icon(
child: Icon(Icons.file_download, Icons.fast_forward,
size: _value * 15, size: _value == 0 ? 1 : 20 * (_value),
color: snapshot.data ),
? Colors.white tooltip:
: null), 'Skip${snapshot.data == 0 ? '' : snapshot.data.toTime}',
height: _value == 0 ? 1 : 20 * _value, onTap: () {
width: _value == 0 ? 1 : 20 * _value, generalDialog(
decoration: BoxDecoration( context,
border: snapshot.data title: Text(s.skipSecondsAtStart,
? Border.all( maxLines: 2),
width: 1, content: DurationPicker(
color: snapshot.data duration: Duration(
? context.accentColor seconds: _skipSeconds ?? 0),
: context.textTheme onChange: (value) =>
.subtitle1.color) _seconds = value.inSeconds,
: null, ),
shape: BoxShape.circle, actions: <Widget>[
color: snapshot.data FlatButton(
? context.accentColor splashColor: context.accentColor
: null), .withAlpha(70),
), onPressed: () {
tooltip: s.autoDownload, Navigator.of(context).pop();
onTap: () async { _seconds = 0;
await _setAutoDownload( },
widget.podcastLocal.id, child: Text(
!snapshot.data); s.cancel,
setState(() {}); style: TextStyle(
}, color: Colors.grey[600]),
);
},
),
FutureBuilder<int>(
future:
_getSkipSecond(widget.podcastLocal.id),
initialData: 0,
builder: (context, snapshot) {
return _buttonOnMenu(
icon: Icon(
Icons.fast_forward,
size: _value == 0 ? 1 : 20 * (_value),
),
tooltip:
'Skip${snapshot.data == 0 ? '' : snapshot.data.toTime}',
onTap: () {
generalDialog(
context,
title: Text(s.skipSecondsAtStart,
maxLines: 2),
content: DurationPicker(
duration: Duration(
seconds: _skipSeconds ?? 0),
onChange: (value) =>
_seconds = value.inSeconds,
),
actions: <Widget>[
FlatButton(
splashColor: context.accentColor
.withAlpha(70),
onPressed: () {
Navigator.of(context).pop();
_seconds = 0;
},
child: Text(
s.cancel,
style: TextStyle(
color: Colors.grey[600]),
),
), ),
FlatButton( ),
splashColor: context.accentColor FlatButton(
.withAlpha(70), splashColor: context.accentColor
onPressed: () { .withAlpha(70),
Navigator.of(context).pop(); onPressed: () {
_saveSkipSeconds( Navigator.of(context).pop();
widget.podcastLocal.id, _saveSkipSeconds(
_seconds); widget.podcastLocal.id,
}, _seconds);
child: Text( },
s.confirm, child: Text(
style: TextStyle( s.confirm,
color: style: TextStyle(
context.accentColor), color: context.accentColor),
), ),
) )
], ],
); );
}); });
}), }),
_buttonOnMenu( _buttonOnMenu(
icon: Icon( icon: Icon(
Icons.delete, Icons.delete,
color: Colors.red, color: Colors.red,
size: _value == 0 ? 1 : 20 * _value, size: _value == 0 ? 1 : 20 * _value,
), ),
tooltip: s.remove, tooltip: s.remove,
onTap: () { onTap: () {
generalDialog( generalDialog(
context, context,
title: Text(s.removeConfirm), title: Text(s.removeConfirm),
content: Text(s.removePodcastDes), content: Text(s.removePodcastDes),
actions: <Widget>[ actions: <Widget>[
FlatButton( FlatButton(
splashColor: splashColor:
context.accentColor.withAlpha(70), context.accentColor.withAlpha(70),
onPressed: () => onPressed: () =>
Navigator.of(context).pop(), Navigator.of(context).pop(),
child: Text( child: Text(
s.cancel, s.cancel,
style: TextStyle( style: TextStyle(
color: Colors.grey[600]), color: Colors.grey[600]),
),
), ),
FlatButton( ),
splashColor: Colors.red.withAlpha(70), FlatButton(
onPressed: () { splashColor: Colors.red.withAlpha(70),
groupList.removePodcast( onPressed: () {
widget.podcastLocal); groupList.removePodcast(
Navigator.of(context).pop(); widget.podcastLocal);
}, Navigator.of(context).pop();
child: Text( },
s.confirm, child: Text(
style: TextStyle(color: Colors.red), s.confirm,
), style: TextStyle(color: Colors.red),
) ),
], )
); ],
}), );
], }),
), ],
), ),
), ),
], ),
), Divider(height: 1)
],
); );
} }
} }
@ -573,12 +564,12 @@ class _RenameGroupState extends State<RenameGroup> {
hintStyle: TextStyle(fontSize: 18), hintStyle: TextStyle(fontSize: 18),
filled: true, filled: true,
focusedBorder: UnderlineInputBorder( focusedBorder: UnderlineInputBorder(
borderSide: BorderSide( borderSide:
color: Theme.of(context).accentColor, width: 2.0), BorderSide(color: context.accentColor, width: 2.0),
), ),
enabledBorder: UnderlineInputBorder( enabledBorder: UnderlineInputBorder(
borderSide: BorderSide( borderSide:
color: Theme.of(context).accentColor, width: 2.0), BorderSide(color: context.accentColor, width: 2.0),
), ),
), ),
cursorRadius: Radius.circular(2), cursorRadius: Radius.circular(2),