mirror of
https://github.com/stonega/tsacdop
synced 2025-02-18 04:20:37 +01:00
Update discovery page.
This commit is contained in:
parent
fa171ce307
commit
8ea216468a
@ -8,7 +8,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:line_icons/line_icons.dart';
|
import 'package:line_icons/line_icons.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tsacdop/state/search_state.dart';
|
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
import '../local_storage/key_value_storage.dart';
|
import '../local_storage/key_value_storage.dart';
|
||||||
@ -1282,7 +1281,7 @@ class _MyDownload extends StatefulWidget {
|
|||||||
class _MyDownloadState extends State<_MyDownload>
|
class _MyDownloadState extends State<_MyDownload>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
Layout _layout;
|
Layout _layout;
|
||||||
int _sortBy = 0;
|
int _sortBy;
|
||||||
bool _hideListened;
|
bool _hideListened;
|
||||||
Future<List<EpisodeBrief>> _getDownloadedEpisodes(int sortBy,
|
Future<List<EpisodeBrief>> _getDownloadedEpisodes(int sortBy,
|
||||||
{bool hideListened}) async {
|
{bool hideListened}) async {
|
||||||
@ -1299,6 +1298,12 @@ class _MyDownloadState extends State<_MyDownload>
|
|||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_sortBy = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
|
@ -23,9 +23,7 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
Genre _selectedGenre;
|
Genre _selectedGenre;
|
||||||
Genre get selectedGenre => _selectedGenre;
|
Genre get selectedGenre => _selectedGenre;
|
||||||
final List<OnlinePodcast> _podcastList = [];
|
final List<OnlinePodcast> _podcastList = [];
|
||||||
bool _loading;
|
|
||||||
Future _searchTopPodcast;
|
Future _searchTopPodcast;
|
||||||
int _page;
|
|
||||||
Future<List<String>> _getSearchHistory() {
|
Future<List<String>> _getSearchHistory() {
|
||||||
final storage = KeyValueStorage(searchHistoryKey);
|
final storage = KeyValueStorage(searchHistoryKey);
|
||||||
final history = storage.getStringList();
|
final history = storage.getStringList();
|
||||||
@ -125,7 +123,6 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
final podcastTopList =
|
final podcastTopList =
|
||||||
searchResult.podcasts.map((e) => e?.toOnlinePodcast).toList();
|
searchResult.podcasts.map((e) => e?.toOnlinePodcast).toList();
|
||||||
_podcastList.addAll(podcastTopList.cast());
|
_podcastList.addAll(podcastTopList.cast());
|
||||||
_loading = false;
|
|
||||||
return _podcastList;
|
return _podcastList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +134,7 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
? SingleChildScrollView(
|
? SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
FutureBuilder<List<String>>(
|
FutureBuilder<List<String>>(
|
||||||
future: _getSearchHistory(),
|
future: _getSearchHistory(),
|
||||||
@ -147,13 +144,15 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
final history = snapshot.data;
|
final history = snapshot.data;
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 50,
|
height: 50,
|
||||||
child: Row(
|
child: Wrap(
|
||||||
|
direction: Axis.horizontal,
|
||||||
children: history
|
children: history
|
||||||
.map<Widget>((e) => Padding(
|
.map<Widget>((e) => Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
8, 8, 0, 8),
|
||||||
child: FlatButton.icon(
|
child: FlatButton.icon(
|
||||||
color: Colors.accents[
|
color: Colors
|
||||||
math.Random().nextInt(10)]
|
.accents[history.indexOf(e)]
|
||||||
.withAlpha(70),
|
.withAlpha(70),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius:
|
borderRadius:
|
||||||
@ -175,6 +174,12 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
height: 1,
|
height: 1,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(20, 10, 10, 4),
|
||||||
|
child: Text('Popular',
|
||||||
|
style: context.textTheme.headline6
|
||||||
|
.copyWith(color: context.accentColor)),
|
||||||
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 200,
|
height: 200,
|
||||||
child: FutureBuilder<List<OnlinePodcast>>(
|
child: FutureBuilder<List<OnlinePodcast>>(
|
||||||
@ -200,8 +205,11 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
BorderRadius.circular(10),
|
BorderRadius.circular(10),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => searchState
|
onTap: () {
|
||||||
.selectedPodcast = podcast,
|
searchState.selectedPodcast =
|
||||||
|
podcast;
|
||||||
|
widget.onTap('');
|
||||||
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.all(4.0),
|
const EdgeInsets.all(4.0),
|
||||||
@ -254,12 +262,22 @@ class DiscoveryPageState extends State<DiscoveryPage> {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(20, 10, 10, 4),
|
||||||
|
child: Text('Categories',
|
||||||
|
style: context.textTheme.headline6
|
||||||
|
.copyWith(color: context.accentColor)),
|
||||||
|
),
|
||||||
ListView(
|
ListView(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: NeverScrollableScrollPhysics(),
|
physics: NeverScrollableScrollPhysics(),
|
||||||
children: genres
|
children: genres
|
||||||
.map<Widget>((e) => ListTile(
|
.map<Widget>((e) => ListTile(
|
||||||
onTap: () => setState(() => _selectedGenre = e),
|
contentPadding: EdgeInsets.fromLTRB(20, 0, 20, 0),
|
||||||
|
onTap: () {
|
||||||
|
widget.onTap('');
|
||||||
|
setState(() => _selectedGenre = e);
|
||||||
|
},
|
||||||
title: Text(e.name),
|
title: Text(e.name),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
@ -331,6 +349,14 @@ class __TopPodcastListState extends State<_TopPodcastList> {
|
|||||||
final content = snapshot.data;
|
final content = snapshot.data;
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(20, 10, 10, 4),
|
||||||
|
child: Text(widget.genre.name,
|
||||||
|
style: context.textTheme.headline6
|
||||||
|
.copyWith(color: context.accentColor)),
|
||||||
|
),
|
||||||
|
),
|
||||||
SliverList(
|
SliverList(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(context, index) {
|
||||||
|
@ -108,6 +108,7 @@ class MyHomePageDelegate extends SearchDelegate<int> {
|
|||||||
icon: const Icon(Icons.clear),
|
icon: const Icon(Icons.clear),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
query = '';
|
query = '';
|
||||||
|
showResults(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@ -122,18 +123,6 @@ class MyHomePageDelegate extends SearchDelegate<int> {
|
|||||||
query = history;
|
query = history;
|
||||||
showResults(context);
|
showResults(context);
|
||||||
});
|
});
|
||||||
// return Container(
|
|
||||||
// height: 10,
|
|
||||||
// width: 10,
|
|
||||||
// margin: EdgeInsets.only(top: 400),
|
|
||||||
// child: SizedBox(
|
|
||||||
// height: 10,
|
|
||||||
// child: Image.asset(
|
|
||||||
// 'assets/listennotes.png',
|
|
||||||
// fit: BoxFit.fill,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
} else if (rssExp.stringMatch(query) != null) {
|
} else if (rssExp.stringMatch(query) != null) {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: getRss(rssExp.stringMatch(query)),
|
future: getRss(rssExp.stringMatch(query)),
|
||||||
@ -222,40 +211,7 @@ class _RssResultState extends State<RssResult> {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: context.textTheme.headline5),
|
style: context.textTheme.headline5),
|
||||||
),
|
),
|
||||||
!_isSubscribed
|
SubscribeButton(_onlinePodcast),
|
||||||
? OutlineButton(
|
|
||||||
highlightedBorderColor: context.accentColor,
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: context.accentColor, width: 2),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(100.0),
|
|
||||||
side:
|
|
||||||
BorderSide(color: context.accentColor)),
|
|
||||||
splashColor:
|
|
||||||
context.accentColor.withOpacity(0.5),
|
|
||||||
child: Text(s.subscribe,
|
|
||||||
style:
|
|
||||||
TextStyle(color: context.accentColor)),
|
|
||||||
onPressed: () {
|
|
||||||
_subscribePodcast(_onlinePodcast);
|
|
||||||
setState(() {
|
|
||||||
_isSubscribed = true;
|
|
||||||
});
|
|
||||||
Fluttertoast.showToast(
|
|
||||||
msg: s.podcastSubscribed,
|
|
||||||
gravity: ToastGravity.BOTTOM,
|
|
||||||
);
|
|
||||||
})
|
|
||||||
: OutlineButton(
|
|
||||||
color: context.accentColor.withOpacity(0.5),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(100.0),
|
|
||||||
side: BorderSide(color: Colors.grey[500])),
|
|
||||||
highlightedBorderColor: Colors.grey[500],
|
|
||||||
disabledTextColor: Colors.grey[500],
|
|
||||||
child: Text(s.subscribe),
|
|
||||||
disabledBorderColor: Colors.grey[500],
|
|
||||||
onPressed: () {})
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -400,7 +356,7 @@ class _SearchListState extends State<SearchList> {
|
|||||||
final storage = KeyValueStorage(searchHistoryKey);
|
final storage = KeyValueStorage(searchHistoryKey);
|
||||||
final history = await storage.getStringList();
|
final history = await storage.getStringList();
|
||||||
if (!history.contains(query)) {
|
if (!history.contains(query)) {
|
||||||
if (history.length == 10) {
|
if (history.length >= 6) {
|
||||||
history.removeLast();
|
history.removeLast();
|
||||||
}
|
}
|
||||||
history.insert(0, query);
|
history.insert(0, query);
|
||||||
@ -623,7 +579,7 @@ class _SearchResultDetailState extends State<SearchResultDetail>
|
|||||||
return _episodeList;
|
return _episodeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
_start(DragStartDetails event) {
|
void _start(DragStartDetails event) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_startdy = event.localPosition.dy;
|
_startdy = event.localPosition.dy;
|
||||||
_animation =
|
_animation =
|
||||||
@ -632,7 +588,7 @@ class _SearchResultDetailState extends State<SearchResultDetail>
|
|||||||
_controller.forward();
|
_controller.forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
_update(DragUpdateDetails event) {
|
void _update(DragUpdateDetails event) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_move = _startdy - event.localPosition.dy;
|
_move = _startdy - event.localPosition.dy;
|
||||||
_animation = Tween<double>(begin: _initSize, end: _initSize + _move)
|
_animation = Tween<double>(begin: _initSize, end: _initSize + _move)
|
||||||
@ -642,7 +598,7 @@ class _SearchResultDetailState extends State<SearchResultDetail>
|
|||||||
_controller.forward();
|
_controller.forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
_end() {
|
void _end() {
|
||||||
if (_slideDirection == SlideDirection.up) {
|
if (_slideDirection == SlideDirection.up) {
|
||||||
if (_move > 20) {
|
if (_move > 20) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -920,7 +876,7 @@ class SubscribeButton extends StatelessWidget {
|
|||||||
final subscribeWorker = context.watch<GroupList>();
|
final subscribeWorker = context.watch<GroupList>();
|
||||||
final searchState = context.watch<SearchState>();
|
final searchState = context.watch<SearchState>();
|
||||||
final s = context.s;
|
final s = context.s;
|
||||||
subscribePodcast(OnlinePodcast podcast) {
|
void subscribePodcast(OnlinePodcast podcast) {
|
||||||
var item = SubscribeItem(podcast.rss, podcast.title,
|
var item = SubscribeItem(podcast.rss, podcast.title,
|
||||||
imgUrl: podcast.image, group: 'Home');
|
imgUrl: podcast.image, group: 'Home');
|
||||||
subscribeWorker.setSubscribeItem(item);
|
subscribeWorker.setSubscribeItem(item);
|
||||||
@ -940,12 +896,12 @@ class SubscribeButton extends StatelessWidget {
|
|||||||
child: Text(s.subscribe,
|
child: Text(s.subscribe,
|
||||||
style: TextStyle(color: context.accentColor)),
|
style: TextStyle(color: context.accentColor)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
subscribePodcast(onlinePodcast);
|
|
||||||
searchState.addPodcast(onlinePodcast);
|
|
||||||
Fluttertoast.showToast(
|
Fluttertoast.showToast(
|
||||||
msg: s.podcastSubscribed,
|
msg: s.podcastSubscribed,
|
||||||
gravity: ToastGravity.BOTTOM,
|
gravity: ToastGravity.BOTTOM,
|
||||||
);
|
);
|
||||||
|
subscribePodcast(onlinePodcast);
|
||||||
|
searchState.addPodcast(onlinePodcast);
|
||||||
})
|
})
|
||||||
: OutlineButton(
|
: OutlineButton(
|
||||||
color: context.accentColor.withOpacity(0.5),
|
color: context.accentColor.withOpacity(0.5),
|
||||||
|
@ -3,9 +3,9 @@ import 'dart:convert';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
|
||||||
import '../.env.dart';
|
import '../.env.dart';
|
||||||
|
import '../type/search_top_podcast.dart';
|
||||||
import '../type/searchepisodes.dart';
|
import '../type/searchepisodes.dart';
|
||||||
import '../type/searchpodcast.dart';
|
import '../type/searchpodcast.dart';
|
||||||
import '../type/search_top_podcast.dart';
|
|
||||||
|
|
||||||
class SearchEngine {
|
class SearchEngine {
|
||||||
final apiKey = environment['apiKey'];
|
final apiKey = environment['apiKey'];
|
||||||
|
@ -3,7 +3,7 @@ import '../type/searchpodcast.dart';
|
|||||||
|
|
||||||
class SearchState extends ChangeNotifier {
|
class SearchState extends ChangeNotifier {
|
||||||
final List<OnlinePodcast> _subscribedList = [];
|
final List<OnlinePodcast> _subscribedList = [];
|
||||||
bool _update;
|
bool _update = false;
|
||||||
List<OnlinePodcast> get subscribedList => _subscribedList;
|
List<OnlinePodcast> get subscribedList => _subscribedList;
|
||||||
bool get update => _update;
|
bool get update => _update;
|
||||||
OnlinePodcast _selectedPodcast;
|
OnlinePodcast _selectedPodcast;
|
||||||
|
@ -5,25 +5,25 @@ class Genre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var genres = [
|
var genres = [
|
||||||
|
Genre(id: '100', name: 'Arts'),
|
||||||
|
Genre(id: '99', name: 'News'),
|
||||||
Genre(id: '144', name: 'Personal Finance'),
|
Genre(id: '144', name: 'Personal Finance'),
|
||||||
Genre(id: '151', name: 'Locally Focused'),
|
Genre(id: '151', name: 'Locally Focused'),
|
||||||
|
Genre(id: '107', name: 'Science'),
|
||||||
|
Genre(id: '77', name: 'Sports'),
|
||||||
|
Genre(id: '134', name: 'Music'),
|
||||||
|
Genre(id: '125', name: 'History'),
|
||||||
Genre(id: '68', name: 'TV & Film'),
|
Genre(id: '68', name: 'TV & Film'),
|
||||||
Genre(id: '127', name: 'Technology'),
|
Genre(id: '127', name: 'Technology'),
|
||||||
Genre(id: '135', name: 'True Crime'),
|
Genre(id: '135', name: 'True Crime'),
|
||||||
Genre(id: '100', name: 'Arts'),
|
|
||||||
Genre(id: '93', name: 'Business'),
|
Genre(id: '93', name: 'Business'),
|
||||||
Genre(id: '67', name: 'Comedy'),
|
Genre(id: '67', name: 'Comedy'),
|
||||||
Genre(id: '111', name: 'Education'),
|
Genre(id: '111', name: 'Education'),
|
||||||
Genre(id: '168', name: 'Fiction'),
|
Genre(id: '168', name: 'Fiction'),
|
||||||
Genre(id: '117', name: 'Government'),
|
|
||||||
Genre(id: '88', name: 'Health & Fitness'),
|
Genre(id: '88', name: 'Health & Fitness'),
|
||||||
Genre(id: '125', name: 'History'),
|
|
||||||
Genre(id: '132', name: 'Kids & Family'),
|
Genre(id: '132', name: 'Kids & Family'),
|
||||||
Genre(id: '82', name: 'Leisure'),
|
Genre(id: '82', name: 'Leisure'),
|
||||||
Genre(id: '134', name: 'Music'),
|
|
||||||
Genre(id: '99', name: 'News'),
|
|
||||||
Genre(id: '69', name: 'Religion & Spirituality'),
|
Genre(id: '69', name: 'Religion & Spirituality'),
|
||||||
Genre(id: '107', name: 'Science'),
|
|
||||||
Genre(id: '122', name: 'Society & Culture'),
|
Genre(id: '122', name: 'Society & Culture'),
|
||||||
Genre(id: '77', name: 'Sports'),
|
Genre(id: '117', name: 'Government'),
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user