1
0
mirror of https://github.com/stonega/tsacdop synced 2025-02-27 00:37:42 +01:00

🎨 code format

This commit is contained in:
xijieyin 2022-06-05 00:48:42 +08:00
parent 94a93be490
commit 199f3e8a28
23 changed files with 82 additions and 62 deletions

View File

@ -25,17 +25,17 @@ import 'messages_ru.dart' as messages_ru;
import 'messages_tr.dart' as messages_tr; import 'messages_tr.dart' as messages_tr;
import 'messages_zh-Hans.dart' as messages_zh_hans; import 'messages_zh-Hans.dart' as messages_zh_hans;
typedef Future<dynamic> LibraryLoader(); typedef LibraryLoader = Future<dynamic> Function();
Map<String, LibraryLoader> _deferredLibraries = { Map<String, LibraryLoader> _deferredLibraries = {
'el': () => new Future.value(null), 'el': () => Future.value(null),
'en': () => new Future.value(null), 'en': () => Future.value(null),
'es': () => new Future.value(null), 'es': () => Future.value(null),
'fr': () => new Future.value(null), 'fr': () => Future.value(null),
'it': () => new Future.value(null), 'it': () => Future.value(null),
'pt': () => new Future.value(null), 'pt': () => Future.value(null),
'ru': () => new Future.value(null), 'ru': () => Future.value(null),
'tr': () => new Future.value(null), 'tr': () => Future.value(null),
'zh_Hans': () => new Future.value(null), 'zh_Hans': () => Future.value(null),
}; };
MessageLookupByLibrary? _findExact(String localeName) { MessageLookupByLibrary? _findExact(String localeName) {
@ -69,13 +69,13 @@ Future<bool> initializeMessages(String localeName) async {
localeName, (locale) => _deferredLibraries[locale] != null, localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null); onFailure: (_) => null);
if (availableLocale == null) { if (availableLocale == null) {
return new Future.value(false); return Future.value(false);
} }
var lib = _deferredLibraries[availableLocale]; var lib = _deferredLibraries[availableLocale];
await (lib == null ? new Future.value(false) : lib()); await (lib == null ? Future.value(false) : lib());
initializeInternalMessageLookup(() => new CompositeMessageLookup()); initializeInternalMessageLookup(() => CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return new Future.value(true); return Future.value(true);
} }
bool _messagesExistFor(String locale) { bool _messagesExistFor(String locale) {

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'el'; String get localeName => 'el';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en'; String get localeName => 'en';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'es'; String get localeName => 'es';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'fr'; String get localeName => 'fr';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'it'; String get localeName => 'it';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'pt'; String get localeName => 'pt';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'ru'; String get localeName => 'ru';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'tr'; String get localeName => 'tr';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/message_lookup_by_library.dart';
final messages = new MessageLookup(); final messages = MessageLookup();
typedef String MessageIfAbsent(String messageStr, List<dynamic> args); typedef MessageIfAbsent = String Function(
String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'zh_Hans'; String get localeName => 'zh_Hans';

View File

@ -15,6 +15,7 @@ import '../type/podcastlocal.dart';
import '../type/sub_history.dart'; import '../type/sub_history.dart';
enum Filter { downloaded, liked, search, all } enum Filter { downloaded, liked, search, all }
const localFolderId = "46e48103-06c7-4fe1-a0b1-68aa7205b7f0"; const localFolderId = "46e48103-06c7-4fe1-a0b1-68aa7205b7f0";
class DBHelper { class DBHelper {

View File

@ -964,7 +964,7 @@ class __NewPlaylistState extends State<_NewPlaylist> {
final image = img.decodeImage(metadata.albumArt!)!; final image = img.decodeImage(metadata.albumArt!)!;
final thumbnail = img.copyResize(image, width: 300); final thumbnail = img.copyResize(image, width: 300);
var uuid = Uuid().v4(); var uuid = Uuid().v4();
File("${dir.path}/$uuid.png")..writeAsBytesSync(img.encodePng(thumbnail)); File("${dir.path}/$uuid.png").writeAsBytesSync(img.encodePng(thumbnail));
imagePath = "${dir.path}/$uuid.png"; imagePath = "${dir.path}/$uuid.png";
primaryColor = await _getColor(File(imagePath)); primaryColor = await _getColor(File(imagePath));
} }

View File

@ -404,7 +404,7 @@ class _PodcastSettingState extends State<PodcastSetting> {
)); ));
var image = img.decodeImage(imageResponse.data!)!; var image = img.decodeImage(imageResponse.data!)!;
thumbnail = img.copyResize(image, width: 300); thumbnail = img.copyResize(image, width: 300);
File(filePath)..writeAsBytesSync(img.encodePng(thumbnail)); File(filePath).writeAsBytesSync(img.encodePng(thumbnail));
_dbHelper.updatePodcastImage( _dbHelper.updatePodcastImage(
id: widget.podcastLocal!.id, filePath: filePath); id: widget.podcastLocal!.id, filePath: filePath);
print('saved image'); print('saved image');

View File

@ -28,7 +28,7 @@ class ListenNotesSearch {
Future<SearchPodcast<dynamic>?> searchPodcasts( Future<SearchPodcast<dynamic>?> searchPodcasts(
{String? searchText, int? nextOffset}) async { {String? searchText, int? nextOffset}) async {
if(!_validApi) return null; if (!_validApi) return null;
var url = "${_baseUrl}search?q=" var url = "${_baseUrl}search?q="
"${Uri.encodeComponent(searchText!)}${"&sort_by_date=0&type=podcast&offset=$nextOffset"}"; "${Uri.encodeComponent(searchText!)}${"&sort_by_date=0&type=podcast&offset=$nextOffset"}";
var response = await _dio.get(url, var response = await _dio.get(url,
@ -37,28 +37,29 @@ class ListenNotesSearch {
'Accept': "application/json" 'Accept': "application/json"
})); }));
Map searchResultMap = jsonDecode(response.toString()); Map searchResultMap = jsonDecode(response.toString());
var searchResult = SearchPodcast.fromJson(searchResultMap as Map<String, dynamic>); var searchResult =
SearchPodcast.fromJson(searchResultMap as Map<String, dynamic>);
return searchResult; return searchResult;
} }
Future<SearchEpisodes<dynamic>?> fetchEpisode( Future<SearchEpisodes<dynamic>?> fetchEpisode(
{String? id, int? nextEpisodeDate}) async { {String? id, int? nextEpisodeDate}) async {
if(!_validApi) return null; if (!_validApi) return null;
var url = var url = "${_baseUrl}podcasts/$id?next_episode_pub_date=$nextEpisodeDate";
"${_baseUrl}podcasts/$id?next_episode_pub_date=$nextEpisodeDate";
var response = await _dio.get(url, var response = await _dio.get(url,
options: Options(headers: { options: Options(headers: {
'X-ListenAPI-Key': "$_apiKey", 'X-ListenAPI-Key': "$_apiKey",
'Accept': "application/json" 'Accept': "application/json"
})); }));
Map searchResultMap = jsonDecode(response.toString()); Map searchResultMap = jsonDecode(response.toString());
var searchResult = SearchEpisodes.fromJson(searchResultMap as Map<String, dynamic>); var searchResult =
SearchEpisodes.fromJson(searchResultMap as Map<String, dynamic>);
return searchResult; return searchResult;
} }
Future<SearchTopPodcast<dynamic>?> fetchBestPodcast( Future<SearchTopPodcast<dynamic>?> fetchBestPodcast(
{String? genre, int? page, String region = 'us'}) async { {String? genre, int? page, String region = 'us'}) async {
if(!_validApi) return null; if (!_validApi) return null;
var url = var url =
"${_baseUrl}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, var response = await Dio().get(url,
@ -67,7 +68,8 @@ class ListenNotesSearch {
'Accept': "application/json" 'Accept': "application/json"
})); }));
Map searchResultMap = jsonDecode(response.toString()); Map searchResultMap = jsonDecode(response.toString());
var searchResult = SearchTopPodcast.fromJson(searchResultMap as Map<String, dynamic>); var searchResult =
SearchTopPodcast.fromJson(searchResultMap as Map<String, dynamic>);
return searchResult; return searchResult;
} }
} }
@ -81,7 +83,8 @@ class ItunesSearch {
.get(url, options: Options(headers: {'Accept': "application/json"})); .get(url, options: Options(headers: {'Accept': "application/json"}));
print(response.toString()); print(response.toString());
Map searchResultMap = jsonDecode(response.toString()); Map searchResultMap = jsonDecode(response.toString());
final searchResult = ItunesSearchResult.fromJson(searchResultMap as Map<String, dynamic>); final searchResult =
ItunesSearchResult.fromJson(searchResultMap as Map<String, dynamic>);
return searchResult; return searchResult;
} }
} }
@ -121,7 +124,8 @@ class PodcastsIndexSearch {
final headers = _initSearch(); final headers = _initSearch();
final response = await _dio.get(url, options: Options(headers: headers)); final response = await _dio.get(url, options: Options(headers: headers));
Map searchResultMap = jsonDecode(response.toString()); Map searchResultMap = jsonDecode(response.toString());
final searchResult = PodcastIndexSearchResult.fromJson(searchResultMap as Map<String, dynamic>); final searchResult = PodcastIndexSearchResult.fromJson(
searchResultMap as Map<String, dynamic>);
return searchResult; return searchResult;
} }
@ -130,7 +134,8 @@ class PodcastsIndexSearch {
final headers = _initSearch(); final headers = _initSearch();
final response = await _dio.get(url, options: Options(headers: headers)); final response = await _dio.get(url, options: Options(headers: headers));
Map searchResultMap = jsonDecode(response.toString()); Map searchResultMap = jsonDecode(response.toString());
final searchResult = IndexEpisodeResult.fromJson(searchResultMap as Map<String, dynamic>); final searchResult =
IndexEpisodeResult.fromJson(searchResultMap as Map<String, dynamic>);
return searchResult; return searchResult;
} }
} }

