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

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'el';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'en';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'es';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'fr';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'it';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'pt';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'ru';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'tr';

View File

@ -13,9 +13,10 @@
import 'package:intl/intl.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 {
String get localeName => 'zh_Hans';

View File

@ -54,12 +54,12 @@ Widget _downloadButton(EpisodeTask task, BuildContext context) {
case 6:
return Row(mainAxisSize: MainAxisSize.min, children: [
IconButton(
splashRadius: 20,
splashRadius: 20,
icon: Icon(Icons.play_circle_filled),
onPressed: () => downloader.resumeTask(task.episode!),
),
IconButton(
splashRadius: 20,
splashRadius: 20,
icon: Icon(Icons.close),
onPressed: () => downloader.delTask(task.episode!),
),

View File

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

View File

@ -964,7 +964,7 @@ class __NewPlaylistState extends State<_NewPlaylist> {
final image = img.decodeImage(metadata.albumArt!)!;
final thumbnail = img.copyResize(image, width: 300);
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";
primaryColor = await _getColor(File(imagePath));
}

View File

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

View File

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

View File

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

View File

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

View File

@ -38,4 +38,4 @@ class Chapters {
data['url'] = url;
return data;
}
}
}

View File

@ -56,7 +56,8 @@ class EpisodeBrief extends Equatable {
artist: feedTitle,
album: feedTitle,
duration: Duration.zero,
artUri: Uri.parse(imagePath == '' ? episodeImage! : 'file://$imagePath'),
artUri:
Uri.parse(imagePath == '' ? episodeImage! : 'file://$imagePath'),
extras: {
'skipSecondsStart': skipSecondsStart,
'skipSecondsEnd': skipSecondsEnd
@ -69,8 +70,9 @@ class EpisodeBrief extends Equatable {
: File(episodeImage!).existsSync()
? FileImage(File(episodeImage!))
: ((episodeImage != '')
? CachedNetworkImageProvider(episodeImage!)
: AssetImage('assets/avatar_backup.png')) as ImageProvider<Object>;
? CachedNetworkImageProvider(episodeImage!)
: AssetImage('assets/avatar_backup.png'))
as ImageProvider<Object>;
}
Color backgroudColor(BuildContext context) {
@ -79,7 +81,7 @@ class EpisodeBrief extends Equatable {
? primaryColor!.colorizedark()
: primaryColor!.colorizeLight();
}
Color cardColor(BuildContext context) {
final schema = ColorScheme.fromSeed(
seedColor: primaryColor!.colorizedark(),

View File

@ -14,7 +14,9 @@ class CustomCacheManager extends CacheManager with ImageCacheManager {
@override
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;
try {
file = await super
@ -41,9 +43,7 @@ class CustomCacheManager extends CacheManager with ImageCacheManager {
withProgress: withProgress,
maxHeight: maxHeight,
maxWidth: maxWidth);
} catch (e) {
}
} catch (e) {}
}
CustomCacheManager._() : super(Config(key));

View File

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

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
//Slide Transition
class SlideLeftRoute extends PageRouteBuilder {
@override
@override
Duration get transitionDuration => Duration(milliseconds: 300);
final Widget? page;
SlideLeftRoute({this.page})

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(
useRootNavigator: true,
isScrollControlled: true,