1
0
mirror of https://github.com/stonega/tsacdop synced 2025-03-05 19:58:11 +01:00

Improve serach result UI.

This commit is contained in:
stonegate 2020-07-22 20:39:25 +08:00
parent b619be9a9b
commit d7b6212cac
11 changed files with 94 additions and 77 deletions

View File

@ -14,7 +14,6 @@ import '../state/audio_state.dart';
import '../local_storage/sqflite_localpodcast.dart';
import '../local_storage/key_value_storage.dart';
import '../util/pageroute.dart';
import '../util/colorize.dart';
import '../util/extension_helper.dart';
import '../util/custompaint.dart';
import '../util/custom_slider.dart';

View File

@ -19,7 +19,6 @@ import '../type/podcastlocal.dart';
import '../state/audio_state.dart';
import '../util/custompaint.dart';
import '../util/pageroute.dart';
import '../util/colorize.dart';
import '../util/extension_helper.dart';
import '../local_storage/sqflite_localpodcast.dart';
import '../local_storage/key_value_storage.dart';

View File

@ -13,7 +13,6 @@ import '../type/episodebrief.dart';
import '../type/playlist.dart';
import '../util/extension_helper.dart';
import '../util/custompaint.dart';
import '../util/colorize.dart';
class PlaylistPage extends StatefulWidget {
@override

View File

@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:color_thief_flutter/color_thief_flutter.dart';
import 'package:dio/dio.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:fluttertoast/fluttertoast.dart';
@ -67,7 +66,6 @@ class MyHomePageDelegate extends SearchDelegate<int> {
@override
Widget buildSuggestions(BuildContext context) {
// if (query.isEmpty)
return Center(
child: Container(
padding: EdgeInsets.only(top: 100),
@ -240,20 +238,20 @@ class _RssResultState extends State<RssResult> {
imageUrl: _onlinePodcast.image,
progressIndicatorBuilder: (context, url, downloadProgress) =>
Container(
height: 40,
width: 40,
height: 120,
width: 120,
alignment: Alignment.center,
color: context.primaryColorDark,
child: SizedBox(
width: 20,
width: 40,
height: 2,
child: LinearProgressIndicator(
value: downloadProgress.progress),
),
),
errorWidget: (context, url, error) => Container(
width: 40,
height: 40,
width: 120,
height: 120,
alignment: Alignment.center,
color: context.primaryColorDark,
child: Icon(Icons.error)),
@ -290,16 +288,24 @@ class _RssResultState extends State<RssResult> {
),
Expanded(
child: TabBarView(children: [
Html(
data: _onlinePodcast.description,
padding: EdgeInsets.only(left: 20.0, right: 20, bottom: 50),
defaultTextStyle:
// GoogleFonts.libreBaskerville(
GoogleFonts.martel(
textStyle: TextStyle(
height: 1.8,
ListView(
children: [
Html(
onLinkTap: (url) {
url.launchUrl;
},
linkStyle: TextStyle(
color: context.accentColor,
// decoration: TextDecoration.underline,
textBaseline: TextBaseline.ideographic),
shrinkToFit: true,
data: _onlinePodcast.description,
padding: EdgeInsets.only(left: 20.0, right: 20, bottom: 20),
defaultTextStyle: TextStyle(
height: 1.8,
),
),
),
],
),
ListView.builder(
itemCount: math.min(_loadItems + 1, items.length),
@ -318,9 +324,7 @@ class _RssResultState extends State<RssResult> {
BorderRadius.all(Radius.circular(100))),
child: Text(context.s.loadMore),
onPressed: () => setState(
() {
_loadItems += 10;
},
() => _loadItems += 10,
),
),
),
@ -364,7 +368,7 @@ class _SearchListState extends State<SearchList> {
Future<List<OnlinePodcast>> _getList(
String searchText, int nextOffset) async {
SearchEngine searchEngine = SearchEngine();
var searchResult = searchEngine.searchPodcasts(
var searchResult = await searchEngine.searchPodcasts(
searchText: searchText, nextOffset: nextOffset);
_offset = searchResult.nextOffset;
_podcastList.addAll(searchResult.results.cast());
@ -458,8 +462,7 @@ class _SearchListState extends State<SearchList> {
child: GestureDetector(
onTap: () => setState(() => _selectedPodcast = null),
child: Container(
color:
Theme.of(context).scaffoldBackgroundColor.withOpacity(0.8),
color: context.scaffoldBackgroundColor.withOpacity(0.8),
),
),
),
@ -496,14 +499,6 @@ class SearchResult extends StatelessWidget {
Key key})
: super(key: key);
Future<String> getColor(File file) async {
final imageProvider = FileImage(file);
var colorImage = await getImageFromProvider(imageProvider);
var color = await getColorFromImage(colorImage);
String primaryColor = color.toString();
return primaryColor;
}
@override
Widget build(BuildContext context) {
var subscribeWorker = Provider.of<GroupList>(context, listen: false);
@ -801,6 +796,8 @@ class _SearchResultDetailState extends State<SearchResultDetail>
Text(
'${widget.onlinePodcast.interval.toInterval(context)} | '
'${widget.onlinePodcast.latestPubDate.toDate(context)}',
maxLines: 1,
overflow: TextOverflow.fade,
style: TextStyle(color: context.accentColor),
),
Padding(
@ -857,20 +854,20 @@ class _SearchResultDetailState extends State<SearchResultDetail>
imageUrl: widget.onlinePodcast.image,
progressIndicatorBuilder:
(context, url, downloadProgress) => Container(
height: 40,
width: 40,
height: 120,
width: 120,
alignment: Alignment.center,
color: context.primaryColorDark,
child: SizedBox(
width: 20,
width: 40,
height: 2,
child: LinearProgressIndicator(
value: downloadProgress.progress),
),
),
errorWidget: (context, url, error) => Container(
width: 40,
height: 40,
width: 120,
height: 120,
alignment: Alignment.center,
color: context.primaryColorDark,
child: Icon(Icons.error)),
@ -907,10 +904,27 @@ class _SearchResultDetailState extends State<SearchResultDetail>
),
Expanded(
child: TabBarView(children: [
Padding(
padding: const EdgeInsets.all(20.0),
child: Text(widget.onlinePodcast.description,
style: TextStyle(height: 1.8)),
ListView(
physics: _animation.value != widget.maxHeight
? NeverScrollableScrollPhysics()
: null,
children: [
Html(
onLinkTap: (url) {
url.launchUrl;
},
linkStyle: TextStyle(
color: context.accentColor,
textBaseline: TextBaseline.ideographic),
shrinkToFit: true,
data: widget.onlinePodcast.description,
padding: const EdgeInsets.only(
left: 20.0, right: 20, bottom: 20),
defaultTextStyle: TextStyle(
height: 1.8,
),
),
],
),
FutureBuilder<List<OnlineEpisode>>(
future: _searchFuture,

View File

@ -22,7 +22,6 @@ import '../local_storage/key_value_storage.dart';
import '../util/episodegrid.dart';
import '../home/audioplayer.dart';
import '../type/fireside_data.dart';
import '../util/colorize.dart';
import '../util/extension_helper.dart';
import '../util/custompaint.dart';
import '../util/general_dialog.dart';

View File

@ -11,7 +11,6 @@ import 'package:provider/provider.dart';
import '../state/podcast_group.dart';
import '../type/podcastlocal.dart';
import '../local_storage/sqflite_localpodcast.dart';
import '../util/colorize.dart';
import '../util/duraiton_picker.dart';
import '../util/extension_helper.dart';
import '../util/general_dialog.dart';

View File

@ -7,7 +7,8 @@ import '../type/searchepisodes.dart';
import '../.env.dart';
class SearchEngine {
searchPodcasts({String searchText, int nextOffset}) async {
Future<SearchPodcast<dynamic>> searchPodcasts(
{String searchText, int nextOffset}) async {
String apiKey = environment['apiKey'];
String url = "https://listen-api.listennotes.com/api/v2/search?q=" +
Uri.encodeComponent(searchText) +

View File

@ -1,5 +1,4 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:tsacdop/type/searchpodcast.dart';
part 'searchepisodes.g.dart';
@JsonSerializable()

View File

@ -1,30 +0,0 @@
import 'dart:convert';
import 'package:flutter/material.dart';
extension Colorize on String {
Color colorizedark() {
Color _c;
var color = json.decode(this);
if (color[0] > 200 && color[1] > 200 && color[2] > 200) {
_c =
Color.fromRGBO((255 - color[0]), 255 - color[1], 255 - color[2], 1.0);
} else {
_c = Color.fromRGBO(color[0], color[1] > 200 ? 190 : color[1],
color[2] > 200 ? 190 : color[2], 1);
}
return _c;
}
Color colorizeLight() {
Color _c;
var color = json.decode(this);
if (color[0] < 50 && color[1] < 50 && color[2] < 50) {
_c =
Color.fromRGBO((255 - color[0]), 255 - color[1], 255 - color[2], 1.0);
} else {
_c = Color.fromRGBO(color[0] < 50 ? 100 : color[0],
color[1] < 50 ? 100 : color[1], color[2] < 50 ? 100 : color[2], 1.0);
}
return _c;
}
}

View File

@ -20,7 +20,6 @@ import '../type/play_histroy.dart';
import '../episodes/episode_detail.dart';
import '../local_storage/sqflite_localpodcast.dart';
import '../local_storage/key_value_storage.dart';
import 'colorize.dart';
import 'extension_helper.dart';
import 'custompaint.dart';

View File

@ -1,5 +1,8 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';
import '../generated/l10n.dart';
extension ContextExtension on BuildContext {
@ -48,3 +51,39 @@ extension IntExtension on int {
return 'Published yearly';
}
}
extension StringExtension on String {
Future get launchUrl async {
if (await canLaunch(this)) {
await launch(this);
} else {
print('Could not launch $this');
}
}
Color colorizedark() {
Color _c;
var color = json.decode(this);
if (color[0] > 200 && color[1] > 200 && color[2] > 200) {
_c =
Color.fromRGBO((255 - color[0]), 255 - color[1], 255 - color[2], 1.0);
} else {
_c = Color.fromRGBO(color[0], color[1] > 200 ? 190 : color[1],
color[2] > 200 ? 190 : color[2], 1);
}
return _c;
}
Color colorizeLight() {
Color _c;
var color = json.decode(this);
if (color[0] < 50 && color[1] < 50 && color[2] < 50) {
_c =
Color.fromRGBO((255 - color[0]), 255 - color[1], 255 - color[2], 1.0);
} else {
_c = Color.fromRGBO(color[0] < 50 ? 100 : color[0],
color[1] < 50 ? 100 : color[1], color[2] < 50 ? 100 : color[2], 1.0);
}
return _c;
}
}