Skip to content

Commit

Permalink
Improve: Changed offline mode function, you need to turn it on manual…
Browse files Browse the repository at this point in the history
…ly if you want to use it
  • Loading branch information
gokadzev committed May 28, 2024
1 parent 1882f9f commit 0534ba1
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 58 deletions.
2 changes: 2 additions & 0 deletions lib/localization/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "لم تعجب بأي قوائم تشغيل بعد",
"notYTlist": "هذا ليس معرف قائمة تشغيل YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "آخرون",
"playlist": "قائمة تشغيل",
Expand All @@ -61,6 +62,7 @@
"remove": "إزالة",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "حدث خطأ أثناء استعادة البيانات",
"restoreUserData": "استعادة بيانات المستخدم",
"restoredSuccess": "تمت الاستعادة بنجاح",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Du hast noch keine Playlists geliked",
"notYTlist": "Das ist keine YouTube-Playlist-ID",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Andere",
"playlist": "Wiedergabeliste",
Expand All @@ -61,6 +62,7 @@
"remove": "Entfernen",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Fehler bei der Datenwiederherstellung",
"restoreUserData": "Benutzerdaten wiederherstellen",
"restoredSuccess": "Erfolgreich wiederhergestellt",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_el.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Δεν έχετε επισημάνει ακόμα λίστες αναπαραγωγής με την ένδειξη Μου αρέσει",
"notYTlist": "Αυτό δεν είναι αναγνωριστικό λίστας αναπαραγωγής του YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Άλλα",
"playlist": "Λίστα αναπαραγωγής",
Expand All @@ -61,6 +62,7 @@
"remove": "Αφαίρεση",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Σφάλμα κατά την επαναφορά δεδομένων",
"restoreUserData": "Επαναφορά δεδομένων χρήστη",
"restoredSuccess": "Η επαναφορά ολοκληρώθηκε με επιτυχία",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "You haven't liked any playlists yet",
"notYTlist": "This is not a valid YouTube playlist ID",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Others",
"playlist": "Playlist",
Expand All @@ -61,6 +62,7 @@
"remove": "Remove",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Error occurred while restoring data",
"restoreUserData": "Restore user data",
"restoredSuccess": "Data restored successfully",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Todavía no has dado like a ninguna lista de reproducción",
"notYTlist": "¡Esto no es un ID de una lista de reproducción de YouTube!",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Otros",
"playlist": "Lista de reproducción",
Expand All @@ -61,6 +62,7 @@
"remove": "Eliminar",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Error al restaurar los datos",
"restoreUserData": "Restaurar datos de usuario",
"restoredSuccess": "Restaurado con éxito",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Pas de liste de lecteur favorite",
"notYTlist": "Ceci n'est pas un ID de playlist YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Autres",
"playlist": "Liste de lecture",
Expand All @@ -61,6 +62,7 @@
"remove": "Supprimer",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Erreur pendant la restauration",
"restoreUserData": "Restaurer les données utilisateur",
"restoredSuccess": "Restauration réussie",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "आपको अभी तक कोई भी प्लेलिस्ट पसंद नहीं आई है",
"notYTlist": "यह यूट्यूब प्लेलिस्ट आईडी नहीं है",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "अन्य",
"playlist": "प्लेलिस्ट",
Expand All @@ -61,6 +62,7 @@
"remove": "निकालना",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "डेटा पुनर्स्थापित करते समय त्रुटि",
"restoreUserData": "यूज़र डेटा को बहाल करें",
"restoredSuccess": "सफलतापूर्वक पुनर्स्थापित किया गया",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_ka.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "ჯერჯერობით არ გაქვს მოწონებული ფლეილისთები",
"notYTlist": "ეს არ არის YouTube ფლეილისთის აიდი",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "სხვა",
"playlist": "ფლეილისთი",
Expand All @@ -61,6 +62,7 @@
"remove": "ამოშლა",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "შეცდომა ინფორმაციის დაბრუნებისას",
"restoreUserData": "მომხმარებლის ინფორმაციის დაბრუნება",
"restoredSuccess": "წარმატებით დაბრუნდა",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Nie polubiłeś jeszcze żadnej playlisty",
"notYTlist": "To nie jest ID playlisty w YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Inne",
"playlist": "Playlista",
Expand All @@ -61,6 +62,7 @@
"remove": "Remove",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Błąd podczas przywracania danych",
"restoreUserData": "Przywróć dane użytkownika",
"restoredSuccess": "Przywrócono pomyślnie",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Você ainda não marcou nenhuma playlist como gostei",
"notYTlist": "Isso não é um ID de playlist do YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Outros",
"playlist": "Playlist",
Expand All @@ -61,6 +62,7 @@
"remove": "Remover",
"removePlaylistQuestion": "Remover essa playlist?",
"removeSearchQueryQuestion": "Remover essa pesquisa?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Erro ao restaurar os dados",
"restoreUserData": "Restaurar dados do usuário",
"restoredSuccess": "Restaurado com sucesso",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Нет понравившихся плейлистов",
"notYTlist": "Неверный ID плейлиста YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Ещё",
"playlist": "Плейлист",
Expand All @@ -61,6 +62,7 @@
"remove": "Удалить",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Ошибка при восстановлении данных",
"restoreUserData": "Восстановить пользовательские данные",
"restoredSuccess": "Данные успешно восстановлены",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_tr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Henüz hiçbir çalma listesini beğenmediniz",
"notYTlist": "Bu bir YouTube çalma listesi kimliği değil",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Diğerleri",
"playlist": "Çalma Listesi",
Expand All @@ -61,6 +62,7 @@
"remove": "Kaldır",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Veri geri yükleme sırasında hata oluştu",
"restoreUserData": "Kullanıcı Verilerini Geri Yükle",
"restoredSuccess": "Başarıyla Geri Yüklendi",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_uk.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Вам ще не сподобався жоден список відтворення",
"notYTlist": "Це не ідентифікатор плейлиста YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Інше",
"playlist": "Плейлист",
Expand All @@ -61,6 +62,7 @@
"remove": "Видалити",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Помилка під час відновлення даних",
"restoreUserData": "Відновити дані користувача",
"restoredSuccess": "Відновлено успішно",
Expand Down
2 changes: 2 additions & 0 deletions lib/localization/app_vi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"noCustomPlaylists": "You haven't created any custom playlists yet",
"noLikedPlaylists": "Bạn chưa thích bất kỳ danh sách phát nào",
"notYTlist": "Đây không phải là ID của danh sách phát YouTube",
"offlineMode": "Offline mode",
"offlineSongs": "Offline songs",
"others": "Khác",
"playlist": "Danh sách phát",
Expand All @@ -61,6 +62,7 @@
"remove": "Xóa",
"removePlaylistQuestion": "Remove this playlist?",
"removeSearchQueryQuestion": "Remove this search query?",
"restartAppMsg": "Restart the app to apply the changes",
"restoreError": "Lỗi khi khôi phục dữ liệu",
"restoreUserData": "Khôi phục dữ liệu người dùng",
"restoredSuccess": "Khôi phục thành công",
Expand Down
10 changes: 4 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:internet_connection_checker_plus/internet_connection_checker_plus.dart';
import 'package:musify/services/audio_service.dart';
import 'package:musify/services/data_manager.dart';
import 'package:musify/services/logger_service.dart';
Expand All @@ -45,8 +44,6 @@ final logger = Logger();
bool isFdroidBuild = false;
bool isUpdateChecked = false;

