diff --git a/lib/app_router.dart b/lib/app_router.dart index d3d77ceb..e249686f 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -20,6 +20,7 @@ final isEverythingLoadedProvider = Provider((ref) => ref.watch(SignificantFigures.provider).hasValue && ref.watch(RemoveTrailingZeros.provider).hasValue && ref.watch(IsDarkAmoled.provider).hasValue && + ref.watch(RevokeInternetNotifier.provider).hasValue && ref.watch(CurrentThemeMode.provider).hasValue && ref.watch(CurrentLocale.provider).hasValue && ref.watch(PropertiesOrderNotifier.provider).hasValue && diff --git a/lib/models/currencies.dart b/lib/models/currencies.dart index 04d3de7d..a49c45ca 100644 --- a/lib/models/currencies.dart +++ b/lib/models/currencies.dart @@ -143,7 +143,8 @@ final currenciesProvider = FutureProvider((ref) async { String? lastUpdate = pref.getString("lastUpdateCurrencies"); // if I have never updated the conversions or if I have updated before today // I have to update - if (lastUpdate == null || lastUpdate != now) { + if (!(ref.read(RevokeInternetNotifier.provider).valueOrNull ?? false) && + (lastUpdate == null || lastUpdate != now)) { return downloadCurrencies(); } // If I already have the data of today I just use it, no need of read them diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 7040415c..c0716720 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -77,6 +77,23 @@ class IsDarkAmoled extends AsyncNotifier { } } +class RevokeInternetNotifier extends AsyncNotifier { + static const _prefKey = 'revokeInternet'; + static final provider = AsyncNotifierProvider( + RevokeInternetNotifier.new); + + @override + Future build() async { + var pref = await ref.watch(sharedPref.future); + return pref.getBool(_prefKey) ?? false; + } + + void set(bool value) { + state = AsyncData(value); + ref.read(sharedPref.future).then((pref) => pref.setBool(_prefKey, value)); + } +} + class CurrentThemeMode extends AsyncNotifier { static const _prefKey = 'currentThemeMode'; static final provider = diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 819203f8..8d136768 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -86,6 +86,59 @@ class SettingsPage extends ConsumerWidget { }, shape: const RoundedRectangleBorder(borderRadius: borderRadius), ), + if (!kIsWeb) + SwitchListTile( + secondary: Icon(Icons.public_off, color: iconColor), + title: Text( + AppLocalizations.of(context)!.revokeInternetAccess, + style: textStyle, + ), + value: + ref.watch(RevokeInternetNotifier.provider).valueOrNull ?? false, + activeColor: Theme.of(context).colorScheme.secondary, + onChanged: (bool val) { + if (val) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + AppLocalizations.of(context)!.revokeInternetAccess, + ), + content: SizedBox( + width: 500, + child: Text( + AppLocalizations.of(context)! + .revokeInternetExplanation, + style: Theme.of(context).textTheme.bodyLarge, + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + // Introduce a tiny delay to let the user see the + // switch to turn on + Future.delayed( + const Duration(milliseconds: 200), + () => ref + .read( + RevokeInternetNotifier.provider.notifier) + .set(val), + ); + }, + child: Text(AppLocalizations.of(context)!.ok), + ), + ], + ); + }, + ); + } else { + ref.read(RevokeInternetNotifier.provider.notifier).set(val); + } + }, + shape: const RoundedRectangleBorder(borderRadius: borderRadius), + ), SwitchListTile( secondary: SvgPicture( const AssetBytesLoader( @@ -280,7 +333,7 @@ class SettingsPage extends ConsumerWidget { width: 500, child: Text( AppLocalizations.of(context)!.donationDialog, - style: const TextStyle(fontSize: 18), + style: Theme.of(context).textTheme.bodyLarge, ), ), actions: [ diff --git a/packages/translations/lib/l10n/app_ar.arb b/packages/translations/lib/l10n/app_ar.arb index 743b9d0d..a8260ab6 100644 --- a/packages/translations/lib/l10n/app_ar.arb +++ b/packages/translations/lib/l10n/app_ar.arb @@ -53,6 +53,18 @@ "undo": "تراجُع", "routeError1": "هذه الصفحة غير موجودة", "routeError2": "الروجوع إلى الصفحة الأولى", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "الطول", "area": "المساحة", diff --git a/packages/translations/lib/l10n/app_ca.arb b/packages/translations/lib/l10n/app_ca.arb index 6039fa5f..b2facf7b 100644 --- a/packages/translations/lib/l10n/app_ca.arb +++ b/packages/translations/lib/l10n/app_ca.arb @@ -53,6 +53,18 @@ "undo": "Desfés", "routeError1": "Aquesta pàgina no existeix", "routeError2": "Torna a la primera pàgina", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Longitud", "area": "Àrea", diff --git a/packages/translations/lib/l10n/app_de.arb b/packages/translations/lib/l10n/app_de.arb index a115e50d..8811f930 100644 --- a/packages/translations/lib/l10n/app_de.arb +++ b/packages/translations/lib/l10n/app_de.arb @@ -53,6 +53,18 @@ "undo": "Rückgängig machen", "routeError1": "Diese Seite existiert nicht.", "routeError2": "Zurück zur ersten Seite gehen", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Länge", "area": "Fläche", diff --git a/packages/translations/lib/l10n/app_en.arb b/packages/translations/lib/l10n/app_en.arb index 9ee534c2..04e3913d 100644 --- a/packages/translations/lib/l10n/app_en.arb +++ b/packages/translations/lib/l10n/app_en.arb @@ -53,6 +53,9 @@ "undo": "Undo", "routeError1": "This page doesn't exist", "routeError2": "Go back to the first page", + "ok": "Ok", + "revokeInternetAccess": "Revoke internet access", + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", "length": "Length", "area": "Area", diff --git a/packages/translations/lib/l10n/app_es.arb b/packages/translations/lib/l10n/app_es.arb index 2fbabe1c..cf2d9360 100644 --- a/packages/translations/lib/l10n/app_es.arb +++ b/packages/translations/lib/l10n/app_es.arb @@ -59,6 +59,18 @@ "@routeError2": { "description": "Not yet translated. Once done, remove this comment" }, + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Longitud", "area": "Área", diff --git a/packages/translations/lib/l10n/app_fr.arb b/packages/translations/lib/l10n/app_fr.arb index 0f6c800e..92d6423d 100644 --- a/packages/translations/lib/l10n/app_fr.arb +++ b/packages/translations/lib/l10n/app_fr.arb @@ -53,6 +53,18 @@ "undo": "Annuler", "routeError1": "Cette page n'existe pas", "routeError2": "Revenir à la première page", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Distance", "area": "Superficie", diff --git a/packages/translations/lib/l10n/app_hr.arb b/packages/translations/lib/l10n/app_hr.arb index ff7386ee..87af77fb 100644 --- a/packages/translations/lib/l10n/app_hr.arb +++ b/packages/translations/lib/l10n/app_hr.arb @@ -53,6 +53,18 @@ "undo": "Poništi", "routeError1": "Ova stranica ne postoji", "routeError2": "Vrati se na prvu stranicu", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Duljina", "area": "Površina", diff --git a/packages/translations/lib/l10n/app_id.arb b/packages/translations/lib/l10n/app_id.arb index 17a8ffd5..96dbe77c 100644 --- a/packages/translations/lib/l10n/app_id.arb +++ b/packages/translations/lib/l10n/app_id.arb @@ -53,6 +53,18 @@ "undo": "Urung", "routeError1": "Halaman ini tidak ada", "routeError2": "Kembali ke beranda", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Panjang", "area": "Luas", diff --git a/packages/translations/lib/l10n/app_it.arb b/packages/translations/lib/l10n/app_it.arb index f8a75c50..eb490d18 100644 --- a/packages/translations/lib/l10n/app_it.arb +++ b/packages/translations/lib/l10n/app_it.arb @@ -53,6 +53,9 @@ "undo": "Annulla", "routeError1": "Questa pagina non esiste", "routeError2": "Ritorna alla prima pagina", + "ok": "Ok", + "revokeInternetAccess": "Revoca l'accesso a internet", + "revokeInternetExplanation": "Questa app utilizza internet per aggiornare i tassi di cambio delle valute una volta al giorno (quando viene aperta). Si tratta di pochi chilobyte di download, ma se non hai bisogno di questa funzionalità puoi prevenire che la app acceda ad intenet abilitando questa opzione.", "length": "Lunghezza", "area": "Superficie", diff --git a/packages/translations/lib/l10n/app_ja.arb b/packages/translations/lib/l10n/app_ja.arb index b75679cf..c88c3bf7 100644 --- a/packages/translations/lib/l10n/app_ja.arb +++ b/packages/translations/lib/l10n/app_ja.arb @@ -53,6 +53,18 @@ "undo": "元に戻す", "routeError1": "このページは存在しません。", "routeError2": "先頭ページに戻る", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "長さ", "area": "面積", diff --git a/packages/translations/lib/l10n/app_nb.arb b/packages/translations/lib/l10n/app_nb.arb index 425beb9f..d36517d9 100644 --- a/packages/translations/lib/l10n/app_nb.arb +++ b/packages/translations/lib/l10n/app_nb.arb @@ -53,6 +53,18 @@ "undo": "Angre", "routeError1": "Denne siden finnes ikke", "routeError2": "Gå tilbake til den første siden", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Lengde", "area": "Areal", diff --git a/packages/translations/lib/l10n/app_nl.arb b/packages/translations/lib/l10n/app_nl.arb index d7d68488..ea986ca0 100644 --- a/packages/translations/lib/l10n/app_nl.arb +++ b/packages/translations/lib/l10n/app_nl.arb @@ -43,7 +43,7 @@ "placeholders": { "property": { "type": "String", - "voorbeeld": "Lengte" + "example": "Lengte" } } }, @@ -53,6 +53,18 @@ "undo": "Ongedaan maken", "routeError1": "Deze pagina lijkt niet te bestaan", "routeError2": "Ga terug naar de eerste pagina", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Lengte", "area": "Oppervlak", diff --git a/packages/translations/lib/l10n/app_pl.arb b/packages/translations/lib/l10n/app_pl.arb index 73dddc94..c3d533ba 100644 --- a/packages/translations/lib/l10n/app_pl.arb +++ b/packages/translations/lib/l10n/app_pl.arb @@ -42,7 +42,7 @@ "@reorderProperty":{ "placeholders": { "property": { - "type": "Ciąg", + "type": "String", "example": "Długość" } } @@ -53,6 +53,18 @@ "undo": "Cofnij", "routeError1": "Ta strona nie istnieje", "routeError2": "Wróć do pierwszej strony", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Długość", "area": "Powierzchnia", diff --git a/packages/translations/lib/l10n/app_pt.arb b/packages/translations/lib/l10n/app_pt.arb index fb3d9895..6b598cf6 100644 --- a/packages/translations/lib/l10n/app_pt.arb +++ b/packages/translations/lib/l10n/app_pt.arb @@ -64,6 +64,18 @@ "@routeError2": { "description": "Not yet translated. Once done, remove this comment" }, + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Comprimento", "area": "Área", diff --git a/packages/translations/lib/l10n/app_ru.arb b/packages/translations/lib/l10n/app_ru.arb index a060ce02..5eb2f9ad 100644 --- a/packages/translations/lib/l10n/app_ru.arb +++ b/packages/translations/lib/l10n/app_ru.arb @@ -55,6 +55,18 @@ "undo": "Отмена", "routeError1": "Этой страницы не существует", "routeError2": "Вернутся на первую страницу", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Длина", "area": "Площадь", diff --git a/packages/translations/lib/l10n/app_tr.arb b/packages/translations/lib/l10n/app_tr.arb index abba696c..d790908b 100644 --- a/packages/translations/lib/l10n/app_tr.arb +++ b/packages/translations/lib/l10n/app_tr.arb @@ -43,7 +43,7 @@ "placeholders": { "property": { "type": "String", - "example": "Uzunluk" + "example": "Lenght" } } }, @@ -53,6 +53,18 @@ "undo": "Geri al", "routeError1": "Bu sayfa mevcut değil", "routeError2": "İlk sayfaya geri dön", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "Uzunluk", "area": "Alan", diff --git a/packages/translations/lib/l10n/app_zh.arb b/packages/translations/lib/l10n/app_zh.arb index 97282851..3c25be67 100644 --- a/packages/translations/lib/l10n/app_zh.arb +++ b/packages/translations/lib/l10n/app_zh.arb @@ -53,6 +53,18 @@ "undo": "撤消", "routeError1": "不存在此页面", "routeError2": "返回上一级", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "长度", "area": "面积", diff --git a/packages/translations/lib/l10n/app_zh_TW.arb b/packages/translations/lib/l10n/app_zh_TW.arb index be384883..00bb918d 100644 --- a/packages/translations/lib/l10n/app_zh_TW.arb +++ b/packages/translations/lib/l10n/app_zh_TW.arb @@ -53,6 +53,18 @@ "undo": "取消", "routeError1": "此頁面不存在", "routeError2": "返回至第一頁", + "ok": "Ok", + "@ok": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetAccess": "Revoke internet access", + "@revokeInternetAccess": { + "description": "Not yet translated. Once done, remove this comment" + }, + "revokeInternetExplanation": "This app uses the internet to update currency exchange rates once a day (when opened). It is a few kilobytes of download, but if you do not need this feature you can prevent the app from accessing the intenet by enabling this option.", + "@revokeInternetExplanation": { + "description": "Not yet translated. Once done, remove this comment" + }, "length": "長度", "area": "面積",