Minor change.
This commit is contained in:
parent
e7839f8249
commit
e9c0e7eae9
|
@ -11,8 +11,6 @@ import 'package:intl/intl.dart';
|
||||||
import 'package:line_icons/line_icons.dart';
|
import 'package:line_icons/line_icons.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tsacdop/podcasts/podcastlist.dart';
|
|
||||||
import 'package:tsacdop/util/general_dialog.dart';
|
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
import '../episodes/episode_detail.dart';
|
import '../episodes/episode_detail.dart';
|
||||||
|
@ -20,6 +18,7 @@ import '../local_storage/key_value_storage.dart';
|
||||||
import '../local_storage/sqflite_localpodcast.dart';
|
import '../local_storage/sqflite_localpodcast.dart';
|
||||||
import '../podcasts/podcast_detail.dart';
|
import '../podcasts/podcast_detail.dart';
|
||||||
import '../podcasts/podcast_manage.dart';
|
import '../podcasts/podcast_manage.dart';
|
||||||
|
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';
|
||||||
|
@ -28,6 +27,7 @@ import '../type/play_histroy.dart';
|
||||||
import '../type/podcastlocal.dart';
|
import '../type/podcastlocal.dart';
|
||||||
import '../util/custom_widget.dart';
|
import '../util/custom_widget.dart';
|
||||||
import '../util/extension_helper.dart';
|
import '../util/extension_helper.dart';
|
||||||
|
import '../util/general_dialog.dart';
|
||||||
import '../util/pageroute.dart';
|
import '../util/pageroute.dart';
|
||||||
|
|
||||||
class ScrollPodcasts extends StatefulWidget {
|
class ScrollPodcasts extends StatefulWidget {
|
||||||
|
@ -542,12 +542,8 @@ class ShowEpisode extends StatelessWidget {
|
||||||
final PodcastLocal podcastLocal;
|
final PodcastLocal podcastLocal;
|
||||||
final DBHelper _dbHelper = DBHelper();
|
final DBHelper _dbHelper = DBHelper();
|
||||||
ShowEpisode({Key key, this.episodes, this.podcastLocal}) : super(key: key);
|
ShowEpisode({Key key, this.episodes, this.podcastLocal}) : super(key: key);
|
||||||
String stringForSeconds(double seconds) {
|
|
||||||
if (seconds == null) return null;
|
|
||||||
return '${(seconds ~/ 60)}:${(seconds.truncate() % 60).toString().padLeft(2, '0')}';
|
|
||||||
}
|
|
||||||
|
|
||||||
String _dateToString(BuildContext context, {int pubDate}) {
|
String _datToString(BuildContext context, {int pubDate}) {
|
||||||
final s = context.s;
|
final s = context.s;
|
||||||
var date = DateTime.fromMillisecondsSinceEpoch(pubDate, isUtc: true);
|
var date = DateTime.fromMillisecondsSinceEpoch(pubDate, isUtc: true);
|
||||||
var difference = DateTime.now().toUtc().difference(date);
|
var difference = DateTime.now().toUtc().difference(date);
|
||||||
|
@ -563,12 +559,11 @@ class ShowEpisode extends StatelessWidget {
|
||||||
|
|
||||||
Future<Tuple5<int, bool, bool, bool, List<int>>> _initData(
|
Future<Tuple5<int, bool, bool, bool, List<int>>> _initData(
|
||||||
EpisodeBrief episode) async {
|
EpisodeBrief episode) async {
|
||||||
var menuList = await _getEpisodeMenu();
|
final menuList = await _getEpisodeMenu();
|
||||||
var tapToOpen = await _getTapToOpenPopupMenu();
|
final tapToOpen = await _getTapToOpenPopupMenu();
|
||||||
var listened = await _isListened(episode);
|
final listened = await _isListened(episode);
|
||||||
|
final liked = await _isLiked(episode);
|
||||||
var liked = await _isLiked(episode);
|
final downloaded = await _isDownloaded(episode);
|
||||||
var downloaded = await _isDownloaded(episode);
|
|
||||||
|
|
||||||
return Tuple5(listened, liked, downloaded, tapToOpen, menuList);
|
return Tuple5(listened, liked, downloaded, tapToOpen, menuList);
|
||||||
}
|
}
|
||||||
|
@ -578,8 +573,7 @@ class ShowEpisode extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _isLiked(EpisodeBrief episode) async {
|
Future<bool> _isLiked(EpisodeBrief episode) async {
|
||||||
var dbHelper = DBHelper();
|
return await _dbHelper.isLiked(episode.enclosureUrl);
|
||||||
return await dbHelper.isLiked(episode.enclosureUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<int>> _getEpisodeMenu() async {
|
Future<List<int>> _getEpisodeMenu() async {
|
||||||
|
@ -589,8 +583,7 @@ class ShowEpisode extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _isDownloaded(EpisodeBrief episode) async {
|
Future<bool> _isDownloaded(EpisodeBrief episode) async {
|
||||||
var dbHelper = DBHelper();
|
return await _dbHelper.isDownloaded(episode.enclosureUrl);
|
||||||
return await dbHelper.isDownloaded(episode.enclosureUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> _getTapToOpenPopupMenu() async {
|
Future<bool> _getTapToOpenPopupMenu() async {
|
||||||
|
@ -600,22 +593,19 @@ class ShowEpisode extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _markListened(EpisodeBrief episode) async {
|
Future<void> _markListened(EpisodeBrief episode) async {
|
||||||
var dbHelper = DBHelper();
|
var marked = await _dbHelper.checkMarked(episode);
|
||||||
var marked = await dbHelper.checkMarked(episode);
|
|
||||||
if (!marked) {
|
if (!marked) {
|
||||||
final history = PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
|
final history = PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
|
||||||
await dbHelper.saveHistory(history);
|
await _dbHelper.saveHistory(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _saveLiked(String url) async {
|
Future<void> _saveLiked(String url) async {
|
||||||
var dbHelper = DBHelper();
|
await _dbHelper.setLiked(url);
|
||||||
await dbHelper.setLiked(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _setUnliked(String url) async {
|
Future<void> _setUnliked(String url) async {
|
||||||
var dbHelper = DBHelper();
|
await _dbHelper.setUniked(url);
|
||||||
await dbHelper.setUniked(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _requestDownload(BuildContext context,
|
Future<void> _requestDownload(BuildContext context,
|
||||||
|
@ -684,7 +674,7 @@ class ShowEpisode extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var _width = context.width;
|
final width = context.width;
|
||||||
final s = context.s;
|
final s = context.s;
|
||||||
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
|
var audio = Provider.of<AudioPlayerNotifier>(context, listen: false);
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
|
@ -723,9 +713,8 @@ class ShowEpisode extends StatelessWidget {
|
||||||
final menuList = snapshot.data.item5;
|
final menuList = snapshot.data.item5;
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius:
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
BorderRadius.all(Radius.circular(5.0)),
|
color: context.scaffoldBackgroundColor,
|
||||||
color: Theme.of(context).scaffoldBackgroundColor,
|
|
||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: FocusedMenuHolder(
|
child: FocusedMenuHolder(
|
||||||
|
@ -913,8 +902,8 @@ class ShowEpisode extends StatelessWidget {
|
||||||
tag:
|
tag:
|
||||||
'${episodes[index].enclosureUrl}scroll',
|
'${episodes[index].enclosureUrl}scroll',
|
||||||
child: Container(
|
child: Container(
|
||||||
height: _width / 18,
|
height: width / 18,
|
||||||
width: _width / 18,
|
width: width / 18,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
backgroundImage:
|
backgroundImage:
|
||||||
podcastLocal.avatarImage,
|
podcastLocal.avatarImage,
|
||||||
|
@ -983,13 +972,13 @@ class ShowEpisode extends StatelessWidget {
|
||||||
CrossAxisAlignment.center,
|
CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
_dateToString(context,
|
episodes[index]
|
||||||
pubDate:
|
.pubDate
|
||||||
episodes[index].pubDate),
|
.toDate(context),
|
||||||
overflow: TextOverflow.visible,
|
overflow: TextOverflow.visible,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
height: 1,
|
height: 1,
|
||||||
fontSize: _width / 35,
|
fontSize: width / 35,
|
||||||
color: c,
|
color: c,
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
|
@ -1003,7 +992,7 @@ class ShowEpisode extends StatelessWidget {
|
||||||
.duration
|
.duration
|
||||||
.toTime,
|
.toTime,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: _width / 35,
|
fontSize: width / 35,
|
||||||
// color: _c,
|
// color: _c,
|
||||||
// fontStyle: FontStyle.italic,
|
// fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
|
@ -1020,7 +1009,7 @@ class ShowEpisode extends StatelessWidget {
|
||||||
: Text(
|
: Text(
|
||||||
'|',
|
'|',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: _width / 35,
|
fontSize: width / 35,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (episodes[index]
|
if (episodes[index]
|
||||||
|
@ -1034,7 +1023,7 @@ class ShowEpisode extends StatelessWidget {
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(episodes[index].enclosureLength) ~/ 1000000}MB',
|
'${(episodes[index].enclosureLength) ~/ 1000000}MB',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: _width / 35),
|
fontSize: width / 35),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue