Little change in playlist page
This commit is contained in:
parent
a1d004aa43
commit
15ef69bbab
|
@ -166,7 +166,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
|
|||
await AudioService.connect();
|
||||
bool running = await AudioService.running;
|
||||
if (running) {
|
||||
await AudioService.pause();
|
||||
print(AudioService.currentMediaItem.artUri);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class EpisodeBrief {
|
|||
|
||||
String dateToString() {
|
||||
DateTime date = DateTime.fromMillisecondsSinceEpoch(pubDate, isUtc: true);
|
||||
var diffrence = DateTime.now().difference(date);
|
||||
var diffrence = DateTime.now().toUtc().difference(date);
|
||||
if (diffrence.inHours < 1) {
|
||||
return '1 hour ago';
|
||||
} else if (diffrence.inHours < 24) {
|
||||
|
@ -44,7 +44,7 @@ class EpisodeBrief {
|
|||
return '${diffrence.inDays} days ago';
|
||||
} else {
|
||||
return DateFormat.yMMMd()
|
||||
.format(DateTime.fromMillisecondsSinceEpoch(pubDate));
|
||||
.format(DateTime.fromMillisecondsSinceEpoch(pubDate, isUtc: true).toLocal());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,4 +56,5 @@ class EpisodeBrief {
|
|||
album: feedTitle,
|
||||
artUri: 'file://$imagePath');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:tsacdop/class/download_state.dart';
|
||||
import 'package:tsacdop/home/audioplayer.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
|
|
@ -53,9 +53,7 @@ class _PopupMenuState extends State<PopupMenu> {
|
|||
return primaryColor;
|
||||
}
|
||||
|
||||
bool _showDate;
|
||||
String _refreshDate;
|
||||
_getRefreshDate() async {
|
||||
Future<String> _getRefreshDate() async {
|
||||
int refreshDate;
|
||||
KeyValueStorage refreshstorage = KeyValueStorage('refreshdate');
|
||||
int i = await refreshstorage.getInt();
|
||||
|
@ -69,29 +67,19 @@ class _PopupMenuState extends State<PopupMenu> {
|
|||
DateTime date = DateTime.fromMillisecondsSinceEpoch(refreshDate);
|
||||
var diffrence = DateTime.now().difference(date);
|
||||
if (diffrence.inMinutes < 10) {
|
||||
_refreshDate = 'Just now';
|
||||
return 'Just now';
|
||||
} else if (diffrence.inHours < 1) {
|
||||
_refreshDate = '1 hour ago';
|
||||
return '1 hour ago';
|
||||
} else if (diffrence.inHours < 24) {
|
||||
_refreshDate = '${diffrence.inHours} hours ago';
|
||||
return '${diffrence.inHours} hours ago';
|
||||
} else if (diffrence.inHours == 24) {
|
||||
_refreshDate = '1 day ago';
|
||||
return '1 day ago';
|
||||
} else if (diffrence.inDays < 7) {
|
||||
_refreshDate = '${diffrence.inDays} days ago';
|
||||
return '${diffrence.inDays} days ago';
|
||||
} else {
|
||||
_refreshDate = DateFormat.yMMMd()
|
||||
return DateFormat.yMMMd()
|
||||
.format(DateTime.fromMillisecondsSinceEpoch(refreshDate));
|
||||
}
|
||||
setState(() {
|
||||
_showDate = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_showDate = false;
|
||||
_getRefreshDate();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -274,12 +262,17 @@ class _PopupMenuState extends State<PopupMenu> {
|
|||
Text(
|
||||
'Refresh All',
|
||||
),
|
||||
_showDate
|
||||
? Text(
|
||||
_refreshDate,
|
||||
FutureBuilder<String>(
|
||||
future: _getRefreshDate(),
|
||||
builder: (_, snapshot) {
|
||||
if (snapshot.hasData)
|
||||
return Text(
|
||||
snapshot.data,
|
||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||
)
|
||||
: Center(),
|
||||
);
|
||||
else
|
||||
return Center();
|
||||
})
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
@ -18,7 +18,6 @@ import 'package:tsacdop/home/audiopanel.dart';
|
|||
import 'package:tsacdop/util/pageroute.dart';
|
||||
import 'package:tsacdop/util/colorize.dart';
|
||||
import 'package:tsacdop/util/day_night_switch.dart';
|
||||
import 'package:tsacdop/util/context_extension.dart';
|
||||
|
||||
class MyRectangularTrackShape extends RectangularSliderTrackShape {
|
||||
Rect getPreferredRect({
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -9,9 +8,9 @@ import 'package:tsacdop/episodes/episodedetail.dart';
|
|||
import 'package:tuple/tuple.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:line_icons/line_icons.dart';
|
||||
|
||||
import 'package:tsacdop/class/audiostate.dart';
|
||||
import 'package:tsacdop/class/episodebrief.dart';
|
||||
import 'package:tsacdop/util/colorize.dart';
|
||||
import 'package:tsacdop/util/context_extension.dart';
|
||||
|
||||
class PlaylistPage extends StatefulWidget {
|
||||
|
@ -74,8 +73,7 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
body: SafeArea(
|
||||
child:
|
||||
Selector<AudioPlayerNotifier, Tuple3<Playlist, bool, bool>>(
|
||||
child: Selector<AudioPlayerNotifier, Tuple3<Playlist, bool, bool>>(
|
||||
selector: (_, audio) =>
|
||||
Tuple3(audio.queue, audio.playerRunning, audio.queueUpdate),
|
||||
builder: (_, data, __) {
|
||||
|
@ -123,8 +121,7 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
fontSize: 20,
|
||||
)),
|
||||
TextSpan(
|
||||
text:
|
||||
_sumPlaylistLength(episodes).toString(),
|
||||
text: _sumPlaylistLength(episodes).toString(),
|
||||
style: GoogleFonts.cairo(
|
||||
textStyle: TextStyle(
|
||||
color: Theme.of(context).accentColor,
|
||||
|
@ -142,24 +139,68 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
),
|
||||
),
|
||||
Spacer(),
|
||||
_topHeight > 65
|
||||
? Center()
|
||||
: Container(
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
right: 20, bottom: 80 - _topHeight),
|
||||
right: 20,
|
||||
),
|
||||
child: data.item2
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(right: 15),
|
||||
? _topHeight < 90
|
||||
? Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
CircleAvatar(
|
||||
radius: 12,
|
||||
backgroundImage: FileImage(File(
|
||||
"${episodes.first.imagePath}")),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 15),
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 15,
|
||||
child: WaveLoader()),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
CircleAvatar(
|
||||
radius: 15,
|
||||
//backgroundColor: _c.withOpacity(0.5),
|
||||
backgroundImage: FileImage(File(
|
||||
"${episodes.first.imagePath}")),
|
||||
),
|
||||
Container(
|
||||
width: 150,
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
episodes.first.title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 15),
|
||||
child: SizedBox(
|
||||
width: 20,
|
||||
height: 15,
|
||||
child: WaveLoader()),
|
||||
),
|
||||
],
|
||||
)
|
||||
: IconButton(
|
||||
icon: Icon(Icons.play_circle_filled,
|
||||
size: 40,
|
||||
color:
|
||||
Theme.of(context).accentColor),
|
||||
color: Theme.of(context).accentColor),
|
||||
onPressed: () => audio.playlistLoad(),
|
||||
),
|
||||
),
|
||||
|
@ -171,18 +212,31 @@ class _PlaylistPageState extends State<PlaylistPage> {
|
|||
),
|
||||
Expanded(
|
||||
child: ReorderableListView(
|
||||
scrollController: _controller,
|
||||
onReorder: (int oldIndex, int newIndex) {
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
final EpisodeBrief episodeRemove =
|
||||
episodes[oldIndex];
|
||||
final EpisodeBrief episodeRemove = episodes[oldIndex];
|
||||
audio.delFromPlaylist(episodeRemove);
|
||||
audio.addToPlaylistAt(episodeRemove, newIndex);
|
||||
setState(() {});
|
||||
},
|
||||
scrollDirection: Axis.vertical,
|
||||
children: episodes
|
||||
children: data.item2
|
||||
? episodes.map<Widget>((episode) {
|
||||
if (episode.enclosureUrl !=
|
||||
episodes.first.enclosureUrl)
|
||||
return DismissibleContainer(
|
||||
episode: episode,
|
||||
key: ValueKey(episode.enclosureUrl),
|
||||
);
|
||||
else
|
||||
return Container(
|
||||
key: ValueKey('sd'),
|
||||
);
|
||||
}).toList()
|
||||
: episodes
|
||||
.map<Widget>((episode) => DismissibleContainer(
|
||||
episode: episode,
|
||||
key: ValueKey(episode.enclosureUrl),
|
||||
|
@ -337,6 +391,7 @@ class _DismissibleContainerState extends State<DismissibleContainer> {
|
|||
],
|
||||
),
|
||||
),
|
||||
trailing: Icon(Icons.menu),
|
||||
),
|
||||
// Divider(
|
||||
// height: 2,
|
||||
|
|
|
@ -425,7 +425,7 @@ class DBHelper {
|
|||
|
||||
if (url != null) {
|
||||
await dbClient.transaction((txn) async {
|
||||
int id = await txn.rawInsert(
|
||||
await txn.rawInsert(
|
||||
"""INSERT OR IGNORE INTO Episodes(title, enclosure_url, enclosure_length, pubDate,
|
||||
description, feed_id, milliseconds, duration, explicit, media_id, is_new) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)""",
|
||||
[
|
||||
|
@ -440,7 +440,6 @@ class DBHelper {
|
|||
explicit,
|
||||
url,
|
||||
]);
|
||||
print("$id");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import 'dart:io';
|
||||
import 'dart:isolate';
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_downloader/flutter_downloader.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
|
Loading…
Reference in New Issue