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

Minor change.

This commit is contained in:
Stonegate 2021-01-01 23:41:33 +08:00
parent 850250efec
commit a9e370fbe7
4 changed files with 205 additions and 158 deletions

View File

@ -21,6 +21,7 @@ import '../podcasts/podcastlist.dart';
import '../state/audio_state.dart'; import '../state/audio_state.dart';
import '../state/download_state.dart'; import '../state/download_state.dart';
import '../state/podcast_group.dart'; import '../state/podcast_group.dart';
import '../state/refresh_podcast.dart';
import '../type/episodebrief.dart'; import '../type/episodebrief.dart';
import '../type/play_histroy.dart'; import '../type/play_histroy.dart';
import '../type/podcastlocal.dart'; import '../type/podcastlocal.dart';
@ -493,23 +494,27 @@ class _PodcastPreviewState extends State<PodcastPreview> {
return Column( return Column(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Selector<GroupList, bool>( child: Selector<RefreshWorker, bool>(
selector: (_, worker) => worker.created, selector: (_, worker) => worker.complete,
builder: (context, created, child) { builder: (_, complete, __) => Selector<GroupList, bool>(
return FutureBuilder<List<EpisodeBrief>>( selector: (_, worker) => worker.created,
future: _getRssItem, builder: (context, created, child) {
builder: (context, snapshot) { _getRssItem = _getRssItemTop(widget.podcastLocal);
return (snapshot.hasData) return FutureBuilder<List<EpisodeBrief>>(
? ShowEpisode( future: _getRssItem,
episodes: snapshot.data, builder: (context, snapshot) {
podcastLocal: widget.podcastLocal, return (snapshot.hasData)
) ? ShowEpisode(
: Padding( episodes: snapshot.data,
padding: const EdgeInsets.all(5.0), podcastLocal: widget.podcastLocal,
); )
}, : Padding(
); padding: const EdgeInsets.all(5.0),
}), );
},
);
}),
),
), ),
Container( Container(
height: 40, height: 40,

View File

@ -871,7 +871,9 @@ class __NewPlaylistState extends State<_NewPlaylist> {
FlatButton( FlatButton(
splashColor: context.accentColor.withAlpha(70), splashColor: context.accentColor.withAlpha(70),
onPressed: () async { onPressed: () async {
if (context if (_playlistName == '') {
setState(() => _error = 0);
} else if (context
.read<AudioPlayerNotifier>() .read<AudioPlayerNotifier>()
.playlistExisted(_playlistName)) { .playlistExisted(_playlistName)) {
setState(() => _error = 1); setState(() => _error = 1);
@ -887,7 +889,7 @@ class __NewPlaylistState extends State<_NewPlaylist> {
final recent = await _recent(); final recent = await _recent();
playlist = Playlist( playlist = Playlist(
_playlistName, _playlistName,
episodeList: [for(var e in recent) e.enclosureUrl], episodeList: [for (var e in recent) e.enclosureUrl],
); );
await playlist.getPlaylist(); await playlist.getPlaylist();
break; break;
@ -895,7 +897,7 @@ class __NewPlaylistState extends State<_NewPlaylist> {
final random = await _random(); final random = await _random();
playlist = Playlist( playlist = Playlist(
_playlistName, _playlistName,
episodeList: [for(var e in random) e.enclosureUrl], episodeList: [for (var e in random) e.enclosureUrl],
); );
await playlist.getPlaylist(); await playlist.getPlaylist();
break; break;
@ -938,14 +940,15 @@ class __NewPlaylistState extends State<_NewPlaylist> {
}, },
), ),
Container( Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: (_error == 1) child: _error != null
? Text( ? Text(
'Playlist existed', _error == 1
style: TextStyle(color: Colors.red[400]), ? 'Playlist existed'
) : 'Playlist name is empty',
: Center(), style: TextStyle(color: Colors.red[400]),
), )
: Center()),
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [

View File

@ -30,6 +30,9 @@ import '../widgets/general_dialog.dart';
import '../widgets/muiliselect_bar.dart'; import '../widgets/muiliselect_bar.dart';
import 'podcast_settings.dart'; import 'podcast_settings.dart';
const KDefaultAvatar = """http://xuanmei.us/assets/default/avatar_small-
170afdc2be97fc6148b283083942d82c101d4c1061f6b28f87c8958b52664af9.jpg""";
class PodcastDetail extends StatefulWidget { class PodcastDetail extends StatefulWidget {
PodcastDetail({Key key, @required this.podcastLocal, this.hide = false}) PodcastDetail({Key key, @required this.podcastLocal, this.hide = false})
: super(key: key); : super(key: key);
@ -88,6 +91,9 @@ class _PodcastDetailState extends State<PodcastDetail> {
bool _selectAfter; bool _selectAfter;
bool _loadEpisodes = false; bool _loadEpisodes = false;
///Show podcast info.
bool _showInfo;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -99,6 +105,7 @@ class _PodcastDetailState extends State<PodcastDetail> {
_selectAll = false; _selectAll = false;
_selectAfter = false; _selectAfter = false;
_selectBefore = false; _selectBefore = false;
_showInfo = false;
Future.delayed(Duration(milliseconds: 200)) Future.delayed(Duration(milliseconds: 200))
.then((value) => setState(() => _loadEpisodes = true)); .then((value) => setState(() => _loadEpisodes = true));
} }
@ -202,16 +209,13 @@ class _PodcastDetailState extends State<PodcastDetail> {
Widget _podcastInfo(BuildContext context) { Widget _podcastInfo(BuildContext context) {
return Container( return Container(
height: 170, height: 170,
padding: EdgeInsets.only(top: 40, left: 80, right: 130), padding: EdgeInsets.only(top: 50, left: 80, right: 130),
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: Container( child: Text(
padding: EdgeInsets.symmetric(vertical: 10), widget.podcastLocal.title,
child: Text( maxLines: 2,
widget.podcastLocal.title, overflow: TextOverflow.ellipsis,
maxLines: 2, style: context.textTheme.headline5.copyWith(color: Colors.white),
overflow: TextOverflow.ellipsis,
style: context.textTheme.headline5.copyWith(color: Colors.white),
),
), ),
); );
} }
@ -233,28 +237,26 @@ class _PodcastDetailState extends State<PodcastDetail> {
errorWidget: (context, url, error) => Center(), errorWidget: (context, url, error) => Center(),
imageBuilder: (context, backgroundImageProvider) => imageBuilder: (context, backgroundImageProvider) =>
Container( Container(
decoration: BoxDecoration( // decoration: BoxDecoration(
image: DecorationImage( // image: DecorationImage(
image: backgroundImageProvider, // image: backgroundImageProvider,
fit: BoxFit.cover)), // fit: BoxFit.cover)),
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: Container( child: Container(
color: Colors.black26, //color: Colors.black26,
padding: EdgeInsets.symmetric(vertical: 5.0), padding: EdgeInsets.symmetric(vertical: 5.0),
width: MediaQuery.of(context).size.width, width: double.infinity,
alignment: Alignment.centerRight, alignment: Alignment.centerLeft,
child: SingleChildScrollView( child: SingleChildScrollView(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: hosts children: hosts
.map<Widget>((host) { .map<Widget>((host) {
final image = host.image == final image =
"http://xuanmei.us/assets/default/avatar_small-" host.image == KDefaultAvatar
"170afdc2be97fc6148b283083942d82c101d4c1061f6b28f87c8958b52664af9.jpg" ? KDefaultAvatar
? "https://fireside.fm/assets/default/avatar_small" : host.image;
"-170afdc2be97fc6148b283083942d82c101d4c1061f6b28f87c8958b52664af9.jpg"
: host.image;
return Container( return Container(
padding: EdgeInsets.all(5.0), padding: EdgeInsets.all(5.0),
width: 80.0, width: 80.0,
@ -299,11 +301,13 @@ class _PodcastDetailState extends State<PodcastDetail> {
Text( Text(
host.name, host.name,
style: TextStyle( style: TextStyle(
backgroundColor: Colors fontWeight:
.black FontWeight.bold
.withOpacity(0.5), // backgroundColor: Colors
color: Colors.white, // .black
), // .withOpacity(0.5),
//color: Colors.white,
),
textAlign: TextAlign.center, textAlign: TextAlign.center,
maxLines: 2, maxLines: 2,
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
@ -320,9 +324,8 @@ class _PodcastDetailState extends State<PodcastDetail> {
return Center(); return Center();
} }
}), }),
Padding(padding: EdgeInsets.all(10.0)),
Container( Container(
padding: EdgeInsets.only(left: 15.0, right: 15.0, bottom: 10.0), padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
color: context.scaffoldBackgroundColor, color: context.scaffoldBackgroundColor,
child: AboutPodcast(podcastLocal: widget.podcastLocal), child: AboutPodcast(podcastLocal: widget.podcastLocal),
@ -331,12 +334,12 @@ class _PodcastDetailState extends State<PodcastDetail> {
); );
} }
Widget _customPopupMenu( Widget _customPopupMenu({
{Widget child, Widget child,
String tooltip, String tooltip,
List<PopupMenuEntry<int>> itemBuilder, List<PopupMenuEntry<int>> itemBuilder,
Function(int) onSelected, Function(int) onSelected,
}) => }) =>
Material( Material(
key: UniqueKey(), key: UniqueKey(),
color: Colors.transparent, color: Colors.transparent,
@ -708,6 +711,7 @@ class _PodcastDetailState extends State<PodcastDetail> {
top: false, top: false,
child: RefreshIndicator( child: RefreshIndicator(
key: _refreshIndicatorKey, key: _refreshIndicatorKey,
displacement: context.paddingTop + 40,
color: context.accentColor, color: context.accentColor,
onRefresh: () async { onRefresh: () async {
await _updateRssItem(context, widget.podcastLocal); await _updateRssItem(context, widget.podcastLocal);
@ -765,38 +769,60 @@ class _PodcastDetailState extends State<PodcastDetail> {
return FlexibleSpaceBar( return FlexibleSpaceBar(
background: Stack( background: Stack(
children: <Widget>[ children: <Widget>[
Container( // if (widget.podcastLocal.provider
margin: EdgeInsets.only( // .contains('fireside'))
top: 100 + context.paddingTop), // Positioned.fill(
padding: EdgeInsets.only( // child: FutureBuilder(
left: 80, right: 20), // future: _getHosts(
color: Colors.white10, // widget.podcastLocal),
alignment: Alignment.centerLeft, // builder: (context, snapshot) {
child: Column( // if (snapshot.hasData) {
mainAxisAlignment: // return CachedNetworkImage(
MainAxisAlignment.start, // imageUrl:
mainAxisSize: MainAxisSize.min, // snapshot.data.item1,
crossAxisAlignment: // fit: BoxFit.fill,
CrossAxisAlignment.start, // );
children: <Widget>[ // } else
Text( // return Center();
widget.podcastLocal.author ?? // }),
'', // ),
maxLines: 1, InkWell(
overflow: onTap: () => setState(
TextOverflow.ellipsis, () => _showInfo = !_showInfo),
style: TextStyle( child: Container(
color: Colors.white)), margin: EdgeInsets.only(
if (widget.podcastLocal.provider top: 100 + context.paddingTop),
.isNotEmpty) padding: EdgeInsets.only(
left: 80, right: 20),
color: Colors.white10,
alignment: Alignment.centerLeft,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text( Text(
s.hostedOn(widget widget.podcastLocal
.podcastLocal.provider), .author ??
maxLines: 1, '',
style: TextStyle( maxLines: 1,
color: Colors.white), overflow:
), TextOverflow.ellipsis,
], style: TextStyle(
color: Colors.white)),
if (widget.podcastLocal.provider
.isNotEmpty)
Text(
s.hostedOn(widget
.podcastLocal.provider),
maxLines: 1,
style: TextStyle(
color: Colors.white),
),
],
),
), ),
), ),
Container( Container(
@ -830,7 +856,9 @@ class _PodcastDetailState extends State<PodcastDetail> {
}), }),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: _hostsList(context, widget.podcastLocal), child: _showInfo
? _hostsList(context, widget.podcastLocal)
: SizedBox(height: 10),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: _multiSelect child: _multiSelect
@ -1004,63 +1032,73 @@ class _AboutPodcastState extends State<AboutPodcast> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return !_load return !_load
? Center() ? Center()
: LayoutBuilder( : Linkify(
builder: (context, size) { text: _description,
final span = TextSpan(text: _description); onOpen: (link) {
final tp = TextPainter( link.url.launchUrl;
text: span, maxLines: 3, textDirection: TextDirection.ltr);
tp.layout(maxWidth: size.maxWidth);
if (tp.didExceedMaxLines) {
return GestureDetector(
onTap: () {
setState(() => _expand = !_expand);
},
child: !_expand
? Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Linkify(
onOpen: (link) {
link.url.launchUrl;
},
text: _description,
linkStyle: TextStyle(
color: Theme.of(context).accentColor,
decoration: TextDecoration.underline,
textBaseline: TextBaseline.ideographic),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
],
)
: Linkify(
onOpen: (link) {
link.url.launchUrl;
},
text: _description,
linkStyle: TextStyle(
color: Theme.of(context).accentColor,
decoration: TextDecoration.underline,
textBaseline: TextBaseline.ideographic),
),
);
} else {
return Linkify(
text: _description,
onOpen: (link) {
link.url.launchUrl;
},
linkStyle: TextStyle(
color: Theme.of(context).accentColor,
decoration: TextDecoration.underline,
textBaseline: TextBaseline.ideographic),
);
}
}, },
linkStyle: TextStyle(
color: Theme.of(context).accentColor,
decoration: TextDecoration.underline,
textBaseline: TextBaseline.ideographic),
); );
// LayoutBuilder(
// builder: (context, size) {
// final span = TextSpan(text: _description);
// final tp = TextPainter(
// text: span, maxLines: 3, textDirection: TextDirection.ltr);
// tp.layout(maxWidth: size.maxWidth);
// if (tp.didExceedMaxLines) {
// return GestureDetector(
// onTap: () {
// setState(() => _expand = !_expand);
// },
// child: !_expand
// ? Column(
// mainAxisAlignment: MainAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// Linkify(
// onOpen: (link) {
// link.url.launchUrl;
// },
// text: _description,
// linkStyle: TextStyle(
// color: Theme.of(context).accentColor,
// decoration: TextDecoration.underline,
// textBaseline: TextBaseline.ideographic),
// maxLines: 3,
// overflow: TextOverflow.ellipsis,
// ),
// ],
// )
// : Linkify(
// onOpen: (link) {
// link.url.launchUrl;
// },
// text: _description,
// linkStyle: TextStyle(
// color: Theme.of(context).accentColor,
// decoration: TextDecoration.underline,
// textBaseline: TextBaseline.ideographic),
// ),
// );
// } else {
// return Linkify(
// text: _description,
// onOpen: (link) {
// link.url.launchUrl;
// },
// linkStyle: TextStyle(
// color: Theme.of(context).accentColor,
// decoration: TextDecoration.underline,
// textBaseline: TextBaseline.ideographic),
// );
// }
// },
// );
} }
} }

View File

@ -505,7 +505,8 @@ class WavePainter extends CustomPainter {
class WaveLoader extends StatefulWidget { class WaveLoader extends StatefulWidget {
final Color color; final Color color;
WaveLoader({this.color, Key key}) : super(key: key); final bool animate;
WaveLoader({this.color, this.animate = true, Key key}) : super(key: key);
@override @override
_WaveLoaderState createState() => _WaveLoaderState(); _WaveLoaderState createState() => _WaveLoaderState();
} }
@ -547,7 +548,8 @@ class _WaveLoaderState extends State<WaveLoader>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CustomPaint( return CustomPaint(
painter: WavePainter(_fraction, widget.color ?? Colors.white)); painter: WavePainter(
widget.animate ? _fraction : 1, widget.color ?? Colors.white));
} }
} }
@ -1300,16 +1302,15 @@ class _SleepTimerPickerState extends State<SleepTimerPicker> {
super.initState(); super.initState();
} }
_initTimer(){ _initTimer() {
int h = DateTime.now().hour; int h = DateTime.now().hour;
int m = DateTime.now().minute; int m = DateTime.now().minute;
if(m > 50){ if (m > 50) {
hour = (h+1) % 24; hour = (h + 1) % 24;
minute = 0; minute = 0;
} } else {
else {
hour = h; hour = h;
minute = m ~/10 * 10 +10; minute = m ~/ 10 * 10 + 10;
} }
} }