Complete null-safety migration

This commit is contained in:
Neeraj Gupta 2023-04-10 09:47:45 +05:30
parent fc2db578a8
commit 8f7226cb02
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
66 changed files with 1108 additions and 596 deletions

View file

@ -1,2 +1,2 @@
// @dart=2.9
export "view/app.dart"; export "view/app.dart";

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
@ -20,10 +20,10 @@ import 'package:flutter_localizations/flutter_localizations.dart';
class App extends StatefulWidget { class App extends StatefulWidget {
final Locale locale; final Locale locale;
const App({Key key, this.locale = const Locale("en")}) : super(key: key); const App({Key? key, this.locale = const Locale("en")}) : super(key: key);
static void setLocale(BuildContext context, Locale newLocale) { static void setLocale(BuildContext context, Locale newLocale) {
_AppState state = context.findAncestorStateOfType<_AppState>(); _AppState state = context.findAncestorStateOfType<_AppState>()!;
state.setLocale(newLocale); state.setLocale(newLocale);
} }
@ -32,9 +32,9 @@ class App extends StatefulWidget {
} }
class _AppState extends State<App> { class _AppState extends State<App> {
StreamSubscription<SignedOutEvent> _signedOutEvent; late StreamSubscription<SignedOutEvent> _signedOutEvent;
StreamSubscription<SignedInEvent> _signedInEvent; late StreamSubscription<SignedInEvent> _signedInEvent;
Locale locale; Locale? locale;
setLocale(Locale newLocale) { setLocale(Locale newLocale) {
setState(() { setState(() {
locale = newLocale; locale = newLocale;

View file

@ -452,7 +452,7 @@ class Configuration {
return _preferences.setBool(keyShouldShowLockScreen, value); return _preferences.setBool(keyShouldShowLockScreen, value);
} }
void setVolatilePassword(String volatilePassword) { void setVolatilePassword(String? volatilePassword) {
_volatilePassword = volatilePassword; _volatilePassword = volatilePassword;
} }

View file

@ -358,6 +358,9 @@ extension CustomColorScheme on ColorScheme {
EnteTheme get enteTheme => EnteTheme get enteTheme =>
brightness == Brightness.light ? lightTheme : darkTheme; brightness == Brightness.light ? lightTheme : darkTheme;
EnteTheme get inverseEnteTheme =>
brightness == Brightness.light ? darkTheme : lightTheme;
} }
OutlinedButtonThemeData buildOutlinedButtonThemeData({ OutlinedButtonThemeData buildOutlinedButtonThemeData({

View file

@ -46,13 +46,13 @@
}, },
"contactSupport": "Support kontaktieren", "contactSupport": "Support kontaktieren",
"verifyPassword": "Passwort überprüfen", "verifyPassword": "Passwort überprüfen",
"pleaseWaitTitle": "Bitte warten...", "pleaseWait": "Bitte warten...",
"generatingEncryptionKeysTitle": "Generierung von Verschlüsselungsschlüsseln...", "generatingEncryptionKeysTitle": "Generierung von Verschlüsselungsschlüsseln...",
"recreatePassword": "Passwort wiederherstellen", "recreatePassword": "Passwort wiederherstellen",
"recreatePasswordMessage": "Das aktuelle Gerät ist nicht leistungsfähig genug, um Ihr Passwort zu verifizieren, daher müssen wir es einmalig auf eine Weise neu generieren, die mit allen Geräten funktioniert. \n\nBitte melden Sie sich mit Ihrem Wiederherstellungsschlüssel an und generieren Sie Ihr Passwort neu (Sie können dasselbe erneut verwenden, wenn Sie möchten).", "recreatePasswordMessage": "Das aktuelle Gerät ist nicht leistungsfähig genug, um Ihr Passwort zu verifizieren, daher müssen wir es einmalig auf eine Weise neu generieren, die mit allen Geräten funktioniert. \n\nBitte melden Sie sich mit Ihrem Wiederherstellungsschlüssel an und generieren Sie Ihr Passwort neu (Sie können dasselbe erneut verwenden, wenn Sie möchten).",
"useRecoveryKeyAction": "Wiederherstellungsschlüssel verwenden", "useRecoveryKey": "Wiederherstellungsschlüssel verwenden",
"incorrectPassword": "Falsches Passwort", "incorrectPasswordTitle": "Falsches Passwort",
"welcomeBackTitle": "Willkommen zurück!", "welcomeBack": "Willkommen zurück!",
"madeWithLoveAtPrefix": "gemacht mit ❤️ bei ", "madeWithLoveAtPrefix": "gemacht mit ❤️ bei ",
"changeEmail": "E-Mail ändern", "changeEmail": "E-Mail ändern",
"cancel": "Abbrechen", "cancel": "Abbrechen",
@ -62,7 +62,7 @@
"support": "Unterstützung", "support": "Unterstützung",
"settings": "Einstellungen", "settings": "Einstellungen",
"copied": "Kopiert", "copied": "Kopiert",
"tryAgainMessage": "Bitte versuchen Sie es erneut", "pleaseTryAgain": "Bitte versuchen Sie es erneut",
"existingUser": "Bestehender Benutzer", "existingUser": "Bestehender Benutzer",
"newUser": "Neu bei ente", "newUser": "Neu bei ente",
"delete": "Löschen", "delete": "Löschen",
@ -103,9 +103,9 @@
"confirmAccountDeleteMessage": "Ihre hochgeladenen Daten werden in allen Anwendungen (sowohl Fotos als auch Authenticator) zur Löschung vorgesehen und Ihr Konto wird dauerhaft gelöscht.", "confirmAccountDeleteMessage": "Ihre hochgeladenen Daten werden in allen Anwendungen (sowohl Fotos als auch Authenticator) zur Löschung vorgesehen und Ihr Konto wird dauerhaft gelöscht.",
"sendEmail": "E-Mail senden", "sendEmail": "E-Mail senden",
"createNewAccount": "Neues Konto erstellen", "createNewAccount": "Neues Konto erstellen",
"passwordStrengthWeak": "Schwach", "weakStrength": "Schwach",
"passwordStrengthStrong": "Stark", "strongStrength": "Stark",
"passwordStrengthModerate": "Mittel", "moderateStrength": "Mittel",
"confirmPassword": "Bestätigen Sie das Passwort", "confirmPassword": "Bestätigen Sie das Passwort",
"close": "Schließen", "close": "Schließen",
"oopsSomethingWentWrong": "Ups, da ist etwas schief gelaufen.", "oopsSomethingWentWrong": "Ups, da ist etwas schief gelaufen.",

View file

@ -55,13 +55,13 @@
}, },
"contactSupport": "Contact support", "contactSupport": "Contact support",
"verifyPassword": "Verify password", "verifyPassword": "Verify password",
"pleaseWaitTitle": "Please wait...", "pleaseWait": "Please wait...",
"generatingEncryptionKeysTitle": "Generating encryption keys...", "generatingEncryptionKeysTitle": "Generating encryption keys...",
"recreatePassword": "Recreate password", "recreatePassword": "Recreate password",
"recreatePasswordMessage": "The current device is not powerful enough to verify your password, so we need to regenerate it once in a way that works with all devices. \n\nPlease login using your recovery key and regenerate your password (you can use the same one again if you wish).", "recreatePasswordMessage": "The current device is not powerful enough to verify your password, so we need to regenerate it once in a way that works with all devices. \n\nPlease login using your recovery key and regenerate your password (you can use the same one again if you wish).",
"useRecoveryKeyAction": "Use recovery key", "useRecoveryKey": "Use recovery key",
"incorrectPassword": "Incorrect password", "incorrectPasswordTitle": "Incorrect password",
"welcomeBackTitle": "Welcome back!", "welcomeBack": "Welcome back!",
"madeWithLoveAtPrefix": "made with ❤️ at ", "madeWithLoveAtPrefix": "made with ❤️ at ",
"supportDevs" : "Subscribe to <bold-green>ente</bold-green> to support this project.", "supportDevs" : "Subscribe to <bold-green>ente</bold-green> to support this project.",
"supportDiscount" : "Use coupon code \"AUTH\" to get 10% off first year", "supportDiscount" : "Use coupon code \"AUTH\" to get 10% off first year",
@ -84,7 +84,7 @@
"support": "Support", "support": "Support",
"settings": "Settings", "settings": "Settings",
"copied": "Copied", "copied": "Copied",
"tryAgainMessage": "Please try again", "pleaseTryAgain": "Please try again",
"existingUser": "Existing User", "existingUser": "Existing User",
"newUser" : "New to ente", "newUser" : "New to ente",
"delete": "Delete", "delete": "Delete",
@ -126,9 +126,9 @@
"confirmAccountDeleteMessage": "Your uploaded data, across all apps (Photos and Authenticator both), will be scheduled for deletion, and your account will be permanently deleted.", "confirmAccountDeleteMessage": "Your uploaded data, across all apps (Photos and Authenticator both), will be scheduled for deletion, and your account will be permanently deleted.",
"sendEmail": "Send email", "sendEmail": "Send email",
"createNewAccount": "Create new account", "createNewAccount": "Create new account",
"passwordStrengthWeak": "Weak", "weakStrength": "Weak",
"passwordStrengthStrong": "Strong", "strongStrength": "Strong",
"passwordStrengthModerate": "Moderate", "moderateStrength": "Moderate",
"confirmPassword": "Confirm password", "confirmPassword": "Confirm password",
"close": "Close", "close": "Close",
"oopsSomethingWentWrong": "Oops, Something went wrong.", "oopsSomethingWentWrong": "Oops, Something went wrong.",
@ -153,9 +153,6 @@
"doThisLater": "Do this later", "doThisLater": "Do this later",
"saveKey": "Save key", "saveKey": "Save key",
"createAccount": "Create account", "createAccount": "Create account",
"weakStrength": "Weak",
"strongStrength": "Strong",
"moderateStrength": "Moderate",
"passwordStrength": "Password strength: {passwordStrengthValue}", "passwordStrength": "Password strength: {passwordStrengthValue}",
"@passwordStrength": { "@passwordStrength": {
"description": "Text to indicate the password strength", "description": "Text to indicate the password strength",
@ -174,7 +171,29 @@
"termsOfServicesTitle": "Terms", "termsOfServicesTitle": "Terms",
"encryption": "Encryption", "encryption": "Encryption",
"ackPasswordLostWarning": "I understand that if I lose my password, I may lose my data since my data is <underline>end-to-end encrypted</underline>.", "ackPasswordLostWarning": "I understand that if I lose my password, I may lose my data since my data is <underline>end-to-end encrypted</underline>.",
"accountWelcomeBack": "Welcome back!",
"loginTerms": "By clicking log in, I agree to the <u-terms>terms of service</u-terms> and <u-policy>privacy policy</u-policy>", "loginTerms": "By clicking log in, I agree to the <u-terms>terms of service</u-terms> and <u-policy>privacy policy</u-policy>",
"logInLabel": "Log in" "logInLabel": "Log in",
"logout": "Logout",
"yesLogout": "Yes, logout",
"exit": "Exit",
"verifyingRecoveryKey": "Verifying recovery key...",
"recoveryKeyVerified": "Recovery key verified",
"recoveryKeySuccessBody": "Great! Your recovery key is valid. Thank you for verifying.\n\nPlease remember to keep your recovery key safely backed up.",
"invalidRecoveryKey": "The recovery key you entered is not valid. Please make sure it contains 24 words, and check the spelling of each.\n\nIf you entered an older recovery code, make sure it is 64 characters long, and check each of them.",
"recreatePasswordTitle": "Recreate password",
"recreatePasswordBody": "The current device is not powerful enough to verify your password, but we can regenerate in a way that works with all devices.\n\nPlease login using your recovery key and regenerate your password (you can use the same one again if you wish).",
"invalidKey": "Invalid key",
"tryAgain": "Try again",
"viewRecoveryKey": "View recovery key",
"confirmRecoveryKey": "Confirm recovery key",
"recoveryKeyVerifyReason": "Your recovery key is the only way to recover your photos if you forget your password. You can find your recovery key in Settings > Account.\n\nPlease enter your recovery key here to verify that you have saved it correctly.",
"confirmYourRecoveryKey": "Confirm your recovery key",
"confirm": "Confirm",
"emailYourLogs": "Email your logs",
"pleaseSendTheLogsTo": "Please send the logs to \n{toEmail}",
"copyEmailAddress": "Copy email address",
"exportLogs": "Export logs",
"enterYourRecoveryKey": "Enter your recovery key",
"tempErrorContactSupportIfPersists": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team.",
"itLooksLikeSomethingWentWrongPleaseRetryAfterSome": "It looks like something went wrong. Please retry after some time. If the error persists, please contact our support team."
} }

View file

@ -52,13 +52,13 @@
}, },
"contactSupport": "Ota yhteyttä käyttötukeen", "contactSupport": "Ota yhteyttä käyttötukeen",
"verifyPassword": "Vahvista salasana", "verifyPassword": "Vahvista salasana",
"pleaseWaitTitle": "Odota hetki...", "pleaseWait": "Odota hetki...",
"generatingEncryptionKeysTitle": "Luodaan salausavaimia...", "generatingEncryptionKeysTitle": "Luodaan salausavaimia...",
"recreatePassword": "Luo salasana uudelleen", "recreatePassword": "Luo salasana uudelleen",
"recreatePasswordMessage": "Nykyinen laite ei ole riittävän tehokas salasanasi varmistamiseen, joten se on uudistettava kerran sillä tavalla että se toimii sen jälkeen kaikkien laitteiden kanssa. \n\nOle hyvä ja kirjaudu sisään palautusavaimellasi ja luo salasanasi uudelleen (voit halutessasi käyttää aivan samaa salasanaa).", "recreatePasswordMessage": "Nykyinen laite ei ole riittävän tehokas salasanasi varmistamiseen, joten se on uudistettava kerran sillä tavalla että se toimii sen jälkeen kaikkien laitteiden kanssa. \n\nOle hyvä ja kirjaudu sisään palautusavaimellasi ja luo salasanasi uudelleen (voit halutessasi käyttää aivan samaa salasanaa).",
"useRecoveryKeyAction": "Käytä palautusavainta", "useRecoveryKey": "Käytä palautusavainta",
"incorrectPassword": "Salasana on väärin", "incorrectPasswordTitle": "Salasana on väärin",
"welcomeBackTitle": "Tervetuloa takaisin!", "welcomeBack": "Tervetuloa takaisin!",
"madeWithLoveAtPrefix": "tehty ❤️:lla täällä ", "madeWithLoveAtPrefix": "tehty ❤️:lla täällä ",
"supportDevs": "Tilaa <bold-green>ente</bold-green> tukeaksesi tätä hanketta.", "supportDevs": "Tilaa <bold-green>ente</bold-green> tukeaksesi tätä hanketta.",
"supportDiscount": "Käytä kuponkikoodia \"AUTH\" saadaksesi 10% alennuksen ensimmäisestä vuodesta", "supportDiscount": "Käytä kuponkikoodia \"AUTH\" saadaksesi 10% alennuksen ensimmäisestä vuodesta",
@ -71,7 +71,7 @@
"support": "Tuki", "support": "Tuki",
"settings": "Asetukset", "settings": "Asetukset",
"copied": "Jäljennetty", "copied": "Jäljennetty",
"tryAgainMessage": "Yritä uudestaan", "pleaseTryAgain": "Yritä uudestaan",
"existingUser": "Jo valmiiksi olemassaoleva käyttäjä", "existingUser": "Jo valmiiksi olemassaoleva käyttäjä",
"newUser": "Uusi Ente-käyttäjä", "newUser": "Uusi Ente-käyttäjä",
"delete": "Poista", "delete": "Poista",
@ -113,9 +113,9 @@
"confirmAccountDeleteMessage": "Lataamasi tiedot kaikkien sovellusten kesken (molemmat, sekä kuvat ja todenteet) ajastetaan poistettavaksi ja tilisi poistetaan pysyvästi.", "confirmAccountDeleteMessage": "Lataamasi tiedot kaikkien sovellusten kesken (molemmat, sekä kuvat ja todenteet) ajastetaan poistettavaksi ja tilisi poistetaan pysyvästi.",
"sendEmail": "Lähetä sähköpostia", "sendEmail": "Lähetä sähköpostia",
"createNewAccount": "Luo uusi tili", "createNewAccount": "Luo uusi tili",
"passwordStrengthWeak": "Heikko salasana", "weakStrength": "Heikko salasana",
"passwordStrengthStrong": "Vahva salasana", "strongStrength": "Vahva salasana",
"passwordStrengthModerate": "Kohtalainen salasana", "moderateStrength": "Kohtalainen salasana",
"confirmPassword": "Vahvista salasana", "confirmPassword": "Vahvista salasana",
"close": "Sulje", "close": "Sulje",
"oopsSomethingWentWrong": "Hupsista! Jotakin meni nyt pieleen." "oopsSomethingWentWrong": "Hupsista! Jotakin meni nyt pieleen."

View file

@ -46,13 +46,13 @@
}, },
"contactSupport": "Contacter le support", "contactSupport": "Contacter le support",
"verifyPassword": "Vérifier le mot de passe", "verifyPassword": "Vérifier le mot de passe",
"pleaseWaitTitle": "Veuillez patienter...", "pleaseWait": "Veuillez patienter...",
"generatingEncryptionKeysTitle": "Génération des clés de chiffrement...", "generatingEncryptionKeysTitle": "Génération des clés de chiffrement...",
"recreatePassword": "Recréer le mot de passe", "recreatePassword": "Recréer le mot de passe",
"recreatePasswordMessage": "L'appareil actuel n'est pas assez puissant pour vérifier votre mot de passe, donc nous avons besoin de le régénérer une fois d'une manière qu'il fonctionne avec tous les périphériques.\n\nVeuillez vous connecter en utilisant votre clé de récupération et régénérer votre mot de passe (vous pouvez utiliser le même si vous le souhaitez).", "recreatePasswordMessage": "L'appareil actuel n'est pas assez puissant pour vérifier votre mot de passe, donc nous avons besoin de le régénérer une fois d'une manière qu'il fonctionne avec tous les périphériques.\n\nVeuillez vous connecter en utilisant votre clé de récupération et régénérer votre mot de passe (vous pouvez utiliser le même si vous le souhaitez).",
"useRecoveryKeyAction": "Utiliser la clé de récupération", "useRecoveryKey": "Utiliser la clé de récupération",
"incorrectPassword": "Mot de passe incorrect", "incorrectPasswordTitle": "Mot de passe incorrect",
"welcomeBackTitle": "Bon retour parmi nous !", "welcomeBack": "Bon retour parmi nous !",
"madeWithLoveAtPrefix": "fait avec ❤️ à ", "madeWithLoveAtPrefix": "fait avec ❤️ à ",
"supportDiscount": "Utilisez le code coupon \"AUTH\" pour obtenir 10% de réduction sur la première année", "supportDiscount": "Utilisez le code coupon \"AUTH\" pour obtenir 10% de réduction sur la première année",
"changeEmail": "modifier l'e-mail", "changeEmail": "modifier l'e-mail",
@ -63,7 +63,7 @@
"support": "Support", "support": "Support",
"settings": "Paramètres", "settings": "Paramètres",
"copied": "Copié", "copied": "Copié",
"tryAgainMessage": "Veuillez réessayer", "pleaseTryAgain": "Veuillez réessayer",
"existingUser": "Utilisateur existant", "existingUser": "Utilisateur existant",
"newUser": "Nouveau sur ente", "newUser": "Nouveau sur ente",
"delete": "Supprimer", "delete": "Supprimer",
@ -105,9 +105,9 @@
"confirmAccountDeleteMessage": "Vos données téléchargées, à travers toutes les applications (Photos et Authenticator), seront planifiées pour la suppression, et votre compte sera définitivement supprimé.", "confirmAccountDeleteMessage": "Vos données téléchargées, à travers toutes les applications (Photos et Authenticator), seront planifiées pour la suppression, et votre compte sera définitivement supprimé.",
"sendEmail": "Envoyer un e-mail", "sendEmail": "Envoyer un e-mail",
"createNewAccount": "Créer un nouveau compte", "createNewAccount": "Créer un nouveau compte",
"passwordStrengthWeak": "Faible", "weakStrength": "Faible",
"passwordStrengthStrong": "Fort", "strongStrength": "Fort",
"passwordStrengthModerate": "Modéré", "moderateStrength": "Modéré",
"confirmPassword": "Confirmer le mot de passe", "confirmPassword": "Confirmer le mot de passe",
"close": "Fermer", "close": "Fermer",
"oopsSomethingWentWrong": "Oops ! Une erreur s'est produite.", "oopsSomethingWentWrong": "Oops ! Une erreur s'est produite.",

View file

@ -46,13 +46,13 @@
}, },
"contactSupport": "Contatta il supporto", "contactSupport": "Contatta il supporto",
"verifyPassword": "Verifica la password", "verifyPassword": "Verifica la password",
"pleaseWaitTitle": "Attendere prego...", "pleaseWait": "Attendere prego...",
"generatingEncryptionKeysTitle": "Generazione delle chiavi di crittografia...", "generatingEncryptionKeysTitle": "Generazione delle chiavi di crittografia...",
"recreatePassword": "Crea una nuova password", "recreatePassword": "Crea una nuova password",
"recreatePasswordMessage": "Il tuo dispositivo non è abbastanza potente per verificare la tua password, quindi abbiamo bisogno di rigenerarla in un modo che funziona con tutti i dispositivi. \n\nEffettua il login utilizzando la tua chiave di recupero e rigenera la tua password (puoi utilizzare nuovamente la stessa se vuoi).", "recreatePasswordMessage": "Il tuo dispositivo non è abbastanza potente per verificare la tua password, quindi abbiamo bisogno di rigenerarla in un modo che funziona con tutti i dispositivi. \n\nEffettua il login utilizzando la tua chiave di recupero e rigenera la tua password (puoi utilizzare nuovamente la stessa se vuoi).",
"useRecoveryKeyAction": "Utilizza un codice di recupero", "useRecoveryKey": "Utilizza un codice di recupero",
"incorrectPassword": "Password sbagliata", "incorrectPasswordTitle": "Password sbagliata",
"welcomeBackTitle": "Bentornato!", "welcomeBack": "Bentornato!",
"madeWithLoveAtPrefix": "realizzato con ❤️ a ", "madeWithLoveAtPrefix": "realizzato con ❤️ a ",
"supportDevs": "Iscriviti a <bold-green>ente</bold-green> per supportare questo progetto.", "supportDevs": "Iscriviti a <bold-green>ente</bold-green> per supportare questo progetto.",
"supportDiscount": "Utilizzare il codice coupon \"AUTH\" per ottenere il 10% di sconto al primo anno", "supportDiscount": "Utilizzare il codice coupon \"AUTH\" per ottenere il 10% di sconto al primo anno",
@ -65,7 +65,7 @@
"support": "Supporto", "support": "Supporto",
"settings": "Impostazioni", "settings": "Impostazioni",
"copied": "Copiato", "copied": "Copiato",
"tryAgainMessage": "Per favore riprova", "pleaseTryAgain": "Per favore riprova",
"existingUser": "Accedi", "existingUser": "Accedi",
"newUser": "Nuovo utente", "newUser": "Nuovo utente",
"delete": "Cancella", "delete": "Cancella",
@ -107,9 +107,9 @@
"confirmAccountDeleteMessage": "I tuoi dati caricati, in tutte le app (sia foto che autenticatore), verranno pianificati per la cancellazione, e il tuo account sarà eliminato in modo permanente.", "confirmAccountDeleteMessage": "I tuoi dati caricati, in tutte le app (sia foto che autenticatore), verranno pianificati per la cancellazione, e il tuo account sarà eliminato in modo permanente.",
"sendEmail": "Invia email", "sendEmail": "Invia email",
"createNewAccount": "Crea un nuovo account", "createNewAccount": "Crea un nuovo account",
"passwordStrengthWeak": "Debole", "weakStrength": "Debole",
"passwordStrengthStrong": "Forte", "strongStrength": "Forte",
"passwordStrengthModerate": "Mediocre", "moderateStrength": "Mediocre",
"confirmPassword": "Conferma la password", "confirmPassword": "Conferma la password",
"close": "Chiudi", "close": "Chiudi",
"oopsSomethingWentWrong": "Oops, qualcosa è andato storto.", "oopsSomethingWentWrong": "Oops, qualcosa è andato storto.",

View file

@ -46,13 +46,13 @@
}, },
"contactSupport": "Klantenservice", "contactSupport": "Klantenservice",
"verifyPassword": "Bevestig wachtwoord", "verifyPassword": "Bevestig wachtwoord",
"pleaseWaitTitle": "Een ogenblik geduld...", "pleaseWait": "Een ogenblik geduld...",
"generatingEncryptionKeysTitle": "Encryptiesleutels genereren...", "generatingEncryptionKeysTitle": "Encryptiesleutels genereren...",
"recreatePassword": "Wachtwoord opnieuw instellen", "recreatePassword": "Wachtwoord opnieuw instellen",
"recreatePasswordMessage": "Het huidige apparaat is niet krachtig genoeg om je wachtwoord te verifiëren, dus moeten we de code een keer opnieuw genereren op een manier die met alle apparaten werkt.\n\nLog in met behulp van uw herstelcode en genereer opnieuw uw wachtwoord (je kunt dezelfde indien gewenst opnieuw gebruiken).", "recreatePasswordMessage": "Het huidige apparaat is niet krachtig genoeg om je wachtwoord te verifiëren, dus moeten we de code een keer opnieuw genereren op een manier die met alle apparaten werkt.\n\nLog in met behulp van uw herstelcode en genereer opnieuw uw wachtwoord (je kunt dezelfde indien gewenst opnieuw gebruiken).",
"useRecoveryKeyAction": "Herstelcode gebruiken", "useRecoveryKey": "Herstelcode gebruiken",
"incorrectPassword": "Onjuist wachtwoord", "incorrectPasswordTitle": "Onjuist wachtwoord",
"welcomeBackTitle": "Welkom terug!", "welcomeBack": "Welkom terug!",
"madeWithLoveAtPrefix": "gemaakt met ❤️ door ", "madeWithLoveAtPrefix": "gemaakt met ❤️ door ",
"supportDiscount": "Gebruik couponcode \"AUTH\" om 10% korting te krijgen op het eerste jaar", "supportDiscount": "Gebruik couponcode \"AUTH\" om 10% korting te krijgen op het eerste jaar",
"changeEmail": "e-mailadres wijzigen", "changeEmail": "e-mailadres wijzigen",
@ -64,7 +64,7 @@
"support": "Ondersteuning", "support": "Ondersteuning",
"settings": "Instellingen", "settings": "Instellingen",
"copied": "Gekopieerd", "copied": "Gekopieerd",
"tryAgainMessage": "Probeer het nog eens", "pleaseTryAgain": "Probeer het nog eens",
"existingUser": "Bestaande gebruiker", "existingUser": "Bestaande gebruiker",
"newUser": "Nieuw bij ente", "newUser": "Nieuw bij ente",
"delete": "Verwijderen", "delete": "Verwijderen",
@ -106,9 +106,9 @@
"confirmAccountDeleteMessage": "Uw geüploade gegevens, in alle apps (Photos en Authenticator), worden ingepland voor verwijdering en uw account zal permanent worden verwijderd.", "confirmAccountDeleteMessage": "Uw geüploade gegevens, in alle apps (Photos en Authenticator), worden ingepland voor verwijdering en uw account zal permanent worden verwijderd.",
"sendEmail": "E-mail versturen", "sendEmail": "E-mail versturen",
"createNewAccount": "Nieuw account aanmaken", "createNewAccount": "Nieuw account aanmaken",
"passwordStrengthWeak": "Zwak", "weakStrength": "Zwak",
"passwordStrengthStrong": "Sterk", "strongStrength": "Sterk",
"passwordStrengthModerate": "Matig", "moderateStrength": "Matig",
"confirmPassword": "Wachtwoord bevestigen", "confirmPassword": "Wachtwoord bevestigen",
"close": "Sluiten", "close": "Sluiten",
"oopsSomethingWentWrong": "Oeps, er is iets fout gegaan." "oopsSomethingWentWrong": "Oeps, er is iets fout gegaan."

