From 6d181611842f2c9df5cf998cb370fa15e2616f78 Mon Sep 17 00:00:00 2001 From: Valeri Gokadze Date: Wed, 18 Oct 2023 14:51:39 +0400 Subject: [PATCH] Improved code --- lib/API/musify.dart | 8 +-- lib/extensions/l10n.dart | 2 +- lib/screens/about_page.dart | 2 +- lib/screens/artist_page.dart | 4 +- lib/screens/home_page.dart | 8 +-- lib/screens/more_page.dart | 72 +++++++++++----------- lib/screens/now_playing_page.dart | 11 ++-- lib/screens/playlist_page.dart | 11 ++-- lib/screens/playlists_page.dart | 6 +- lib/screens/recently_played_page.dart | 2 +- lib/screens/root_page.dart | 8 +-- lib/screens/search_page.dart | 4 +- lib/screens/user_added_playlists_page.dart | 26 ++++---- lib/screens/user_liked_playlists_page.dart | 4 +- lib/screens/user_liked_songs_page.dart | 10 +-- lib/services/data_manager.dart | 12 ++-- lib/services/download_manager.dart | 12 ++-- lib/services/logger_service.dart | 4 +- lib/services/update_manager.dart | 4 +- 19 files changed, 104 insertions(+), 106 deletions(-) diff --git a/lib/API/musify.dart b/lib/API/musify.dart index 8c6557109..779a07da3 100644 --- a/lib/API/musify.dart +++ b/lib/API/musify.dart @@ -100,11 +100,11 @@ Future> getUserPlaylists() async { String addUserPlaylist(String playlistId, BuildContext context) { if (playlistId.length != 34) { - return '${context.l10n()!.notYTlist}!'; + return '${context.l10n!.notYTlist}!'; } else { userPlaylists.add(playlistId); addOrUpdateData('user', 'playlists', userPlaylists); - return '${context.l10n()!.addedSuccess}!'; + return '${context.l10n!.addedSuccess}!'; } } @@ -123,7 +123,7 @@ String createCustomPlaylist( }; userCustomPlaylists.add(customPlaylist); addOrUpdateData('user', 'customPlaylists', userCustomPlaylists); - return '${context.l10n()!.addedSuccess}!'; + return '${context.l10n!.addedSuccess}!'; } String addSongInCustomPlaylist( @@ -387,7 +387,7 @@ Future updatePlaylistList( playlists[index]['list'] = songList; addOrUpdateData('cache', 'playlistSongs$playlistId', songList); - showToast(context, context.l10n()!.playlistUpdated); + showToast(context, context.l10n!.playlistUpdated); } return playlists[index]; } diff --git a/lib/extensions/l10n.dart b/lib/extensions/l10n.dart index 285087d09..47ad2c310 100644 --- a/lib/extensions/l10n.dart +++ b/lib/extensions/l10n.dart @@ -2,5 +2,5 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; extension ContextX on BuildContext { - AppLocalizations? l10n() => AppLocalizations.of(this); + AppLocalizations? get l10n => AppLocalizations.of(this); } diff --git a/lib/screens/about_page.dart b/lib/screens/about_page.dart index 9c9ab6760..40edd0111 100644 --- a/lib/screens/about_page.dart +++ b/lib/screens/about_page.dart @@ -14,7 +14,7 @@ class AboutPage extends StatelessWidget { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.about, + context.l10n!.about, ), ), body: const SingleChildScrollView(child: AboutCards()), diff --git a/lib/screens/artist_page.dart b/lib/screens/artist_page.dart index 5ec59423c..ce0cff9d0 100644 --- a/lib/screens/artist_page.dart +++ b/lib/screens/artist_page.dart @@ -60,7 +60,7 @@ class _ArtistPagePageState extends State { if (snapshot.hasError || snapshot.data.isEmpty) { return Center( child: Text( - '${context.l10n()!.nothingFound}!', + '${context.l10n!.nothingFound}!', style: TextStyle( color: colorScheme.primary, fontSize: 18, @@ -107,7 +107,7 @@ class _ArtistPagePageState extends State { setActivePlaylist(widget.playlist); showToast( context, - context.l10n()!.queueInitText, + context.l10n!.queueInitText, ); }, child: Icon( diff --git a/lib/screens/home_page.dart b/lib/screens/home_page.dart index bbce2b665..dd5ec1ff7 100644 --- a/lib/screens/home_page.dart +++ b/lib/screens/home_page.dart @@ -75,7 +75,7 @@ class _HomePageState extends State { width: context.screenSize.width / 1.4, child: MarqueeWidget( child: Text( - context.l10n()!.suggestedPlaylists, + context.l10n!.suggestedPlaylists, style: TextStyle( color: colorScheme.primary, fontSize: 20, @@ -165,7 +165,7 @@ class _HomePageState extends State { Widget _buildErrorWidget(BuildContext context) { return Center( child: Text( - '${context.l10n()!.error}!', + '${context.l10n!.error}!', style: TextStyle( color: colorScheme.primary, fontSize: 18, @@ -190,7 +190,7 @@ class _HomePageState extends State { width: context.screenSize.width / 1.4, child: MarqueeWidget( child: Text( - context.l10n()!.suggestedArtists, + context.l10n!.suggestedArtists, style: TextStyle( color: colorScheme.primary, fontSize: 20, @@ -232,7 +232,7 @@ class _HomePageState extends State { Padding( padding: const EdgeInsets.fromLTRB(20, 10, 20, 10), child: Text( - context.l10n()!.recommendedForYou, + context.l10n!.recommendedForYou, style: TextStyle( color: colorScheme.primary, fontSize: 20, diff --git a/lib/screens/more_page.dart b/lib/screens/more_page.dart index 4731e1dea..dcec4fa1b 100644 --- a/lib/screens/more_page.dart +++ b/lib/screens/more_page.dart @@ -31,7 +31,7 @@ class _MorePageState extends State { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.more, + context.l10n!.more, ), ), body: SingleChildScrollView(child: SettingsCards()), @@ -46,7 +46,7 @@ class SettingsCards extends StatelessWidget { children: [ // CATEGORY: PAGES Text( - context.l10n()!.pages, + context.l10n!.pages, style: TextStyle( color: colorScheme.primary, fontSize: 15, @@ -54,7 +54,7 @@ class SettingsCards extends StatelessWidget { ), ), SettingBar( - context.l10n()!.recentlyPlayed, + context.l10n!.recentlyPlayed, FluentIcons.history_24_filled, () => { Navigator.push( @@ -66,7 +66,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.playlists, + context.l10n!.playlists, FluentIcons.list_24_filled, () => { Navigator.push( @@ -78,7 +78,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.userLikedSongs, + context.l10n!.userLikedSongs, FluentIcons.heart_24_filled, () => { Navigator.push( @@ -88,7 +88,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.userLikedPlaylists, + context.l10n!.userLikedPlaylists, FluentIcons.star_24_filled, () => { Navigator.push( @@ -102,7 +102,7 @@ class SettingsCards extends StatelessWidget { // CATEGORY: SETTINGS Text( - context.l10n()!.settings, + context.l10n!.settings, style: TextStyle( color: colorScheme.primary, fontSize: 15, @@ -110,7 +110,7 @@ class SettingsCards extends StatelessWidget { ), ), SettingBar( - context.l10n()!.accentColor, + context.l10n!.accentColor, FluentIcons.color_24_filled, () => { showModalBottomSheet( @@ -156,7 +156,7 @@ class SettingsCards extends StatelessWidget { ); showToast( context, - context.l10n()!.accentChangeMsg, + context.l10n!.accentChangeMsg, ); Navigator.pop(context); }, @@ -187,7 +187,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.themeMode, + context.l10n!.themeMode, FluentIcons.weather_sunny_28_filled, () => { showModalBottomSheet( @@ -246,7 +246,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.language, + context.l10n!.language, FluentIcons.translate_24_filled, () => { showModalBottomSheet( @@ -291,7 +291,7 @@ class SettingsCards extends StatelessWidget { showToast( context, - context.l10n()!.languageMsg, + context.l10n!.languageMsg, ); Navigator.pop(context); }, @@ -307,7 +307,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingSwitchBar( - context.l10n()!.dynamicColor, + context.l10n!.dynamicColor, FluentIcons.toggle_left_24_filled, useSystemColor.value, (value) { @@ -324,7 +324,7 @@ class SettingsCards extends StatelessWidget { ); showToast( context, - context.l10n()!.settingChangedMsg, + context.l10n!.settingChangedMsg, ); }, ), @@ -344,7 +344,7 @@ class SettingsCards extends StatelessWidget { sponsorBlockSupport.value = value; showToast( context, - context.l10n()!.settingChangedMsg, + context.l10n!.settingChangedMsg, ); }, ); @@ -352,7 +352,7 @@ class SettingsCards extends StatelessWidget { ), SettingBar( - context.l10n()!.audioFileType, + context.l10n!.audioFileType, FluentIcons.multiselect_ltr_24_filled, () => { showModalBottomSheet( @@ -396,7 +396,7 @@ class SettingsCards extends StatelessWidget { availableFileTypes[index]; showToast( context, - context.l10n()!.audioFileTypeMsg, + context.l10n!.audioFileTypeMsg, ); Navigator.pop(context); }, @@ -412,7 +412,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.downloadMode, + context.l10n!.downloadMode, FluentIcons.clock_arrow_download_24_filled, () { showModalBottomSheet( @@ -435,7 +435,7 @@ class SettingsCards extends StatelessWidget { Padding( padding: const EdgeInsets.all(25), child: Text( - context.l10n()!.fasterDownloadMsg, + context.l10n!.fasterDownloadMsg, style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, @@ -470,7 +470,7 @@ class SettingsCards extends StatelessWidget { availableModes[index]; showToast( context, - context.l10n()!.downloadModeMsg, + context.l10n!.downloadModeMsg, ); Navigator.pop(context); }, @@ -489,7 +489,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.audioQuality, + context.l10n!.audioQuality, Icons.music_note, () { showModalBottomSheet( @@ -538,7 +538,7 @@ class SettingsCards extends StatelessWidget { audioQualitySetting.value = quality; showToast( context, - context.l10n()!.audioQualityMsg, + context.l10n!.audioQualityMsg, ); Navigator.pop(context); }, @@ -556,7 +556,7 @@ class SettingsCards extends StatelessWidget { // CATEGORY: TOOLS Text( - context.l10n()!.tools, + context.l10n!.tools, style: TextStyle( color: colorScheme.primary, fontSize: 15, @@ -564,27 +564,27 @@ class SettingsCards extends StatelessWidget { ), ), SettingBar( - context.l10n()!.clearCache, + context.l10n!.clearCache, FluentIcons.broom_24_filled, () => { clearCache(), showToast( context, - '${context.l10n()!.cacheMsg}!', + '${context.l10n!.cacheMsg}!', ), }, ), SettingBar( - context.l10n()!.clearSearchHistory, + context.l10n!.clearSearchHistory, FluentIcons.history_24_filled, () => { searchHistory = [], deleteData('user', 'searchHistory'), - showToast(context, '${context.l10n()!.searchHistoryMsg}!'), + showToast(context, '${context.l10n!.searchHistoryMsg}!'), }, ), SettingBar( - context.l10n()!.backupUserData, + context.l10n!.backupUserData, FluentIcons.cloud_sync_24_filled, () => { backupData(context).then( @@ -593,7 +593,7 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - context.l10n()!.restoreUserData, + context.l10n!.restoreUserData, FluentIcons.cloud_add_24_filled, () => { restoreData(context).then( @@ -603,7 +603,7 @@ class SettingsCards extends StatelessWidget { ), if (!isFdroidBuild) SettingBar( - context.l10n()!.downloadAppUpdate, + context.l10n!.downloadAppUpdate, FluentIcons.arrow_download_24_filled, () => { checkAppUpdates(context, downloadUpdateAutomatically: true), @@ -613,7 +613,7 @@ class SettingsCards extends StatelessWidget { const SizedBox(), // CATEGORY: BECOME A SPONSOR Text( - context.l10n()!.becomeSponsor, + context.l10n!.becomeSponsor, style: TextStyle( color: colorScheme.primary, fontSize: 15, @@ -628,7 +628,7 @@ class SettingsCards extends StatelessWidget { leading: const Icon(FluentIcons.heart_24_filled, color: Colors.white), title: Text( - context.l10n()!.sponsorProject, + context.l10n!.sponsorProject, style: const TextStyle( fontWeight: FontWeight.w600, color: Colors.white, @@ -644,7 +644,7 @@ class SettingsCards extends StatelessWidget { ), // CATEGORY: OTHERS Text( - context.l10n()!.others, + context.l10n!.others, style: TextStyle( color: colorScheme.primary, fontSize: 15, @@ -652,7 +652,7 @@ class SettingsCards extends StatelessWidget { ), ), SettingBar( - context.l10n()!.licenses, + context.l10n!.licenses, FluentIcons.document_24_filled, () => { Navigator.of(context).push( @@ -666,12 +666,12 @@ class SettingsCards extends StatelessWidget { }, ), SettingBar( - '${context.l10n()!.copyLogs} (${logger.getLogCount()})', + '${context.l10n!.copyLogs} (${logger.getLogCount()})', FluentIcons.error_circle_24_filled, () async => {showToast(context, await logger.copyLogs(context))}, ), SettingBar( - context.l10n()!.about, + context.l10n!.about, FluentIcons.book_information_24_filled, () => { Navigator.of(context).push( diff --git a/lib/screens/now_playing_page.dart b/lib/screens/now_playing_page.dart index 3b7d91b42..c9d90928a 100644 --- a/lib/screens/now_playing_page.dart +++ b/lib/screens/now_playing_page.dart @@ -30,7 +30,7 @@ class _NowPlayingPageState extends State { appBar: AppBar( toolbarHeight: size.height * 0.07, title: Text( - context.l10n()!.nowPlaying, + context.l10n!.nowPlaying, ), leading: Padding( padding: const EdgeInsets.only(left: 14), @@ -518,7 +518,7 @@ class _NowPlayingPageState extends State { ), ); }, - child: Text(context.l10n()!.playlist), + child: Text(context.l10n!.playlist), ); }, ), @@ -570,7 +570,7 @@ class _NowPlayingPageState extends State { ), child: Center( child: Text( - context.l10n()!.lyrics, + context.l10n!.lyrics, style: TextStyle( color: colorScheme .primary, @@ -624,8 +624,7 @@ class _NowPlayingPageState extends State { ), child: Center( child: Text( - context - .l10n()! + context.l10n! .lyricsNotAvailable, style: const TextStyle( fontSize: 25, @@ -641,7 +640,7 @@ class _NowPlayingPageState extends State { ), ); }, - child: Text(context.l10n()!.lyrics), + child: Text(context.l10n!.lyrics), ); }, ), diff --git a/lib/screens/playlist_page.dart b/lib/screens/playlist_page.dart index ade726928..e8264aaf8 100644 --- a/lib/screens/playlist_page.dart +++ b/lib/screens/playlist_page.dart @@ -102,7 +102,7 @@ class _PlaylistPageState extends State { appBar: AppBar( title: MarqueeWidget( child: Text( - _playlist != null ? _playlist['title'] : context.l10n()!.playlist, + _playlist != null ? _playlist['title'] : context.l10n!.playlist, ), ), ), @@ -185,8 +185,7 @@ class _PlaylistPageState extends State { children: [ SizedBox(height: screenHeight * 0.03), Text( - '[ $playlistLength ${context.l10n()!.songs} ]' - .toUpperCase(), + '[ $playlistLength ${context.l10n!.songs} ]'.toUpperCase(), style: const TextStyle( fontWeight: FontWeight.w300, ), @@ -279,8 +278,8 @@ class _PlaylistPageState extends State { final dynamic songToRemove = _songsList.elementAt(indexOfRemovedSong); showToastWithButton( context, - context.l10n()!.songRemoved, - context.l10n()!.undo.toUpperCase(), + context.l10n!.songRemoved, + context.l10n!.undo.toUpperCase(), () => { addSongInCustomPlaylist( _playlist['title'], @@ -301,7 +300,7 @@ class _PlaylistPageState extends State { setActivePlaylist(_playlist); showToast( context, - context.l10n()!.queueInitText, + context.l10n!.queueInitText, ); }, child: Icon( diff --git a/lib/screens/playlists_page.dart b/lib/screens/playlists_page.dart index 85bc89c29..e33aa5851 100644 --- a/lib/screens/playlists_page.dart +++ b/lib/screens/playlists_page.dart @@ -34,7 +34,7 @@ class _PlaylistsPageState extends State { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.playlists, + context.l10n!.playlists, ), ), body: SingleChildScrollView( @@ -73,7 +73,7 @@ class _PlaylistsPageState extends State { FocusManager.instance.primaryFocus?.unfocus(); }, ), - labelText: '${context.l10n()!.search}...', + labelText: '${context.l10n!.search}...', ), ), ), @@ -87,7 +87,7 @@ class _PlaylistsPageState extends State { } else if (snapshot.hasError) { logger.log('Error on playlists page: ${snapshot.error}'); return Center( - child: Text(context.l10n()!.error), + child: Text(context.l10n!.error), ); } else if (!snapshot.hasData || (snapshot.data as List).isEmpty) { diff --git a/lib/screens/recently_played_page.dart b/lib/screens/recently_played_page.dart index b75cbf4a0..9f4e7eb9c 100644 --- a/lib/screens/recently_played_page.dart +++ b/lib/screens/recently_played_page.dart @@ -17,7 +17,7 @@ class _RecentlyPlayedState extends State { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.recentlyPlayed, + context.l10n!.recentlyPlayed, ), ), body: ValueListenableBuilder( diff --git a/lib/screens/root_page.dart b/lib/screens/root_page.dart index 819402864..12b458d4f 100644 --- a/lib/screens/root_page.dart +++ b/lib/screens/root_page.dart @@ -160,22 +160,22 @@ class _MusifyState extends State { NavigationDestination( icon: const Icon(FluentIcons.home_24_regular), selectedIcon: const Icon(FluentIcons.home_24_filled), - label: context.l10n()!.home, + label: context.l10n!.home, ), NavigationDestination( icon: const Icon(FluentIcons.search_24_regular), selectedIcon: const Icon(FluentIcons.search_24_filled), - label: context.l10n()!.search, + label: context.l10n!.search, ), NavigationDestination( icon: const Icon(FluentIcons.book_24_regular), selectedIcon: const Icon(FluentIcons.book_24_filled), - label: context.l10n()!.userPlaylists, + label: context.l10n!.userPlaylists, ), NavigationDestination( icon: const Icon(FluentIcons.more_horizontal_24_regular), selectedIcon: const Icon(FluentIcons.more_horizontal_24_filled), - label: context.l10n()!.more, + label: context.l10n!.more, ), ], ), diff --git a/lib/screens/search_page.dart b/lib/screens/search_page.dart index bf3de79f6..07efffe02 100644 --- a/lib/screens/search_page.dart +++ b/lib/screens/search_page.dart @@ -67,7 +67,7 @@ class _SearchPageState extends State { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.search, + context.l10n!.search, ), ), body: SingleChildScrollView( @@ -133,7 +133,7 @@ class _SearchPageState extends State { } }, ), - labelText: '${context.l10n()!.search}...', + labelText: '${context.l10n!.search}...', ), ), ), diff --git a/lib/screens/user_added_playlists_page.dart b/lib/screens/user_added_playlists_page.dart index 30993a445..ebc9e0c2e 100644 --- a/lib/screens/user_added_playlists_page.dart +++ b/lib/screens/user_added_playlists_page.dart @@ -19,7 +19,7 @@ class _UserPlaylistsPageState extends State { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.userPlaylists, + context.l10n!.userPlaylists, ), ), floatingActionButton: FloatingActionButton( @@ -39,7 +39,7 @@ class _UserPlaylistsPageState extends State { child: Column( children: [ Text( - context.l10n()!.customPlaylistAddInstruction, + context.l10n!.customPlaylistAddInstruction, textAlign: TextAlign.center, style: TextStyle( fontWeight: FontWeight.bold, @@ -49,7 +49,7 @@ class _UserPlaylistsPageState extends State { const SizedBox(height: 20), TextField( decoration: InputDecoration( - labelText: context.l10n()!.youtubePlaylistID, + labelText: context.l10n!.youtubePlaylistID, ), onChanged: (value) { id = value; @@ -58,7 +58,7 @@ class _UserPlaylistsPageState extends State { const SizedBox(height: 7), TextField( decoration: InputDecoration( - labelText: context.l10n()!.customPlaylistName, + labelText: context.l10n!.customPlaylistName, ), onChanged: (value) { customPlaylistName = value; @@ -67,7 +67,7 @@ class _UserPlaylistsPageState extends State { const SizedBox(height: 7), TextField( decoration: InputDecoration( - labelText: context.l10n()!.customPlaylistImgUrl, + labelText: context.l10n!.customPlaylistImgUrl, ), onChanged: (value) { imageUrl = value; @@ -76,7 +76,7 @@ class _UserPlaylistsPageState extends State { const SizedBox(height: 7), TextField( decoration: InputDecoration( - labelText: context.l10n()!.customPlaylistDesc, + labelText: context.l10n!.customPlaylistDesc, ), onChanged: (value) { description = value; @@ -88,7 +88,7 @@ class _UserPlaylistsPageState extends State { actions: [ TextButton( child: Text( - context.l10n()!.add.toUpperCase(), + context.l10n!.add.toUpperCase(), ), onPressed: () { if (id.isNotEmpty) { @@ -106,7 +106,7 @@ class _UserPlaylistsPageState extends State { } else { showToast( context, - '${context.l10n()!.provideIdOrNameError}.', + '${context.l10n!.provideIdOrNameError}.', ); } @@ -139,7 +139,7 @@ class _UserPlaylistsPageState extends State { logger .log('Error on user playlists page: ${snapshot.error}'); return Center( - child: Text(context.l10n()!.error), + child: Text(context.l10n!.error), ); } else if (!snapshot.hasData || (snapshot.data as List).isEmpty) { @@ -169,19 +169,19 @@ class _UserPlaylistsPageState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - title: Text(context.l10n()!.confirmation), + title: Text(context.l10n!.confirmation), content: Text( - context.l10n()!.removePlaylistQuestion, + context.l10n!.removePlaylistQuestion, ), actions: [ TextButton( - child: Text(context.l10n()!.cancel), + child: Text(context.l10n!.cancel), onPressed: () { Navigator.of(context).pop(); }, ), TextButton( - child: Text(context.l10n()!.remove), + child: Text(context.l10n!.remove), onPressed: () { Navigator.of(context).pop(); diff --git a/lib/screens/user_liked_playlists_page.dart b/lib/screens/user_liked_playlists_page.dart index 25bb7f649..4dbb28464 100644 --- a/lib/screens/user_liked_playlists_page.dart +++ b/lib/screens/user_liked_playlists_page.dart @@ -10,7 +10,7 @@ class UserLikedPlaylistsPage extends StatelessWidget { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.userLikedPlaylists, + context.l10n!.userLikedPlaylists, ), ), body: ValueListenableBuilder( @@ -19,7 +19,7 @@ class UserLikedPlaylistsPage extends StatelessWidget { return userLikedPlaylists.isEmpty ? Center( child: Text( - context.l10n()!.noLikedPlaylists, + context.l10n!.noLikedPlaylists, textAlign: TextAlign.center, style: TextStyle( fontSize: 16, diff --git a/lib/screens/user_liked_songs_page.dart b/lib/screens/user_liked_songs_page.dart index bf9b891cc..98be30726 100644 --- a/lib/screens/user_liked_songs_page.dart +++ b/lib/screens/user_liked_songs_page.dart @@ -21,7 +21,7 @@ class _UserLikedSongsState extends State { return Scaffold( appBar: AppBar( title: Text( - context.l10n()!.userLikedSongs, + context.l10n!.userLikedSongs, ), ), body: CustomScrollView( @@ -84,7 +84,7 @@ class _UserLikedSongsState extends State { Padding( padding: const EdgeInsets.symmetric(vertical: 20), child: Text( - '${context.l10n()!.yourFavoriteSongsHere}!', + '${context.l10n!.yourFavoriteSongsHere}!', style: const TextStyle( fontWeight: FontWeight.w300, ), @@ -100,7 +100,7 @@ class _UserLikedSongsState extends State { return Card( color: Colors.transparent, child: PlaylistCube( - title: context.l10n()!.userLikedSongs, + title: context.l10n!.userLikedSongs, onClickOpen: false, showFavoriteButton: false, zoomNumber: 0.55, @@ -114,7 +114,7 @@ class _UserLikedSongsState extends State { setActivePlaylist( { 'ytid': '', - 'title': context.l10n()!.userLikedSongs, + 'title': context.l10n!.userLikedSongs, 'header_desc': '', 'image': '', 'list': userLikedSongsList, @@ -122,7 +122,7 @@ class _UserLikedSongsState extends State { ); showToast( context, - context.l10n()!.queueInitText, + context.l10n!.queueInitText, ); }, child: Icon( diff --git a/lib/services/data_manager.dart b/lib/services/data_manager.dart index 85046010a..8be5c6af0 100644 --- a/lib/services/data_manager.dart +++ b/lib/services/data_manager.dart @@ -64,7 +64,7 @@ Future backupData(BuildContext context) async { final dlPath = await FilePicker.platform.getDirectoryPath(); if (dlPath == null) { - return '${context.l10n()!.chooseBackupDir}!'; + return '${context.l10n!.chooseBackupDir}!'; } for (var i = 0; i < boxNames.length; i++) { @@ -74,10 +74,10 @@ Future backupData(BuildContext context) async { await File(_box.path!).copy('$dlPath/${boxNames[i]}Data.hive'); await _box.close(); } catch (e) { - return '${context.l10n()!.backupError}: $e'; + return '${context.l10n!.backupError}: $e'; } } - return '${context.l10n()!.backedupSuccess}!'; + return '${context.l10n!.backedupSuccess}!'; } Future restoreData(BuildContext context) async { @@ -85,7 +85,7 @@ Future restoreData(BuildContext context) async { final uplPath = await FilePicker.platform.getDirectoryPath(); if (uplPath == null) { - return '${context.l10n()!.chooseRestoreDir}!'; + return '${context.l10n!.chooseRestoreDir}!'; } for (var i = 0; i < boxNames.length; i++) { @@ -95,9 +95,9 @@ Future restoreData(BuildContext context) async { await File('$uplPath/${boxNames[i]}Data.hive').copy(boxPath!); await _box.close(); } catch (e) { - return '${context.l10n()!.restoreError}: $e'; + return '${context.l10n!.restoreError}: $e'; } } - return '${context.l10n()!.restoredSuccess}!'; + return '${context.l10n!.restoredSuccess}!'; } diff --git a/lib/services/download_manager.dart b/lib/services/download_manager.dart index 5a226f617..774fec463 100644 --- a/lib/services/download_manager.dart +++ b/lib/services/download_manager.dart @@ -48,7 +48,7 @@ Future downloadSong(BuildContext context, dynamic song) async { ); } catch (e) { logger.log('Error while downloading song: $e'); - showToast(context, '${context.l10n()!.downloadFailed}, $e'); + showToast(context, '${context.l10n!.downloadFailed}, $e'); } } @@ -80,10 +80,10 @@ Future downloadSongFaster(BuildContext context, dynamic song) async { await FileDownloader() .moveFileToSharedStorage(file.path, SharedStorage.downloads); } - showToast(context, '${context.l10n()!.downloadCompleted} - $songName'); + showToast(context, '${context.l10n!.downloadCompleted} - $songName'); } catch (e) { logger.log('Error while downloading song: $e'); - showToast(context, '${context.l10n()!.downloadFailed}, $e'); + showToast(context, '${context.l10n!.downloadFailed}, $e'); } } @@ -96,14 +96,14 @@ Future downloadSongsFromPlaylist( final _pauseDuration = _isHeavyProcess ? const Duration(seconds: 10) : const Duration(seconds: 5); - showToast(context, context.l10n()!.fasterDownloadMsg); + showToast(context, context.l10n!.fasterDownloadMsg); for (final song in list) { await downloadSongFaster(context, song); await Future.delayed(_pauseDuration); } } catch (e) { logger.log('Error while downloading playlist songs: $e'); - showToast(context, '${context.l10n()!.downloadFailed}, $e'); + showToast(context, '${context.l10n!.downloadFailed}, $e'); } } @@ -116,7 +116,7 @@ Future checkNecessaryPermissions(BuildContext context) async { logger.log('Error while requesting permissions: $e'); showToast( context, - '${context.l10n()!.errorWhileRequestingPerms} + $e', + '${context.l10n!.errorWhileRequestingPerms} + $e', ); } } diff --git a/lib/services/logger_service.dart b/lib/services/logger_service.dart index 591ad03de..f542533fe 100644 --- a/lib/services/logger_service.dart +++ b/lib/services/logger_service.dart @@ -18,9 +18,9 @@ class Logger { try { if (_logs != '') { await Clipboard.setData(ClipboardData(text: _logs)); - return '${context.l10n()!.copyLogsSuccess}.'; + return '${context.l10n!.copyLogsSuccess}.'; } else { - return '${context.l10n()!.copyLogsNoLogs}.'; + return '${context.l10n!.copyLogsNoLogs}.'; } } catch (e) { log('Error copying logs: $e'); diff --git a/lib/services/update_manager.dart b/lib/services/update_manager.dart index 440b786b8..eb3ac2696 100644 --- a/lib/services/update_manager.dart +++ b/lib/services/update_manager.dart @@ -29,12 +29,12 @@ Future checkAppUpdates( await downloadAppUpdates(map); showToast( context, - '${context.l10n()!.appUpdateAvailableAndDownloading}!', + '${context.l10n!.appUpdateAvailableAndDownloading}!', ); } else { showToast( context, - '${context.l10n()!.appUpdateIsAvailable}!', + '${context.l10n!.appUpdateIsAvailable}!', ); } }