late bool isOnline;

final appLanguages = <String, String>{
'English': 'en',
'Arabic': 'ar',
Expand Down Expand Up @@ -135,7 +132,10 @@ class _MusifyState extends State<Musify> {
logger.log('License Registration Error', e, stackTrace);
}

if (!isFdroidBuild && !isUpdateChecked && isOnline && kReleaseMode) {
if (!isFdroidBuild &&
!isUpdateChecked &&
!offlineMode.value &&
kReleaseMode) {
Future.delayed(Duration.zero, () {
checkAppUpdates();
isUpdateChecked = true;
Expand Down Expand Up @@ -202,8 +202,6 @@ Future<void> initialisation() async {
),
);

isOnline = await InternetConnection().hasInternetAccess;

// Init router
NavigationManager.instance;
} catch (e, stackTrace) {
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/bottom_navigation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _BottomNavigationPageState extends State<BottomNavigationPage> {
_selectedIndex.value = index;
});
},
destinations: isOnline
destinations: !offlineMode.value
? [
NavigationDestination(
icon: const Icon(FluentIcons.home_24_regular),
Expand Down
10 changes: 5 additions & 5 deletions lib/screens/now_playing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class NowPlayingPage extends StatelessWidget {

return FlipCard(
rotateSide: RotateSide.right,
onTapFlipping: isOnline,
onTapFlipping: !offlineMode.value,
controller: _lyricsController,
frontWidget: SongArtworkWidget(
metadata: metadata,
Expand Down Expand Up @@ -398,7 +398,7 @@ class NowPlayingPage extends StatelessWidget {
);
},
),
if (isOnline)
if (!offlineMode.value)
IconButton.filledTonal(
icon: Icon(
Icons.add,
Expand Down Expand Up @@ -444,7 +444,7 @@ class NowPlayingPage extends StatelessWidget {
);
},
),
if (isOnline)
if (!offlineMode.value)
IconButton.filledTonal(
icon: Icon(
FluentIcons.text_32_filled,
Expand All @@ -453,7 +453,7 @@ class NowPlayingPage extends StatelessWidget {
iconSize: iconSize,
onPressed: _lyricsController.flipcard,
),
if (isOnline)
if (!offlineMode.value)
ValueListenableBuilder<bool>(
valueListenable: songLikeStatus,
builder: (_, value, __) {
Expand All @@ -472,7 +472,7 @@ class NowPlayingPage extends StatelessWidget {
);
},
),
if (isOnline)
if (!offlineMode.value)
ValueListenableBuilder<bool>(
valueListenable: playNextSongAutomatically,
builder: (_, value, __) {
Expand Down
24 changes: 23 additions & 1 deletion lib/screens/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,29 @@ class SettingsPage extends StatelessWidget {
);
},
),
if (isOnline)
ValueListenableBuilder<bool>(
valueListenable: offlineMode,
builder: (_, value, __) {
return SettingSwitchBar(
tileName: context.l10n!.offlineMode,
tileIcon: FluentIcons.cellular_off_24_regular,
value: value,
onChanged: (value) {
addOrUpdateData(
'settings',
'offlineMode',
value,
);
offlineMode.value = value;
showToast(
context,
context.l10n!.restartAppMsg,
);
},
);
},
),
if (!offlineMode.value)
Column(
children: [
ValueListenableBuilder<bool>(
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/user_songs_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'package:flutter/material.dart';
import 'package:musify/API/musify.dart';
import 'package:musify/extensions/l10n.dart';
import 'package:musify/main.dart';
import 'package:musify/services/settings_manager.dart';
import 'package:musify/widgets/playlist_cube.dart';
import 'package:musify/widgets/playlist_header.dart';
import 'package:musify/widgets/song_bar.dart';
Expand Down Expand Up @@ -52,7 +53,7 @@ class _UserSongsPageState extends State<UserSongsPage> {

return Scaffold(
appBar: AppBar(
title: !isOnline ? Text(title) : null,
title: offlineMode.value ? Text(title) : null,
actions: [
if (title == context.l10n!.likedSongs)
IconButton(
Expand Down
4 changes: 2 additions & 2 deletions lib/services/router_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:musify/API/version.dart';
import 'package:musify/main.dart';
import 'package:musify/screens/about_page.dart';
import 'package:musify/screens/bottom_navigation_page.dart';
import 'package:musify/screens/home_page.dart';
Expand All @@ -32,6 +31,7 @@ import 'package:musify/screens/settings_page.dart';
import 'package:musify/screens/user_added_playlists_page.dart';
import 'package:musify/screens/user_liked_playlists_page.dart';
import 'package:musify/screens/user_songs_page.dart';
import 'package:musify/services/settings_manager.dart';

class NavigationManager {
factory NavigationManager() {
Expand All @@ -42,7 +42,7 @@ class NavigationManager {
final routes = [
StatefulShellRoute.indexedStack(
parentNavigatorKey: parentNavigatorKey,
branches: isOnline ? _onlineRoutes() : _offlineRoutes(),
branches: !offlineMode.value ? _onlineRoutes() : _offlineRoutes(),
pageBuilder: (
BuildContext context,
GoRouterState state,
Expand Down
4 changes: 4 additions & 0 deletions lib/services/settings_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ final useSystemColor = ValueNotifier<bool>(
Hive.box('settings').get('useSystemColor', defaultValue: true),
);

final offlineMode = ValueNotifier<bool>(
Hive.box('settings').get('offlineMode', defaultValue: false),
);

final sponsorBlockSupport = ValueNotifier<bool>(
Hive.box('settings').get('sponsorBlockSupport', defaultValue: false),
);
Expand Down
Loading

0 comments on commit 0534ba1

Please sign in to comment.