View file

@ -46,13 +46,13 @@
}, },
"contactSupport": "Связаться с поддержкой", "contactSupport": "Связаться с поддержкой",
"verifyPassword": "Подтверждение пароля", "verifyPassword": "Подтверждение пароля",
"pleaseWaitTitle": "Пожалуйста, подождите...", "pleaseWait": "Пожалуйста, подождите...",
"generatingEncryptionKeysTitle": "Генерируем ключи шифрования...", "generatingEncryptionKeysTitle": "Генерируем ключи шифрования...",
"recreatePassword": "Воссоздать пароль заново", "recreatePassword": "Воссоздать пароль заново",
"recreatePasswordMessage": "Текущее устройство недостаточно мощное для проверки пароля, поэтому нам нужно регенерировать его один раз таким образом, чтобы работать со всеми устройствами. \n\nПожалуйста, войдите, используя ваш ключ восстановления и сгенерируйте ваш пароль (вы можете использовать тот же самый, если пожелаете).", "recreatePasswordMessage": "Текущее устройство недостаточно мощное для проверки пароля, поэтому нам нужно регенерировать его один раз таким образом, чтобы работать со всеми устройствами. \n\nПожалуйста, войдите, используя ваш ключ восстановления и сгенерируйте ваш пароль (вы можете использовать тот же самый, если пожелаете).",
"useRecoveryKeyAction": "Использовать ключ восстановления", "useRecoveryKey": "Использовать ключ восстановления",
"incorrectPassword": "Неправильный пароль", "incorrectPasswordTitle": "Неправильный пароль",
"welcomeBackTitle": "С возвращением!", "welcomeBack": "С возвращением!",
"madeWithLoveAtPrefix": "сделана с ❤️ в ", "madeWithLoveAtPrefix": "сделана с ❤️ в ",
"supportDevs": "Подпишитесь на <bold-green>ente</bold-green> для поддержки этого проекта.", "supportDevs": "Подпишитесь на <bold-green>ente</bold-green> для поддержки этого проекта.",
"supportDiscount": "Используйте код скидки \"AUTH\", чтобы получить скидку 10% в первый год", "supportDiscount": "Используйте код скидки \"AUTH\", чтобы получить скидку 10% в первый год",
@ -64,7 +64,7 @@
"support": "Поддержка", "support": "Поддержка",
"settings": "Настройки", "settings": "Настройки",
"copied": "Скопировано", "copied": "Скопировано",
"tryAgainMessage": "Пожалуйста, попробуйте ещё раз", "pleaseTryAgain": "Пожалуйста, попробуйте ещё раз",
"existingUser": "Существующий пользователь", "existingUser": "Существующий пользователь",
"newUser": "Новый аккаунт", "newUser": "Новый аккаунт",
"delete": "Удалить", "delete": "Удалить",
@ -106,9 +106,9 @@
"confirmAccountDeleteMessage": "Ваши загруженные данные во всех приложениях (как фотографии, так и средство аутентификации) будут запланированы к удалению, а ваш аккаунт будет удален безвозвратно.", "confirmAccountDeleteMessage": "Ваши загруженные данные во всех приложениях (как фотографии, так и средство аутентификации) будут запланированы к удалению, а ваш аккаунт будет удален безвозвратно.",
"sendEmail": "Отправить электронное письмо", "sendEmail": "Отправить электронное письмо",
"createNewAccount": "Создать новый аккаунт", "createNewAccount": "Создать новый аккаунт",
"passwordStrengthWeak": "Слабый", "weakStrength": "Слабый",
"passwordStrengthStrong": "Крепкий", "strongStrength": "Крепкий",
"passwordStrengthModerate": "Средний", "moderateStrength": "Средний",
"confirmPassword": "Подтвердить пароль", "confirmPassword": "Подтвердить пароль",
"close": "Закрыть", "close": "Закрыть",
"oopsSomethingWentWrong": "Ой, что-то пошло не так." "oopsSomethingWentWrong": "Ой, что-то пошло не так."

View file

@ -52,13 +52,13 @@
}, },
"contactSupport": "Destek ekibiyle iletişime geçin", "contactSupport": "Destek ekibiyle iletişime geçin",
"verifyPassword": "Şifreyi doğrulayın", "verifyPassword": "Şifreyi doğrulayın",
"pleaseWaitTitle": "Lütfen bekleyin...", "pleaseWait": "Lütfen bekleyin...",
"generatingEncryptionKeysTitle": "Şifreleme anahtarları üretiliyor...", "generatingEncryptionKeysTitle": "Şifreleme anahtarları üretiliyor...",
"recreatePassword": "Şifreyi yeniden oluştur", "recreatePassword": "Şifreyi yeniden oluştur",
"recreatePasswordMessage": "Bu cihaz, şifrenizi doğrulayabilecek kadar güçlü değil, bu sebeple şifreyi her cihazda çalışabilecek bir yolla oluşturmamız gerekiyor.\n\nLütfen kurtarma anahtarınızla giriş yapın ve şifrenizi tekrar oluşturun (dilerseniz aynı şifreyi kullanabilirsiniz).", "recreatePasswordMessage": "Bu cihaz, şifrenizi doğrulayabilecek kadar güçlü değil, bu sebeple şifreyi her cihazda çalışabilecek bir yolla oluşturmamız gerekiyor.\n\nLütfen kurtarma anahtarınızla giriş yapın ve şifrenizi tekrar oluşturun (dilerseniz aynı şifreyi kullanabilirsiniz).",
"useRecoveryKeyAction": "Kurtarma anahtarını kullan", "useRecoveryKey": "Kurtarma anahtarını kullan",
"incorrectPassword": "Yanlış şifre", "incorrectPasswordTitle": "Yanlış şifre",
"welcomeBackTitle": "Tekrar hoş geldiniz!", "welcomeBack": "Tekrar hoş geldiniz!",
"madeWithLoveAtPrefix": "❤️ ile yapılmıştır ", "madeWithLoveAtPrefix": "❤️ ile yapılmıştır ",
"supportDevs": "Bu projeyi desteklemek için <bold-green>ente</bold-green> kanalına abone olun.", "supportDevs": "Bu projeyi desteklemek için <bold-green>ente</bold-green> kanalına abone olun.",
"supportDiscount": "İlk yılda %10 indirim için \"AUTH\" kupon kodunu kullanın", "supportDiscount": "İlk yılda %10 indirim için \"AUTH\" kupon kodunu kullanın",
@ -71,7 +71,7 @@
"support": "Destek", "support": "Destek",
"settings": "Ayarlar", "settings": "Ayarlar",
"copied": "Kopyalandı", "copied": "Kopyalandı",
"tryAgainMessage": "Lütfen tekrar deneyin", "pleaseTryAgain": "Lütfen tekrar deneyin",
"existingUser": "Mevcut kullanıcı", "existingUser": "Mevcut kullanıcı",
"newUser": "Yeni ente kullanıcısı", "newUser": "Yeni ente kullanıcısı",
"delete": "Sil", "delete": "Sil",
@ -113,9 +113,9 @@
"confirmAccountDeleteMessage": "Tüm uygulamalarda (Fotoğraflar ve Kimlik doğrulayıcı) kaydedilen verileriniz zamanlı silinmeye ayarlanacak ve hesabınız kalıcı olarak silinecektir.", "confirmAccountDeleteMessage": "Tüm uygulamalarda (Fotoğraflar ve Kimlik doğrulayıcı) kaydedilen verileriniz zamanlı silinmeye ayarlanacak ve hesabınız kalıcı olarak silinecektir.",
"sendEmail": "E-posta gönder", "sendEmail": "E-posta gönder",
"createNewAccount": "Yeni hesap oluşturun", "createNewAccount": "Yeni hesap oluşturun",
"passwordStrengthWeak": "Zayıf", "weakStrength": "Zayıf",
"passwordStrengthStrong": "Güçlü", "strongStrength": "Güçlü",
"passwordStrengthModerate": "Orta", "moderateStrength": "Orta",
"confirmPassword": "Şifreyi onayla", "confirmPassword": "Şifreyi onayla",
"close": "Kapat", "close": "Kapat",
"oopsSomethingWentWrong": "Hay aksi, bir sorun oluştu." "oopsSomethingWentWrong": "Hay aksi, bir sorun oluştu."

View file

