2020-02-23 14:20:07 +01:00
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:async';
|
|
|
|
|
2020-06-10 09:42:40 +02:00
|
|
|
import 'package:connectivity/connectivity.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2020-02-22 13:25:06 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-02-23 14:20:07 +01:00
|
|
|
import 'package:html/parser.dart';
|
2020-06-10 09:42:40 +02:00
|
|
|
import 'package:tsacdop/state/download_state.dart';
|
2020-03-01 13:17:06 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2020-02-20 16:44:42 +01:00
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
2020-03-21 17:14:10 +01:00
|
|
|
import 'package:flutter_linkify/flutter_linkify.dart';
|
2020-03-25 16:33:48 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2020-04-11 19:23:12 +02:00
|
|
|
import 'package:line_icons/line_icons.dart';
|
2020-02-26 10:54:59 +01:00
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
2020-04-22 20:10:57 +02:00
|
|
|
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../type/podcastlocal.dart';
|
|
|
|
import '../type/episodebrief.dart';
|
2020-07-22 11:34:32 +02:00
|
|
|
import '../type/play_histroy.dart';
|
2020-04-22 20:10:57 +02:00
|
|
|
import '../local_storage/sqflite_localpodcast.dart';
|
2020-06-03 14:39:15 +02:00
|
|
|
import '../local_storage/key_value_storage.dart';
|
2020-04-22 20:10:57 +02:00
|
|
|
import '../util/episodegrid.dart';
|
|
|
|
import '../home/audioplayer.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
import '../type/fireside_data.dart';
|
2020-07-22 11:34:32 +02:00
|
|
|
import '../util/extension_helper.dart';
|
2020-07-24 16:10:08 +02:00
|
|
|
import '../util/custom_widget.dart';
|
2020-06-07 14:47:28 +02:00
|
|
|
import '../util/general_dialog.dart';
|
2020-07-07 17:29:21 +02:00
|
|
|
import '../state/audio_state.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
|
|
|
|
class PodcastDetail extends StatefulWidget {
|
2020-06-03 14:39:15 +02:00
|
|
|
PodcastDetail({Key key, @required this.podcastLocal, this.hide = false})
|
|
|
|
: super(key: key);
|
2020-02-09 13:29:09 +01:00
|
|
|
final PodcastLocal podcastLocal;
|
2020-06-03 14:39:15 +02:00
|
|
|
final bool hide;
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
_PodcastDetailState createState() => _PodcastDetailState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PodcastDetailState extends State<PodcastDetail> {
|
|
|
|
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
|
|
|
GlobalKey<RefreshIndicatorState>();
|
2020-07-16 09:18:45 +02:00
|
|
|
|
|
|
|
/// Fireside background if hosted on fireside.
|
2020-06-03 14:39:15 +02:00
|
|
|
String _backgroundImage;
|
2020-07-16 09:18:45 +02:00
|
|
|
|
|
|
|
/// Fireside hosts if hosted on fireside.
|
2020-06-03 14:39:15 +02:00
|
|
|
List<PodcastHost> _hosts;
|
2020-07-16 09:18:45 +02:00
|
|
|
|
|
|
|
/// Episodes total count.
|
2020-06-03 14:39:15 +02:00
|
|
|
int _episodeCount;
|
2020-07-16 09:18:45 +02:00
|
|
|
|
|
|
|
/// Default layout.
|
2020-06-03 14:39:15 +02:00
|
|
|
Layout _layout;
|
2020-07-16 09:18:45 +02:00
|
|
|
|
2020-07-23 20:42:25 +02:00
|
|
|
/// If true, stop grid load animation.
|
|
|
|
bool _scroll = false;
|
|
|
|
|
|
|
|
double _topHeight = 0;
|
|
|
|
|
|
|
|
ScrollController _controller;
|
|
|
|
|
|
|
|
/// Episodes num load first time.
|
|
|
|
int _top = 96;
|
|
|
|
|
|
|
|
/// Load more episodes when scroll to bottom.
|
|
|
|
bool _loadMore = false;
|
|
|
|
|
|
|
|
/// Change sort by.
|
|
|
|
bool _reverse = false;
|
|
|
|
|
|
|
|
/// Filter type.
|
|
|
|
Filter _filter = Filter.all;
|
|
|
|
|
|
|
|
/// Query string
|
|
|
|
String _query = '';
|
|
|
|
|
|
|
|
///Hide listened.
|
|
|
|
bool _hideListened = false;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_loadMore = false;
|
|
|
|
_reverse = false;
|
|
|
|
_controller = ScrollController();
|
|
|
|
_scroll = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2020-07-04 16:42:56 +02:00
|
|
|
Future _updateRssItem(BuildContext context, PodcastLocal podcastLocal) async {
|
2020-02-09 13:29:09 +01:00
|
|
|
var dbHelper = DBHelper();
|
2020-04-23 19:46:36 +02:00
|
|
|
final result = await dbHelper.updatePodcastRss(podcastLocal);
|
|
|
|
if (result == 0) {
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
msg: 'No Update',
|
|
|
|
gravity: ToastGravity.TOP,
|
|
|
|
);
|
|
|
|
} else if (result > 0) {
|
|
|
|
Fluttertoast.showToast(
|
2020-07-04 16:42:56 +02:00
|
|
|
msg: context.s.updateEpisodesCount(result),
|
2020-04-23 19:46:36 +02:00
|
|
|
gravity: ToastGravity.TOP,
|
|
|
|
);
|
2020-06-11 17:13:10 +02:00
|
|
|
|
2020-06-10 09:42:40 +02:00
|
|
|
bool autoDownload = await dbHelper.getAutoDownload(podcastLocal.id);
|
|
|
|
if (autoDownload) {
|
2020-06-11 17:13:10 +02:00
|
|
|
var downloader = Provider.of<DownloadState>(context, listen: false);
|
2020-06-10 09:42:40 +02:00
|
|
|
var result = await Connectivity().checkConnectivity();
|
|
|
|
KeyValueStorage autoDownloadStorage =
|
|
|
|
KeyValueStorage(autoDownloadNetworkKey);
|
|
|
|
int autoDownloadNetwork = await autoDownloadStorage.getInt();
|
|
|
|
if (autoDownloadNetwork == 1) {
|
|
|
|
List<EpisodeBrief> episodes =
|
|
|
|
await dbHelper.getNewEpisodes(podcastLocal.id);
|
2020-06-11 17:13:10 +02:00
|
|
|
// For safety
|
|
|
|
if (episodes.length < 100)
|
2020-07-13 09:41:59 +02:00
|
|
|
for (var episode in episodes)
|
2020-06-11 17:13:10 +02:00
|
|
|
downloader.startTask(episode, showNotification: false);
|
2020-06-10 09:42:40 +02:00
|
|
|
} else if (result == ConnectivityResult.wifi) {
|
|
|
|
List<EpisodeBrief> episodes =
|
|
|
|
await dbHelper.getNewEpisodes(podcastLocal.id);
|
2020-06-11 17:13:10 +02:00
|
|
|
//For safety
|
|
|
|
if (episodes.length < 100)
|
2020-07-13 09:41:59 +02:00
|
|
|
for (var episode in episodes)
|
2020-06-11 17:13:10 +02:00
|
|
|
downloader.startTask(episode, showNotification: false);
|
2020-06-10 09:42:40 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-23 19:46:36 +02:00
|
|
|
} else {
|
2020-04-11 19:23:12 +02:00
|
|
|
Fluttertoast.showToast(
|
2020-07-04 16:42:56 +02:00
|
|
|
msg: context.s.updateFailed,
|
2020-04-11 19:23:12 +02:00
|
|
|
gravity: ToastGravity.TOP,
|
|
|
|
);
|
|
|
|
}
|
2020-02-22 13:25:06 +01:00
|
|
|
if (mounted) setState(() {});
|
2020-02-09 13:29:09 +01:00
|
|
|
}
|
|
|
|
|
2020-07-23 20:42:25 +02:00
|
|
|
Future<List<EpisodeBrief>> _getRssItem(PodcastLocal podcastLocal,
|
|
|
|
{int count, bool reverse, Filter filter, String query}) async {
|
2020-02-09 13:29:09 +01:00
|
|
|
var dbHelper = DBHelper();
|
2020-07-23 20:42:25 +02:00
|
|
|
List<EpisodeBrief> episodes = [];
|
2020-06-03 14:39:15 +02:00
|
|
|
_episodeCount = await dbHelper.getPodcastCounts(podcastLocal.id);
|
|
|
|
KeyValueStorage storage = KeyValueStorage(podcastLayoutKey);
|
2020-07-16 09:18:45 +02:00
|
|
|
int index = await storage.getInt(defaultValue: 1);
|
2020-06-03 14:39:15 +02:00
|
|
|
if (_layout == null) _layout = Layout.values[index];
|
2020-07-23 20:42:25 +02:00
|
|
|
episodes = await dbHelper.getRssItem(podcastLocal.id, count, reverse,
|
2020-07-24 16:10:08 +02:00
|
|
|
filter: filter, query: query, hideListened: _hideListened);
|
|
|
|
|
2020-02-26 10:54:59 +01:00
|
|
|
if (podcastLocal.provider.contains('fireside')) {
|
|
|
|
FiresideData data = FiresideData(podcastLocal.id, podcastLocal.link);
|
|
|
|
await data.getData();
|
2020-06-03 14:39:15 +02:00
|
|
|
_backgroundImage = data.background;
|
|
|
|
_hosts = data.hosts;
|
2020-02-26 10:54:59 +01:00
|
|
|
}
|
2020-02-09 13:29:09 +01:00
|
|
|
return episodes;
|
|
|
|
}
|
|
|
|
|
2020-06-07 14:47:28 +02:00
|
|
|
_markListened(String podcastId) async {
|
|
|
|
DBHelper dbHelper = DBHelper();
|
|
|
|
List<EpisodeBrief> episodes =
|
|
|
|
await dbHelper.getRssItem(podcastId, -1, true);
|
2020-07-13 09:41:59 +02:00
|
|
|
for (var episode in episodes) {
|
2020-06-07 14:47:28 +02:00
|
|
|
bool marked = await dbHelper.checkMarked(episode);
|
|
|
|
if (!marked) {
|
|
|
|
final PlayHistory history =
|
|
|
|
PlayHistory(episode.title, episode.enclosureUrl, 0, 1);
|
|
|
|
await dbHelper.saveHistory(history);
|
|
|
|
if (mounted) setState(() {});
|
|
|
|
}
|
2020-07-13 09:41:59 +02:00
|
|
|
}
|
2020-06-07 14:47:28 +02:00
|
|
|
}
|
|
|
|
|
2020-02-23 14:20:07 +01:00
|
|
|
Widget podcastInfo(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
height: 170,
|
2020-06-28 17:47:29 +02:00
|
|
|
padding: EdgeInsets.only(top: 40, left: 80, right: 130),
|
2020-02-23 14:20:07 +01:00
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: Container(
|
2020-07-18 11:52:31 +02:00
|
|
|
padding: EdgeInsets.symmetric(vertical: 10),
|
|
|
|
child: Text(
|
|
|
|
widget.podcastLocal.title,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: Theme.of(context)
|
|
|
|
.textTheme
|
|
|
|
.headline5
|
|
|
|
.copyWith(color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
2020-02-23 14:20:07 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-03-01 13:17:06 +01:00
|
|
|
Widget hostsList(BuildContext context, List<PodcastHost> hosts) {
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
hosts != null
|
|
|
|
? Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
// colorFilter: ColorFilter.mode(_color, BlendMode.color),
|
|
|
|
image: CachedNetworkImageProvider(
|
2020-06-03 14:39:15 +02:00
|
|
|
_backgroundImage,
|
2020-03-01 13:17:06 +01:00
|
|
|
),
|
|
|
|
fit: BoxFit.cover)),
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Container(
|
2020-03-19 20:58:30 +01:00
|
|
|
color: Colors.black26,
|
2020-03-01 13:17:06 +01:00
|
|
|
padding: EdgeInsets.symmetric(vertical: 5.0),
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: hosts
|
|
|
|
.map((host) => Container(
|
|
|
|
padding: EdgeInsets.all(5.0),
|
|
|
|
width: 80.0,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
CircleAvatar(
|
|
|
|
backgroundColor: Colors.grey[400],
|
2020-03-14 04:14:24 +01:00
|
|
|
backgroundImage:
|
|
|
|
CachedNetworkImageProvider(
|
2020-03-01 13:17:06 +01:00
|
|
|
host.image,
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.all(2),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
host.name,
|
|
|
|
style: TextStyle(
|
|
|
|
backgroundColor:
|
|
|
|
Colors.black.withOpacity(0.5),
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.fade,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)))
|
|
|
|
.toList()
|
|
|
|
.cast<Widget>(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
: Center(),
|
|
|
|
Padding(padding: EdgeInsets.all(10.0)),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(left: 15.0, right: 15.0, bottom: 10.0),
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
child: AboutPodcast(podcastLocal: widget.podcastLocal),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-06-07 14:47:28 +02:00
|
|
|
_confirmMarkListened(BuildContext context) => generalDialog(
|
|
|
|
context,
|
2020-07-04 16:42:56 +02:00
|
|
|
title: Text(context.s.markConfirm),
|
|
|
|
content: Text(context.s.markConfirmContent),
|
2020-06-07 14:47:28 +02:00
|
|
|
actions: <Widget>[
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: Text(
|
2020-07-04 16:42:56 +02:00
|
|
|
context.s.cancel,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: TextStyle(color: Colors.grey[600]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () async {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
await _markListened(widget.podcastLocal.id);
|
|
|
|
},
|
|
|
|
child: Text(
|
2020-07-04 16:42:56 +02:00
|
|
|
context.s.confirm,
|
2020-06-07 14:47:28 +02:00
|
|
|
style: TextStyle(color: context.accentColor),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2020-07-24 16:10:08 +02:00
|
|
|
_customPopupMenu(
|
|
|
|
{Widget child,
|
|
|
|
String tooltip,
|
|
|
|
List<PopupMenuEntry<int>> itemBuilder,
|
|
|
|
Function(int) onSelected,
|
|
|
|
bool clip = true}) =>
|
|
|
|
Material(
|
|
|
|
key: UniqueKey(),
|
|
|
|
color: Colors.transparent,
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
clipBehavior: clip ? Clip.hardEdge : Clip.none,
|
|
|
|
child: PopupMenuButton<int>(
|
|
|
|
shape:
|
|
|
|
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
elevation: 1,
|
|
|
|
tooltip: tooltip,
|
|
|
|
child: child,
|
|
|
|
itemBuilder: (context) => itemBuilder,
|
|
|
|
onSelected: (value) => onSelected(value),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
Widget _rightTopMenu(BuildContext context) {
|
|
|
|
final s = context.s;
|
|
|
|
return _customPopupMenu(
|
|
|
|
tooltip: s.menu,
|
|
|
|
clip: false,
|
|
|
|
onSelected: (int value) {
|
|
|
|
switch (value) {
|
|
|
|
case 0:
|
|
|
|
widget.podcastLocal.link.launchUrl;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
widget.podcastLocal.rssUrl.launchUrl;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
_confirmMarkListened(context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
itemBuilder: [
|
|
|
|
if (widget.podcastLocal.link != null)
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 0,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: 10),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(Icons.link, color: context.textColor),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5.0),
|
|
|
|
),
|
|
|
|
Text(s.menuVisitSite),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 1,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: 10),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.rss_feed,
|
|
|
|
color: context.textColor,
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5.0),
|
|
|
|
),
|
|
|
|
Text(s.menuViewRSS),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 2,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: 10),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: <Widget>[
|
|
|
|
SizedBox(
|
|
|
|
width: 25,
|
|
|
|
height: 25,
|
|
|
|
child: CustomPaint(
|
|
|
|
painter:
|
|
|
|
ListenedAllPainter(context.textColor, stroke: 2)),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 5.0),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
s.menuMarkAllListened,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _actionBar(BuildContext context) {
|
|
|
|
final s = context.s;
|
|
|
|
return Container(
|
|
|
|
height: 30,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
SizedBox(width: 10),
|
|
|
|
_customPopupMenu(
|
|
|
|
tooltip: s.homeSubMenuSortBy,
|
|
|
|
child: Container(
|
|
|
|
height: 30,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(100.0),
|
|
|
|
border: Border.all(color: context.primaryColorDark),
|
|
|
|
),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10),
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(s.homeSubMenuSortBy),
|
|
|
|
SizedBox(width: 5),
|
|
|
|
Icon(
|
|
|
|
_reverse
|
|
|
|
? LineIcons.hourglass_start_solid
|
|
|
|
: LineIcons.hourglass_end_solid,
|
|
|
|
size: 18,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
itemBuilder: [
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 0,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(s.newestFirst),
|
|
|
|
Spacer(),
|
|
|
|
if (!_reverse) DotIndicator()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 1,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(s.oldestFirst),
|
|
|
|
Spacer(),
|
|
|
|
if (_reverse) DotIndicator()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
onSelected: (value) {
|
|
|
|
if (value == 0)
|
|
|
|
setState(() => _reverse = false);
|
|
|
|
else if (value == 1) setState(() => _reverse = true);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SizedBox(width: 10),
|
|
|
|
_customPopupMenu(
|
|
|
|
tooltip: s.filter,
|
|
|
|
child: Container(
|
|
|
|
height: 30,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
border: Border.all(color: context.primaryColorDark)),
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 10),
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(s.filter),
|
|
|
|
SizedBox(width: 5),
|
|
|
|
Icon(
|
|
|
|
LineIcons.filter_solid,
|
|
|
|
size: 18,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
itemBuilder: [
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 0,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(s.all),
|
|
|
|
Spacer(),
|
|
|
|
if (_filter == Filter.all) DotIndicator(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 1,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(s.homeTabMenuFavotite),
|
|
|
|
Spacer(),
|
|
|
|
if (_filter == Filter.liked) DotIndicator()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 2,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(s.downloaded),
|
|
|
|
Spacer(),
|
|
|
|
if (_filter == Filter.downloaded) DotIndicator()
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
PopupMenuItem(
|
|
|
|
value: 3,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: 5, bottom: 5, left: 2, right: 2),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(5),
|
|
|
|
border: Border.all(
|
|
|
|
width: 2,
|
|
|
|
color: context.textColor.withOpacity(0.2))),
|
|
|
|
child: _query == ''
|
|
|
|
? Row(
|
|
|
|
children: [
|
|
|
|
Text(s.search,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.textColor
|
|
|
|
.withOpacity(0.4))),
|
|
|
|
Spacer()
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(_query,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color: context.accentColor)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
onSelected: (value) {
|
|
|
|
switch (value) {
|
|
|
|
case 0:
|
|
|
|
if (_filter != Filter.all)
|
|
|
|
setState(() {
|
|
|
|
_filter = Filter.all;
|
|
|
|
_query = '';
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (_filter != Filter.liked)
|
|
|
|
setState(() {
|
|
|
|
_query = '';
|
|
|
|
_filter = Filter.liked;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (_filter != Filter.downloaded)
|
|
|
|
setState(() {
|
|
|
|
_query = '';
|
|
|
|
_filter = Filter.downloaded;
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
showGeneralDialog(
|
|
|
|
context: context,
|
|
|
|
barrierDismissible: true,
|
|
|
|
barrierLabel: MaterialLocalizations.of(context)
|
|
|
|
.modalBarrierDismissLabel,
|
|
|
|
barrierColor: Colors.black54,
|
|
|
|
transitionDuration: const Duration(milliseconds: 200),
|
|
|
|
pageBuilder: (BuildContext context,
|
|
|
|
Animation animaiton,
|
|
|
|
Animation secondaryAnimation) =>
|
|
|
|
SearchEpisdoe(
|
|
|
|
onSearch: (query) {
|
|
|
|
setState(() {
|
|
|
|
_query = query;
|
|
|
|
_filter = Filter.search;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Spacer(),
|
|
|
|
Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
child: IconButton(
|
|
|
|
icon: SizedBox(
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
child: HideListened(
|
|
|
|
hideListened: _hideListened,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
setState(() => _hideListened = !_hideListened);
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
Material(
|
|
|
|
color: Colors.transparent,
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
child: IconButton(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
onPressed: () {
|
|
|
|
if (_layout == Layout.three)
|
|
|
|
setState(() {
|
|
|
|
_layout = Layout.one;
|
|
|
|
});
|
|
|
|
else if (_layout == Layout.two)
|
|
|
|
setState(() {
|
|
|
|
_layout = Layout.three;
|
|
|
|
});
|
|
|
|
else
|
|
|
|
setState(() {
|
|
|
|
_layout = Layout.two;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
icon: _layout == Layout.three
|
|
|
|
? IconPainter(
|
|
|
|
LayoutPainter(0, context.textColor),
|
|
|
|
)
|
|
|
|
: _layout == Layout.two
|
|
|
|
? IconPainter(
|
|
|
|
LayoutPainter(1, context.textColor),
|
|
|
|
)
|
|
|
|
: IconPainter(
|
|
|
|
LayoutPainter(4, context.textColor),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 10)
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-03-01 13:17:06 +01:00
|
|
|
Color _color = widget.podcastLocal.primaryColor.colorizedark();
|
2020-07-02 14:58:55 +02:00
|
|
|
final s = context.s;
|
2020-02-22 13:25:06 +01:00
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
2020-03-19 20:58:30 +01:00
|
|
|
statusBarIconBrightness: Brightness.dark,
|
2020-02-22 13:25:06 +01:00
|
|
|
systemNavigationBarColor: Theme.of(context).primaryColor,
|
2020-03-19 20:58:30 +01:00
|
|
|
systemNavigationBarIconBrightness:
|
|
|
|
Theme.of(context).accentColorBrightness,
|
|
|
|
//statusBarColor: _color,
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Scaffold(
|
|
|
|
body: SafeArea(
|
|
|
|
top: false,
|
2020-06-03 14:39:15 +02:00
|
|
|
minimum: widget.hide ? EdgeInsets.only(bottom: 50) : EdgeInsets.zero,
|
2020-03-19 20:58:30 +01:00
|
|
|
child: RefreshIndicator(
|
|
|
|
key: _refreshIndicatorKey,
|
|
|
|
color: Theme.of(context).accentColor,
|
2020-04-22 20:10:57 +02:00
|
|
|
onRefresh: () async {
|
2020-07-04 16:42:56 +02:00
|
|
|
await _updateRssItem(context, widget.podcastLocal);
|
2020-04-23 19:46:36 +02:00
|
|
|
// audio.addNewEpisode(widget.podcastLocal.id);
|
2020-04-22 20:10:57 +02:00
|
|
|
},
|
2020-03-19 20:58:30 +01:00
|
|
|
child: Stack(
|
|
|
|
children: <Widget>[
|
2020-03-25 16:33:48 +01:00
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: FutureBuilder<List<EpisodeBrief>>(
|
2020-07-23 20:42:25 +02:00
|
|
|
future: _getRssItem(widget.podcastLocal,
|
|
|
|
count: _top,
|
|
|
|
reverse: _reverse,
|
|
|
|
filter: _filter,
|
|
|
|
query: _query),
|
2020-03-25 16:33:48 +01:00
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
return (snapshot.hasData)
|
|
|
|
? CustomScrollView(
|
|
|
|
controller: _controller
|
|
|
|
..addListener(() async {
|
|
|
|
if (_controller.offset ==
|
|
|
|
_controller
|
|
|
|
.position.maxScrollExtent &&
|
|
|
|
snapshot.data.length == _top) {
|
|
|
|
if (mounted)
|
|
|
|
setState(() => _loadMore = true);
|
|
|
|
await Future.delayed(
|
|
|
|
Duration(seconds: 3));
|
|
|
|
if (mounted)
|
|
|
|
setState(() {
|
2020-07-23 20:42:25 +02:00
|
|
|
_top = _top + 36;
|
2020-03-25 16:33:48 +01:00
|
|
|
_loadMore = false;
|
|
|
|
});
|
|
|
|
}
|
2020-06-07 14:47:28 +02:00
|
|
|
if (_controller.offset > 0 &&
|
|
|
|
mounted &&
|
|
|
|
!_scroll)
|
2020-07-23 20:42:25 +02:00
|
|
|
setState(() => _scroll = true);
|
2020-03-25 16:33:48 +01:00
|
|
|
}),
|
2020-04-11 19:23:12 +02:00
|
|
|
physics:
|
|
|
|
const AlwaysScrollableScrollPhysics(),
|
2020-03-25 16:33:48 +01:00
|
|
|
slivers: <Widget>[
|
|
|
|
SliverAppBar(
|
|
|
|
brightness: Brightness.dark,
|
2020-07-24 16:10:08 +02:00
|
|
|
actions: <Widget>[_rightTopMenu(context)],
|
2020-03-25 16:33:48 +01:00
|
|
|
elevation: 0,
|
|
|
|
iconTheme: IconThemeData(
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
2020-07-23 20:42:25 +02:00
|
|
|
expandedHeight: 150 + context.paddingTop,
|
2020-03-25 16:33:48 +01:00
|
|
|
backgroundColor: _color,
|
|
|
|
floating: true,
|
|
|
|
pinned: true,
|
2020-07-23 20:42:25 +02:00
|
|
|
flexibleSpace: LayoutBuilder(
|
|
|
|
builder: (context, constraints) {
|
2020-03-25 16:33:48 +01:00
|
|
|
_topHeight = constraints.biggest.height;
|
|
|
|
return FlexibleSpaceBar(
|
|
|
|
background: Stack(
|
2020-03-19 20:58:30 +01:00
|
|
|
children: <Widget>[
|
2020-03-25 16:33:48 +01:00
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(
|
|
|
|
top: 120 +
|
2020-07-23 20:42:25 +02:00
|
|
|
context.paddingTop),
|
2020-03-25 16:33:48 +01:00
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 80, right: 120),
|
|
|
|
color: Colors.white10,
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.start,
|
|
|
|
mainAxisSize:
|
|
|
|
MainAxisSize.min,
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
widget.podcastLocal
|
|
|
|
.author ??
|
|
|
|
'',
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow
|
|
|
|
.ellipsis,
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
Colors.white)),
|
2020-07-23 20:42:25 +02:00
|
|
|
if (widget.podcastLocal
|
|
|
|
.provider.isNotEmpty)
|
|
|
|
Text(
|
|
|
|
s.hostedOn(widget
|
|
|
|
.podcastLocal
|
|
|
|
.provider),
|
|
|
|
maxLines: 1,
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
Colors.white),
|
|
|
|
),
|
2020-03-25 16:33:48 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
alignment:
|
|
|
|
Alignment.centerRight,
|
|
|
|
padding:
|
|
|
|
EdgeInsets.only(right: 10),
|
|
|
|
child: SizedBox(
|
|
|
|
height: 120,
|
|
|
|
child: Image.file(File(
|
|
|
|
"${widget.podcastLocal.imagePath}")),
|
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
2020-03-25 16:33:48 +01:00
|
|
|
Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: podcastInfo(context),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-03-25 16:33:48 +01:00
|
|
|
title: _topHeight <
|
2020-07-23 20:42:25 +02:00
|
|
|
70 + context.paddingTop
|
2020-03-25 16:33:48 +01:00
|
|
|
? Text(widget.podcastLocal.title,
|
2020-03-19 20:58:30 +01:00
|
|
|
maxLines: 1,
|
|
|
|
overflow:
|
|
|
|
TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
2020-03-25 16:33:48 +01:00
|
|
|
color: Colors.white))
|
|
|
|
: Center(),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
),
|
2020-04-11 19:23:12 +02:00
|
|
|
SliverToBoxAdapter(
|
2020-06-03 14:39:15 +02:00
|
|
|
child: hostsList(context, _hosts),
|
2020-04-11 19:23:12 +02:00
|
|
|
),
|
|
|
|
SliverToBoxAdapter(
|
2020-07-24 16:10:08 +02:00
|
|
|
child: _actionBar(context)),
|
2020-03-25 16:33:48 +01:00
|
|
|
EpisodeGrid(
|
|
|
|
episodes: snapshot.data,
|
|
|
|
showFavorite: true,
|
2020-07-24 16:10:08 +02:00
|
|
|
showNumber: _filter == Filter.all &&
|
|
|
|
!_hideListened
|
|
|
|
? true
|
|
|
|
: false,
|
2020-04-11 19:23:12 +02:00
|
|
|
layout: _layout,
|
|
|
|
reverse: _reverse,
|
2020-06-03 14:39:15 +02:00
|
|
|
episodeCount: _episodeCount,
|
2020-06-05 20:33:47 +02:00
|
|
|
initNum: _scroll ? 0 : 12,
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
2020-03-25 16:33:48 +01:00
|
|
|
SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
(BuildContext context, int index) {
|
|
|
|
return _loadMore
|
|
|
|
? Container(
|
|
|
|
height: 2,
|
|
|
|
child:
|
|
|
|
LinearProgressIndicator())
|
|
|
|
: Center();
|
|
|
|
},
|
|
|
|
childCount: 1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: Center(child: CircularProgressIndicator());
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Selector<AudioPlayerNotifier, bool>(
|
|
|
|
selector: (_, audio) => audio.playerRunning,
|
|
|
|
builder: (_, data, __) {
|
|
|
|
return Padding(
|
|
|
|
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
],
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
|
|
|
Container(child: PlayerWidget()),
|
|
|
|
],
|
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-03-19 20:58:30 +01:00
|
|
|
),
|
2020-02-22 13:25:06 +01:00
|
|
|
),
|
2020-02-09 13:29:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-02-23 14:20:07 +01:00
|
|
|
|
|
|
|
class AboutPodcast extends StatefulWidget {
|
|
|
|
final PodcastLocal podcastLocal;
|
|
|
|
AboutPodcast({this.podcastLocal, Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_AboutPodcastState createState() => _AboutPodcastState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AboutPodcastState extends State<AboutPodcast> {
|
|
|
|
String _description;
|
|
|
|
bool _load;
|
|
|
|
bool _expand;
|
|
|
|
void getDescription(String id) async {
|
|
|
|
var dbHelper = DBHelper();
|
|
|
|
String description = await dbHelper.getFeedDescription(id);
|
|
|
|
if (description == null || description.isEmpty) {
|
|
|
|
_description = '';
|
|
|
|
} else {
|
|
|
|
var doc = parse(description);
|
|
|
|
_description = parse(doc.body.text).documentElement.text;
|
|
|
|
}
|
2020-06-03 14:39:15 +02:00
|
|
|
if (mounted) setState(() => _load = true);
|
2020-02-23 14:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_load = false;
|
|
|
|
_expand = false;
|
|
|
|
getDescription(widget.podcastLocal.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return !_load
|
|
|
|
? Center()
|
|
|
|
: 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(
|
2020-02-25 10:57:12 +01:00
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2020-03-21 17:14:10 +01:00
|
|
|
Linkify(
|
|
|
|
onOpen: (link) {
|
2020-07-24 16:10:08 +02:00
|
|
|
link.url.launchUrl;
|
2020-03-21 17:14:10 +01:00
|
|
|
},
|
|
|
|
text: _description,
|
|
|
|
linkStyle: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
textBaseline: TextBaseline.ideographic),
|
2020-02-23 14:20:07 +01:00
|
|
|
maxLines: 3,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
2020-02-25 10:57:12 +01:00
|
|
|
],
|
|
|
|
)
|
2020-03-21 17:14:10 +01:00
|
|
|
: Linkify(
|
|
|
|
onOpen: (link) {
|
2020-07-24 16:10:08 +02:00
|
|
|
link.url.launchUrl;
|
2020-03-21 17:14:10 +01:00
|
|
|
},
|
|
|
|
text: _description,
|
|
|
|
linkStyle: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
textBaseline: TextBaseline.ideographic),
|
|
|
|
),
|
2020-02-23 14:20:07 +01:00
|
|
|
);
|
|
|
|
} else {
|
2020-03-21 17:14:10 +01:00
|
|
|
return Linkify(
|
|
|
|
text: _description,
|
|
|
|
onOpen: (link) {
|
2020-07-24 16:10:08 +02:00
|
|
|
link.url.launchUrl;
|
2020-03-21 17:14:10 +01:00
|
|
|
},
|
|
|
|
linkStyle: TextStyle(
|
|
|
|
color: Theme.of(context).accentColor,
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
textBaseline: TextBaseline.ideographic),
|
2020-03-01 13:17:06 +01:00
|
|
|
);
|
2020-02-23 14:20:07 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-07-23 20:42:25 +02:00
|
|
|
|
|
|
|
class SearchEpisdoe extends StatefulWidget {
|
|
|
|
SearchEpisdoe({this.onSearch, Key key}) : super(key: key);
|
|
|
|
final ValueChanged<String> onSearch;
|
|
|
|
@override
|
|
|
|
_SearchEpisodeState createState() => _SearchEpisodeState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SearchEpisodeState extends State<SearchEpisdoe> {
|
|
|
|
TextEditingController _controller;
|
|
|
|
String _query;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_controller = TextEditingController();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final s = context.s;
|
|
|
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
|
value: SystemUiOverlayStyle(
|
|
|
|
statusBarIconBrightness: Brightness.light,
|
|
|
|
systemNavigationBarColor:
|
|
|
|
Theme.of(context).brightness == Brightness.light
|
|
|
|
? Color.fromRGBO(113, 113, 113, 1)
|
|
|
|
: Color.fromRGBO(5, 5, 5, 1),
|
|
|
|
),
|
|
|
|
child: AlertDialog(
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10))),
|
|
|
|
elevation: 1,
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
titlePadding:
|
|
|
|
const EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 20),
|
|
|
|
actionsPadding: EdgeInsets.all(0),
|
|
|
|
actions: <Widget>[
|
|
|
|
FlatButton(
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
child: Text(
|
|
|
|
s.cancel,
|
|
|
|
style: TextStyle(color: Colors.grey[600]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
FlatButton(
|
|
|
|
onPressed: (_query != null && _query != '')
|
|
|
|
? () {
|
|
|
|
{
|
|
|
|
widget.onSearch(_query);
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
: null,
|
2020-07-24 16:10:08 +02:00
|
|
|
child:
|
|
|
|
Text(s.confirm, style: TextStyle(color: context.accentColor)),
|
2020-07-23 20:42:25 +02:00
|
|
|
)
|
|
|
|
],
|
2020-07-24 16:10:08 +02:00
|
|
|
title: SizedBox(width: context.width - 160, child: Text(s.search)),
|
2020-07-23 20:42:25 +02:00
|
|
|
content: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
TextField(
|
|
|
|
decoration: InputDecoration(
|
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 10),
|
2020-07-24 16:10:08 +02:00
|
|
|
hintText: s.searchEpisode,
|
2020-07-23 20:42:25 +02:00
|
|
|
hintStyle: TextStyle(fontSize: 18),
|
|
|
|
filled: true,
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
borderSide:
|
|
|
|
BorderSide(color: context.accentColor, width: 2.0),
|
|
|
|
),
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
borderSide:
|
|
|
|
BorderSide(color: context.accentColor, width: 2.0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
cursorRadius: Radius.circular(2),
|
|
|
|
autofocus: true,
|
|
|
|
maxLines: 1,
|
|
|
|
controller: _controller,
|
|
|
|
onChanged: (value) {
|
|
|
|
_query = value;
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|