View File

@ -660,7 +660,7 @@ Future<void> subIsolateEntryPoint(SendPort sendPort) async {
} }
var uuid = Uuid().v4(); var uuid = Uuid().v4();
File("${dir.path}/$uuid.png") File("${dir.path}/$uuid.png")
..writeAsBytesSync(img.encodePng(thumbnail!)); .writeAsBytesSync(img.encodePng(thumbnail!));
var imagePath = "${dir.path}/$uuid.png"; var imagePath = "${dir.path}/$uuid.png";
var primaryColor = await _getColor(File(imagePath)); var primaryColor = await _getColor(File(imagePath));
var author = p.itunes!.author ?? p.author ?? ''; var author = p.itunes!.author ?? p.author ?? '';

View File

@ -22,7 +22,8 @@ class SearchState extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
bool isSubscribed(OnlinePodcast? podcast) => _subscribedList.contains(podcast); bool isSubscribed(OnlinePodcast? podcast) =>
_subscribedList.contains(podcast);
void clearSelect() { void clearSelect() {
_selectedPodcast = null; _selectedPodcast = null;
@ -33,7 +34,7 @@ class SearchState extends ChangeNotifier {
_subscribedList.clear(); _subscribedList.clear();
} }
void clearGenre(){ void clearGenre() {
_genre = null; _genre = null;
notifyListeners(); notifyListeners();
} }

View File

@ -56,7 +56,8 @@ class EpisodeBrief extends Equatable {
artist: feedTitle, artist: feedTitle,
album: feedTitle, album: feedTitle,
duration: Duration.zero, duration: Duration.zero,
artUri: Uri.parse(imagePath == '' ? episodeImage! : 'file://$imagePath'), artUri:
Uri.parse(imagePath == '' ? episodeImage! : 'file://$imagePath'),
extras: { extras: {
'skipSecondsStart': skipSecondsStart, 'skipSecondsStart': skipSecondsStart,
'skipSecondsEnd': skipSecondsEnd 'skipSecondsEnd': skipSecondsEnd
@ -70,7 +71,8 @@ class EpisodeBrief extends Equatable {
? FileImage(File(episodeImage!)) ? FileImage(File(episodeImage!))
: ((episodeImage != '') : ((episodeImage != '')
? CachedNetworkImageProvider(episodeImage!) ? CachedNetworkImageProvider(episodeImage!)
: AssetImage('assets/avatar_backup.png')) as ImageProvider<Object>; : AssetImage('assets/avatar_backup.png'))
as ImageProvider<Object>;
} }
Color backgroudColor(BuildContext context) { Color backgroudColor(BuildContext context) {

View File

@ -14,7 +14,9 @@ class CustomCacheManager extends CacheManager with ImageCacheManager {
@override @override
Future<FileInfo> downloadFile(String url, Future<FileInfo> downloadFile(String url,
{String? key, Map<String, String>? authHeaders, bool force = false}) async { {String? key,
Map<String, String>? authHeaders,
bool force = false}) async {
var file; var file;
try { try {
file = await super file = await super
@ -41,9 +43,7 @@ class CustomCacheManager extends CacheManager with ImageCacheManager {
withProgress: withProgress, withProgress: withProgress,
maxHeight: maxHeight, maxHeight: maxHeight,
maxWidth: maxWidth); maxWidth: maxWidth);
} catch (e) { } catch (e) {}
}
} }
CustomCacheManager._() : super(Config(key)); CustomCacheManager._() : super(Config(key));

View File

@ -7,7 +7,8 @@ import '../state/audio_state.dart';
import '../util/extension_helper.dart'; import '../util/extension_helper.dart';
class HidePlayerRoute extends ModalRoute<void> { class HidePlayerRoute extends ModalRoute<void> {
HidePlayerRoute(this.openPage, this.transitionPage, {required Duration duration}) HidePlayerRoute(this.openPage, this.transitionPage,
{required Duration duration})
: transitionDuration = duration; : transitionDuration = duration;
final openPage; final openPage;
final transitionPage; final transitionPage;

View File

@ -31,7 +31,8 @@ Future generalDialog(BuildContext context,
), ),
); );
Future generalSheet(BuildContext context, {Widget? child, String? title}) async => Future generalSheet(BuildContext context,
{Widget? child, String? title}) async =>
await showModalBottomSheet( await showModalBottomSheet(
useRootNavigator: true, useRootNavigator: true,
isScrollControlled: true, isScrollControlled: true,