@ -1,4 +1,4 @@
// @dart=2.9 import 'package:adaptive_theme/adaptive_theme.dart';
import "package:ente_auth/app/view/app.dart"; import "package:ente_auth/app/view/app.dart";
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/core/constants.dart'; import 'package:ente_auth/core/constants.dart';
@ -25,10 +25,11 @@ final _logger = Logger("main");
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await _runInForeground(); final savedThemeMode = await AdaptiveTheme.getThemeMode();
await _runInForeground(savedThemeMode);
} }
Future<void> _runInForeground() async { Future<void> _runInForeground(AdaptiveThemeMode? savedThemeMode) async {
return await _runWithLogs(() async { return await _runWithLogs(() async {
_logger.info("Starting app in foreground"); _logger.info("Starting app in foreground");
await _init(false, via: 'mainMethod'); await _init(false, via: 'mainMethod');
@ -42,11 +43,19 @@ Future<void> _runInForeground() async {
locale: locale, locale: locale,
lightTheme: lightThemeData, lightTheme: lightThemeData,
darkTheme: darkThemeData, darkTheme: darkThemeData,
savedThemeMode: _themeMode(savedThemeMode),
), ),
); );
}); });
} }
ThemeMode _themeMode(AdaptiveThemeMode? savedThemeMode) {
if (savedThemeMode == null) return ThemeMode.system;
if (savedThemeMode.isLight) return ThemeMode.light;
if (savedThemeMode.isDark) return ThemeMode.dark;
return ThemeMode.system;
}
Future _runWithLogs(Function() function, {String prefix = ""}) async { Future _runWithLogs(Function() function, {String prefix = ""}) async {
await SuperLogging.main( await SuperLogging.main(
LogConfig( LogConfig(
@ -60,7 +69,7 @@ Future _runWithLogs(Function() function, {String prefix = ""}) async {
); );
} }
Future<void> _init(bool bool, {String via}) async { Future<void> _init(bool bool, {String? via}) async {
CryptoUtil.init(); CryptoUtil.init();
await PreferenceService.instance.init(); await PreferenceService.instance.init();
await CodeStore.instance.init(); await CodeStore.instance.init();

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
@ -32,9 +30,9 @@ class BillingService {
bool _isOnSubscriptionPage = false; bool _isOnSubscriptionPage = false;
Subscription _cachedSubscription; Subscription? _cachedSubscription;
Future<BillingPlans> _future; Future<BillingPlans>? _future;
Future<void> init() async {} Future<void> init() async {}
@ -49,7 +47,7 @@ class BillingService {
.then((response) { .then((response) {
return BillingPlans.fromMap(response.data); return BillingPlans.fromMap(response.data);
}); });
return _future; return _future!;
} }
Future<Response<dynamic>> _fetchPrivateBillingPlans() { Future<Response<dynamic>> _fetchPrivateBillingPlans() {
@ -89,7 +87,7 @@ class BillingService {
); );
return Subscription.fromMap(response.data["subscription"]); return Subscription.fromMap(response.data["subscription"]);
} on DioError catch (e) { } on DioError catch (e) {
if (e.response != null && e.response.statusCode == 409) { if (e.response != null && e.response!.statusCode == 409) {
throw SubscriptionAlreadyClaimedError(); throw SubscriptionAlreadyClaimedError();
} else { } else {
rethrow; rethrow;
@ -118,7 +116,7 @@ class BillingService {
rethrow; rethrow;
} }
} }
return _cachedSubscription; return _cachedSubscription!;
} }
Future<Subscription> cancelStripeSubscription() async { Future<Subscription> cancelStripeSubscription() async {

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/ui/tools/app_lock.dart'; import 'package:ente_auth/ui/tools/app_lock.dart';
@ -18,9 +18,9 @@ class LocalAuthenticationService {
String infoMessage, String infoMessage,
) async { ) async {
if (await _isLocalAuthSupportedOnDevice()) { if (await _isLocalAuthSupportedOnDevice()) {
AppLock.of(context).setEnabled(false); AppLock.of(context)!.setEnabled(false);
final result = await requestAuthentication(infoMessage); final result = await requestAuthentication(infoMessage);
AppLock.of(context).setEnabled( AppLock.of(context)!.setEnabled(
Configuration.instance.shouldShowLockScreen(), Configuration.instance.shouldShowLockScreen(),
); );
if (!result) { if (!result) {
@ -41,17 +41,17 @@ class LocalAuthenticationService {
String errorDialogTitle = "", String errorDialogTitle = "",
]) async { ]) async {
if (await LocalAuthentication().isDeviceSupported()) { if (await LocalAuthentication().isDeviceSupported()) {
AppLock.of(context).disable(); AppLock.of(context)!.disable();
final result = await requestAuthentication( final result = await requestAuthentication(
infoMessage, infoMessage,
); );
if (result) { if (result) {
AppLock.of(context).setEnabled(shouldEnableLockScreen); AppLock.of(context)!.setEnabled(shouldEnableLockScreen);
await Configuration.instance await Configuration.instance
.setShouldShowLockScreen(shouldEnableLockScreen); .setShouldShowLockScreen(shouldEnableLockScreen);
return true; return true;
} else { } else {
AppLock.of(context) AppLock.of(context)!
.setEnabled(Configuration.instance.shouldShowLockScreen()); .setEnabled(Configuration.instance.shouldShowLockScreen());
} }
} else { } else {

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
@ -16,10 +16,10 @@ class UpdateService {
static final UpdateService instance = UpdateService._privateConstructor(); static final UpdateService instance = UpdateService._privateConstructor();
static const kUpdateAvailableShownTimeKey = "update_available_shown_time_key"; static const kUpdateAvailableShownTimeKey = "update_available_shown_time_key";
LatestVersionInfo _latestVersion; LatestVersionInfo? _latestVersion;
final _logger = Logger("UpdateService"); final _logger = Logger("UpdateService");
PackageInfo _packageInfo; late PackageInfo _packageInfo;
SharedPreferences _prefs; late SharedPreferences _prefs;
Future<void> init() async { Future<void> init() async {
_packageInfo = await PackageInfo.fromPlatform(); _packageInfo = await PackageInfo.fromPlatform();
@ -33,27 +33,27 @@ class UpdateService {
try { try {
_latestVersion = await _getLatestVersionInfo(); _latestVersion = await _getLatestVersionInfo();
final currentVersionCode = int.parse(_packageInfo.buildNumber); final currentVersionCode = int.parse(_packageInfo.buildNumber);
return currentVersionCode < _latestVersion.code; return currentVersionCode < _latestVersion!.code!;
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
return false; return false;
} }
} }
bool shouldForceUpdate(LatestVersionInfo info) { bool shouldForceUpdate(LatestVersionInfo? info) {
if (!isIndependent()) { if (!isIndependent()) {
return false; return false;
} }
try { try {
final currentVersionCode = int.parse(_packageInfo.buildNumber); final currentVersionCode = int.parse(_packageInfo.buildNumber);
return currentVersionCode < info.lastSupportedVersionCode; return currentVersionCode < info!.lastSupportedVersionCode;
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
return false; return false;
} }
} }
LatestVersionInfo getLatestVersionInfo() { LatestVersionInfo? getLatestVersionInfo() {
return _latestVersion; return _latestVersion;
} }
@ -69,7 +69,7 @@ class UpdateService {
(now - lastNotificationShownTime) > (3 * microSecondsInDay); (now - lastNotificationShownTime) > (3 * microSecondsInDay);
if (shouldUpdate && if (shouldUpdate &&
hasBeen3DaysSinceLastNotification && hasBeen3DaysSinceLastNotification &&
_latestVersion.shouldNotify) { _latestVersion!.shouldNotify!) {
NotificationService.instance.showNotification( NotificationService.instance.showNotification(
"Update available", "Update available",
"Click to install our best version yet", "Click to install our best version yet",
@ -96,14 +96,14 @@ class UpdateService {
} }
class LatestVersionInfo { class LatestVersionInfo {
final String name; final String? name;
final int code; final int? code;
final List<String> changelog; final List<String> changelog;
final bool shouldForceUpdate; final bool? shouldForceUpdate;
final int lastSupportedVersionCode; final int lastSupportedVersionCode;
final String url; final String? url;
final int size; final int? size;
final bool shouldNotify; final bool? shouldNotify;
LatestVersionInfo( LatestVersionInfo(
this.name, this.name,

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:bip39/bip39.dart' as bip39; import 'package:bip39/bip39.dart' as bip39;
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
@ -32,14 +30,14 @@ class UserService {
final _dio = Network.instance.getDio(); final _dio = Network.instance.getDio();
final _logger = Logger("UserSerivce"); final _logger = Logger("UserSerivce");
final _config = Configuration.instance; final _config = Configuration.instance;
ValueNotifier<String> emailValueNotifier; late ValueNotifier<String?> emailValueNotifier;
UserService._privateConstructor(); UserService._privateConstructor();
static final UserService instance = UserService._privateConstructor(); static final UserService instance = UserService._privateConstructor();
Future<void> init() async { Future<void> init() async {
emailValueNotifier = emailValueNotifier =
ValueNotifier<String>(Configuration.instance.getEmail()); ValueNotifier<String?>(Configuration.instance.getEmail());
} }
Future<void> sendOtt( Future<void> sendOtt(
@ -49,7 +47,7 @@ class UserService {
bool isCreateAccountScreen = false, bool isCreateAccountScreen = false,
}) async { }) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
final response = await _dio.post( final response = await _dio.post(
@ -75,19 +73,19 @@ class UserService {
); );
return; return;
} }
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} on DioError catch (e) { } on DioError catch (e) {
await dialog.hide(); await dialog.hide();
_logger.info(e); _logger.info(e);
if (e.response != null && e.response.statusCode == 403) { if (e.response != null && e.response!.statusCode == 403) {
showErrorDialog(context, "Oops", "This email is already in use"); showErrorDialog(context, "Oops", "This email is already in use");
} else { } else {
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} catch (e) { } catch (e) {
await dialog.hide(); await dialog.hide();
_logger.severe(e); _logger.severe(e);
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} }
@ -186,15 +184,15 @@ class UserService {
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
await dialog.hide(); await dialog.hide();
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} }
Future<DeleteChallengeResponse> getDeleteChallenge( Future<DeleteChallengeResponse?> getDeleteChallenge(
BuildContext context, BuildContext context,
) async { ) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
final response = await _dio.get( final response = await _dio.get(
@ -218,7 +216,7 @@ class UserService {
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
await dialog.hide(); await dialog.hide();
await showGenericErrorDialog(context); await showGenericErrorDialog(context: context);
return null; return null;
} }
} }
@ -257,13 +255,13 @@ class UserService {
} catch (e) { } catch (e) {
_logger.severe(e); _logger.severe(e);
await dialog.hide(); await dialog.hide();
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} }
Future<void> verifyEmail(BuildContext context, String ott) async { Future<void> verifyEmail(BuildContext context, String ott) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
final response = await _dio.post( final response = await _dio.post(
@ -302,7 +300,7 @@ class UserService {
} on DioError catch (e) { } on DioError catch (e) {
_logger.info(e); _logger.info(e);
await dialog.hide(); await dialog.hide();
if (e.response != null && e.response.statusCode == 410) { if (e.response != null && e.response!.statusCode == 410) {
await showErrorDialog( await showErrorDialog(
context, context,
"Oops", "Oops",
@ -334,7 +332,7 @@ class UserService {
String ott, String ott,
) async { ) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
final response = await _dio.post( final response = await _dio.post(
@ -360,7 +358,7 @@ class UserService {
showErrorDialog(context, "Oops", "Verification failed, please try again"); showErrorDialog(context, "Oops", "Verification failed, please try again");
} on DioError catch (e) { } on DioError catch (e) {
await dialog.hide(); await dialog.hide();
if (e.response != null && e.response.statusCode == 403) { if (e.response != null && e.response!.statusCode == 403) {
showErrorDialog(context, "Oops", "This email is already in use"); showErrorDialog(context, "Oops", "This email is already in use");
} else { } else {
showErrorDialog( showErrorDialog(
@ -447,7 +445,7 @@ class UserService {
} }
} }
Future<String> getPaymentToken() async { Future<String?> getPaymentToken() async {
try { try {
final response = await _dio.get( final response = await _dio.get(
"${_config.getHttpEndpoint()}/users/payment-token", "${_config.getHttpEndpoint()}/users/payment-token",
@ -504,7 +502,7 @@ class UserService {
Future<void> recoverTwoFactor(BuildContext context, String sessionID) async { Future<void> recoverTwoFactor(BuildContext context, String sessionID) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
final response = await _dio.get( final response = await _dio.get(
@ -529,7 +527,7 @@ class UserService {
} }
} on DioError catch (e) { } on DioError catch (e) {
_logger.severe(e); _logger.severe(e);
if (e.response != null && e.response.statusCode == 404) { if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired"); showToast(context, "Session expired");
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(
@ -589,7 +587,7 @@ class UserService {
} on DioError catch (e) { } on DioError catch (e) {
await dialog.hide(); await dialog.hide();
_logger.severe(e); _logger.severe(e);
if (e.response != null && e.response.statusCode == 404) { if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired"); showToast(context, "Session expired");
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(
@ -625,7 +623,7 @@ class UserService {
String secretDecryptionNonce, String secretDecryptionNonce,
) async { ) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
String secret; String secret;
try { try {
@ -675,7 +673,7 @@ class UserService {
} }
} on DioError catch (e) { } on DioError catch (e) {
_logger.severe(e); _logger.severe(e);
if (e.response != null && e.response.statusCode == 404) { if (e.response != null && e.response!.statusCode == 404) {
showToast(context, "Session expired"); showToast(context, "Session expired");
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute( MaterialPageRoute(

View file

@ -11,6 +11,7 @@ class EnteColorScheme {
// Backdrop Colors // Backdrop Colors
final Color backdropBase; final Color backdropBase;
final Color backdropBaseMute; final Color backdropBaseMute;
final Color backdropFaint;
// Text Colors // Text Colors
final Color textBase; final Color textBase;
@ -19,6 +20,7 @@ class EnteColorScheme {
// Fill Colors // Fill Colors
final Color fillBase; final Color fillBase;
final Color fillBasePressed;
final Color fillMuted; final Color fillMuted;
final Color fillFaint; final Color fillFaint;
final Color fillFaintPressed; final Color fillFaintPressed;
@ -42,6 +44,8 @@ class EnteColorScheme {
final Color warning700; final Color warning700;
final Color warning500; final Color warning500;
final Color warning400; final Color warning400;
final Color warning800;
final Color caution500; final Color caution500;
const EnteColorScheme( const EnteColorScheme(
@ -50,10 +54,12 @@ class EnteColorScheme {
this.backgroundElevated2, this.backgroundElevated2,
this.backdropBase, this.backdropBase,
this.backdropBaseMute, this.backdropBaseMute,
this.backdropFaint,
this.textBase, this.textBase,
this.textMuted, this.textMuted,
this.textFaint, this.textFaint,
this.fillBase, this.fillBase,
this.fillBasePressed,
this.fillMuted, this.fillMuted,
this.fillFaint, this.fillFaint,
this.fillFaintPressed, this.fillFaintPressed,
@ -70,6 +76,7 @@ class EnteColorScheme {
this.primary400 = _primary400, this.primary400 = _primary400,
this.primary300 = _primary300, this.primary300 = _primary300,
this.warning700 = _warning700, this.warning700 = _warning700,
this.warning800 = _warning800,
this.warning500 = _warning500, this.warning500 = _warning500,
this.warning400 = _warning700, this.warning400 = _warning700,
this.caution500 = _caution500, this.caution500 = _caution500,
@ -81,11 +88,13 @@ const EnteColorScheme lightScheme = EnteColorScheme(
backgroundElevatedLight, backgroundElevatedLight,
backgroundElevated2Light, backgroundElevated2Light,
backdropBaseLight, backdropBaseLight,
backdropBaseMuteLight, backdropMutedLight,
backdropFaintLight,
textBaseLight, textBaseLight,
textMutedLight, textMutedLight,
textFaintLight, textFaintLight,
fillBaseLight, fillBaseLight,
fillBasePressedLight,
fillMutedLight, fillMutedLight,
fillFaintLight, fillFaintLight,
fillFaintPressedLight, fillFaintPressedLight,
@ -103,11 +112,13 @@ const EnteColorScheme darkScheme = EnteColorScheme(
backgroundElevatedDark, backgroundElevatedDark,
backgroundElevated2Dark, backgroundElevated2Dark,
backdropBaseDark, backdropBaseDark,
backdropBaseMuteDark, backdropMutedDark,
backdropFaintDark,
textBaseDark, textBaseDark,
textMutedDark, textMutedDark,
textFaintDark, textFaintDark,
fillBaseDark, fillBaseDark,
fillBasePressedDark,
fillMutedDark, fillMutedDark,
fillFaintDark, fillFaintDark,
fillFaintPressedDark, fillFaintPressedDark,
@ -130,11 +141,13 @@ const Color backgroundElevatedDark = Color.fromRGBO(27, 27, 27, 1);
const Color backgroundElevated2Dark = Color.fromRGBO(37, 37, 37, 1); const Color backgroundElevated2Dark = Color.fromRGBO(37, 37, 37, 1);
// Backdrop Colors // Backdrop Colors
const Color backdropBaseLight = Color.fromRGBO(255, 255, 255, 0.75); const Color backdropBaseLight = Color.fromRGBO(255, 255, 255, 0.92);
const Color backdropBaseMuteLight = Color.fromRGBO(255, 255, 255, 0.30); const Color backdropMutedLight = Color.fromRGBO(255, 255, 255, 0.75);
const Color backdropFaintLight = Color.fromRGBO(255, 255, 255, 0.30);
const Color backdropBaseDark = Color.fromRGBO(0, 0, 0, 0.65); const Color backdropBaseDark = Color.fromRGBO(0, 0, 0, 0.90);
const Color backdropBaseMuteDark = Color.fromRGBO(0, 0, 0, 0.20); const Color backdropMutedDark = Color.fromRGBO(0, 0, 0, 0.65);
const Color backdropFaintDark = Color.fromRGBO(0, 0, 0, 0.20);
// Text Colors // Text Colors
const Color textBaseLight = Color.fromRGBO(0, 0, 0, 1); const Color textBaseLight = Color.fromRGBO(0, 0, 0, 1);
@ -147,11 +160,13 @@ const Color textFaintDark = Color.fromRGBO(255, 255, 255, 0.5);
// Fill Colors // Fill Colors
const Color fillBaseLight = Color.fromRGBO(0, 0, 0, 1); const Color fillBaseLight = Color.fromRGBO(0, 0, 0, 1);
const Color fillBasePressedLight = Color.fromRGBO(0, 0, 0, 0.87);
const Color fillMutedLight = Color.fromRGBO(0, 0, 0, 0.12); const Color fillMutedLight = Color.fromRGBO(0, 0, 0, 0.12);
const Color fillFaintLight = Color.fromRGBO(0, 0, 0, 0.04); const Color fillFaintLight = Color.fromRGBO(0, 0, 0, 0.04);
const Color fillFaintPressedLight = Color.fromRGBO(0, 0, 0, 0.08); const Color fillFaintPressedLight = Color.fromRGBO(0, 0, 0, 0.08);
const Color fillBaseDark = Color.fromRGBO(255, 255, 255, 1); const Color fillBaseDark = Color.fromRGBO(255, 255, 255, 1);
const Color fillBasePressedDark = Color.fromRGBO(255, 255, 255, 0.9);
const Color fillMutedDark = Color.fromRGBO(255, 255, 255, 0.16); const Color fillMutedDark = Color.fromRGBO(255, 255, 255, 0.16);
const Color fillFaintDark = Color.fromRGBO(255, 255, 255, 0.12); const Color fillFaintDark = Color.fromRGBO(255, 255, 255, 0.12);
const Color fillFaintPressedDark = Color.fromRGBO(255, 255, 255, 0.06); const Color fillFaintPressedDark = Color.fromRGBO(255, 255, 255, 0.06);
@ -184,6 +199,7 @@ const Color _primary300 = Color.fromARGB(255, 152, 77, 244);
const Color _warning700 = Color.fromRGBO(234, 63, 63, 1); const Color _warning700 = Color.fromRGBO(234, 63, 63, 1);
const Color _warning500 = Color.fromRGBO(255, 101, 101, 1); const Color _warning500 = Color.fromRGBO(255, 101, 101, 1);
const Color _warning800 = Color(0xFFF53434);
const Color warning500 = Color.fromRGBO(255, 101, 101, 1); const Color warning500 = Color.fromRGBO(255, 101, 101, 1);
const Color _warning400 = Color.fromRGBO(255, 111, 111, 1); const Color _warning400 = Color.fromRGBO(255, 111, 111, 1);

View file

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
const blurBase = 96; const blurBase = 96.0;
const blurMuted = 48; const blurMuted = 48.0;
const blurFaint = 24; const blurFaint = 24.0;
List<BoxShadow> shadowFloatLight = const [ List<BoxShadow> shadowFloatLight = const [
BoxShadow(blurRadius: 10, color: Color.fromRGBO(0, 0, 0, 0.25)), BoxShadow(blurRadius: 10, color: Color.fromRGBO(0, 0, 0, 0.25)),

View file

@ -36,10 +36,20 @@ EnteTheme darkTheme = EnteTheme(
shadowButton: shadowButtonDark, shadowButton: shadowButtonDark,
); );
EnteColorScheme getEnteColorScheme(BuildContext context) { EnteColorScheme getEnteColorScheme(
return Theme.of(context).colorScheme.enteTheme.colorScheme; BuildContext context, {
bool inverse = false,
}) {
return inverse
? Theme.of(context).colorScheme.inverseEnteTheme.colorScheme
: Theme.of(context).colorScheme.enteTheme.colorScheme;
} }
EnteTextTheme getEnteTextTheme(BuildContext context) { EnteTextTheme getEnteTextTheme(
return Theme.of(context).colorScheme.enteTheme.textTheme; BuildContext context, {
bool inverse = false,
}) {
return inverse
? Theme.of(context).colorScheme.inverseEnteTheme.textTheme
: Theme.of(context).colorScheme.enteTheme.textTheme;
} }

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:convert'; import 'dart:convert';
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
@ -16,7 +14,7 @@ import 'package:flutter_sodium/flutter_sodium.dart';
class DeleteAccountPage extends StatelessWidget { class DeleteAccountPage extends StatelessWidget {
const DeleteAccountPage({ const DeleteAccountPage({
Key key, Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -153,7 +151,7 @@ class DeleteAccountPage extends StatelessWidget {
); );
if (hasAuthenticated) { if (hasAuthenticated) {
final choice = await showChoiceDialog( final choice = await showChoiceDialogOld(
context, context,
l10n.confirmAccountDeleteTitle, l10n.confirmAccountDeleteTitle,
l10n.confirmAccountDeleteMessage, l10n.confirmAccountDeleteMessage,
@ -167,8 +165,8 @@ class DeleteAccountPage extends StatelessWidget {
} }
final decryptChallenge = CryptoUtil.openSealSync( final decryptChallenge = CryptoUtil.openSealSync(
Sodium.base642bin(response.encryptedChallenge), Sodium.base642bin(response.encryptedChallenge),
Sodium.base642bin(Configuration.instance.getKeyAttributes().publicKey), Sodium.base642bin(Configuration.instance.getKeyAttributes()!.publicKey),
Configuration.instance.getSecretKey(), Configuration.instance.getSecretKey()!,
); );
final challengeResponseStr = utf8.decode(decryptChallenge); final challengeResponseStr = utf8.decode(decryptChallenge);
await UserService.instance.deleteAccount(context, challengeResponseStr); await UserService.instance.deleteAccount(context, challengeResponseStr);

View file

@ -79,7 +79,7 @@ class _LoginPageState extends State<LoginPage> {
padding: padding:
const EdgeInsets.symmetric(vertical: 30, horizontal: 20), const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text( child: Text(
l10n.accountWelcomeBack, l10n.welcomeBack,
style: Theme.of(context).textTheme.headline4, style: Theme.of(context).textTheme.headline4,
), ),
), ),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
import 'package:ente_auth/services/user_service.dart'; import 'package:ente_auth/services/user_service.dart';
@ -15,7 +15,7 @@ class OTTVerificationPage extends StatefulWidget {
this.email, { this.email, {
this.isChangeEmail = false, this.isChangeEmail = false,
this.isCreateAccountScreen = false, this.isCreateAccountScreen = false,
Key key, Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -29,7 +29,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100; final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
FloatingActionButtonLocation fabLocation() { FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) { if (isKeypadOpen) {
return null; return null;
} else { } else {
@ -114,7 +114,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
text: TextSpan( text: TextSpan(
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.subtitle1 .subtitle1!
.copyWith(fontSize: 14), .copyWith(fontSize: 14),
children: [ children: [
const TextSpan(text: "We've sent a mail to "), const TextSpan(text: "We've sent a mail to "),
@ -134,7 +134,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
'Please check your inbox (and spam) to complete verification', 'Please check your inbox (and spam) to complete verification',
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.subtitle1 .subtitle1!
.copyWith(fontSize: 14), .copyWith(fontSize: 14),
), ),
], ],
@ -187,7 +187,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
}, },
child: Text( child: Text(
"Resend email", "Resend email",
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1!.copyWith(
fontSize: 14, fontSize: 14,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
), ),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
@ -24,7 +24,7 @@ enum PasswordEntryMode {
class PasswordEntryPage extends StatefulWidget { class PasswordEntryPage extends StatefulWidget {
final PasswordEntryMode mode; final PasswordEntryMode mode;
const PasswordEntryPage({this.mode = PasswordEntryMode.set, Key key}) const PasswordEntryPage({this.mode = PasswordEntryMode.set, Key? key})
: super(key: key); : super(key: key);
@override @override
@ -39,7 +39,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
final _passwordController1 = TextEditingController(), final _passwordController1 = TextEditingController(),
_passwordController2 = TextEditingController(); _passwordController2 = TextEditingController();
final Color _validFieldValueColor = const Color.fromRGBO(45, 194, 98, 0.2); final Color _validFieldValueColor = const Color.fromRGBO(45, 194, 98, 0.2);
String _volatilePassword; String? _volatilePassword;
String _passwordInInputBox = ''; String _passwordInInputBox = '';
String _passwordInInputConfirmationBox = ''; String _passwordInInputConfirmationBox = '';
double _passwordStrength = 0.0; double _passwordStrength = 0.0;
@ -60,7 +60,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
if (_volatilePassword != null) { if (_volatilePassword != null) {
Future.delayed( Future.delayed(
Duration.zero, Duration.zero,
() => _showRecoveryCodeDialog(_volatilePassword), () => _showRecoveryCodeDialog(_volatilePassword!),
); );
} }
_password1FocusNode.addListener(() { _password1FocusNode.addListener(() {
@ -79,7 +79,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100; final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
FloatingActionButtonLocation fabLocation() { FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) { if (isKeypadOpen) {
return null; return null;
} else { } else {
@ -165,7 +165,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.subtitle1 .subtitle1!
.copyWith(fontSize: 14), .copyWith(fontSize: 14),
), ),
), ),
@ -176,7 +176,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
text: TextSpan( text: TextSpan(
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.subtitle1 .subtitle1!
.copyWith(fontSize: 14), .copyWith(fontSize: 14),
children: [ children: [
const TextSpan( const TextSpan(
@ -185,7 +185,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
), ),
TextSpan( TextSpan(
text: "we cannot decrypt your data", text: "we cannot decrypt your data",
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1!.copyWith(
fontSize: 14, fontSize: 14,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
), ),
@ -243,7 +243,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
Icons.check, Icons.check,
color: Theme.of(context) color: Theme.of(context)
.inputDecorationTheme .inputDecorationTheme
.focusedBorder .focusedBorder!
.borderSide .borderSide
.color, .color,
) )
@ -305,7 +305,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
Icons.check, Icons.check,
color: Theme.of(context) color: Theme.of(context)
.inputDecorationTheme .inputDecorationTheme
.focusedBorder .focusedBorder!
.borderSide .borderSide
.color, .color,
) )
@ -362,7 +362,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
text: "How it works", text: "How it works",
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1!.copyWith(
fontSize: 14, fontSize: 14,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
), ),
@ -396,7 +396,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
} catch (e, s) { } catch (e, s) {
_logger.severe(e, s); _logger.severe(e, s);
await dialog.hide(); await dialog.hide();
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} }
@ -410,7 +410,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
Configuration.instance.setVolatilePassword(null); Configuration.instance.setVolatilePassword(null);
await dialog.hide(); await dialog.hide();
onDone() async { onDone() async {
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
await UserService.instance.setAttributes(result); await UserService.instance.setAttributes(result);
@ -426,7 +426,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
} catch (e, s) { } catch (e, s) {
_logger.severe(e, s); _logger.severe(e, s);
await dialog.hide(); await dialog.hide();
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} }
@ -451,7 +451,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
"Sorry, we could not generate secure keys on this device.\n\nplease sign up from a different device.", "Sorry, we could not generate secure keys on this device.\n\nplease sign up from a different device.",
); );
} else { } else {
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
} }
} }
} }

View file

@ -1,12 +1,11 @@
// @dart=2.9 import 'dart:async';
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/core/errors.dart'; import 'package:ente_auth/core/errors.dart';
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/models/key_attributes.dart';
import 'package:ente_auth/ui/account/recovery_page.dart'; import 'package:ente_auth/ui/account/recovery_page.dart';
import 'package:ente_auth/ui/common/dialogs.dart';
import 'package:ente_auth/ui/common/dynamic_fab.dart'; import 'package:ente_auth/ui/common/dynamic_fab.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/home_page.dart'; import 'package:ente_auth/ui/home_page.dart';
import 'package:ente_auth/utils/dialog_util.dart'; import 'package:ente_auth/utils/dialog_util.dart';
import 'package:ente_auth/utils/email_util.dart'; import 'package:ente_auth/utils/email_util.dart';
@ -14,7 +13,7 @@ import 'package:flutter/material.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class PasswordReentryPage extends StatefulWidget { class PasswordReentryPage extends StatefulWidget {
const PasswordReentryPage({Key key}) : super(key: key); const PasswordReentryPage({Key? key}) : super(key: key);
@override @override
State<PasswordReentryPage> createState() => _PasswordReentryPageState(); State<PasswordReentryPage> createState() => _PasswordReentryPageState();
@ -24,7 +23,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
final _logger = Logger((_PasswordReentryPageState).toString()); final _logger = Logger((_PasswordReentryPageState).toString());
final _passwordController = TextEditingController(); final _passwordController = TextEditingController();
final FocusNode _passwordFocusNode = FocusNode(); final FocusNode _passwordFocusNode = FocusNode();
String email; String? email;
bool _passwordInFocus = false; bool _passwordInFocus = false;
bool _passwordVisible = false; bool _passwordVisible = false;
@ -41,10 +40,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final l10n = context.l10n;
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100; final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
FloatingActionButtonLocation fabLocation() { FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) { if (isKeypadOpen) {
return null; return null;
} else { } else {
@ -68,29 +66,26 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
floatingActionButton: DynamicFAB( floatingActionButton: DynamicFAB(
isKeypadOpen: isKeypadOpen, isKeypadOpen: isKeypadOpen,
isFormValid: _passwordController.text.isNotEmpty, isFormValid: _passwordController.text.isNotEmpty,
buttonText: l10n.verifyPassword, buttonText: context.l10n.verifyPassword,
onPressedFunction: () async { onPressedFunction: () async {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, context.l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
await Configuration.instance.decryptAndSaveSecrets( await Configuration.instance.decryptAndSaveSecrets(
_passwordController.text, _passwordController.text,
Configuration.instance.getKeyAttributes(), Configuration.instance.getKeyAttributes()!,
); );
} on KeyDerivationError catch (e, s) { } on KeyDerivationError catch (e, s) {
_logger.severe("Password verification failed", e, s); _logger.severe("Password verification failed", e, s);
await dialog.hide(); await dialog.hide();
final dialogUserChoice = await showChoiceDialog( final dialogChoice = await showChoiceDialog(
context, context,
l10n.recreatePassword, title: context.l10n.recreatePasswordTitle,
l10n.recreatePasswordMessage, body: context.l10n.recreatePasswordBody,
firstAction: l10n.cancel, firstButtonLabel: context.l10n.useRecoveryKey,
firstActionColor: Theme.of(context).colorScheme.primary,
secondAction: l10n.useRecoveryKeyAction,
secondActionColor: Theme.of(context).colorScheme.primary,
); );
if (dialogUserChoice == DialogUserChoice.secondChoice) { if (dialogChoice!.action == ButtonAction.first) {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -103,20 +98,17 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
} catch (e, s) { } catch (e, s) {
_logger.severe("Password verification failed", e, s); _logger.severe("Password verification failed", e, s);
await dialog.hide(); await dialog.hide();
final dialogChoice = await showChoiceDialog(
final dialogUserChoice = await showChoiceDialog(
context, context,
l10n.incorrectPassword, title: context.l10n.incorrectPasswordTitle,
l10n.tryAgainMessage, body: context.l10n.pleaseTryAgain,
firstAction: l10n.contactSupport, firstButtonLabel: context.l10n.contactSupport,
firstActionColor: Theme.of(context).colorScheme.primary, secondButtonLabel: context.l10n.ok,
secondAction: l10n.ok,
secondActionColor: Theme.of(context).colorScheme.primary,
); );
if (dialogUserChoice == DialogUserChoice.firstChoice) { if (dialogChoice!.action == ButtonAction.first) {
await sendLogs( await sendLogs(
context, context,
l10n.contactSupport, context.l10n.contactSupport,
"support@ente.io", "support@ente.io",
postShare: () {}, postShare: () {},
); );
@ -124,13 +116,15 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
return; return;
} }
await dialog.hide(); await dialog.hide();
Navigator.of(context).pushAndRemoveUntil( unawaited(
MaterialPageRoute( Navigator.of(context).pushAndRemoveUntil(
builder: (BuildContext context) { MaterialPageRoute(
return const HomePage(); builder: (BuildContext context) {
}, return const HomePage();
},
),
(route) => false,
), ),
(route) => false,
); );
}, },
), ),
@ -140,7 +134,6 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
} }
Widget _getBody() { Widget _getBody() {
final l10n = context.l10n;
return Column( return Column(
children: [ children: [
Expanded( Expanded(
@ -151,7 +144,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
padding: padding:
const EdgeInsets.symmetric(vertical: 30, horizontal: 20), const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text( child: Text(
l10n.welcomeBackTitle, context.l10n.welcomeBack,
style: Theme.of(context).textTheme.headline4, style: Theme.of(context).textTheme.headline4,
), ),
), ),
@ -174,7 +167,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
child: TextFormField( child: TextFormField(
autofillHints: const [AutofillHints.password], autofillHints: const [AutofillHints.password],
decoration: InputDecoration( decoration: InputDecoration(
hintText: l10n.enterYourPasswordHint, hintText: context.l10n.enterYourPasswordHint,
filled: true, filled: true,
contentPadding: const EdgeInsets.all(20), contentPadding: const EdgeInsets.all(20),
border: UnderlineInputBorder( border: UnderlineInputBorder(
@ -236,9 +229,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
}, },
child: Center( child: Center(
child: Text( child: Text(
l10n.forgotPassword, context.l10n.forgotPassword,
style: style:
Theme.of(context).textTheme.subtitle1.copyWith( Theme.of(context).textTheme.subtitle1!.copyWith(
fontSize: 14, fontSize: 14,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
), ),
@ -250,7 +243,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
onTap: () async { onTap: () async {
final dialog = createProgressDialog( final dialog = createProgressDialog(
context, context,
l10n.pleaseWaitTitle, context.l10n.pleaseWait,
); );
await dialog.show(); await dialog.show();
await Configuration.instance.logout(); await Configuration.instance.logout();
@ -260,9 +253,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
}, },
child: Center( child: Center(
child: Text( child: Text(
l10n.changeEmail, context.l10n.changeEmail,
style: style:
Theme.of(context).textTheme.subtitle1.copyWith( Theme.of(context).textTheme.subtitle1!.copyWith(
fontSize: 14, fontSize: 14,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
), ),
@ -279,10 +272,4 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
], ],
); );
} }
void validatePreVerificationState(KeyAttributes keyAttributes) {
if (keyAttributes == null) {
throw Exception("Key Attributes can not be null");
}
}
} }

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:ui'; import 'dart:ui';
@ -10,7 +10,7 @@ import 'package:ente_auth/utils/toast_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class RecoveryPage extends StatefulWidget { class RecoveryPage extends StatefulWidget {
const RecoveryPage({Key key}) : super(key: key); const RecoveryPage({Key? key}) : super(key: key);
@override @override
State<RecoveryPage> createState() => _RecoveryPageState(); State<RecoveryPage> createState() => _RecoveryPageState();
@ -22,7 +22,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100; final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
FloatingActionButtonLocation fabLocation() { FloatingActionButtonLocation? fabLocation() {
if (isKeypadOpen) { if (isKeypadOpen) {
return null; return null;
} else { } else {
@ -140,7 +140,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
child: Text( child: Text(
"No recovery key?", "No recovery key?",
style: style:
Theme.of(context).textTheme.subtitle1.copyWith( Theme.of(context).textTheme.subtitle1!.copyWith(
fontSize: 14, fontSize: 14,
decoration: TextDecoration.underline, decoration: TextDecoration.underline,
), ),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
@ -13,14 +13,14 @@ import 'package:flutter/material.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class SessionsPage extends StatefulWidget { class SessionsPage extends StatefulWidget {
const SessionsPage({Key key}) : super(key: key); const SessionsPage({Key? key}) : super(key: key);
@override @override
State<SessionsPage> createState() => _SessionsPageState(); State<SessionsPage> createState() => _SessionsPageState();
} }
class _SessionsPageState extends State<SessionsPage> { class _SessionsPageState extends State<SessionsPage> {
Sessions _sessions; Sessions? _sessions;
final Logger _logger = Logger("SessionsPageState"); final Logger _logger = Logger("SessionsPageState");
@override @override
@ -46,7 +46,7 @@ class _SessionsPageState extends State<SessionsPage> {
} }
final List<Widget> rows = []; final List<Widget> rows = [];
rows.add(const Padding(padding: EdgeInsets.all(4))); rows.add(const Padding(padding: EdgeInsets.all(4)));
for (final session in _sessions.sessions) { for (final session in _sessions!.sessions) {
rows.add(_getSessionWidget(session)); rows.add(_getSessionWidget(session));
} }
return SingleChildScrollView( return SingleChildScrollView(
@ -113,7 +113,7 @@ class _SessionsPageState extends State<SessionsPage> {
Future<void> _terminateSession(Session session) async { Future<void> _terminateSession(Session session) async {
final l10n = context.l10n; final l10n = context.l10n;
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
await UserService.instance.terminateSession(session.token); await UserService.instance.terminateSession(session.token);
@ -133,11 +133,11 @@ class _SessionsPageState extends State<SessionsPage> {
Future<void> _fetchActiveSessions() async { Future<void> _fetchActiveSessions() async {
_sessions = await UserService.instance _sessions = await UserService.instance
.getActiveSessions() .getActiveSessions()
.onError((error, stackTrace) { .onError((dynamic error, stackTrace) {
showToast(context, "Failed to fetch active sessions"); showToast(context, "Failed to fetch active sessions");
throw error; throw error;
}); });
_sessions.sessions.sort((first, second) { _sessions!.sessions.sort((first, second) {
return second.lastUsedTime.compareTo(first.lastUsedTime); return second.lastUsedTime.compareTo(first.lastUsedTime);
}); });
setState(() {}); setState(() {});

View file

@ -1,18 +1,15 @@
// ignore_for_file: import_of_legacy_library_into_null_safe
import 'dart:ui'; import 'dart:ui';
import 'package:bip39/bip39.dart' as bip39; import 'package:bip39/bip39.dart' as bip39;
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/core/event_bus.dart';
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
import 'package:ente_auth/events/notification_event.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/services/local_authentication_service.dart'; import 'package:ente_auth/services/local_authentication_service.dart';
import 'package:ente_auth/services/user_remote_flag_service.dart'; import 'package:ente_auth/services/user_remote_flag_service.dart';
import 'package:ente_auth/ui/account/recovery_key_page.dart'; import 'package:ente_auth/ui/account/recovery_key_page.dart';
import 'package:ente_auth/ui/common/dialogs.dart';
import 'package:ente_auth/ui/common/gradient_button.dart'; import 'package:ente_auth/ui/common/gradient_button.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/utils/dialog_util.dart'; import 'package:ente_auth/utils/dialog_util.dart';
import 'package:ente_auth/utils/navigation_util.dart'; import 'package:ente_auth/utils/navigation_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -31,7 +28,8 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
final Logger _logger = Logger((_VerifyRecoveryPageState).toString()); final Logger _logger = Logger((_VerifyRecoveryPageState).toString());
void _verifyRecoveryKey() async { void _verifyRecoveryKey() async {
final dialog = createProgressDialog(context, "Verifying recovery key..."); final dialog =
createProgressDialog(context, context.l10n.verifyingRecoveryKey);
await dialog.show(); await dialog.show();
try { try {
final String inputKey = _recoveryKey.text.trim(); final String inputKey = _recoveryKey.text.trim();
@ -50,19 +48,17 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
"Please check your internet connection and try again.", "Please check your internet connection and try again.",
); );
} else { } else {
await showGenericErrorDialog(context); await showGenericErrorDialog(context: context);
} }
return; return;
} }
Bus.instance.fire(NotificationEvent());
await dialog.hide(); await dialog.hide();
// todo: change this as per figma once the component is ready // todo: change this as per figma once the component is ready
await showErrorDialog( await showErrorDialog(
context, context,
"Recovery key verified", context.l10n.recoveryKeyVerified,
"Great! Your recovery key is valid. Thank you for verifying.\n" context.l10n.recoveryKeySuccessBody,
"\nPlease"
" remember to keep your recovery key safely backed up.",
); );
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
@ -71,18 +67,16 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
} catch (e, s) { } catch (e, s) {
_logger.severe("failed to verify recovery key", e, s); _logger.severe("failed to verify recovery key", e, s);
await dialog.hide(); await dialog.hide();
const String errMessage = final String errMessage = context.l10n.invalidRecoveryKey;
"The recovery key you entered is not valid. Please make sure it "
"contains 24 words, and check the spelling of each.\n\nIf you "
"entered an older recovery code, make sure it is 64 characters long, and check each of them.";
final result = await showChoiceDialog( final result = await showChoiceDialog(
context, context,
"Invalid key", title: context.l10n.invalidKey,
errMessage, body: errMessage,
firstAction: "Try again", firstButtonLabel: context.l10n.tryAgain,
secondAction: "View recovery key", secondButtonLabel: context.l10n.viewRecoveryKey,
secondButtonAction: ButtonAction.second,
); );
if (result == DialogUserChoice.secondChoice) { if (result!.action == ButtonAction.second) {
await _onViewRecoveryKeyClick(); await _onViewRecoveryKeyClick();
} }
} }
@ -102,7 +96,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
context, context,
RecoveryKeyPage( RecoveryKeyPage(
recoveryKey, recoveryKey,
"OK", context.l10n.ok,
showAppBar: true, showAppBar: true,
onDone: () { onDone: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
@ -110,7 +104,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
), ),
); );
} catch (e) { } catch (e) {
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
return; return;
} }
} }
@ -147,16 +141,14 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
'Verify recovery key', context.l10n.confirmRecoveryKey,
style: enteTheme.textTheme.h3Bold, style: enteTheme.textTheme.h3Bold,
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
), ),
const SizedBox(height: 18), const SizedBox(height: 18),
Text( Text(
"If you forget your password, your recovery key is the " context.l10n.recoveryKeyVerifyReason,
"only way to recover your photos.\n\nPlease verify that "
"you have safely backed up your 24 word recovery key by re-entering it.",
style: enteTheme.textTheme.small style: enteTheme.textTheme.small
.copyWith(color: enteTheme.colorScheme.textMuted), .copyWith(color: enteTheme.colorScheme.textMuted),
), ),
@ -164,7 +156,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
TextFormField( TextFormField(
decoration: InputDecoration( decoration: InputDecoration(
filled: true, filled: true,
hintText: "Enter your recovery key", hintText: context.l10n.enterYourRecoveryKey,
contentPadding: const EdgeInsets.all(20), contentPadding: const EdgeInsets.all(20),
border: UnderlineInputBorder( border: UnderlineInputBorder(
borderSide: BorderSide.none, borderSide: BorderSide.none,
@ -186,12 +178,6 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
}, },
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
Text(
"If you saved the recovery key from older app versions, you might have a 64 character recovery code instead of 24 words. You can enter that too.",
style: enteTheme.textTheme.mini
.copyWith(color: enteTheme.colorScheme.textMuted),
),
const SizedBox(height: 8),
Expanded( Expanded(
child: Container( child: Container(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
@ -203,8 +189,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
children: [ children: [
GradientButton( GradientButton(
onTap: _verifyRecoveryKey, onTap: _verifyRecoveryKey,
text: "Verify", text: context.l10n.confirm,
iconData: Icons.shield_outlined,
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
], ],

View file

@ -1,11 +1,11 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class DividerWithPadding extends StatelessWidget { class DividerWithPadding extends StatelessWidget {
final double left, top, right, bottom, thinckness; final double left, top, right, bottom, thinckness;
const DividerWithPadding({ const DividerWithPadding({
Key key, Key? key,
this.left = 0, this.left = 0,
this.top = 0, this.top = 0,
this.right = 0, this.right = 0,

View file

@ -1,11 +1,11 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class BottomShadowWidget extends StatelessWidget { class BottomShadowWidget extends StatelessWidget {
final double offsetDy; final double offsetDy;
final Color shadowColor; final Color? shadowColor;
const BottomShadowWidget({this.offsetDy = 28, this.shadowColor, Key key}) const BottomShadowWidget({this.offsetDy = 28, this.shadowColor, Key? key})
: super(key: key); : super(key: key);
@override @override

View file

@ -1,8 +1,10 @@
// @dart=2.9
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
import 'package:ente_auth/models/typedefs.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/dialog_widget.dart';
import 'package:ente_auth/ui/components/models/button_result.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
enum DialogUserChoice { firstChoice, secondChoice } enum DialogUserChoice { firstChoice, secondChoice }
@ -12,14 +14,14 @@ enum ActionType {
} }
// if dialog is dismissed by tapping outside, this will return null // if dialog is dismissed by tapping outside, this will return null
Future<DialogUserChoice> showChoiceDialog<T>( Future<DialogUserChoice?> showChoiceDialogOld<T>(
BuildContext context, BuildContext context,
String title, String title,
String content, { String content, {
String firstAction = 'Ok', String firstAction = 'Ok',
Color firstActionColor, Color? firstActionColor,
String secondAction = 'Cancel', String secondAction = 'Cancel',
Color secondActionColor, Color? secondActionColor,
ActionType actionType = ActionType.confirm, ActionType actionType = ActionType.confirm,
}) { }) {
final AlertDialog alert = AlertDialog( final AlertDialog alert = AlertDialog(
@ -69,7 +71,7 @@ Future<DialogUserChoice> showChoiceDialog<T>(
], ],
); );
return showDialog( return showDialog<DialogUserChoice>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return alert; return alert;
@ -77,3 +79,46 @@ Future<DialogUserChoice> showChoiceDialog<T>(
barrierColor: Colors.black87, barrierColor: Colors.black87,
); );
} }
///Will return null if dismissed by tapping outside
Future<ButtonResult?> showChoiceDialog(
BuildContext context, {
required String title,
String? body,
required String firstButtonLabel,
String secondButtonLabel = "Cancel",
ButtonType firstButtonType = ButtonType.neutral,
ButtonType secondButtonType = ButtonType.secondary,
ButtonAction firstButtonAction = ButtonAction.first,
ButtonAction secondButtonAction = ButtonAction.cancel,
FutureVoidCallback? firstButtonOnTap,
FutureVoidCallback? secondButtonOnTap,
bool isCritical = false,
IconData? icon,
bool isDismissible = true,
}) async {
final buttons = [
ButtonWidget(
buttonType: isCritical ? ButtonType.critical : firstButtonType,
labelText: firstButtonLabel,
isInAlert: true,
onTap: firstButtonOnTap,
buttonAction: firstButtonAction,
),
ButtonWidget(
buttonType: secondButtonType,
labelText: secondButtonLabel,
isInAlert: true,
onTap: secondButtonOnTap,
buttonAction: secondButtonAction,
),
];
return showDialogWidget(
context: context,
title: title,
body: body,
buttons: buttons,
icon: icon,
isDismissible: isDismissible,
);
}

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:math' as math; import 'dart:math' as math;
@ -6,13 +6,13 @@ import 'package:ente_auth/ente_theme_data.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class DynamicFAB extends StatelessWidget { class DynamicFAB extends StatelessWidget {
final bool isKeypadOpen; final bool? isKeypadOpen;
final bool isFormValid; final bool? isFormValid;
final String buttonText; final String? buttonText;
final Function onPressedFunction; final Function? onPressedFunction;
const DynamicFAB({ const DynamicFAB({
Key key, Key? key,
this.isKeypadOpen, this.isKeypadOpen,
this.buttonText, this.buttonText,
this.isFormValid, this.isFormValid,
@ -21,7 +21,7 @@ class DynamicFAB extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (isKeypadOpen) { if (isKeypadOpen!) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
boxShadow: [ boxShadow: [
@ -43,13 +43,13 @@ class DynamicFAB extends StatelessWidget {
Theme.of(context).colorScheme.dynamicFABBackgroundColor, Theme.of(context).colorScheme.dynamicFABBackgroundColor,
foregroundColor: foregroundColor:
Theme.of(context).colorScheme.dynamicFABTextColor, Theme.of(context).colorScheme.dynamicFABTextColor,
onPressed: isFormValid onPressed: isFormValid!
? onPressedFunction ? onPressedFunction as void Function()?
: () { : () {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
}, },
child: Transform.rotate( child: Transform.rotate(
angle: isFormValid ? 0 : math.pi / 2, angle: isFormValid! ? 0 : math.pi / 2,
child: const Icon( child: const Icon(
Icons.chevron_right, Icons.chevron_right,
size: 36, size: 36,
@ -65,8 +65,8 @@ class DynamicFAB extends StatelessWidget {
height: 56, height: 56,
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
child: OutlinedButton( child: OutlinedButton(
onPressed: isFormValid ? onPressedFunction : null, onPressed: isFormValid! ? onPressedFunction as void Function()? : null,
child: Text(buttonText), child: Text(buttonText!),
), ),
); );
} }
@ -75,17 +75,17 @@ class DynamicFAB extends StatelessWidget {
class NoScalingAnimation extends FloatingActionButtonAnimator { class NoScalingAnimation extends FloatingActionButtonAnimator {
@override @override
Offset getOffset({Offset begin, Offset end, double progress}) { Offset getOffset({Offset? begin, required Offset end, double? progress}) {
return end; return end;
} }
@override @override
Animation<double> getRotationAnimation({Animation<double> parent}) { Animation<double> getRotationAnimation({required Animation<double> parent}) {
return Tween<double>(begin: 1.0, end: 1.0).animate(parent); return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
} }
@override @override
Animation<double> getScaleAnimation({Animation<double> parent}) { Animation<double> getScaleAnimation({required Animation<double> parent}) {
return Tween<double>(begin: 1.0, end: 1.0).animate(parent); return Tween<double>(begin: 1.0, end: 1.0).animate(parent);
} }
} }

View file

@ -1,22 +1,22 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class GradientButton extends StatelessWidget { class GradientButton extends StatelessWidget {
final List<Color> linearGradientColors; final List<Color> linearGradientColors;
final Function onTap; final Function? onTap;
// text is ignored if child is specified // text is ignored if child is specified
final String text; final String text;
// nullable // nullable
final IconData iconData; final IconData? iconData;
// padding between the text and icon // padding between the text and icon
final double paddingValue; final double paddingValue;
const GradientButton({ const GradientButton({
Key key, Key? key,
this.linearGradientColors = const [ this.linearGradientColors = const [
Color.fromARGB(255, 133, 44, 210), Color.fromARGB(255, 133, 44, 210),
Color.fromARGB(255, 187, 26, 93), Color.fromARGB(255, 187, 26, 93),
@ -64,7 +64,7 @@ class GradientButton extends StatelessWidget {
); );
} }
return InkWell( return InkWell(
onTap: onTap, onTap: onTap as void Function()?,
child: Container( child: Container(
height: 56, height: 56,
decoration: BoxDecoration( decoration: BoxDecoration(

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -6,14 +6,14 @@ import 'package:flutter/material.dart';
class LinearProgressDialog extends StatefulWidget { class LinearProgressDialog extends StatefulWidget {
final String message; final String message;
const LinearProgressDialog(this.message, {Key key}) : super(key: key); const LinearProgressDialog(this.message, {Key? key}) : super(key: key);
@override @override
LinearProgressDialogState createState() => LinearProgressDialogState(); LinearProgressDialogState createState() => LinearProgressDialogState();
} }
class LinearProgressDialogState extends State<LinearProgressDialog> { class LinearProgressDialogState extends State<LinearProgressDialog> {
double _progress; double? _progress;
@override @override
void initState() { void initState() {

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
enum ProgressDialogType { normal, download } enum ProgressDialogType { normal, download }
@ -7,7 +5,7 @@ enum ProgressDialogType { normal, download }
String _dialogMessage = "Loading..."; String _dialogMessage = "Loading...";
double _progress = 0.0, _maxProgress = 100.0; double _progress = 0.0, _maxProgress = 100.0;
Widget _customBody; Widget? _customBody;
TextAlign _textAlign = TextAlign.left; TextAlign _textAlign = TextAlign.left;
Alignment _progressWidgetAlignment = Alignment.centerLeft; Alignment _progressWidgetAlignment = Alignment.centerLeft;
@ -15,10 +13,10 @@ Alignment _progressWidgetAlignment = Alignment.centerLeft;
TextDirection _direction = TextDirection.ltr; TextDirection _direction = TextDirection.ltr;
bool _isShowing = false; bool _isShowing = false;
BuildContext _context, _dismissingContext; BuildContext? _context, _dismissingContext;
ProgressDialogType _progressDialogType; ProgressDialogType? _progressDialogType;
bool _barrierDismissible = true, _showLogs = false; bool _barrierDismissible = true, _showLogs = false;
Color _barrierColor; Color? _barrierColor;
TextStyle _progressTextStyle = const TextStyle( TextStyle _progressTextStyle = const TextStyle(
color: Colors.black, color: Colors.black,
@ -42,16 +40,16 @@ Widget _progressWidget = Image.asset(
); );
class ProgressDialog { class ProgressDialog {
_Body _dialog; _Body? _dialog;
ProgressDialog( ProgressDialog(
BuildContext context, { BuildContext context, {
ProgressDialogType type, ProgressDialogType? type,
bool isDismissible, bool? isDismissible,
bool showLogs, bool? showLogs,
TextDirection textDirection, TextDirection? textDirection,
Widget customBody, Widget? customBody,
Color barrierColor, Color? barrierColor,
}) { }) {
_context = context; _context = context;
_progressDialogType = type ?? ProgressDialogType.normal; _progressDialogType = type ?? ProgressDialogType.normal;
@ -63,20 +61,20 @@ class ProgressDialog {
} }
void style({ void style({
Widget child, Widget? child,
double progress, double? progress,
double maxProgress, double? maxProgress,
String message, String? message,
Widget progressWidget, Widget? progressWidget,
Color backgroundColor, Color? backgroundColor,
TextStyle progressTextStyle, TextStyle? progressTextStyle,
TextStyle messageTextStyle, TextStyle? messageTextStyle,
double elevation, double? elevation,
TextAlign textAlign, TextAlign? textAlign,
double borderRadius, double? borderRadius,
Curve insetAnimCurve, Curve? insetAnimCurve,
EdgeInsets padding, EdgeInsets? padding,
Alignment progressWidgetAlignment, Alignment? progressWidgetAlignment,
}) { }) {
if (_isShowing) return; if (_isShowing) return;
if (_progressDialogType == ProgressDialogType.download) { if (_progressDialogType == ProgressDialogType.download) {
@ -100,12 +98,12 @@ class ProgressDialog {
} }
void update({ void update({
double progress, double? progress,
double maxProgress, double? maxProgress,
String message, String? message,
Widget progressWidget, Widget? progressWidget,
TextStyle progressTextStyle, TextStyle? progressTextStyle,
TextStyle messageTextStyle, TextStyle? messageTextStyle,
}) { }) {
if (_progressDialogType == ProgressDialogType.download) { if (_progressDialogType == ProgressDialogType.download) {
_progress = progress ?? _progress; _progress = progress ?? _progress;
@ -117,7 +115,7 @@ class ProgressDialog {
_messageStyle = messageTextStyle ?? _messageStyle; _messageStyle = messageTextStyle ?? _messageStyle;
_progressTextStyle = progressTextStyle ?? _progressTextStyle; _progressTextStyle = progressTextStyle ?? _progressTextStyle;
if (_isShowing) _dialog.update(); if (_isShowing) _dialog!.update();
} }
bool isShowing() { bool isShowing() {
@ -128,7 +126,9 @@ class ProgressDialog {
try { try {
if (_isShowing) { if (_isShowing) {
_isShowing = false; _isShowing = false;
Navigator.of(_dismissingContext).pop(); if (_dismissingContext != null) {
Navigator.of(_dismissingContext!).pop();
}
if (_showLogs) debugPrint('ProgressDialog dismissed'); if (_showLogs) debugPrint('ProgressDialog dismissed');
return Future.value(true); return Future.value(true);
} else { } else {
@ -147,7 +147,7 @@ class ProgressDialog {
if (!_isShowing) { if (!_isShowing) {
_dialog = _Body(); _dialog = _Body();
showDialog<dynamic>( showDialog<dynamic>(
context: _context, context: _context!,
barrierDismissible: _barrierDismissible, barrierDismissible: _barrierDismissible,
barrierColor: _barrierColor, barrierColor: _barrierColor,
builder: (BuildContext context) { builder: (BuildContext context) {

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/utils/dialog_util.dart'; import 'package:ente_auth/utils/dialog_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -8,7 +8,7 @@ class RenameDialog extends StatefulWidget {
final String type; final String type;
final int maxLength; final int maxLength;
const RenameDialog(this.name, this.type, {Key key, this.maxLength = 100}) const RenameDialog(this.name, this.type, {Key? key, this.maxLength = 100})
: super(key: key); : super(key: key);
@override @override
@ -16,7 +16,7 @@ class RenameDialog extends StatefulWidget {
} }
class _RenameDialogState extends State<RenameDialog> { class _RenameDialogState extends State<RenameDialog> {
String _newName; String? _newName;
@override @override
void initState() { void initState() {
@ -74,7 +74,7 @@ class _RenameDialogState extends State<RenameDialog> {
), ),
), ),
onPressed: () { onPressed: () {
if (_newName.trim().isEmpty) { if (_newName!.trim().isEmpty) {
showErrorDialog( showErrorDialog(
context, context,
"Empty name", "Empty name",
@ -82,7 +82,7 @@ class _RenameDialogState extends State<RenameDialog> {
); );
return; return;
} }
if (_newName.trim().length > widget.maxLength) { if (_newName!.trim().length > widget.maxLength) {
showErrorDialog( showErrorDialog(
context, context,
"Name too large", "Name too large",
@ -90,7 +90,7 @@ class _RenameDialogState extends State<RenameDialog> {
); );
return; return;
} }
Navigator.of(context).pop(_newName.trim()); Navigator.of(context).pop(_newName!.trim());
}, },
), ),
], ],

View file

@ -0,0 +1,221 @@
import 'dart:ui';
import 'package:ente_auth/theme/colors.dart';
import 'package:ente_auth/theme/effects.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/components_constants.dart';
import 'package:ente_auth/ui/components/models/button_result.dart';
import 'package:ente_auth/ui/components/separators.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
enum ActionSheetType {
defaultActionSheet,
iconOnly,
}
///Returns null if dismissed
Future<ButtonResult?> showActionSheet({
required BuildContext context,
required List<ButtonWidget> buttons,
ActionSheetType actionSheetType = ActionSheetType.defaultActionSheet,
bool enableDrag = true,
bool isDismissible = true,
bool isCheckIconGreen = false,
String? title,
Widget? bodyWidget,
String? body,
String? bodyHighlight,
}) {
return showMaterialModalBottomSheet(
backgroundColor: Colors.transparent,
barrierColor: backdropFaintDark,
useRootNavigator: true,
context: context,
isDismissible: isDismissible,
enableDrag: enableDrag,
builder: (_) {
return ActionSheetWidget(
title: title,
bodyWidget: bodyWidget,
body: body,
bodyHighlight: bodyHighlight,
actionButtons: buttons,
actionSheetType: actionSheetType,
isCheckIconGreen: isCheckIconGreen,
);
},
);
}
class ActionSheetWidget extends StatelessWidget {
final String? title;
final Widget? bodyWidget;
final String? body;
final String? bodyHighlight;
final List<ButtonWidget> actionButtons;
final ActionSheetType actionSheetType;
final bool isCheckIconGreen;
const ActionSheetWidget({
required this.actionButtons,
required this.actionSheetType,
required this.isCheckIconGreen,
this.title,
this.bodyWidget,
this.body,
this.bodyHighlight,
super.key,
});
@override
Widget build(BuildContext context) {
final isTitleAndBodyNull =
title == null && bodyWidget == null && body == null;
final blur = MediaQuery.of(context).platformBrightness == Brightness.light
? blurMuted
: blurBase;
final extraWidth = MediaQuery.of(context).size.width - restrictedMaxWidth;
final double? horizontalPadding = extraWidth > 0 ? extraWidth / 2 : null;
return Padding(
padding: EdgeInsets.fromLTRB(
horizontalPadding ?? 12,
12,
horizontalPadding ?? 12,
32,
),
child: Container(
decoration: BoxDecoration(boxShadow: shadowMenuLight),
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(8)),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: blur, sigmaY: blur),
child: Container(
color: backdropMutedDark,
child: Padding(
padding: EdgeInsets.fromLTRB(
24,
24,
24,
isTitleAndBodyNull ? 24 : 28,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
isTitleAndBodyNull
? const SizedBox.shrink()
: Padding(
padding: const EdgeInsets.only(bottom: 36),
child: ContentContainerWidget(
title: title,
bodyWidget: bodyWidget,
body: body,
bodyHighlight: bodyHighlight,
actionSheetType: actionSheetType,
isCheckIconGreen: isCheckIconGreen,
),
),
ActionButtons(
actionButtons,
),
],
),
),
),
),
),
),
);
}
}
class ContentContainerWidget extends StatelessWidget {
final String? title;
final Widget? bodyWidget;
final String? body;
final String? bodyHighlight;
final ActionSheetType actionSheetType;
final bool isCheckIconGreen;
const ContentContainerWidget({
required this.actionSheetType,
required this.isCheckIconGreen,
this.title,
this.bodyWidget,
this.body,
this.bodyHighlight,
super.key,
});
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final bool bodyMissing = body == null && bodyWidget == null;
debugPrint("body missing $bodyMissing");
return Column(
mainAxisSize: MainAxisSize.min,
//todo: set cross axis to center when icon should be shown in place of body
crossAxisAlignment: actionSheetType == ActionSheetType.defaultActionSheet
? CrossAxisAlignment.stretch
: CrossAxisAlignment.center,
children: [
title == null
? const SizedBox.shrink()
: Text(
title!,
style: textTheme.largeBold
.copyWith(color: textBaseDark), //constant color
),
title == null || bodyMissing
? const SizedBox.shrink()
: const SizedBox(height: 19),
actionSheetType == ActionSheetType.defaultActionSheet
? bodyMissing
? const SizedBox.shrink()
: (bodyWidget != null
? bodyWidget!
: Text(
body!,
style: textTheme.body
.copyWith(color: textMutedDark), //constant color
))
: Icon(
Icons.check_outlined,
size: 48,
color: isCheckIconGreen
? getEnteColorScheme(context).primary700
: strokeBaseDark,
),
actionSheetType == ActionSheetType.defaultActionSheet &&
bodyHighlight != null
? Padding(
padding: const EdgeInsets.only(top: 19.0),
child: Text(
bodyHighlight!,
style: textTheme.body
.copyWith(color: textBaseDark), //constant color
),
)
: const SizedBox.shrink(),
],
);
}
}
class ActionButtons extends StatelessWidget {
final List<Widget> actionButtons;
const ActionButtons(this.actionButtons, {super.key});
@override
Widget build(BuildContext context) {
final actionButtonsWithSeparators = actionButtons;
return Column(
children:
//Separator height is 8pts in figma. -2pts here as the action
//buttons are 2pts extra in height in code compared to figma because
//of the border(1pt top + 1pt bottom) of action buttons.
addSeparators(actionButtonsWithSeparators, const SizedBox(height: 6)),
);
}
}

View file

@ -0,0 +1,4 @@
const double mobileSmallThreshold = 336;
//Screen width of iPhone 14 pro max in points is taken as maximum
const double restrictedMaxWidth = 430;

View file

@ -1,17 +1,17 @@
import 'dart:math'; import 'dart:math';
import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/models/typedefs.dart';
import 'package:ente_auth/theme/colors.dart';
import 'package:ente_auth/theme/effects.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/components_constants.dart';
import 'package:ente_auth/ui/components/models/button_result.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
import 'package:ente_auth/ui/components/separators.dart';
import 'package:ente_auth/ui/components/text_input_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:photos/core/constants.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/models/search/button_result.dart";
import 'package:photos/models/typedefs.dart';
import 'package:photos/theme/colors.dart';
import 'package:photos/theme/effects.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
import 'package:photos/ui/components/text_input_widget.dart';
import 'package:photos/utils/separators_util.dart';
///Will return null if dismissed by tapping outside ///Will return null if dismissed by tapping outside
Future<ButtonResult?> showDialogWidget({ Future<ButtonResult?> showDialogWidget({
@ -261,7 +261,7 @@ class _TextInputDialogState extends State<TextInputDialog> {
child: ButtonWidget( child: ButtonWidget(
buttonType: ButtonType.secondary, buttonType: ButtonType.secondary,
buttonSize: ButtonSize.small, buttonSize: ButtonSize.small,
labelText: S.of(context).cancel, labelText: context.l10n.cancel,
isInAlert: true, isInAlert: true,
), ),
), ),

View file

@ -69,7 +69,7 @@ class _ExpandableMenuItemWidgetState extends State<ExpandableMenuItemWidget> {
), ),
collapsed: const SizedBox.shrink(), collapsed: const SizedBox.shrink(),
expanded: widget.selectionOptionsWidget, expanded: widget.selectionOptionsWidget,
theme: getExpandableTheme(context), theme: getExpandableTheme(),
controller: expandableController, controller: expandableController,
), ),
), ),

View file

@ -1,11 +1,11 @@
import 'package:ente_auth/models/execution_states.dart';
import 'package:ente_auth/models/typedefs.dart';
import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/common/loading_widget.dart';
import 'package:ente_auth/ui/components/separators.dart';
import 'package:ente_auth/utils/debouncer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:photos/models/execution_states.dart';
import 'package:photos/models/typedefs.dart';
import 'package:photos/theme/ente_theme.dart';
import 'package:photos/ui/common/loading_widget.dart';
import 'package:photos/utils/debouncer.dart';
import 'package:photos/utils/separators_util.dart';
class TextInputWidget extends StatefulWidget { class TextInputWidget extends StatefulWidget {
final String? label; final String? label;

View file

@ -1,11 +1,11 @@
// @dart=2.9
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
class LifecycleEventHandler extends WidgetsBindingObserver { class LifecycleEventHandler extends WidgetsBindingObserver {
final AsyncCallback resumeCallBack; final AsyncCallback? resumeCallBack;
final AsyncCallback suspendingCallBack; final AsyncCallback? suspendingCallBack;
LifecycleEventHandler({ LifecycleEventHandler({
this.resumeCallBack, this.resumeCallBack,
@ -17,14 +17,14 @@ class LifecycleEventHandler extends WidgetsBindingObserver {
switch (state) { switch (state) {
case AppLifecycleState.resumed: case AppLifecycleState.resumed:
if (resumeCallBack != null) { if (resumeCallBack != null) {
await resumeCallBack(); await resumeCallBack!();
} }
break; break;
case AppLifecycleState.inactive: case AppLifecycleState.inactive:
case AppLifecycleState.paused: case AppLifecycleState.paused:
case AppLifecycleState.detached: case AppLifecycleState.detached:
if (suspendingCallBack != null) { if (suspendingCallBack != null) {
await suspendingCallBack(); await suspendingCallBack!();
} }
break; break;
} }

View file

@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class AboutSectionWidget extends StatelessWidget { class AboutSectionWidget extends StatelessWidget {
const AboutSectionWidget({Key key}) : super(key: key); const AboutSectionWidget({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/app/view/app.dart'; import 'package:ente_auth/app/view/app.dart';
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
@ -20,7 +20,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_sodium/flutter_sodium.dart'; import 'package:flutter_sodium/flutter_sodium.dart';
class AccountSectionWidget extends StatelessWidget { class AccountSectionWidget extends StatelessWidget {
AccountSectionWidget({Key key}) : super(key: key); AccountSectionWidget({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -56,7 +56,7 @@ class AccountSectionWidget extends StatelessWidget {
recoveryKey = recoveryKey =
Sodium.bin2hex(Configuration.instance.getRecoveryKey()); Sodium.bin2hex(Configuration.instance.getRecoveryKey());
} catch (e) { } catch (e) {
showGenericErrorDialog(context); showGenericErrorDialog(context: context);
return; return;
} }
routeToPage( routeToPage(

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/core/network.dart'; import 'package:ente_auth/core/network.dart';
@ -9,9 +9,9 @@ import 'package:logging/logging.dart';
import 'package:open_filex/open_filex.dart'; import 'package:open_filex/open_filex.dart';
class AppUpdateDialog extends StatefulWidget { class AppUpdateDialog extends StatefulWidget {
final LatestVersionInfo latestVersionInfo; final LatestVersionInfo? latestVersionInfo;
const AppUpdateDialog(this.latestVersionInfo, {Key key}) : super(key: key); const AppUpdateDialog(this.latestVersionInfo, {Key? key}) : super(key: key);
@override @override
State<AppUpdateDialog> createState() => _AppUpdateDialogState(); State<AppUpdateDialog> createState() => _AppUpdateDialogState();
@ -21,13 +21,13 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final List<Widget> changelog = []; final List<Widget> changelog = [];
for (final log in widget.latestVersionInfo.changelog) { for (final log in widget.latestVersionInfo!.changelog) {
changelog.add( changelog.add(
Padding( Padding(
padding: const EdgeInsets.fromLTRB(8, 4, 0, 4), padding: const EdgeInsets.fromLTRB(8, 4, 0, 4),
child: Text( child: Text(
"- " + log, "- " + log,
style: Theme.of(context).textTheme.caption.copyWith( style: Theme.of(context).textTheme.caption!.copyWith(
fontSize: 14, fontSize: 14,
), ),
), ),
@ -39,7 +39,7 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
widget.latestVersionInfo.name, widget.latestVersionInfo!.name!,
style: const TextStyle( style: const TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -62,8 +62,8 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
width: double.infinity, width: double.infinity,
height: 64, height: 64,
child: OutlinedButton( child: OutlinedButton(
style: Theme.of(context).outlinedButtonTheme.style.copyWith( style: Theme.of(context).outlinedButtonTheme.style!.copyWith(
textStyle: MaterialStateProperty.resolveWith<TextStyle>( textStyle: MaterialStateProperty.resolveWith<TextStyle?>(
(Set<MaterialState> states) { (Set<MaterialState> states) {
return Theme.of(context).textTheme.subtitle1; return Theme.of(context).textTheme.subtitle1;
}, },
@ -101,24 +101,24 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
} }
class ApkDownloaderDialog extends StatefulWidget { class ApkDownloaderDialog extends StatefulWidget {
final LatestVersionInfo versionInfo; final LatestVersionInfo? versionInfo;
const ApkDownloaderDialog(this.versionInfo, {Key key}) : super(key: key); const ApkDownloaderDialog(this.versionInfo, {Key? key}) : super(key: key);
@override @override
State<ApkDownloaderDialog> createState() => _ApkDownloaderDialogState(); State<ApkDownloaderDialog> createState() => _ApkDownloaderDialogState();
} }
class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> { class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> {
String _saveUrl; String? _saveUrl;
double _downloadProgress; double? _downloadProgress;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_saveUrl = Configuration.instance.getTempDirectory() + _saveUrl = Configuration.instance.getTempDirectory() +
"ente-" + "ente-" +
widget.versionInfo.name + widget.versionInfo!.name! +
".apk"; ".apk";
_downloadApk(); _downloadApk();
} }
@ -148,11 +148,11 @@ class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> {
Future<void> _downloadApk() async { Future<void> _downloadApk() async {
try { try {
await Network.instance.getDio().download( await Network.instance.getDio().download(
widget.versionInfo.url, widget.versionInfo!.url!,
_saveUrl, _saveUrl,
onReceiveProgress: (count, _) { onReceiveProgress: (count, _) {
setState(() { setState(() {
_downloadProgress = count / widget.versionInfo.size; _downloadProgress = count / widget.versionInfo!.size!;
}); });
}, },
); );

View file

@ -1,12 +1,10 @@
// @dart=2.9
import 'package:ente_auth/utils/dialog_util.dart'; import 'package:ente_auth/utils/dialog_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
class AppVersionWidget extends StatefulWidget { class AppVersionWidget extends StatefulWidget {
const AppVersionWidget({ const AppVersionWidget({
Key key, Key? key,
}) : super(key: key); }) : super(key: key);
@override @override
@ -18,7 +16,7 @@ class _AppVersionWidgetState extends State<AppVersionWidget> {
static const kConsecutiveTapTimeWindowInMilliseconds = 2000; static const kConsecutiveTapTimeWindowInMilliseconds = 2000;
static const kDummyDelayDurationInMilliseconds = 1500; static const kDummyDelayDurationInMilliseconds = 1500;
int _lastTap; int? _lastTap;
int _consecutiveTaps = 0; int _consecutiveTaps = 0;
@override @override
@ -43,14 +41,14 @@ class _AppVersionWidgetState extends State<AppVersionWidget> {
} }
_lastTap = now; _lastTap = now;
}, },
child: FutureBuilder( child: FutureBuilder<String>(
future: _getAppVersion(), future: _getAppVersion(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
return Padding( return Padding(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: Text( child: Text(
"Version: " + snapshot.data, "Version: " + snapshot.data!,
style: Theme.of(context).textTheme.caption, style: Theme.of(context).textTheme.caption,
), ),
); );

View file

@ -1,18 +1,10 @@
// @dart=2.9
import 'dart:io';
import 'package:expandable/expandable.dart'; import 'package:expandable/expandable.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Widget sectionOptionDivider = Padding(
padding: EdgeInsets.all(Platform.isIOS ? 4 : 2),
);
Widget sectionOptionSpacing = const SizedBox(height: 6); Widget sectionOptionSpacing = const SizedBox(height: 6);
ExpandableThemeData getExpandableTheme(BuildContext context) { ExpandableThemeData getExpandableTheme() {
return const ExpandableThemeData( return const ExpandableThemeData(
hasIcon: false, hasIcon: false,
useInkWell: false, useInkWell: false,

View file

@ -1,5 +1,6 @@
// @dart=2.9
import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/services/user_service.dart'; import 'package:ente_auth/services/user_service.dart';
import 'package:ente_auth/theme/ente_theme.dart'; import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/account/delete_account_page.dart'; import 'package:ente_auth/ui/account/delete_account_page.dart';
@ -11,12 +12,12 @@ import 'package:ente_auth/utils/navigation_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class DangerSectionWidget extends StatelessWidget { class DangerSectionWidget extends StatelessWidget {
const DangerSectionWidget({Key key}) : super(key: key); const DangerSectionWidget({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ExpandableMenuItemWidget( return ExpandableMenuItemWidget(
title: "Exit", title: context.l10n.exit,
selectionOptionsWidget: _getSectionOptions(context), selectionOptionsWidget: _getSectionOptions(context),
leadingIcon: Icons.logout_outlined, leadingIcon: Icons.logout_outlined,
); );
@ -27,25 +28,25 @@ class DangerSectionWidget extends StatelessWidget {
children: [ children: [
sectionOptionSpacing, sectionOptionSpacing,
MenuItemWidget( MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget( captionedTextWidget: CaptionedTextWidget(
title: "Logout", title: context.l10n.logout,
), ),
pressedColor: getEnteColorScheme(context).fillFaint, pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined, trailingIcon: Icons.chevron_right_outlined,
trailingIconIsMuted: true, trailingIconIsMuted: true,
onTap: () { onTap: () async {
_onLogoutTapped(context); _onLogoutTapped(context);
}, },
), ),
sectionOptionSpacing, sectionOptionSpacing,
MenuItemWidget( MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget( captionedTextWidget: CaptionedTextWidget(
title: "Delete account", title: context.l10n.deleteAccount,
), ),
pressedColor: getEnteColorScheme(context).fillFaint, pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined, trailingIcon: Icons.chevron_right_outlined,
trailingIconIsMuted: true, trailingIconIsMuted: true,
onTap: () { onTap: () async {
routeToPage(context, const DeleteAccountPage()); routeToPage(context, const DeleteAccountPage());
}, },
), ),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
@ -13,8 +13,10 @@ import 'package:ente_auth/services/local_authentication_service.dart';
import 'package:ente_auth/store/code_store.dart'; import 'package:ente_auth/store/code_store.dart';
import 'package:ente_auth/theme/ente_theme.dart'; import 'package:ente_auth/theme/ente_theme.dart';
import 'package:ente_auth/ui/components/captioned_text_widget.dart'; import 'package:ente_auth/ui/components/captioned_text_widget.dart';
import 'package:ente_auth/ui/components/dialog_widget.dart';
import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart'; import 'package:ente_auth/ui/components/expandable_menu_item_widget.dart';
import 'package:ente_auth/ui/components/menu_item_widget.dart'; import 'package:ente_auth/ui/components/menu_item_widget.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
import 'package:ente_auth/ui/settings/common_settings.dart'; import 'package:ente_auth/ui/settings/common_settings.dart';
import 'package:ente_auth/utils/dialog_util.dart'; import 'package:ente_auth/utils/dialog_util.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
@ -29,7 +31,7 @@ class DataSectionWidget extends StatelessWidget {
Configuration.instance.getTempDirectory() + "ente-authenticator-codes.txt", Configuration.instance.getTempDirectory() + "ente-authenticator-codes.txt",
); );
DataSectionWidget({Key key}) : super(key: key); DataSectionWidget({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -216,14 +218,14 @@ class DataSectionWidget extends StatelessWidget {
Future<void> _pickImportFile(BuildContext context) async { Future<void> _pickImportFile(BuildContext context) async {
final l10n = context.l10n; final l10n = context.l10n;
FilePickerResult result = await FilePicker.platform.pickFiles(); FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result == null) { if (result == null) {
return; return;
} }
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle); final dialog = createProgressDialog(context, l10n.pleaseWait);
await dialog.show(); await dialog.show();
try { try {
File file = File(result.files.single.path); File file = File(result.files.single.path!);
final codes = await file.readAsString(); final codes = await file.readAsString();
List<String> splitCodes = codes.split(","); List<String> splitCodes = codes.split(",");
if (splitCodes.length == 1) { if (splitCodes.length == 1) {
@ -241,34 +243,20 @@ class DataSectionWidget extends StatelessWidget {
await CodeStore.instance.addCode(code, shouldSync: false); await CodeStore.instance.addCode(code, shouldSync: false);
} }
unawaited(AuthenticatorService.instance.sync()); unawaited(AuthenticatorService.instance.sync());
await dialog.hide();
final DialogWidget dialog = choiceDialog(
title: "Yay!",
body: "You have imported " + parsedCodes.length.toString() + " codes!",
firstButtonLabel: l10n.ok,
firstButtonOnTap: () async {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
firstButtonType: ButtonType.primary,
);
await showConfettiDialog( await showConfettiDialog(
context: context, context: context,
builder: (BuildContext context) { dialogBuilder: (BuildContext context) {
return AlertDialog( return dialog;
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: Text(
"Yay!",
style: Theme.of(context).textTheme.headline6,
),
content: Text(
"You have imported " + parsedCodes.length.toString() + " codes!",
),
actions: [
TextButton(
child: Text(
l10n.ok,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
),
],
);
}, },
); );
} catch (e) { } catch (e) {

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/ui/settings/common_settings.dart'; import 'package:ente_auth/ui/settings/common_settings.dart';
@ -10,7 +8,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_sodium/flutter_sodium.dart'; import 'package:flutter_sodium/flutter_sodium.dart';
class DebugSectionWidget extends StatelessWidget { class DebugSectionWidget extends StatelessWidget {
const DebugSectionWidget({Key key}) : super(key: key); const DebugSectionWidget({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// This is a debug only section not shown to end users, so these strings are // This is a debug only section not shown to end users, so these strings are
@ -19,7 +18,7 @@ class DebugSectionWidget extends StatelessWidget {
header: const SettingsSectionTitle("Debug"), header: const SettingsSectionTitle("Debug"),
collapsed: Container(), collapsed: Container(),
expanded: _getSectionOptions(context), expanded: _getSectionOptions(context),
theme: getExpandableTheme(context), theme: getExpandableTheme(),
); );
} }
@ -42,7 +41,7 @@ class DebugSectionWidget extends StatelessWidget {
void _showKeyAttributesDialog(BuildContext context) { void _showKeyAttributesDialog(BuildContext context) {
final l10n = context.l10n; final l10n = context.l10n;
final keyAttributes = Configuration.instance.getKeyAttributes(); final keyAttributes = Configuration.instance.getKeyAttributes()!;
final AlertDialog alert = AlertDialog( final AlertDialog alert = AlertDialog(
title: const Text("key attributes"), title: const Text("key attributes"),
content: SingleChildScrollView( content: SingleChildScrollView(
@ -52,7 +51,7 @@ class DebugSectionWidget extends StatelessWidget {
"Key", "Key",
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(fontWeight: FontWeight.bold),
), ),
Text(Sodium.bin2base64(Configuration.instance.getKey())), Text(Sodium.bin2base64(Configuration.instance.getKey()!)),
const Padding(padding: EdgeInsets.all(12)), const Padding(padding: EdgeInsets.all(12)),
const Text( const Text(
"Encrypted Key", "Encrypted Key",

View file

@ -54,7 +54,7 @@ class LanguageSelectorPage extends StatelessWidget {
), ),
), ),
// MenuSectionDescriptionWidget( // MenuSectionDescriptionWidget(
// content: S.of(context).maxDeviceLimitSpikeHandling(50), // content: context.l10n.maxDeviceLimitSpikeHandling(50),
// ) // )
], ],
), ),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/core/configuration.dart'; import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
@ -13,7 +13,7 @@ import 'package:ente_auth/ui/settings/common_settings.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class SecuritySectionWidget extends StatefulWidget { class SecuritySectionWidget extends StatefulWidget {
const SecuritySectionWidget({Key key}) : super(key: key); const SecuritySectionWidget({Key? key}) : super(key: key);
@override @override
State<SecuritySectionWidget> createState() => _SecuritySectionWidgetState(); State<SecuritySectionWidget> createState() => _SecuritySectionWidgetState();

View file

@ -1,14 +1,14 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class SettingsSectionTitle extends StatelessWidget { class SettingsSectionTitle extends StatelessWidget {
final String title; final String title;
final Color color; final Color? color;
const SettingsSectionTitle( const SettingsSectionTitle(
this.title, { this.title, {
Key key, Key? key,
this.color, this.color,
}) : super(key: key); }) : super(key: key);
@ -24,7 +24,7 @@ class SettingsSectionTitle extends StatelessWidget {
style: color != null style: color != null
? Theme.of(context) ? Theme.of(context)
.textTheme .textTheme
.headline6 .headline6!
.merge(TextStyle(color: color)) .merge(TextStyle(color: color))
: Theme.of(context).textTheme.headline6, : Theme.of(context).textTheme.headline6,
), ),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
@ -8,9 +8,9 @@ class SettingsTextItem extends StatelessWidget {
final String text; final String text;
final IconData icon; final IconData icon;
const SettingsTextItem({ const SettingsTextItem({
Key key, Key? key,
@required this.text, required this.text,
@required this.icon, required this.icon,
}) : super(key: key); }) : super(key: key);
@override @override

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/theme/ente_theme.dart'; import 'package:ente_auth/theme/ente_theme.dart';
@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
class SocialSectionWidget extends StatelessWidget { class SocialSectionWidget extends StatelessWidget {
const SocialSectionWidget({Key key}) : super(key: key); const SocialSectionWidget({Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -39,7 +39,7 @@ class SocialSectionWidget extends StatelessWidget {
class SocialsMenuItemWidget extends StatelessWidget { class SocialsMenuItemWidget extends StatelessWidget {
final String text; final String text;
final String urlSring; final String urlSring;
const SocialsMenuItemWidget(this.text, this.urlSring, {Key key}) const SocialsMenuItemWidget(this.text, this.urlSring, {Key? key})
: super(key: key); : super(key: key);
@override @override
@ -53,7 +53,7 @@ class SocialsMenuItemWidget extends StatelessWidget {
trailingIconIsMuted: true, trailingIconIsMuted: true,
onTap: () { onTap: () {
launchUrlString(urlSring); launchUrlString(urlSring);
}, } as Future<void> Function()?,
); );
} }
} }

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/core/constants.dart'; import 'package:ente_auth/core/constants.dart';
import 'package:ente_auth/core/logging/super_logging.dart'; import 'package:ente_auth/core/logging/super_logging.dart';
@ -13,7 +13,7 @@ import 'package:ente_auth/utils/email_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class SupportSectionWidget extends StatefulWidget { class SupportSectionWidget extends StatefulWidget {
const SupportSectionWidget({Key key}) : super(key: key); const SupportSectionWidget({Key? key}) : super(key: key);
@override @override
State<SupportSectionWidget> createState() => _SupportSectionWidgetState(); State<SupportSectionWidget> createState() => _SupportSectionWidgetState();

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:adaptive_theme/adaptive_theme.dart';
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
@ -11,14 +11,14 @@ import 'package:flutter/material.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
class ThemeSwitchWidget extends StatefulWidget { class ThemeSwitchWidget extends StatefulWidget {
const ThemeSwitchWidget({Key key}) : super(key: key); const ThemeSwitchWidget({Key? key}) : super(key: key);
@override @override
State<ThemeSwitchWidget> createState() => _ThemeSwitchWidgetState(); State<ThemeSwitchWidget> createState() => _ThemeSwitchWidgetState();
} }
class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> { class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
AdaptiveThemeMode currentThemeMode; AdaptiveThemeMode? currentThemeMode;
@override @override
void initState() { void initState() {
@ -67,7 +67,7 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
Widget _menuItem(BuildContext context, AdaptiveThemeMode themeMode) { Widget _menuItem(BuildContext context, AdaptiveThemeMode themeMode) {
return MenuItemWidget( return MenuItemWidget(
captionedTextWidget: CaptionedTextWidget( captionedTextWidget: CaptionedTextWidget(
title: toBeginningOfSentenceCase(themeMode.name), title: toBeginningOfSentenceCase(themeMode.name)!,
textStyle: Theme.of(context).colorScheme.enteTheme.textTheme.body, textStyle: Theme.of(context).colorScheme.enteTheme.textTheme.body,
), ),
pressedColor: getEnteColorScheme(context).fillFaint, pressedColor: getEnteColorScheme(context).fillFaint,

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
import 'package:ente_auth/theme/colors.dart'; import 'package:ente_auth/theme/colors.dart';
@ -19,8 +17,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class SettingsPage extends StatelessWidget { class SettingsPage extends StatelessWidget {
final ValueNotifier<String> emailNotifier; final ValueNotifier<String?> emailNotifier;
const SettingsPage({Key key, @required this.emailNotifier}) : super(key: key); const SettingsPage({Key? key, required this.emailNotifier}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -44,9 +42,9 @@ class SettingsPage extends StatelessWidget {
child: AnimatedBuilder( child: AnimatedBuilder(
// [AnimatedBuilder] accepts any [Listenable] subtype. // [AnimatedBuilder] accepts any [Listenable] subtype.
animation: emailNotifier, animation: emailNotifier,
builder: (BuildContext context, Widget child) { builder: (BuildContext context, Widget? child) {
return Text( return Text(
emailNotifier.value, emailNotifier.value!,
style: enteTextTheme.body.copyWith( style: enteTextTheme.body.copyWith(
color: colorScheme.textMuted, color: colorScheme.textMuted,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
import 'dart:ui'; import 'dart:ui';
@ -8,14 +6,14 @@ import 'package:flutter/material.dart';
class LogFileViewer extends StatefulWidget { class LogFileViewer extends StatefulWidget {
final File file; final File file;
const LogFileViewer(this.file, {Key key}) : super(key: key); const LogFileViewer(this.file, {Key? key}) : super(key: key);
@override @override
State<LogFileViewer> createState() => _LogFileViewerState(); State<LogFileViewer> createState() => _LogFileViewerState();
} }
class _LogFileViewerState extends State<LogFileViewer> { class _LogFileViewerState extends State<LogFileViewer> {
String _logs; String? _logs;
@override @override
void initState() { void initState() {
widget.file.readAsString().then((logs) { widget.file.readAsString().then((logs) {
@ -45,7 +43,7 @@ class _LogFileViewerState extends State<LogFileViewer> {
padding: const EdgeInsets.only(left: 12, top: 8, right: 12), padding: const EdgeInsets.only(left: 12, top: 8, right: 12),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Text( child: Text(
_logs, _logs!,
style: const TextStyle( style: const TextStyle(
fontFeatures: [ fontFeatures: [
FontFeature.tabularFigures(), FontFeature.tabularFigures(),

View file

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:ente_auth/ui/common/gradient_button.dart'; import 'package:ente_auth/ui/common/gradient_button.dart';
import 'package:ente_auth/ui/tools/app_lock.dart'; import 'package:ente_auth/ui/tools/app_lock.dart';
@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
class LockScreen extends StatefulWidget { class LockScreen extends StatefulWidget {
const LockScreen({Key key}) : super(key: key); const LockScreen({Key? key}) : super(key: key);
@override @override
State<LockScreen> createState() => _LockScreenState(); State<LockScreen> createState() => _LockScreenState();
@ -62,7 +62,7 @@ class _LockScreenState extends State<LockScreen> {
"Please authenticate to view your secrets", "Please authenticate to view your secrets",
); );
if (result) { if (result) {
AppLock.of(context).didUnlock(); AppLock.of(context)!.didUnlock();
} }
} catch (e, s) { } catch (e, s) {
_logger.severe(e, s); _logger.severe(e, s);

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/services/user_service.dart'; import 'package:ente_auth/services/user_service.dart';
import 'package:ente_auth/ui/lifecycle_event_handler.dart'; import 'package:ente_auth/ui/lifecycle_event_handler.dart';
@ -10,7 +8,7 @@ import 'package:pinput/pin_put/pin_put.dart';
class TwoFactorAuthenticationPage extends StatefulWidget { class TwoFactorAuthenticationPage extends StatefulWidget {
final String sessionID; final String sessionID;
const TwoFactorAuthenticationPage(this.sessionID, {Key key}) const TwoFactorAuthenticationPage(this.sessionID, {Key? key})
: super(key: key); : super(key: key);
@override @override
@ -22,7 +20,7 @@ class _TwoFactorAuthenticationPageState
extends State<TwoFactorAuthenticationPage> { extends State<TwoFactorAuthenticationPage> {
final _pinController = TextEditingController(); final _pinController = TextEditingController();
String _code = ""; String _code = "";
LifecycleEventHandler _lifecycleEventHandler; late LifecycleEventHandler _lifecycleEventHandler;
@override @override
void initState() { void initState() {
@ -30,8 +28,8 @@ class _TwoFactorAuthenticationPageState
resumeCallBack: () async { resumeCallBack: () async {
if (mounted) { if (mounted) {
final data = await Clipboard.getData(Clipboard.kTextPlain); final data = await Clipboard.getData(Clipboard.kTextPlain);
if (data != null && data.text != null && data.text.length == 6) { if (data != null && data.text != null && data.text!.length == 6) {
_pinController.text = data.text; _pinController.text = data.text!;
} }
} }
}, },
@ -65,7 +63,7 @@ class _TwoFactorAuthenticationPageState
border: Border.all( border: Border.all(
color: Theme.of(context) color: Theme.of(context)
.inputDecorationTheme .inputDecorationTheme
.focusedBorder .focusedBorder!
.borderSide .borderSide
.color, .color,
), ),

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:ui'; import 'dart:ui';
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
@ -16,7 +14,7 @@ class TwoFactorRecoveryPage extends StatefulWidget {
this.sessionID, this.sessionID,
this.encryptedSecret, this.encryptedSecret,
this.secretDecryptionNonce, { this.secretDecryptionNonce, {
Key key, Key? key,
}) : super(key: key); }) : super(key: key);
@override @override

View file

@ -1,24 +1,230 @@
// @dart=2.9
import 'dart:math'; import 'dart:math';
import 'package:confetti/confetti.dart'; import 'package:confetti/confetti.dart';
import "package:dio/dio.dart";
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/models/typedefs.dart';
import 'package:ente_auth/theme/colors.dart';
import 'package:ente_auth/ui/common/loading_widget.dart'; import 'package:ente_auth/ui/common/loading_widget.dart';
import 'package:ente_auth/ui/common/progress_dialog.dart'; import 'package:ente_auth/ui/common/progress_dialog.dart';
import 'package:ente_auth/ui/components/action_sheet_widget.dart';
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/components_constants.dart';
import 'package:ente_auth/ui/components/dialog_widget.dart';
import 'package:ente_auth/ui/components/models/button_result.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
ProgressDialog createProgressDialog(BuildContext context, String message) { typedef DialogBuilder = DialogWidget Function(BuildContext context);
///Will return null if dismissed by tapping outside
Future<ButtonResult?> showErrorDialog(
BuildContext context,
String title,
String? body, {
bool isDismissable = true,
}) async {
return showDialogWidget(
context: context,
title: title,
body: body,
isDismissible: isDismissable,
buttons: const [
ButtonWidget(
buttonType: ButtonType.secondary,
labelText: "OK",
isInAlert: true,
buttonAction: ButtonAction.first,
),
],
);
}
Future<ButtonResult?> showErrorDialogForException({
required BuildContext context,
required Exception exception,
bool isDismissible = true,
String apiErrorPrefix = "It looks like something went wrong.",
}) async {
String errorMessage = context.l10n.tempErrorContactSupportIfPersists;
if (exception is DioError &&
exception.response != null &&
exception.response!.data["code"] != null) {
errorMessage =
"$apiErrorPrefix\n\nReason: " + exception.response!.data["code"];
}
return showDialogWidget(
context: context,
title: context.l10n.error,
icon: Icons.error_outline_outlined,
body: errorMessage,
isDismissible: isDismissible,
buttons: const [
ButtonWidget(
buttonType: ButtonType.secondary,
labelText: "OK",
isInAlert: true,
),
],
);
}
///Will return null if dismissed by tapping outside
Future<ButtonResult?> showGenericErrorDialog({
required BuildContext context,
bool isDismissible = true,
}) async {
return showDialogWidget(
context: context,
title: context.l10n.error,
icon: Icons.error_outline_outlined,
body: context.l10n.itLooksLikeSomethingWentWrongPleaseRetryAfterSome,
isDismissible: isDismissible,
buttons: const [
ButtonWidget(
buttonType: ButtonType.secondary,
labelText: "OK",
isInAlert: true,
),
],
);
}
DialogWidget choiceDialog({
required String title,
String? body,
required String firstButtonLabel,
String secondButtonLabel = "Cancel",
ButtonType firstButtonType = ButtonType.neutral,
ButtonType secondButtonType = ButtonType.secondary,
ButtonAction firstButtonAction = ButtonAction.first,
ButtonAction secondButtonAction = ButtonAction.cancel,
FutureVoidCallback? firstButtonOnTap,
FutureVoidCallback? secondButtonOnTap,
bool isCritical = false,
IconData? icon,
}) {
final buttons = [
ButtonWidget(
buttonType: isCritical ? ButtonType.critical : firstButtonType,
labelText: firstButtonLabel,
isInAlert: true,
onTap: firstButtonOnTap,
buttonAction: firstButtonAction,
),
ButtonWidget(
buttonType: secondButtonType,
labelText: secondButtonLabel,
isInAlert: true,
onTap: secondButtonOnTap,
buttonAction: secondButtonAction,
),
];
return DialogWidget(title: title, body: body, buttons: buttons, icon: icon);
}
///Will return null if dismissed by tapping outside
Future<ButtonResult?> showChoiceDialog(
BuildContext context, {
required String title,
String? body,
required String firstButtonLabel,
String secondButtonLabel = "Cancel",
ButtonType firstButtonType = ButtonType.neutral,
ButtonType secondButtonType = ButtonType.secondary,
ButtonAction firstButtonAction = ButtonAction.first,
ButtonAction secondButtonAction = ButtonAction.cancel,
FutureVoidCallback? firstButtonOnTap,
FutureVoidCallback? secondButtonOnTap,
bool isCritical = false,
IconData? icon,
bool isDismissible = true,
}) async {
final buttons = [
ButtonWidget(
buttonType: isCritical ? ButtonType.critical : firstButtonType,
labelText: firstButtonLabel,
isInAlert: true,
onTap: firstButtonOnTap,
buttonAction: firstButtonAction,
),
ButtonWidget(
buttonType: secondButtonType,
labelText: secondButtonLabel,
isInAlert: true,
onTap: secondButtonOnTap,
buttonAction: secondButtonAction,
),
];
return showDialogWidget(
context: context,
title: title,
body: body,
buttons: buttons,
icon: icon,
isDismissible: isDismissible,
);
}
///Will return null if dismissed by tapping outside
Future<ButtonResult?> showChoiceActionSheet(
BuildContext context, {
required String title,
String? body,
required String firstButtonLabel,
String secondButtonLabel = "Cancel",
ButtonType firstButtonType = ButtonType.neutral,
ButtonType secondButtonType = ButtonType.secondary,
ButtonAction firstButtonAction = ButtonAction.first,
ButtonAction secondButtonAction = ButtonAction.cancel,
FutureVoidCallback? firstButtonOnTap,
FutureVoidCallback? secondButtonOnTap,
bool isCritical = false,
IconData? icon,
bool isDismissible = true,
}) async {
final buttons = [
ButtonWidget(
buttonType: isCritical ? ButtonType.critical : firstButtonType,
labelText: firstButtonLabel,
isInAlert: true,
onTap: firstButtonOnTap,
buttonAction: firstButtonAction,
shouldStickToDarkTheme: true,
),
ButtonWidget(
buttonType: secondButtonType,
labelText: secondButtonLabel,
isInAlert: true,
onTap: secondButtonOnTap,
buttonAction: secondButtonAction,
shouldStickToDarkTheme: true,
),
];
return showActionSheet(
context: context,
title: title,
body: body,
buttons: buttons,
isDismissible: isDismissible,
);
}
ProgressDialog createProgressDialog(
BuildContext context,
String message, {
isDismissible = false,
}) {
final dialog = ProgressDialog( final dialog = ProgressDialog(
context, context,
type: ProgressDialogType.normal, type: ProgressDialogType.normal,
isDismissible: false, isDismissible: isDismissible,
barrierColor: Colors.black12, barrierColor: Colors.black12,
); );
dialog.style( dialog.style(
message: message, message: message,
messageTextStyle: messageTextStyle: Theme.of(context).textTheme.caption,
Theme.of(context).textTheme.caption.copyWith(fontSize: 14),
backgroundColor: Theme.of(context).dialogTheme.backgroundColor, backgroundColor: Theme.of(context).dialogTheme.backgroundColor,
progressWidget: const EnteLoadingWidget(), progressWidget: const EnteLoadingWidget(),
borderRadius: 10, borderRadius: 10,
@ -28,61 +234,20 @@ ProgressDialog createProgressDialog(BuildContext context, String message) {
return dialog; return dialog;
} }
Future<dynamic> showErrorDialog( Future<ButtonResult?> showConfettiDialog<T>({
BuildContext context, required BuildContext context,
String title, required DialogBuilder dialogBuilder,
String content,
) {
final l10n = context.l10n;
final AlertDialog alert = AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
title: title.isEmpty
? const SizedBox.shrink()
: Text(
title,
style: Theme.of(context).textTheme.headline6,
),
content: Text(content),
actions: [
TextButton(
child: Text(
l10n.ok,
style: TextStyle(
color: Theme.of(context).colorScheme.onSurface,
),
),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
),
],
);
return showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
barrierColor: Colors.black12,
);
}
Future<dynamic> showGenericErrorDialog(BuildContext context) {
return showErrorDialog(context, "Something went wrong", "Please try again.");
}
Future<T> showConfettiDialog<T>({
@required BuildContext context,
WidgetBuilder builder,
bool barrierDismissible = true, bool barrierDismissible = true,
Color barrierColor, Color? barrierColor,
bool useSafeArea = true, bool useSafeArea = true,
bool useRootNavigator = true, bool useRootNavigator = true,
RouteSettings routeSettings, RouteSettings? routeSettings,
Alignment confettiAlignment = Alignment.center, Alignment confettiAlignment = Alignment.center,
}) { }) {
final widthOfScreen = MediaQuery.of(context).size.width;
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
final pageBuilder = Builder( final pageBuilder = Builder(
builder: builder, builder: dialogBuilder,
); );
final ConfettiController confettiController = final ConfettiController confettiController =
ConfettiController(duration: const Duration(seconds: 1)); ConfettiController(duration: const Duration(seconds: 1));
@ -90,22 +255,25 @@ Future<T> showConfettiDialog<T>({
return showDialog( return showDialog(
context: context, context: context,
builder: (BuildContext buildContext) { builder: (BuildContext buildContext) {
return Stack( return Padding(
children: [ padding: EdgeInsets.symmetric(horizontal: isMobileSmall ? 8 : 0),
pageBuilder, child: Stack(
Align( children: [
alignment: confettiAlignment, Align(alignment: Alignment.center, child: pageBuilder),
child: ConfettiWidget( Align(
confettiController: confettiController, alignment: confettiAlignment,
blastDirection: pi / 2, child: ConfettiWidget(
emissionFrequency: 0, confettiController: confettiController,
numberOfParticles: 100, blastDirection: pi / 2,
// a lot of particles at once emissionFrequency: 0,
gravity: 1, numberOfParticles: 100,
blastDirectionality: BlastDirectionality.explosive, // a lot of particles at once
gravity: 1,
blastDirectionality: BlastDirectionality.explosive,
),
), ),
), ],
], ),
); );
}, },
barrierDismissible: barrierDismissible, barrierDismissible: barrierDismissible,
@ -115,3 +283,56 @@ Future<T> showConfettiDialog<T>({
routeSettings: routeSettings, routeSettings: routeSettings,
); );
} }
//Can return ButtonResult? from ButtonWidget or Exception? from TextInputDialog
Future<dynamic> showTextInputDialog(
BuildContext context, {
required String title,
String? body,
required String submitButtonLabel,
IconData? icon,
String? label,
String? message,
String? hintText,
required FutureVoidCallbackParamStr onSubmit,
IconData? prefixIcon,
String? initialValue,
Alignment? alignMessage,
int? maxLength,
bool showOnlyLoadingState = false,
TextCapitalization textCapitalization = TextCapitalization.none,
bool alwaysShowSuccessState = false,
bool isPasswordInput = false,
}) {
return showDialog(
barrierColor: backdropFaintDark,
context: context,
builder: (context) {
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
final isKeyboardUp = bottomInset > 100;
return Center(
child: Padding(
padding: EdgeInsets.only(bottom: isKeyboardUp ? bottomInset : 0),
child: TextInputDialog(
title: title,
message: message,
label: label,
body: body,
icon: icon,
submitButtonLabel: submitButtonLabel,
onSubmit: onSubmit,
hintText: hintText,
prefixIcon: prefixIcon,
initialValue: initialValue,
alignMessage: alignMessage,
maxLength: maxLength,
showOnlyLoadingState: showOnlyLoadingState,
textCapitalization: textCapitalization,
alwaysShowSuccessState: alwaysShowSuccessState,
isPasswordInput: isPasswordInput,
),
),
);
},
);
}

View file

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
import 'package:archive/archive_io.dart'; import 'package:archive/archive_io.dart';
@ -8,12 +6,13 @@ import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/core/logging/super_logging.dart'; import 'package:ente_auth/core/logging/super_logging.dart';
import 'package:ente_auth/ente_theme_data.dart'; import 'package:ente_auth/ente_theme_data.dart';
import 'package:ente_auth/l10n/l10n.dart'; import 'package:ente_auth/l10n/l10n.dart';
import 'package:ente_auth/ui/common/dialogs.dart'; import 'package:ente_auth/ui/components/buttons/button_widget.dart';
import 'package:ente_auth/ui/components/dialog_widget.dart';
import 'package:ente_auth/ui/components/models/button_type.dart';
import 'package:ente_auth/ui/tools/debug/log_file_viewer.dart'; import 'package:ente_auth/ui/tools/debug/log_file_viewer.dart';
// import 'package:ente_auth/ui/tools/debug/log_file_viewer.dart'; // import 'package:ente_auth/ui/tools/debug/log_file_viewer.dart';
import 'package:ente_auth/utils/dialog_util.dart'; import 'package:ente_auth/utils/dialog_util.dart';
import 'package:ente_auth/utils/toast_util.dart'; import 'package:ente_auth/utils/toast_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_email_sender/flutter_email_sender.dart'; import 'package:flutter_email_sender/flutter_email_sender.dart';
@ -34,9 +33,9 @@ Future<void> sendLogs(
BuildContext context, BuildContext context,
String title, String title,
String toEmail, { String toEmail, {
Function postShare, Function? postShare,
String subject, String? subject,
String body, String? body,
}) async { }) async {
final l10n = context.l10n; final l10n = context.l10n;
final List<Widget> actions = [ final List<Widget> actions = [
@ -46,7 +45,7 @@ Future<void> sendLogs(
children: [ children: [
Icon( Icon(
Icons.feed_outlined, Icons.feed_outlined,
color: Theme.of(context).iconTheme.color.withOpacity(0.85), color: Theme.of(context).iconTheme.color?.withOpacity(0.85),
), ),
const Padding(padding: EdgeInsets.all(4)), const Padding(padding: EdgeInsets.all(4)),
Text( Text(
@ -64,7 +63,7 @@ Future<void> sendLogs(
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return LogFileViewer(SuperLogging.logFile); return LogFileViewer(SuperLogging.logFile!);
}, },
barrierColor: Colors.black87, barrierColor: Colors.black87,
barrierDismissible: false, barrierDismissible: false,
@ -128,14 +127,14 @@ Future<void> sendLogs(
Future<void> _sendLogs( Future<void> _sendLogs(
BuildContext context, BuildContext context,
String toEmail, String toEmail,
String subject, String? subject,
String body, String? body,
) async { ) async {
final String zipFilePath = await getZippedLogsFile(context); final String zipFilePath = await getZippedLogsFile(context);
final Email email = Email( final Email email = Email(
recipients: [toEmail], recipients: [toEmail],
subject: subject, subject: subject ?? '',
body: body, body: body ?? '',
attachmentPaths: [zipFilePath], attachmentPaths: [zipFilePath],
isHTML: false, isHTML: false,
); );
@ -169,29 +168,49 @@ Future<void> shareLogs(
String toEmail, String toEmail,
String zipFilePath, String zipFilePath,
) async { ) async {
final l10n = context.l10n; final result = await showDialogWidget(
final result = await showChoiceDialog( context: context,
context, title: context.l10n.emailYourLogs,
l10n.emailLogsTitle, body: context.l10n.pleaseSendTheLogsTo(toEmail),
l10n.emailLogsMessage(toEmail), buttons: [
firstAction: l10n.copyEmailAction, ButtonWidget(
secondAction: l10n.exportLogsAction, buttonType: ButtonType.neutral,
labelText: context.l10n.copyEmailAddress,
isInAlert: true,
buttonAction: ButtonAction.first,
onTap: () async {
await Clipboard.setData(ClipboardData(text: toEmail));
},
shouldShowSuccessConfirmation: true,
),
ButtonWidget(
buttonType: ButtonType.neutral,
labelText: context.l10n.exportLogs,
isInAlert: true,
buttonAction: ButtonAction.second,
),
ButtonWidget(
buttonType: ButtonType.secondary,
labelText: context.l10n.cancel,
isInAlert: true,
buttonAction: ButtonAction.cancel,
),
],
); );
if (result != null && result == DialogUserChoice.firstChoice) { if (result?.action != null && result!.action == ButtonAction.second) {
await Clipboard.setData(ClipboardData(text: toEmail)); final Size size = MediaQuery.of(context).size;
await Share.shareFiles(
[zipFilePath],
sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
);
} }
final Size size = MediaQuery.of(context).size;
await Share.shareFiles(
[zipFilePath],
sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
);
} }
Future<void> sendEmail( Future<void> sendEmail(
BuildContext context, { BuildContext context, {
@required String to, required String to,
String subject, String? subject,
String body, String? body,
}) async { }) async {
try { try {
final String clientDebugInfo = await _clientInfo(); final String clientDebugInfo = await _clientInfo();

View file

@ -790,6 +790,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.0" version: "0.3.0"
modal_bottom_sheet:
dependency: "direct main"
description:
name: modal_bottom_sheet
sha256: "3bba63c62d35c931bce7f8ae23a47f9a05836d8cb3c11122ada64e0b2f3d718f"
url: "https://pub.dev"
source: hosted
version: "3.0.0-pre"
move_to_background: move_to_background:
dependency: "direct main" dependency: "direct main"
description: description:

View file

@ -4,7 +4,7 @@ version: 1.0.36+36
publish_to: none publish_to: none
environment: environment:
sdk: ">=2.12.0 <3.0.0" sdk: '>=2.17.0 <3.0.0'
dependencies: dependencies:
adaptive_theme: ^3.1.0 # done adaptive_theme: ^3.1.0 # done
@ -48,6 +48,7 @@ dependencies:
json_annotation: ^4.5.0 json_annotation: ^4.5.0
local_auth: ^1.1.5 local_auth: ^1.1.5
logging: ^1.0.1 logging: ^1.0.1
modal_bottom_sheet: ^3.0.0-pre
move_to_background: ^1.0.2 move_to_background: ^1.0.2
open_filex: ^4.3.2 open_filex: ^4.3.2
otp: ^3.1.1 otp: ^3.1.1