Minor change.

This commit is contained in:
stonega 2020-11-04 01:54:29 +08:00
parent 1e42cde733
commit f801fb65f4
5 changed files with 39 additions and 76 deletions

View File

@ -242,7 +242,7 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
),
),
Selector<AudioPlayerNotifier, bool>(
selector: (_, audio) => audio.playerRunning,
selector: (_, audio) => audio?.playerRunning ?? false,
builder: (_, data, __) {
return Padding(
padding: EdgeInsets.only(bottom: data ? 60.0 : 0),

View File

@ -193,7 +193,7 @@ class _PodcastSettingState extends State<PodcastSetting> {
Widget build(BuildContext context) {
final s = context.s;
final groupList = context.watch<GroupList>();
final textStyle = context.textTheme.bodyText1;
final textStyle = context.textTheme.bodyText2;
return Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,

View File

@ -16,13 +16,15 @@ import '../type/search_api/searchpodcast.dart';
enum SearchEngine { podcastIndex, listenNotes }
class ListenNotesSearch {
final _dio = Dio(BaseOptions(connectTimeout: 30000, receiveTimeout: 90000));
final _baseUrl = "https://listen-api.listennotes.com/api/v2/";
final _apiKey = environment['apiKey'];
Future<SearchPodcast<dynamic>> searchPodcasts(
{String searchText, int nextOffset}) async {
var url = "https://listen-api.listennotes.com/api/v2/search?q="
var url = "${_baseUrl}search?q="
"${Uri.encodeComponent(searchText)}${"&sort_by_date=0&type=podcast&offset=$nextOffset"}";
var response = await Dio().get(url,
var response = await _dio.get(url,
options: Options(headers: {
'X-ListenAPI-Key': "$_apiKey",
'Accept': "application/json"
@ -35,8 +37,8 @@ class ListenNotesSearch {
Future<SearchEpisodes<dynamic>> fetchEpisode(
{String id, int nextEpisodeDate}) async {
var url =
"https://listen-api.listennotes.com/api/v2/podcasts/$id?next_episode_pub_date=$nextEpisodeDate";
var response = await Dio().get(url,
"${_baseUrl}podcasts/$id?next_episode_pub_date=$nextEpisodeDate";
var response = await _dio.get(url,
options: Options(headers: {
'X-ListenAPI-Key': "$_apiKey",
'Accept': "application/json"
@ -49,7 +51,7 @@ class ListenNotesSearch {
Future<SearchTopPodcast<dynamic>> fetchBestPodcast(
{String genre, int page, String region = 'us'}) async {
var url =
"https://listen-api.listennotes.com/api/v2/best_podcasts?genre_id=$genre&page=$page&region=$region";
"${_baseUrl}best_podcasts?genre_id=$genre&page=$page&region=$region";
var response = await Dio().get(url,
options: Options(headers: {
'X-ListenAPI-Key': "$_apiKey",

View File

@ -15,6 +15,12 @@ class LanguagesSetting extends StatefulWidget {
}
class _LanguagesSettingState extends State<LanguagesSetting> {
@override
void initState() {
super.initState();
findSystemLocale();
}
_setLocale(Locale locale, {bool systemDefault = false}) async {
var localeStorage = KeyValueStorage(localeKey);
if (systemDefault) {
@ -43,15 +49,23 @@ class _LanguagesSettingState extends State<LanguagesSetting> {
}
}
@override
void initState() {
super.initState();
findSystemLocale();
}
Widget _langListTile(String lang, {Locale locale}) => ListTile(
title: Text(lang, style: context.textTheme.bodyText2),
onTap: () => _setLocale(locale),
dense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 20),
trailing: Transform.scale(
scale: 0.8,
child: Radio<Locale>(
value: locale,
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale),
),
);
@override
Widget build(BuildContext context) {
final textStyle = context.textTheme.bodyText1;
final textStyle = context.textTheme.bodyText2;
final s = context.s;
return Column(
children: [
@ -63,75 +77,24 @@ class _LanguagesSettingState extends State<LanguagesSetting> {
? context.accentColor
: null),
),
dense: true,
onTap: () =>
_setLocale(Locale(Intl.systemLocale), systemDefault: true),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
),
Divider(height: 1),
ListTile(
title: Text('English',style: textStyle),
onTap: () => _setLocale(Locale('en')),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
trailing: Radio<Locale>(
value: Locale('en'),
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale)),
Divider(height: 1),
ListTile(
title: Text('简体中文', style: textStyle),
onTap: () => _setLocale(Locale('zh_Hans')),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
trailing: Radio<Locale>(
value: Locale('zh_Hans'),
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale,
)),
Divider(height: 1),
ListTile(
title: Text('Français', style: textStyle),
onTap: () => _setLocale(Locale('fr')),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
trailing: Radio<Locale>(
value: Locale('fr'),
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale),
),
Divider(height: 1),
ListTile(
title: Text('Español',style: textStyle),
onTap: () => _setLocale(Locale('es')),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
trailing: Radio<Locale>(
value: Locale('es'),
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale),
),
Divider(height: 1),
ListTile(
title: Text('Português',style: textStyle),
onTap: () => _setLocale(Locale('pt')),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
trailing: Radio<Locale>(
value: Locale('pt'),
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale),
),
Divider(height: 1),
ListTile(
title: Text('Italiano', style: textStyle),
onTap: () => _setLocale(Locale('it')),
contentPadding: const EdgeInsets.only(left: 20, right: 20),
trailing: Radio<Locale>(
value: Locale('it'),
groupValue: Locale(Intl.getCurrentLocale()),
onChanged: _setLocale),
),
_langListTile('English', locale: Locale('en')),
_langListTile('简体中文', locale: Locale('zh_Hans')),
_langListTile('Français', locale: Locale('fr')),
_langListTile('Español', locale: Locale('es')),
_langListTile('Português', locale: Locale('pt')),
_langListTile('Italiano', locale: Locale('it')),
Divider(height: 1),
ListTile(
onTap: () =>
'mailto:<tsacdop.app@gmail.com>?subject=Tsacdop localization project'
.launchUrl,
contentPadding: const EdgeInsets.only(left: 20, right: 20),
dense: true,
title: Align(
alignment: Alignment.centerLeft,
child: Image(

View File

@ -30,6 +30,7 @@ class _SettingsState extends State<Settings> {
url.launchUrl;
Navigator.pop(context);
},
dense: true,
leading: Icon(
icon,
size: 20,
@ -37,6 +38,7 @@ class _SettingsState extends State<Settings> {
title: Text(
name,
maxLines: 2,
style: context.textTheme.bodyText2,
),
);
@ -193,18 +195,14 @@ class _SettingsState extends State<Settings> {
children: [
_feedbackItem(LineIcons.github, s.feedbackGithub,
'https://github.com/stonega/tsacdop/issues'),
Divider(height: 1),
_feedbackItem(LineIcons.telegram, s.feedbackTelegram,
'https://t.me/joinchat/Bk3LkRpTHy40QYC78PK7Qg'),
Divider(height: 1),
_feedbackItem(
LineIcons.envelope_open_text_solid,
s.feedbackEmail,
'mailto:<tsacdop.app@gmail.com>?subject=Tsacdop Feedback'),
Divider(height: 1),
_feedbackItem(LineIcons.google_play, s.feedbackPlay,
'https://play.google.com/store/apps/details?id=com.stonegate.tsacdop'),
Divider(height: 1),
],
),
),