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