Minor change.

This commit is contained in:
stonegate 2020-10-01 00:15:41 +08:00
parent a70103c3eb
commit 36a23f2de5
5 changed files with 91 additions and 33 deletions

View File

@ -546,6 +546,7 @@ class __PlaylistButtonState extends State<_PlaylistButton> {
var audio = context.watch<AudioPlayerNotifier>();
final s = context.s;
return Material(
color: Colors.transparent,
child: MyPopupMenuButton<int>(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10))),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:line_icons/line_icons.dart';
import 'package:provider/provider.dart';
import '../local_storage/key_value_storage.dart';
@ -171,9 +172,49 @@ class DiscoveryPageState extends State<DiscoveryPage> {
future: _getHideDiscovery(),
initialData: true,
builder: (context, snapshot) => snapshot.data
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [_historyList(), Spacer()],
? SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_historyList(),
SizedBox(height: 100),
SizedBox(
height: 150,
child: Center(
child: Icon(
Icons.search,
size: 80,
color: Colors.grey[400],
),
),
),
SizedBox(
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
LineIcons.microphone_solid,
size: 30,
color: Colors.redAccent,
),
SizedBox(width: 50),
Icon(
LineIcons.broadcast_tower_solid,
size: 30,
color: Colors.deepPurple,
),
SizedBox(width: 50),
Icon(
LineIcons.rss_square_solid,
size: 30,
color: Colors.blueGrey,
),
],
),
),
],
),
)
: PodcastSlideup(
searchEngine: SearchEngine.listenNotes,

View File

@ -128,25 +128,16 @@ class MyHomePageDelegate extends SearchDelegate<int> {
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
elevation: 1,
icon: snapshot.data == SearchEngine.podcastIndex
? SizedBox(
height: 30,
width: 30,
child: CircleAvatar(
backgroundImage: AssetImage('assets/podcastindex_logo.png'),
backgroundColor: Colors.redAccent[700].withAlpha(70),
maxRadius: 25,
),
)
: SizedBox(
height: 30,
width: 30,
child: CircleAvatar(
backgroundImage: AssetImage('assets/listennotes_logo.png'),
backgroundColor: Colors.red.withAlpha(70),
maxRadius: 25,
),
),
icon: SizedBox(
height: 30,
width: 30,
child: CircleAvatar(
backgroundImage: snapshot.data == SearchEngine.podcastIndex
? AssetImage('assets/podcastindex_logo.png')
: AssetImage('assets/listennotes_logo.png'),
maxRadius: 25,
),
),
onSelected: (value) {
_searchEngine = value;
showSuggestions(context);
@ -175,7 +166,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
padding: EdgeInsets.only(left: 10),
child: Row(
children: <Widget>[
Text('PodcastIndex'),
Text('Podcastindex'),
Spacer(),
if (_searchEngine == SearchEngine.podcastIndex)
DotIndicator()
@ -186,6 +177,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
],
),
),
SizedBox(width: 10),
];
}
@ -509,7 +501,19 @@ class __ListenNotesSearchState extends State<_ListenNotesSearch> {
)
],
),
)
),
SliverToBoxAdapter(
child: SizedBox(
height: 20,
child: Center(
child: Image(
image: context.brightness == Brightness.light
? AssetImage('assets/listennotes.png')
: AssetImage('assets/listennotes_light.png'),
height: 15,
),
),
))
],
);
},
@ -531,6 +535,7 @@ class __PodcastIndexSearchState extends State<_PodcastIndexSearch> {
bool _loading;
Future _searchFuture;
List _podcastList = [];
final _searchEngine = PodcastsIndexSearch();
Future<void> _saveHistory(String query) async {
final storage = KeyValueStorage(searchHistoryKey);
@ -554,10 +559,9 @@ class __PodcastIndexSearchState extends State<_PodcastIndexSearch> {
Future<List<OnlinePodcast>> _getPodcatsIndexList(String searchText,
{int limit}) async {
if (_limit == 20) _saveHistory(searchText);
final searchEngine = PodcastsIndexSearch();
var searchResult =
await searchEngine.searchPodcasts(searchText: searchText, limit: limit);
if (_limit == 10) _saveHistory(searchText);
var searchResult = await _searchEngine.searchPodcasts(
searchText: searchText, limit: limit);
var list = searchResult.feeds.cast();
_podcastList = <OnlinePodcast>[
for (var podcast in list) podcast.toOnlinePodcast
@ -626,7 +630,17 @@ class __PodcastIndexSearchState extends State<_PodcastIndexSearch> {
)
],
),
)
),
SliverToBoxAdapter(
child: SizedBox(
height: 20,
child: Center(
child: Image(
image: AssetImage('assets/podcastindex.png'),
height: 15,
),
),
))
],
);
}),

View File

@ -104,9 +104,9 @@ class PodcastsIndexSearch {
}
Future<PodcastIndexSearchResult<dynamic>> searchPodcasts(
{String searchText, int limit}) async {
{String searchText, int limit = 99}) async {
final url = "$_baseUrl/api/1.0/search/byterm"
"?q=${Uri.encodeComponent(searchText)}&max=$limit";
"?q=${Uri.encodeComponent(searchText)}&max=$limit&fulltext=true";
final headers = _initSearch();
final response = await _dio.get(url, options: Options(headers: headers));
Map searchResultMap = jsonDecode(response.toString());

View File

@ -57,6 +57,10 @@ class RefreshWorker extends ChangeNotifier {
Future<void> start(List<String> podcasts) async {
if (!_created) {
if (podcasts.isEmpty) {
final refreshstorage = KeyValueStorage(refreshdateKey);
await refreshstorage.saveInt(DateTime.now().millisecondsSinceEpoch);
}
_complete = false;
await _createIsolate();
_listen(podcasts);
@ -79,8 +83,6 @@ Future<void> refreshIsolateEntryPoint(SendPort sendPort) async {
Future<void> _refreshAll(List<String> podcasts) async {
var podcastList;
if (podcasts.isEmpty) {
var refreshstorage = KeyValueStorage(refreshdateKey);
await refreshstorage.saveInt(DateTime.now().millisecondsSinceEpoch);
podcastList = await _dbHelper.getPodcastLocalAll(updateOnly: true);
} else {
podcastList = await _dbHelper.getPodcastLocal(podcasts, updateOnly: true);