Merge pull request #90 from ente-io/update_pages
Nullsafety + string extractions
This commit is contained in:
commit
11d6e672b1
81 changed files with 2794 additions and 1792 deletions
|
@ -1,2 +1,2 @@
|
|||
// @dart=2.9
|
||||
|
||||
export "view/app.dart";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -20,10 +20,10 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
|||
|
||||
class App extends StatefulWidget {
|
||||
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) {
|
||||
_AppState state = context.findAncestorStateOfType<_AppState>();
|
||||
_AppState state = context.findAncestorStateOfType<_AppState>()!;
|
||||
state.setLocale(newLocale);
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ class App extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _AppState extends State<App> {
|
||||
StreamSubscription<SignedOutEvent> _signedOutEvent;
|
||||
StreamSubscription<SignedInEvent> _signedInEvent;
|
||||
Locale locale;
|
||||
late StreamSubscription<SignedOutEvent> _signedOutEvent;
|
||||
late StreamSubscription<SignedInEvent> _signedInEvent;
|
||||
Locale? locale;
|
||||
setLocale(Locale newLocale) {
|
||||
setState(() {
|
||||
locale = newLocale;
|
||||
|
|
|
@ -452,7 +452,7 @@ class Configuration {
|
|||
return _preferences.setBool(keyShouldShowLockScreen, value);
|
||||
}
|
||||
|
||||
void setVolatilePassword(String volatilePassword) {
|
||||
void setVolatilePassword(String? volatilePassword) {
|
||||
_volatilePassword = volatilePassword;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
library super_logging;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -8,6 +6,7 @@ import 'dart:core';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:ente_auth/core/logging/tunneled_transport.dart';
|
||||
import 'package:ente_auth/models/typedefs.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
@ -20,8 +19,6 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
typedef FutureOrVoidCallback = FutureOr<void> Function();
|
||||
|
||||
extension SuperString on String {
|
||||
Iterable<String> chunked(int chunkSize) sync* {
|
||||
var start = 0;
|
||||
|
@ -40,7 +37,7 @@ extension SuperString on String {
|
|||
}
|
||||
|
||||
extension SuperLogRecord on LogRecord {
|
||||
String toPrettyString([String extraLines]) {
|
||||
String toPrettyString([String? extraLines]) {
|
||||
final header = "[$loggerName] [$level] [$time]";
|
||||
|
||||
var msg = "$header $message";
|
||||
|
@ -78,9 +75,9 @@ class LogConfig {
|
|||
/// ```
|
||||
///
|
||||
/// If this is [null], Sentry logger is completely disabled (default).
|
||||
String sentryDsn;
|
||||
String? sentryDsn;
|
||||
|
||||
String tunnel;
|
||||
String? tunnel;
|
||||
|
||||
/// A built-in retry mechanism for sending errors to sentry.
|
||||
///
|
||||
|
@ -97,7 +94,7 @@ class LogConfig {
|
|||
/// A non-empty string will be treated as an explicit path to a directory.
|
||||
///
|
||||
/// The chosen directory can be accessed using [SuperLogging.logFile.parent].
|
||||
String logDirPath;
|
||||
String? logDirPath;
|
||||
|
||||
/// The maximum number of log files inside [logDirPath].
|
||||
///
|
||||
|
@ -115,12 +112,12 @@ class LogConfig {
|
|||
/// any uncaught errors during its execution will be reported.
|
||||
///
|
||||
/// Works by using [FlutterError.onError] and [runZoned].
|
||||
FutureOrVoidCallback body;
|
||||
FutureOrVoidCallback? body;
|
||||
|
||||
/// The date format for storing log files.
|
||||
///
|
||||
/// `DateFormat('y-M-d')` by default.
|
||||
DateFormat dateFmt;
|
||||
DateFormat? dateFmt;
|
||||
|
||||
String prefix;
|
||||
|
||||
|
@ -144,77 +141,78 @@ class SuperLogging {
|
|||
static final $ = Logger('ente_logging');
|
||||
|
||||
/// The current super logging configuration
|
||||
static LogConfig config;
|
||||
static late LogConfig config;
|
||||
|
||||
static SharedPreferences _preferences;
|
||||
static late SharedPreferences _preferences;
|
||||
|
||||
static const keyShouldReportErrors = "should_report_errors";
|
||||
|
||||
static const keyAnonymousUserID = "anonymous_user_id";
|
||||
|
||||
static Future<void> main([LogConfig config]) async {
|
||||
config ??= LogConfig();
|
||||
|
||||
SuperLogging.config = config;
|
||||
static Future<void> main([LogConfig? appConfig]) async {
|
||||
appConfig ??= LogConfig();
|
||||
SuperLogging.config = appConfig;
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
_preferences = await SharedPreferences.getInstance();
|
||||
|
||||
appVersion ??= await getAppVersion();
|
||||
|
||||
final loggingEnabled = config.enableInDebugMode || kReleaseMode;
|
||||
final enable = appConfig.enableInDebugMode || kReleaseMode;
|
||||
sentryIsEnabled =
|
||||
loggingEnabled && config.sentryDsn != null && shouldReportErrors();
|
||||
fileIsEnabled = loggingEnabled && config.logDirPath != null;
|
||||
enable && appConfig.sentryDsn != null && shouldReportErrors();
|
||||
fileIsEnabled = enable && appConfig.logDirPath != null;
|
||||
|
||||
if (fileIsEnabled) {
|
||||
await setupLogDir();
|
||||
}
|
||||
if (sentryIsEnabled) {
|
||||
setupSentry();
|
||||
}
|
||||
|
||||
Logger.root.level = Level.ALL;
|
||||
Logger.root.onRecord.listen(onLogRecord);
|
||||
|
||||
if (sentryIsEnabled) {
|
||||
setupSentry();
|
||||
} else {
|
||||
$.info("Sentry is disabled");
|
||||
}
|
||||
|
||||
if (!loggingEnabled) {
|
||||
if (!enable) {
|
||||
$.info("detected debug mode; sentry & file logging disabled.");
|
||||
}
|
||||
if (fileIsEnabled) {
|
||||
$.info("log file for today: $logFile with prefix ${config.prefix}");
|
||||
$.info("log file for today: $logFile with prefix ${appConfig.prefix}");
|
||||
}
|
||||
if (sentryIsEnabled) {
|
||||
$.info("sentry uploader started");
|
||||
}
|
||||
|
||||
if (config.body == null) return;
|
||||
if (appConfig.body == null) return;
|
||||
|
||||
if (loggingEnabled && sentryIsEnabled) {
|
||||
if (enable && sentryIsEnabled) {
|
||||
await SentryFlutter.init(
|
||||
(options) {
|
||||
options.dsn = config.sentryDsn;
|
||||
options.dsn = appConfig!.sentryDsn;
|
||||
options.httpClient = http.Client();
|
||||
if (config.tunnel != null) {
|
||||
if (appConfig.tunnel != null) {
|
||||
options.transport =
|
||||
TunneledTransport(Uri.parse(config.tunnel), options);
|
||||
TunneledTransport(Uri.parse(appConfig.tunnel!), options);
|
||||
}
|
||||
},
|
||||
appRunner: () => config.body(),
|
||||
appRunner: () => appConfig!.body!(),
|
||||
);
|
||||
} else {
|
||||
await config.body();
|
||||
await appConfig.body!();
|
||||
}
|
||||
}
|
||||
|
||||
static void setUserID(String userID) async {
|
||||
if (config?.sentryDsn != null) {
|
||||
if (config.sentryDsn != null) {
|
||||
Sentry.configureScope((scope) => scope.user = SentryUser(id: userID));
|
||||
$.info("setting sentry user ID to: $userID");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _sendErrorToSentry(Object error, StackTrace stack) async {
|
||||
static Future<void> _sendErrorToSentry(
|
||||
Object error,
|
||||
StackTrace? stack,
|
||||
) async {
|
||||
try {
|
||||
await Sentry.captureException(
|
||||
error,
|
||||
|
@ -230,14 +228,14 @@ class SuperLogging {
|
|||
|
||||
static Future onLogRecord(LogRecord rec) async {
|
||||
// log misc info if it changed
|
||||
String extraLines = "app version: '$appVersion'\n";
|
||||
String? extraLines = "app version: '$appVersion'\n";
|
||||
if (extraLines != _lastExtraLines) {
|
||||
_lastExtraLines = extraLines;
|
||||
} else {
|
||||
extraLines = null;
|
||||
}
|
||||
|
||||
final str = config.prefix + " " + rec.toPrettyString(extraLines);
|
||||
final str = (config.prefix) + " " + rec.toPrettyString(extraLines);
|
||||
|
||||
// write to stdout
|
||||
printLog(str);
|
||||
|
@ -251,16 +249,8 @@ class SuperLogging {
|
|||
}
|
||||
|
||||
// add error to sentry queue
|
||||
if (sentryIsEnabled) {
|
||||
if (rec.error != null) {
|
||||
_sendErrorToSentry(rec.error, null);
|
||||
} else if (rec.level == Level.SEVERE || rec.level == Level.SHOUT) {
|
||||
if (rec.error != null) {
|
||||
_sendErrorToSentry(rec.error, null);
|
||||
} else {
|
||||
_sendErrorToSentry(rec.message, null);
|
||||
}
|
||||
}
|
||||
if (sentryIsEnabled && rec.error != null) {
|
||||
_sendErrorToSentry(rec.error!, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,12 +258,12 @@ class SuperLogging {
|
|||
static bool isFlushing = false;
|
||||
|
||||
static void flushQueue() async {
|
||||
if (isFlushing) {
|
||||
if (isFlushing || logFile == null) {
|
||||
return;
|
||||
}
|
||||
isFlushing = true;
|
||||
final entry = fileQueueEntries.removeFirst();
|
||||
await logFile.writeAsString(entry, mode: FileMode.append, flush: true);
|
||||
await logFile!.writeAsString(entry, mode: FileMode.append, flush: true);
|
||||
isFlushing = false;
|
||||
if (fileQueueEntries.isNotEmpty) {
|
||||
flushQueue();
|
||||
|
@ -292,7 +282,7 @@ class SuperLogging {
|
|||
static final sentryQueueControl = StreamController<Error>();
|
||||
|
||||
/// Whether sentry logging is currently enabled or not.
|
||||
static bool sentryIsEnabled;
|
||||
static bool sentryIsEnabled = false;
|
||||
|
||||
static Future<void> setupSentry() async {
|
||||
$.info("Setting up sentry");
|
||||
|
@ -318,7 +308,7 @@ class SuperLogging {
|
|||
|
||||
static bool shouldReportErrors() {
|
||||
if (_preferences.containsKey(keyShouldReportErrors)) {
|
||||
return _preferences.getBool(keyShouldReportErrors);
|
||||
return _preferences.getBool(keyShouldReportErrors)!;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -333,22 +323,22 @@ class SuperLogging {
|
|||
//ignore: prefer_const_constructors
|
||||
await _preferences.setString(keyAnonymousUserID, Uuid().v4());
|
||||
}
|
||||
return _preferences.getString(keyAnonymousUserID);
|
||||
return _preferences.getString(keyAnonymousUserID)!;
|
||||
}
|
||||
|
||||
/// The log file currently in use.
|
||||
static File logFile;
|
||||
static File? logFile;
|
||||
|
||||
/// Whether file logging is currently enabled or not.
|
||||
static bool fileIsEnabled;
|
||||
static bool fileIsEnabled = false;
|
||||
|
||||
static Future<void> setupLogDir() async {
|
||||
var dirPath = config.logDirPath;
|
||||
|
||||
// choose [logDir]
|
||||
if (dirPath.isEmpty) {
|
||||
if (dirPath == null || dirPath.isEmpty) {
|
||||
final root = await getExternalStorageDirectory();
|
||||
dirPath = '${root.path}/logs';
|
||||
dirPath = '${root!.path}/logs';
|
||||
}
|
||||
|
||||
// create [logDir]
|
||||
|
@ -361,16 +351,19 @@ class SuperLogging {
|
|||
// collect all log files with valid names
|
||||
await for (final file in dir.list()) {
|
||||
try {
|
||||
final date = config.dateFmt.parse(basename(file.path));
|
||||
final date = config.dateFmt!.parse(basename(file.path));
|
||||
dates[file as File] = date;
|
||||
files.add(file);
|
||||
} on FormatException {}
|
||||
}
|
||||
final nowTime = DateTime.now();
|
||||
|
||||
// delete old log files, if [maxLogFiles] is exceeded.
|
||||
if (files.length > config.maxLogFiles) {
|
||||
// sort files based on ascending order of date (older first)
|
||||
files.sort((a, b) => dates[a].compareTo(dates[b]));
|
||||
files.sort(
|
||||
(a, b) => (dates[a] ?? nowTime).compareTo((dates[b] ?? nowTime)),
|
||||
);
|
||||
|
||||
final extra = files.length - config.maxLogFiles;
|
||||
final toDelete = files.sublist(0, extra);
|
||||
|
@ -385,13 +378,13 @@ class SuperLogging {
|
|||
}
|
||||
}
|
||||
|
||||
logFile = File("$dirPath/${config.dateFmt.format(DateTime.now())}.txt");
|
||||
logFile = File("$dirPath/${config.dateFmt!.format(DateTime.now())}.txt");
|
||||
}
|
||||
|
||||
/// Current app version, obtained from package_info plugin.
|
||||
///
|
||||
/// See: [getAppVersion]
|
||||
static String appVersion;
|
||||
static String? appVersion;
|
||||
|
||||
static Future<String> getAppVersion() async {
|
||||
final pkgInfo = await PackageInfo.fromPlatform();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
|
@ -10,9 +8,9 @@ class TunneledTransport implements Transport {
|
|||
final Uri _tunnel;
|
||||
final SentryOptions _options;
|
||||
|
||||
final Dsn _dsn;
|
||||
final Dsn? _dsn;
|
||||
|
||||
_CredentialBuilder _credentialBuilder;
|
||||
_CredentialBuilder? _credentialBuilder;
|
||||
|
||||
final Map<String, String> _headers;
|
||||
|
||||
|
@ -21,7 +19,7 @@ class TunneledTransport implements Transport {
|
|||
}
|
||||
|
||||
TunneledTransport._(this._tunnel, this._options)
|
||||
: _dsn = Dsn.parse(_options.dsn),
|
||||
: _dsn = _options.dsn != null ? Dsn.parse(_options.dsn!) : null,
|
||||
_headers = _buildHeaders(
|
||||
_options.platformChecker.isWeb,
|
||||
_options.sdk.identifier,
|
||||
|
@ -34,7 +32,7 @@ class TunneledTransport implements Transport {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<SentryId> send(SentryEnvelope envelope) async {
|
||||
Future<SentryId?> send(SentryEnvelope envelope) async {
|
||||
final streamedRequest = await _createStreamedRequest(envelope);
|
||||
final response = await _options.httpClient
|
||||
.send(streamedRequest)
|
||||
|
@ -47,7 +45,7 @@ class TunneledTransport implements Transport {
|
|||
_options.logger(
|
||||
SentryLevel.error,
|
||||
'API returned an error, statusCode = ${response.statusCode}, '
|
||||
'body = ${response.body}',
|
||||
'body = ${response.body}',
|
||||
);
|
||||
}
|
||||
return const SentryId.empty();
|
||||
|
@ -66,15 +64,15 @@ class TunneledTransport implements Transport {
|
|||
}
|
||||
|
||||
Future<StreamedRequest> _createStreamedRequest(
|
||||
SentryEnvelope envelope,
|
||||
) async {
|
||||
SentryEnvelope envelope,
|
||||
) async {
|
||||
final streamedRequest = StreamedRequest('POST', _tunnel);
|
||||
envelope
|
||||
.envelopeStream(_options)
|
||||
.listen(streamedRequest.sink.add)
|
||||
.onDone(streamedRequest.sink.close);
|
||||
|
||||
streamedRequest.headers.addAll(_credentialBuilder.configure(_headers));
|
||||
streamedRequest.headers.addAll(_credentialBuilder!.configure(_headers));
|
||||
|
||||
return streamedRequest;
|
||||
}
|
||||
|
@ -92,13 +90,13 @@ class _CredentialBuilder {
|
|||
_clock = clock;
|
||||
|
||||
factory _CredentialBuilder(
|
||||
Dsn dsn,
|
||||
String sdkIdentifier,
|
||||
ClockProvider clock,
|
||||
) {
|
||||
Dsn? dsn,
|
||||
String sdkIdentifier,
|
||||
ClockProvider clock,
|
||||
) {
|
||||
final authHeader = _buildAuthHeader(
|
||||
publicKey: dsn.publicKey,
|
||||
secretKey: dsn.secretKey,
|
||||
publicKey: dsn?.publicKey,
|
||||
secretKey: dsn?.secretKey,
|
||||
sdkIdentifier: sdkIdentifier,
|
||||
);
|
||||
|
||||
|
@ -106,9 +104,9 @@ class _CredentialBuilder {
|
|||
}
|
||||
|
||||
static String _buildAuthHeader({
|
||||
String publicKey,
|
||||
String secretKey,
|
||||
String sdkIdentifier,
|
||||
String? publicKey,
|
||||
String? secretKey,
|
||||
String? sdkIdentifier,
|
||||
}) {
|
||||
var header = 'Sentry sentry_version=7, sentry_client=$sdkIdentifier, '
|
||||
'sentry_key=$publicKey';
|
||||
|
|
|
@ -358,6 +358,9 @@ extension CustomColorScheme on ColorScheme {
|
|||
|
||||
EnteTheme get enteTheme =>
|
||||
brightness == Brightness.light ? lightTheme : darkTheme;
|
||||
|
||||
EnteTheme get inverseEnteTheme =>
|
||||
brightness == Brightness.light ? darkTheme : lightTheme;
|
||||
}
|
||||
|
||||
OutlinedButtonThemeData buildOutlinedButtonThemeData({
|
||||
|
|
|
@ -46,13 +46,13 @@
|
|||
},
|
||||
"contactSupport": "Support kontaktieren",
|
||||
"verifyPassword": "Passwort überprüfen",
|
||||
"pleaseWaitTitle": "Bitte warten...",
|
||||
"pleaseWait": "Bitte warten...",
|
||||
"generatingEncryptionKeysTitle": "Generierung von Verschlüsselungsschlüsseln...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Wiederherstellungsschlüssel verwenden",
|
||||
"incorrectPassword": "Falsches Passwort",
|
||||
"welcomeBackTitle": "Willkommen zurück!",
|
||||
"useRecoveryKey": "Wiederherstellungsschlüssel verwenden",
|
||||
"incorrectPasswordTitle": "Falsches Passwort",
|
||||
"welcomeBack": "Willkommen zurück!",
|
||||
"madeWithLoveAtPrefix": "gemacht mit ❤️ bei ",
|
||||
"changeEmail": "E-Mail ändern",
|
||||
"cancel": "Abbrechen",
|
||||
|
@ -62,7 +62,7 @@
|
|||
"support": "Unterstützung",
|
||||
"settings": "Einstellungen",
|
||||
"copied": "Kopiert",
|
||||
"tryAgainMessage": "Bitte versuchen Sie es erneut",
|
||||
"pleaseTryAgain": "Bitte versuchen Sie es erneut",
|
||||
"existingUser": "Bestehender Benutzer",
|
||||
"newUser": "Neu bei ente",
|
||||
"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.",
|
||||
"sendEmail": "E-Mail senden",
|
||||
"createNewAccount": "Neues Konto erstellen",
|
||||
"passwordStrengthWeak": "Schwach",
|
||||
"passwordStrengthStrong": "Stark",
|
||||
"passwordStrengthModerate": "Mittel",
|
||||
"weakStrength": "Schwach",
|
||||
"strongStrength": "Stark",
|
||||
"moderateStrength": "Mittel",
|
||||
"confirmPassword": "Bestätigen Sie das Passwort",
|
||||
"close": "Schließen",
|
||||
"oopsSomethingWentWrong": "Ups, da ist etwas schief gelaufen.",
|
||||
|
|
|
@ -55,13 +55,13 @@
|
|||
},
|
||||
"contactSupport": "Contact support",
|
||||
"verifyPassword": "Verify password",
|
||||
"pleaseWaitTitle": "Please wait...",
|
||||
"pleaseWait": "Please wait...",
|
||||
"generatingEncryptionKeysTitle": "Generating encryption keys...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Use recovery key",
|
||||
"incorrectPassword": "Incorrect password",
|
||||
"welcomeBackTitle": "Welcome back!",
|
||||
"useRecoveryKey": "Use recovery key",
|
||||
"incorrectPasswordTitle": "Incorrect password",
|
||||
"welcomeBack": "Welcome back!",
|
||||
"madeWithLoveAtPrefix": "made with ❤️ at ",
|
||||
"supportDevs" : "Subscribe to <bold-green>ente</bold-green> to support this project.",
|
||||
"supportDiscount" : "Use coupon code \"AUTH\" to get 10% off first year",
|
||||
|
@ -84,7 +84,7 @@
|
|||
"support": "Support",
|
||||
"settings": "Settings",
|
||||
"copied": "Copied",
|
||||
"tryAgainMessage": "Please try again",
|
||||
"pleaseTryAgain": "Please try again",
|
||||
"existingUser": "Existing User",
|
||||
"newUser" : "New to ente",
|
||||
"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.",
|
||||
"sendEmail": "Send email",
|
||||
"createNewAccount": "Create new account",
|
||||
"passwordStrengthWeak": "Weak",
|
||||
"passwordStrengthStrong": "Strong",
|
||||
"passwordStrengthModerate": "Moderate",
|
||||
"weakStrength": "Weak",
|
||||
"strongStrength": "Strong",
|
||||
"moderateStrength": "Moderate",
|
||||
"confirmPassword": "Confirm password",
|
||||
"close": "Close",
|
||||
"oopsSomethingWentWrong": "Oops, Something went wrong.",
|
||||
|
@ -151,5 +151,49 @@
|
|||
"recoveryKeyOnForgotPassword": "If you forget your password, the only way you can recover your data is with this key.",
|
||||
"recoveryKeySaveDescription": "We don't store this key, please save this 24 word key in a safe place.",
|
||||
"doThisLater": "Do this later",
|
||||
"saveKey": "Save key"
|
||||
"saveKey": "Save key",
|
||||
"createAccount": "Create account",
|
||||
"passwordStrength": "Password strength: {passwordStrengthValue}",
|
||||
"@passwordStrength": {
|
||||
"description": "Text to indicate the password strength",
|
||||
"placeholders": {
|
||||
"passwordStrengthValue": {
|
||||
"description": "The strength of the password as a string",
|
||||
"type": "String",
|
||||
"example": "Weak or Moderate or Strong"
|
||||
}
|
||||
},
|
||||
"message": "Password Strength: {passwordStrengthText}"
|
||||
},
|
||||
"password": "Password",
|
||||
"signUpTerms" : "I agree to the <u-terms>terms of service</u-terms> and <u-policy>privacy policy</u-policy>",
|
||||
"privacyPolicyTitle": "Privacy Policy",
|
||||
"termsOfServicesTitle": "Terms",
|
||||
"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>.",
|
||||
"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",
|
||||
"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."
|
||||
}
|
||||
|
|
|
@ -52,13 +52,13 @@
|
|||
},
|
||||
"contactSupport": "Ota yhteyttä käyttötukeen",
|
||||
"verifyPassword": "Vahvista salasana",
|
||||
"pleaseWaitTitle": "Odota hetki...",
|
||||
"pleaseWait": "Odota hetki...",
|
||||
"generatingEncryptionKeysTitle": "Luodaan salausavaimia...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Käytä palautusavainta",
|
||||
"incorrectPassword": "Salasana on väärin",
|
||||
"welcomeBackTitle": "Tervetuloa takaisin!",
|
||||
"useRecoveryKey": "Käytä palautusavainta",
|
||||
"incorrectPasswordTitle": "Salasana on väärin",
|
||||
"welcomeBack": "Tervetuloa takaisin!",
|
||||
"madeWithLoveAtPrefix": "tehty ❤️:lla täällä ",
|
||||
"supportDevs": "Tilaa <bold-green>ente</bold-green> tukeaksesi tätä hanketta.",
|
||||
"supportDiscount": "Käytä kuponkikoodia \"AUTH\" saadaksesi 10% alennuksen ensimmäisestä vuodesta",
|
||||
|
@ -71,7 +71,7 @@
|
|||
"support": "Tuki",
|
||||
"settings": "Asetukset",
|
||||
"copied": "Jäljennetty",
|
||||
"tryAgainMessage": "Yritä uudestaan",
|
||||
"pleaseTryAgain": "Yritä uudestaan",
|
||||
"existingUser": "Jo valmiiksi olemassaoleva käyttäjä",
|
||||
"newUser": "Uusi Ente-käyttäjä",
|
||||
"delete": "Poista",
|
||||
|
@ -113,9 +113,9 @@
|
|||
"confirmAccountDeleteMessage": "Lataamasi tiedot kaikkien sovellusten kesken (molemmat, sekä kuvat ja todenteet) ajastetaan poistettavaksi ja tilisi poistetaan pysyvästi.",
|
||||
"sendEmail": "Lähetä sähköpostia",
|
||||
"createNewAccount": "Luo uusi tili",
|
||||
"passwordStrengthWeak": "Heikko salasana",
|
||||
"passwordStrengthStrong": "Vahva salasana",
|
||||
"passwordStrengthModerate": "Kohtalainen salasana",
|
||||
"weakStrength": "Heikko salasana",
|
||||
"strongStrength": "Vahva salasana",
|
||||
"moderateStrength": "Kohtalainen salasana",
|
||||
"confirmPassword": "Vahvista salasana",
|
||||
"close": "Sulje",
|
||||
"oopsSomethingWentWrong": "Hupsista! Jotakin meni nyt pieleen."
|
||||
|
|
|
@ -47,13 +47,13 @@
|
|||
},
|
||||
"contactSupport": "Contacter le support",
|
||||
"verifyPassword": "Vérifier le mot de passe",
|
||||
"pleaseWaitTitle": "Veuillez patienter...",
|
||||
"pleaseWait": "Veuillez patienter...",
|
||||
"generatingEncryptionKeysTitle": "Génération des clés de chiffrement...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Utiliser la clé de récupération",
|
||||
"incorrectPassword": "Mot de passe incorrect",
|
||||
"welcomeBackTitle": "Bon retour parmi nous !",
|
||||
"useRecoveryKey": "Utiliser la clé de récupération",
|
||||
"incorrectPasswordTitle": "Mot de passe incorrect",
|
||||
"welcomeBack": "Bon retour parmi nous !",
|
||||
"madeWithLoveAtPrefix": "fait avec ❤️ à ",
|
||||
"supportDiscount": "Utilisez le code coupon \"AUTH\" pour obtenir 10% de réduction sur la première année",
|
||||
"changeEmail": "Modifier l'e-mail",
|
||||
|
@ -65,7 +65,7 @@
|
|||
"support": "Support",
|
||||
"settings": "Paramètres",
|
||||
"copied": "Copié",
|
||||
"tryAgainMessage": "Veuillez réessayer",
|
||||
"pleaseTryAgain": "Veuillez réessayer",
|
||||
"existingUser": "Utilisateur existant",
|
||||
"newUser": "Nouveau sur ente",
|
||||
"delete": "Supprimer",
|
||||
|
@ -107,9 +107,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é.",
|
||||
"sendEmail": "Envoyer un e-mail",
|
||||
"createNewAccount": "Créer un nouveau compte",
|
||||
"passwordStrengthWeak": "Faible",
|
||||
"passwordStrengthStrong": "Fort",
|
||||
"passwordStrengthModerate": "Modéré",
|
||||
"weakStrength": "Faible",
|
||||
"strongStrength": "Fort",
|
||||
"moderateStrength": "Modéré",
|
||||
"confirmPassword": "Confirmer le mot de passe",
|
||||
"close": "Fermer",
|
||||
"oopsSomethingWentWrong": "Oops ! Une erreur s'est produite.",
|
||||
|
|
|
@ -46,13 +46,13 @@
|
|||
},
|
||||
"contactSupport": "Contatta il supporto",
|
||||
"verifyPassword": "Verifica la password",
|
||||
"pleaseWaitTitle": "Attendere prego...",
|
||||
"pleaseWait": "Attendere prego...",
|
||||
"generatingEncryptionKeysTitle": "Generazione delle chiavi di crittografia...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Utilizza un codice di recupero",
|
||||
"incorrectPassword": "Password sbagliata",
|
||||
"welcomeBackTitle": "Bentornato!",
|
||||
"useRecoveryKey": "Utilizza un codice di recupero",
|
||||
"incorrectPasswordTitle": "Password sbagliata",
|
||||
"welcomeBack": "Bentornato!",
|
||||
"madeWithLoveAtPrefix": "realizzato con ❤️ a ",
|
||||
"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",
|
||||
|
@ -65,7 +65,7 @@
|
|||
"support": "Supporto",
|
||||
"settings": "Impostazioni",
|
||||
"copied": "Copiato",
|
||||
"tryAgainMessage": "Per favore riprova",
|
||||
"pleaseTryAgain": "Per favore riprova",
|
||||
"existingUser": "Accedi",
|
||||
"newUser": "Nuovo utente",
|
||||
"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.",
|
||||
"sendEmail": "Invia email",
|
||||
"createNewAccount": "Crea un nuovo account",
|
||||
"passwordStrengthWeak": "Debole",
|
||||
"passwordStrengthStrong": "Forte",
|
||||
"passwordStrengthModerate": "Mediocre",
|
||||
"weakStrength": "Debole",
|
||||
"strongStrength": "Forte",
|
||||
"moderateStrength": "Mediocre",
|
||||
"confirmPassword": "Conferma la password",
|
||||
"close": "Chiudi",
|
||||
"oopsSomethingWentWrong": "Oops, qualcosa è andato storto.",
|
||||
|
|
|
@ -46,13 +46,13 @@
|
|||
},
|
||||
"contactSupport": "Klantenservice",
|
||||
"verifyPassword": "Bevestig wachtwoord",
|
||||
"pleaseWaitTitle": "Een ogenblik geduld...",
|
||||
"pleaseWait": "Een ogenblik geduld...",
|
||||
"generatingEncryptionKeysTitle": "Encryptiesleutels genereren...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Herstelcode gebruiken",
|
||||
"incorrectPassword": "Onjuist wachtwoord",
|
||||
"welcomeBackTitle": "Welkom terug!",
|
||||
"useRecoveryKey": "Herstelcode gebruiken",
|
||||
"incorrectPasswordTitle": "Onjuist wachtwoord",
|
||||
"welcomeBack": "Welkom terug!",
|
||||
"madeWithLoveAtPrefix": "gemaakt met ❤️ door ",
|
||||
"supportDiscount": "Gebruik couponcode \"AUTH\" om 10% korting te krijgen op het eerste jaar",
|
||||
"changeEmail": "e-mailadres wijzigen",
|
||||
|
@ -64,7 +64,7 @@
|
|||
"support": "Ondersteuning",
|
||||
"settings": "Instellingen",
|
||||
"copied": "Gekopieerd",
|
||||
"tryAgainMessage": "Probeer het nog eens",
|
||||
"pleaseTryAgain": "Probeer het nog eens",
|
||||
"existingUser": "Bestaande gebruiker",
|
||||
"newUser": "Nieuw bij ente",
|
||||
"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.",
|
||||
"sendEmail": "E-mail versturen",
|
||||
"createNewAccount": "Nieuw account aanmaken",
|
||||
"passwordStrengthWeak": "Zwak",
|
||||
"passwordStrengthStrong": "Sterk",
|
||||
"passwordStrengthModerate": "Matig",
|
||||
"weakStrength": "Zwak",
|
||||
"strongStrength": "Sterk",
|
||||
"moderateStrength": "Matig",
|
||||
"confirmPassword": "Wachtwoord bevestigen",
|
||||
"close": "Sluiten",
|
||||
"oopsSomethingWentWrong": "Oeps, er is iets fout gegaan."
|
||||
|
|
|
@ -46,13 +46,13 @@
|
|||
},
|
||||
"contactSupport": "Связаться с поддержкой",
|
||||
"verifyPassword": "Подтверждение пароля",
|
||||
"pleaseWaitTitle": "Пожалуйста, подождите...",
|
||||
"pleaseWait": "Пожалуйста, подождите...",
|
||||
"generatingEncryptionKeysTitle": "Генерируем ключи шифрования...",
|
||||
"recreatePassword": "Воссоздать пароль заново",
|
||||
"recreatePasswordMessage": "Текущее устройство недостаточно мощное для проверки пароля, поэтому нам нужно регенерировать его один раз таким образом, чтобы работать со всеми устройствами. \n\nПожалуйста, войдите, используя ваш ключ восстановления и сгенерируйте ваш пароль (вы можете использовать тот же самый, если пожелаете).",
|
||||
"useRecoveryKeyAction": "Использовать ключ восстановления",
|
||||
"incorrectPassword": "Неправильный пароль",
|
||||
"welcomeBackTitle": "С возвращением!",
|
||||
"useRecoveryKey": "Использовать ключ восстановления",
|
||||
"incorrectPasswordTitle": "Неправильный пароль",
|
||||
"welcomeBack": "С возвращением!",
|
||||
"madeWithLoveAtPrefix": "сделана с ❤️ в ",
|
||||
"supportDevs": "Подпишитесь на <bold-green>ente</bold-green> для поддержки этого проекта.",
|
||||
"supportDiscount": "Используйте код скидки \"AUTH\", чтобы получить скидку 10% в первый год",
|
||||
|
@ -64,7 +64,7 @@
|
|||
"support": "Поддержка",
|
||||
"settings": "Настройки",
|
||||
"copied": "Скопировано",
|
||||
"tryAgainMessage": "Пожалуйста, попробуйте ещё раз",
|
||||
"pleaseTryAgain": "Пожалуйста, попробуйте ещё раз",
|
||||
"existingUser": "Существующий пользователь",
|
||||
"newUser": "Новый аккаунт",
|
||||
"delete": "Удалить",
|
||||
|
@ -106,9 +106,9 @@
|
|||
"confirmAccountDeleteMessage": "Ваши загруженные данные во всех приложениях (как фотографии, так и средство аутентификации) будут запланированы к удалению, а ваш аккаунт будет удален безвозвратно.",
|
||||
"sendEmail": "Отправить электронное письмо",
|
||||
"createNewAccount": "Создать новый аккаунт",
|
||||
"passwordStrengthWeak": "Слабый",
|
||||
"passwordStrengthStrong": "Крепкий",
|
||||
"passwordStrengthModerate": "Средний",
|
||||
"weakStrength": "Слабый",
|
||||
"strongStrength": "Крепкий",
|
||||
"moderateStrength": "Средний",
|
||||
"confirmPassword": "Подтвердить пароль",
|
||||
"close": "Закрыть",
|
||||
"oopsSomethingWentWrong": "Ой, что-то пошло не так."
|
||||
|
|
|
@ -52,13 +52,13 @@
|
|||
},
|
||||
"contactSupport": "Destek ekibiyle iletişime geçin",
|
||||
"verifyPassword": "Şifreyi doğrulayın",
|
||||
"pleaseWaitTitle": "Lütfen bekleyin...",
|
||||
"pleaseWait": "Lütfen bekleyin...",
|
||||
"generatingEncryptionKeysTitle": "Şifreleme anahtarları üretiliyor...",
|
||||
"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).",
|
||||
"useRecoveryKeyAction": "Kurtarma anahtarını kullan",
|
||||
"incorrectPassword": "Yanlış şifre",
|
||||
"welcomeBackTitle": "Tekrar hoş geldiniz!",
|
||||
"useRecoveryKey": "Kurtarma anahtarını kullan",
|
||||
"incorrectPasswordTitle": "Yanlış şifre",
|
||||
"welcomeBack": "Tekrar hoş geldiniz!",
|
||||
"madeWithLoveAtPrefix": "❤️ ile yapılmıştır ",
|
||||
"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",
|
||||
|
@ -71,7 +71,7 @@
|
|||
"support": "Destek",
|
||||
"settings": "Ayarlar",
|
||||
"copied": "Kopyalandı",
|
||||
"tryAgainMessage": "Lütfen tekrar deneyin",
|
||||
"pleaseTryAgain": "Lütfen tekrar deneyin",
|
||||
"existingUser": "Mevcut kullanıcı",
|
||||
"newUser": "Yeni ente kullanıcısı",
|
||||
"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.",
|
||||
"sendEmail": "E-posta gönder",
|
||||
"createNewAccount": "Yeni hesap oluşturun",
|
||||
"passwordStrengthWeak": "Zayıf",
|
||||
"passwordStrengthStrong": "Güçlü",
|
||||
"passwordStrengthModerate": "Orta",
|
||||
"weakStrength": "Zayıf",
|
||||
"strongStrength": "Güçlü",
|
||||
"moderateStrength": "Orta",
|
||||
"confirmPassword": "Şifreyi onayla",
|
||||
"close": "Kapat",
|
||||
"oopsSomethingWentWrong": "Hay aksi, bir sorun oluştu."
|
||||
|
|
|
@ -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/core/configuration.dart';
|
||||
import 'package:ente_auth/core/constants.dart';
|
||||
|
@ -25,10 +25,11 @@ final _logger = Logger("main");
|
|||
|
||||
void main() async {
|
||||
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 {
|
||||
_logger.info("Starting app in foreground");
|
||||
await _init(false, via: 'mainMethod');
|
||||
|
@ -42,11 +43,19 @@ Future<void> _runInForeground() async {
|
|||
locale: locale,
|
||||
lightTheme: lightThemeData,
|
||||
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 {
|
||||
await SuperLogging.main(
|
||||
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();
|
||||
await PreferenceService.instance.init();
|
||||
await CodeStore.instance.init();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
@ -32,9 +30,9 @@ class BillingService {
|
|||
|
||||
bool _isOnSubscriptionPage = false;
|
||||
|
||||
Subscription _cachedSubscription;
|
||||
Subscription? _cachedSubscription;
|
||||
|
||||
Future<BillingPlans> _future;
|
||||
Future<BillingPlans>? _future;
|
||||
|
||||
Future<void> init() async {}
|
||||
|
||||
|
@ -49,7 +47,7 @@ class BillingService {
|
|||
.then((response) {
|
||||
return BillingPlans.fromMap(response.data);
|
||||
});
|
||||
return _future;
|
||||
return _future!;
|
||||
}
|
||||
|
||||
Future<Response<dynamic>> _fetchPrivateBillingPlans() {
|
||||
|
@ -89,7 +87,7 @@ class BillingService {
|
|||
);
|
||||
return Subscription.fromMap(response.data["subscription"]);
|
||||
} on DioError catch (e) {
|
||||
if (e.response != null && e.response.statusCode == 409) {
|
||||
if (e.response != null && e.response!.statusCode == 409) {
|
||||
throw SubscriptionAlreadyClaimedError();
|
||||
} else {
|
||||
rethrow;
|
||||
|
@ -118,7 +116,7 @@ class BillingService {
|
|||
rethrow;
|
||||
}
|
||||
}
|
||||
return _cachedSubscription;
|
||||
return _cachedSubscription!;
|
||||
}
|
||||
|
||||
Future<Subscription> cancelStripeSubscription() async {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/ui/tools/app_lock.dart';
|
||||
|
@ -18,9 +18,9 @@ class LocalAuthenticationService {
|
|||
String infoMessage,
|
||||
) async {
|
||||
if (await _isLocalAuthSupportedOnDevice()) {
|
||||
AppLock.of(context).setEnabled(false);
|
||||
AppLock.of(context)!.setEnabled(false);
|
||||
final result = await requestAuthentication(infoMessage);
|
||||
AppLock.of(context).setEnabled(
|
||||
AppLock.of(context)!.setEnabled(
|
||||
Configuration.instance.shouldShowLockScreen(),
|
||||
);
|
||||
if (!result) {
|
||||
|
@ -41,17 +41,17 @@ class LocalAuthenticationService {
|
|||
String errorDialogTitle = "",
|
||||
]) async {
|
||||
if (await LocalAuthentication().isDeviceSupported()) {
|
||||
AppLock.of(context).disable();
|
||||
AppLock.of(context)!.disable();
|
||||
final result = await requestAuthentication(
|
||||
infoMessage,
|
||||
);
|
||||
if (result) {
|
||||
AppLock.of(context).setEnabled(shouldEnableLockScreen);
|
||||
AppLock.of(context)!.setEnabled(shouldEnableLockScreen);
|
||||
await Configuration.instance
|
||||
.setShouldShowLockScreen(shouldEnableLockScreen);
|
||||
return true;
|
||||
} else {
|
||||
AppLock.of(context)
|
||||
AppLock.of(context)!
|
||||
.setEnabled(Configuration.instance.shouldShowLockScreen());
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -16,10 +16,10 @@ class UpdateService {
|
|||
static final UpdateService instance = UpdateService._privateConstructor();
|
||||
static const kUpdateAvailableShownTimeKey = "update_available_shown_time_key";
|
||||
|
||||
LatestVersionInfo _latestVersion;
|
||||
LatestVersionInfo? _latestVersion;
|
||||
final _logger = Logger("UpdateService");
|
||||
PackageInfo _packageInfo;
|
||||
SharedPreferences _prefs;
|
||||
late PackageInfo _packageInfo;
|
||||
late SharedPreferences _prefs;
|
||||
|
||||
Future<void> init() async {
|
||||
_packageInfo = await PackageInfo.fromPlatform();
|
||||
|
@ -33,27 +33,27 @@ class UpdateService {
|
|||
try {
|
||||
_latestVersion = await _getLatestVersionInfo();
|
||||
final currentVersionCode = int.parse(_packageInfo.buildNumber);
|
||||
return currentVersionCode < _latestVersion.code;
|
||||
return currentVersionCode < _latestVersion!.code!;
|
||||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldForceUpdate(LatestVersionInfo info) {
|
||||
bool shouldForceUpdate(LatestVersionInfo? info) {
|
||||
if (!isIndependent()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
final currentVersionCode = int.parse(_packageInfo.buildNumber);
|
||||
return currentVersionCode < info.lastSupportedVersionCode;
|
||||
return currentVersionCode < info!.lastSupportedVersionCode;
|
||||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LatestVersionInfo getLatestVersionInfo() {
|
||||
LatestVersionInfo? getLatestVersionInfo() {
|
||||
return _latestVersion;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class UpdateService {
|
|||
(now - lastNotificationShownTime) > (3 * microSecondsInDay);
|
||||
if (shouldUpdate &&
|
||||
hasBeen3DaysSinceLastNotification &&
|
||||
_latestVersion.shouldNotify) {
|
||||
_latestVersion!.shouldNotify!) {
|
||||
NotificationService.instance.showNotification(
|
||||
"Update available",
|
||||
"Click to install our best version yet",
|
||||
|
@ -96,14 +96,14 @@ class UpdateService {
|
|||
}
|
||||
|
||||
class LatestVersionInfo {
|
||||
final String name;
|
||||
final int code;
|
||||
final String? name;
|
||||
final int? code;
|
||||
final List<String> changelog;
|
||||
final bool shouldForceUpdate;
|
||||
final bool? shouldForceUpdate;
|
||||
final int lastSupportedVersionCode;
|
||||
final String url;
|
||||
final int size;
|
||||
final bool shouldNotify;
|
||||
final String? url;
|
||||
final int? size;
|
||||
final bool? shouldNotify;
|
||||
|
||||
LatestVersionInfo(
|
||||
this.name,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
|
@ -32,14 +30,14 @@ class UserService {
|
|||
final _dio = Network.instance.getDio();
|
||||
final _logger = Logger("UserSerivce");
|
||||
final _config = Configuration.instance;
|
||||
ValueNotifier<String> emailValueNotifier;
|
||||
late ValueNotifier<String?> emailValueNotifier;
|
||||
|
||||
UserService._privateConstructor();
|
||||
static final UserService instance = UserService._privateConstructor();
|
||||
|
||||
Future<void> init() async {
|
||||
emailValueNotifier =
|
||||
ValueNotifier<String>(Configuration.instance.getEmail());
|
||||
ValueNotifier<String?>(Configuration.instance.getEmail());
|
||||
}
|
||||
|
||||
Future<void> sendOtt(
|
||||
|
@ -49,7 +47,7 @@ class UserService {
|
|||
bool isCreateAccountScreen = false,
|
||||
}) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
|
@ -75,19 +73,19 @@ class UserService {
|
|||
);
|
||||
return;
|
||||
}
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
} on DioError catch (e) {
|
||||
await dialog.hide();
|
||||
_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");
|
||||
} else {
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
} catch (e) {
|
||||
await dialog.hide();
|
||||
_logger.severe(e);
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,15 +184,15 @@ class UserService {
|
|||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
await dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<DeleteChallengeResponse> getDeleteChallenge(
|
||||
Future<DeleteChallengeResponse?> getDeleteChallenge(
|
||||
BuildContext context,
|
||||
) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
|
@ -218,7 +216,7 @@ class UserService {
|
|||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
await dialog.hide();
|
||||
await showGenericErrorDialog(context);
|
||||
await showGenericErrorDialog(context: context);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -257,13 +255,13 @@ class UserService {
|
|||
} catch (e) {
|
||||
_logger.severe(e);
|
||||
await dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> verifyEmail(BuildContext context, String ott) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
|
@ -302,7 +300,7 @@ class UserService {
|
|||
} on DioError catch (e) {
|
||||
_logger.info(e);
|
||||
await dialog.hide();
|
||||
if (e.response != null && e.response.statusCode == 410) {
|
||||
if (e.response != null && e.response!.statusCode == 410) {
|
||||
await showErrorDialog(
|
||||
context,
|
||||
"Oops",
|
||||
|
@ -334,7 +332,7 @@ class UserService {
|
|||
String ott,
|
||||
) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
final response = await _dio.post(
|
||||
|
@ -360,7 +358,7 @@ class UserService {
|
|||
showErrorDialog(context, "Oops", "Verification failed, please try again");
|
||||
} on DioError catch (e) {
|
||||
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");
|
||||
} else {
|
||||
showErrorDialog(
|
||||
|
@ -447,7 +445,7 @@ class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
Future<String> getPaymentToken() async {
|
||||
Future<String?> getPaymentToken() async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
"${_config.getHttpEndpoint()}/users/payment-token",
|
||||
|
@ -504,7 +502,7 @@ class UserService {
|
|||
|
||||
Future<void> recoverTwoFactor(BuildContext context, String sessionID) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
|
@ -529,7 +527,7 @@ class UserService {
|
|||
}
|
||||
} on DioError catch (e) {
|
||||
_logger.severe(e);
|
||||
if (e.response != null && e.response.statusCode == 404) {
|
||||
if (e.response != null && e.response!.statusCode == 404) {
|
||||
showToast(context, "Session expired");
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
|
@ -589,7 +587,7 @@ class UserService {
|
|||
} on DioError catch (e) {
|
||||
await dialog.hide();
|
||||
_logger.severe(e);
|
||||
if (e.response != null && e.response.statusCode == 404) {
|
||||
if (e.response != null && e.response!.statusCode == 404) {
|
||||
showToast(context, "Session expired");
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
|
@ -625,7 +623,7 @@ class UserService {
|
|||
String secretDecryptionNonce,
|
||||
) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
String secret;
|
||||
try {
|
||||
|
@ -675,7 +673,7 @@ class UserService {
|
|||
}
|
||||
} on DioError catch (e) {
|
||||
_logger.severe(e);
|
||||
if (e.response != null && e.response.statusCode == 404) {
|
||||
if (e.response != null && e.response!.statusCode == 404) {
|
||||
showToast(context, "Session expired");
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
|
|
|
@ -11,6 +11,7 @@ class EnteColorScheme {
|
|||
// Backdrop Colors
|
||||
final Color backdropBase;
|
||||
final Color backdropBaseMute;
|
||||
final Color backdropFaint;
|
||||
|
||||
// Text Colors
|
||||
final Color textBase;
|
||||
|
@ -19,6 +20,7 @@ class EnteColorScheme {
|
|||
|
||||
// Fill Colors
|
||||
final Color fillBase;
|
||||
final Color fillBasePressed;
|
||||
final Color fillMuted;
|
||||
final Color fillFaint;
|
||||
final Color fillFaintPressed;
|
||||
|
@ -42,6 +44,8 @@ class EnteColorScheme {
|
|||
final Color warning700;
|
||||
final Color warning500;
|
||||
final Color warning400;
|
||||
final Color warning800;
|
||||
|
||||
final Color caution500;
|
||||
|
||||
const EnteColorScheme(
|
||||
|
@ -50,10 +54,12 @@ class EnteColorScheme {
|
|||
this.backgroundElevated2,
|
||||
this.backdropBase,
|
||||
this.backdropBaseMute,
|
||||
this.backdropFaint,
|
||||
this.textBase,
|
||||
this.textMuted,
|
||||
this.textFaint,
|
||||
this.fillBase,
|
||||
this.fillBasePressed,
|
||||
this.fillMuted,
|
||||
this.fillFaint,
|
||||
this.fillFaintPressed,
|
||||
|
@ -70,6 +76,7 @@ class EnteColorScheme {
|
|||
this.primary400 = _primary400,
|
||||
this.primary300 = _primary300,
|
||||
this.warning700 = _warning700,
|
||||
this.warning800 = _warning800,
|
||||
this.warning500 = _warning500,
|
||||
this.warning400 = _warning700,
|
||||
this.caution500 = _caution500,
|
||||
|
@ -81,11 +88,13 @@ const EnteColorScheme lightScheme = EnteColorScheme(
|
|||
backgroundElevatedLight,
|
||||
backgroundElevated2Light,
|
||||
backdropBaseLight,
|
||||
backdropBaseMuteLight,
|
||||
backdropMutedLight,
|
||||
backdropFaintLight,
|
||||
textBaseLight,
|
||||
textMutedLight,
|
||||
textFaintLight,
|
||||
fillBaseLight,
|
||||
fillBasePressedLight,
|
||||
fillMutedLight,
|
||||
fillFaintLight,
|
||||
fillFaintPressedLight,
|
||||
|
@ -103,11 +112,13 @@ const EnteColorScheme darkScheme = EnteColorScheme(
|
|||
backgroundElevatedDark,
|
||||
backgroundElevated2Dark,
|
||||
backdropBaseDark,
|
||||
backdropBaseMuteDark,
|
||||
backdropMutedDark,
|
||||
backdropFaintDark,
|
||||
textBaseDark,
|
||||
textMutedDark,
|
||||
textFaintDark,
|
||||
fillBaseDark,
|
||||
fillBasePressedDark,
|
||||
fillMutedDark,
|
||||
fillFaintDark,
|
||||
fillFaintPressedDark,
|
||||
|
@ -130,11 +141,13 @@ const Color backgroundElevatedDark = Color.fromRGBO(27, 27, 27, 1);
|
|||
const Color backgroundElevated2Dark = Color.fromRGBO(37, 37, 37, 1);
|
||||
|
||||
// Backdrop Colors
|
||||
const Color backdropBaseLight = Color.fromRGBO(255, 255, 255, 0.75);
|
||||
const Color backdropBaseMuteLight = Color.fromRGBO(255, 255, 255, 0.30);
|
||||
const Color backdropBaseLight = Color.fromRGBO(255, 255, 255, 0.92);
|
||||
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 backdropBaseMuteDark = Color.fromRGBO(0, 0, 0, 0.20);
|
||||
const Color backdropBaseDark = Color.fromRGBO(0, 0, 0, 0.90);
|
||||
const Color backdropMutedDark = Color.fromRGBO(0, 0, 0, 0.65);
|
||||
const Color backdropFaintDark = Color.fromRGBO(0, 0, 0, 0.20);
|
||||
|
||||
// Text Colors
|
||||
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
|
||||
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 fillFaintLight = Color.fromRGBO(0, 0, 0, 0.04);
|
||||
const Color fillFaintPressedLight = Color.fromRGBO(0, 0, 0, 0.08);
|
||||
|
||||
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 fillFaintDark = Color.fromRGBO(255, 255, 255, 0.12);
|
||||
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 _warning500 = Color.fromRGBO(255, 101, 101, 1);
|
||||
const Color _warning800 = Color(0xFFF53434);
|
||||
const Color warning500 = Color.fromRGBO(255, 101, 101, 1);
|
||||
const Color _warning400 = Color.fromRGBO(255, 111, 111, 1);
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
const blurBase = 96;
|
||||
const blurMuted = 48;
|
||||
const blurFaint = 24;
|
||||
const blurBase = 96.0;
|
||||
const blurMuted = 48.0;
|
||||
const blurFaint = 24.0;
|
||||
|
||||
List<BoxShadow> shadowFloatLight = const [
|
||||
BoxShadow(blurRadius: 10, color: Color.fromRGBO(0, 0, 0, 0.25)),
|
||||
|
|
|
@ -36,10 +36,20 @@ EnteTheme darkTheme = EnteTheme(
|
|||
shadowButton: shadowButtonDark,
|
||||
);
|
||||
|
||||
EnteColorScheme getEnteColorScheme(BuildContext context) {
|
||||
return Theme.of(context).colorScheme.enteTheme.colorScheme;
|
||||
EnteColorScheme getEnteColorScheme(
|
||||
BuildContext context, {
|
||||
bool inverse = false,
|
||||
}) {
|
||||
return inverse
|
||||
? Theme.of(context).colorScheme.inverseEnteTheme.colorScheme
|
||||
: Theme.of(context).colorScheme.enteTheme.colorScheme;
|
||||
}
|
||||
|
||||
EnteTextTheme getEnteTextTheme(BuildContext context) {
|
||||
return Theme.of(context).colorScheme.enteTheme.textTheme;
|
||||
EnteTextTheme getEnteTextTheme(
|
||||
BuildContext context, {
|
||||
bool inverse = false,
|
||||
}) {
|
||||
return inverse
|
||||
? Theme.of(context).colorScheme.inverseEnteTheme.textTheme
|
||||
: Theme.of(context).colorScheme.enteTheme.textTheme;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
|
@ -16,7 +14,7 @@ import 'package:flutter_sodium/flutter_sodium.dart';
|
|||
|
||||
class DeleteAccountPage extends StatelessWidget {
|
||||
const DeleteAccountPage({
|
||||
Key key,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -153,7 +151,7 @@ class DeleteAccountPage extends StatelessWidget {
|
|||
);
|
||||
|
||||
if (hasAuthenticated) {
|
||||
final choice = await showChoiceDialog(
|
||||
final choice = await showChoiceDialogOld(
|
||||
context,
|
||||
l10n.confirmAccountDeleteTitle,
|
||||
l10n.confirmAccountDeleteMessage,
|
||||
|
@ -167,8 +165,8 @@ class DeleteAccountPage extends StatelessWidget {
|
|||
}
|
||||
final decryptChallenge = CryptoUtil.openSealSync(
|
||||
Sodium.base642bin(response.encryptedChallenge),
|
||||
Sodium.base642bin(Configuration.instance.getKeyAttributes().publicKey),
|
||||
Configuration.instance.getSecretKey(),
|
||||
Sodium.base642bin(Configuration.instance.getKeyAttributes()!.publicKey),
|
||||
Configuration.instance.getSecretKey()!,
|
||||
);
|
||||
final challengeResponseStr = utf8.decode(decryptChallenge);
|
||||
await UserService.instance.deleteAccount(context, challengeResponseStr);
|
||||
|
|
|
@ -1,26 +1,18 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:email_validator/email_validator.dart';
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
import 'package:ente_auth/models/billing_plan.dart';
|
||||
import 'package:ente_auth/services/billing_service.dart';
|
||||
import 'package:ente_auth/services/user_service.dart';
|
||||
import 'package:ente_auth/ui/common/dynamic_fab.dart';
|
||||
import 'package:ente_auth/ui/common/loading_widget.dart';
|
||||
import 'package:ente_auth/ui/common/web_page.dart';
|
||||
import 'package:ente_auth/utils/data_util.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:password_strength/password_strength.dart';
|
||||
import 'package:step_progress_indicator/step_progress_indicator.dart';
|
||||
import "package:styled_text/styled_text.dart";
|
||||
|
||||
class EmailEntryPage extends StatefulWidget {
|
||||
const EmailEntryPage({Key key}) : super(key: key);
|
||||
const EmailEntryPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<EmailEntryPage> createState() => _EmailEntryPageState();
|
||||
|
@ -35,8 +27,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
final _passwordController2 = TextEditingController();
|
||||
final Color _validFieldValueColor = const Color.fromARGB(51, 157, 45, 194);
|
||||
|
||||
String _email;
|
||||
String _password;
|
||||
String? _email;
|
||||
String? _password;
|
||||
String _cnfPassword = '';
|
||||
double _passwordStrength = 0.0;
|
||||
bool _emailIsValid = false;
|
||||
|
@ -72,7 +64,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
Widget build(BuildContext context) {
|
||||
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
|
||||
|
||||
FloatingActionButtonLocation fabLocation() {
|
||||
FloatingActionButtonLocation? fabLocation() {
|
||||
if (isKeypadOpen) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -108,12 +100,12 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
floatingActionButton: DynamicFAB(
|
||||
isKeypadOpen: isKeypadOpen,
|
||||
isFormValid: _isFormValid(),
|
||||
buttonText: 'Create account',
|
||||
buttonText: context.l10n.createAccount,
|
||||
onPressedFunction: () {
|
||||
_config.setVolatilePassword(_passwordController1.text);
|
||||
UserService.instance.setEmail(_email);
|
||||
UserService.instance.setEmail(_email!);
|
||||
UserService.instance
|
||||
.sendOtt(context, _email, isCreateAccountScreen: true);
|
||||
.sendOtt(context, _email!, isCreateAccountScreen: true);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
),
|
||||
|
@ -123,14 +115,13 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
}
|
||||
|
||||
Widget _getBody() {
|
||||
final l10n = context.l10n;
|
||||
var passwordStrengthText = l10n.passwordStrengthWeak;
|
||||
var passwordStrengthText = context.l10n.weakStrength;
|
||||
var passwordStrengthColor = Colors.redAccent;
|
||||
if (_passwordStrength > kStrongPasswordStrengthThreshold) {
|
||||
passwordStrengthText = l10n.passwordStrengthStrong;
|
||||
passwordStrengthText = context.l10n.strongStrength;
|
||||
passwordStrengthColor = Colors.greenAccent;
|
||||
} else if (_passwordStrength > kMildPasswordStrengthThreshold) {
|
||||
passwordStrengthText = l10n.passwordStrengthModerate;
|
||||
passwordStrengthText = context.l10n.moderateStrength;
|
||||
passwordStrengthColor = Colors.orangeAccent;
|
||||
}
|
||||
return Column(
|
||||
|
@ -143,7 +134,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
|
||||
child: Text(
|
||||
l10n.createNewAccount,
|
||||
context.l10n.createNewAccount,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
|
@ -155,7 +146,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
decoration: InputDecoration(
|
||||
fillColor: _emailIsValid ? _validFieldValueColor : null,
|
||||
filled: true,
|
||||
hintText: l10n.email,
|
||||
hintText: context.l10n.email,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 14,
|
||||
|
@ -170,7 +161,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
size: 20,
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
)
|
||||
|
@ -178,9 +169,9 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
),
|
||||
onChanged: (value) {
|
||||
_email = value.trim();
|
||||
if (_emailIsValid != EmailValidator.validate(_email)) {
|
||||
if (_emailIsValid != EmailValidator.validate(_email!)) {
|
||||
setState(() {
|
||||
_emailIsValid = EmailValidator.validate(_email);
|
||||
_emailIsValid = EmailValidator.validate(_email!);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@ -203,7 +194,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
fillColor:
|
||||
_passwordIsValid ? _validFieldValueColor : null,
|
||||
filled: true,
|
||||
hintText: "Password",
|
||||
hintText: context.l10n.password,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 14,
|
||||
|
@ -228,7 +219,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
Icons.check,
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
)
|
||||
|
@ -268,9 +259,11 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
autofillHints: const [AutofillHints.newPassword],
|
||||
onEditingComplete: () => TextInput.finishAutofillContext(),
|
||||
decoration: InputDecoration(
|
||||
fillColor: _passwordsMatch ? _validFieldValueColor : null,
|
||||
fillColor: _passwordsMatch && _passwordIsValid
|
||||
? _validFieldValueColor
|
||||
: null,
|
||||
filled: true,
|
||||
hintText: l10n.confirmPassword,
|
||||
hintText: context.l10n.confirmPassword,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 14,
|
||||
|
@ -295,7 +288,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
Icons.check,
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
)
|
||||
|
@ -322,7 +315,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
||||
child: Text(
|
||||
'Password strength: $passwordStrengthText',
|
||||
context.l10n.passwordStrength(passwordStrengthText),
|
||||
style: TextStyle(
|
||||
color: passwordStrengthColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
|
@ -371,63 +364,51 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
side: CheckboxTheme.of(context).side,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_hasAgreedToTOS = value;
|
||||
_hasAgreedToTOS = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: "I agree to the ",
|
||||
child: StyledText(
|
||||
text: context.l10n.signUpTerms,
|
||||
style:
|
||||
Theme.of(context).textTheme.subtitle1!.copyWith(fontSize: 12),
|
||||
tags: {
|
||||
'u-terms': StyledTextActionTag(
|
||||
(String? text, Map<String?, String?> attrs) => {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return WebPage(
|
||||
context.l10n.termsOfServicesTitle,
|
||||
"https://ente.io/terms",
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
TextSpan(
|
||||
text: "terms of service",
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const WebPage(
|
||||
"Terms",
|
||||
"https://ente.io/terms",
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
'u-policy': StyledTextActionTag(
|
||||
(String? text, Map<String?, String?> attrs) => {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return WebPage(
|
||||
context.l10n.privacyPolicyTitle,
|
||||
"https://ente.io/privacy",
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
const TextSpan(text: " and "),
|
||||
TextSpan(
|
||||
text: "privacy policy",
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const WebPage(
|
||||
"Privacy",
|
||||
"https://ente.io/privacy",
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.copyWith(fontSize: 12),
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -450,45 +431,34 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
side: CheckboxTheme.of(context).side,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_hasAgreedToE2E = value;
|
||||
_hasAgreedToE2E = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text:
|
||||
"I understand that if I lose my password, I may lose my data since my data is ",
|
||||
child: StyledText(
|
||||
text: context.l10n.ackPasswordLostWarning,
|
||||
style:
|
||||
Theme.of(context).textTheme.subtitle1!.copyWith(fontSize: 12),
|
||||
tags: {
|
||||
'underline': StyledTextActionTag(
|
||||
(String? text, Map<String?, String?> attrs) => {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return WebPage(
|
||||
context.l10n.encryption,
|
||||
"https://ente.io/architecture",
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
TextSpan(
|
||||
text: "end-to-end encrypted",
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const WebPage(
|
||||
"Encryption",
|
||||
"https://ente.io/architecture",
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const TextSpan(text: " with ente"),
|
||||
],
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.copyWith(fontSize: 12),
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -504,136 +474,3 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
|
|||
_passwordIsValid;
|
||||
}
|
||||
}
|
||||
|
||||
class PricingWidget extends StatelessWidget {
|
||||
const PricingWidget({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return FutureBuilder<BillingPlans>(
|
||||
future: BillingService.instance.getBillingPlans(),
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return _buildPlans(context, snapshot.data);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text(l10n.oopsSomethingWentWrong);
|
||||
}
|
||||
return const EnteLoadingWidget();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Container _buildPlans(BuildContext context, BillingPlans plans) {
|
||||
final l10n = context.l10n;
|
||||
final planWidgets = <BillingPlanWidget>[];
|
||||
for (final plan in plans.plans) {
|
||||
final productID = Platform.isAndroid ? plan.androidID : plan.iosID;
|
||||
if (productID != null && productID.isNotEmpty) {
|
||||
planWidgets.add(BillingPlanWidget(plan));
|
||||
}
|
||||
}
|
||||
final freePlan = plans.freePlan;
|
||||
return Container(
|
||||
height: 280,
|
||||
color: Theme.of(context).cardColor,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
"Pricing",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: planWidgets,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"We offer a free trial of " +
|
||||
convertBytesToReadableFormat(freePlan.storage) +
|
||||
" for " +
|
||||
freePlan.duration.toString() +
|
||||
" " +
|
||||
freePlan.period,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.close,
|
||||
size: 12,
|
||||
color: Colors.white38,
|
||||
),
|
||||
const Padding(padding: EdgeInsets.all(1)),
|
||||
Text(
|
||||
l10n.close,
|
||||
style: const TextStyle(
|
||||
color: Colors.white38,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () => Navigator.pop(context),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BillingPlanWidget extends StatelessWidget {
|
||||
final BillingPlan plan;
|
||||
|
||||
const BillingPlanWidget(
|
||||
this.plan, {
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(2.0),
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
),
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(12, 20, 12, 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
convertBytesToGBs(plan.storage, precision: 0).toString() +
|
||||
" GB",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
),
|
||||
Text(
|
||||
plan.price + " / " + plan.period,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.white70,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:email_validator/email_validator.dart';
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import "package:ente_auth/l10n/l10n.dart";
|
||||
import 'package:ente_auth/services/user_service.dart';
|
||||
import 'package:ente_auth/ui/common/dynamic_fab.dart';
|
||||
import 'package:ente_auth/ui/common/web_page.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import "package:styled_text/styled_text.dart";
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({Key key}) : super(key: key);
|
||||
const LoginPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LoginPage> createState() => _LoginPageState();
|
||||
|
@ -18,8 +17,8 @@ class LoginPage extends StatefulWidget {
|
|||
class _LoginPageState extends State<LoginPage> {
|
||||
final _config = Configuration.instance;
|
||||
bool _emailIsValid = false;
|
||||
String _email;
|
||||
Color _emailInputFieldColor;
|
||||
String? _email;
|
||||
Color? _emailInputFieldColor;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -31,7 +30,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
Widget build(BuildContext context) {
|
||||
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
|
||||
|
||||
FloatingActionButtonLocation fabLocation() {
|
||||
FloatingActionButtonLocation? fabLocation() {
|
||||
if (isKeypadOpen) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -55,11 +54,11 @@ class _LoginPageState extends State<LoginPage> {
|
|||
floatingActionButton: DynamicFAB(
|
||||
isKeypadOpen: isKeypadOpen,
|
||||
isFormValid: _emailIsValid,
|
||||
buttonText: 'Log in',
|
||||
buttonText: context.l10n.logInLabel,
|
||||
onPressedFunction: () {
|
||||
UserService.instance.setEmail(_email);
|
||||
UserService.instance.setEmail(_email!);
|
||||
UserService.instance
|
||||
.sendOtt(context, _email, isCreateAccountScreen: false);
|
||||
.sendOtt(context, _email!, isCreateAccountScreen: false);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
),
|
||||
|
@ -69,6 +68,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
}
|
||||
|
||||
Widget _getBody() {
|
||||
final l10n = context.l10n;
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
|
@ -79,7 +79,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
|
||||
child: Text(
|
||||
'Welcome back!',
|
||||
l10n.welcomeBack,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
|
@ -90,7 +90,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
decoration: InputDecoration(
|
||||
fillColor: _emailInputFieldColor,
|
||||
filled: true,
|
||||
hintText: 'Email',
|
||||
hintText: l10n.email,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
vertical: 15,
|
||||
|
@ -105,7 +105,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
size: 20,
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
)
|
||||
|
@ -114,7 +114,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
onChanged: (value) {
|
||||
setState(() {
|
||||
_email = value.trim();
|
||||
_emailIsValid = EmailValidator.validate(_email);
|
||||
_emailIsValid = EmailValidator.validate(_email!);
|
||||
if (_emailIsValid) {
|
||||
_emailInputFieldColor =
|
||||
const Color.fromARGB(51, 157, 45, 194);
|
||||
|
@ -141,58 +141,48 @@ class _LoginPageState extends State<LoginPage> {
|
|||
children: [
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.copyWith(fontSize: 12),
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: "By clicking log in, I agree to the ",
|
||||
child: StyledText(
|
||||
text: context.l10n.loginTerms,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1!
|
||||
.copyWith(fontSize: 12),
|
||||
tags: {
|
||||
'u-terms': StyledTextActionTag(
|
||||
(String? text, Map<String?, String?> attrs) => {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return WebPage(
|
||||
context.l10n.termsOfServicesTitle,
|
||||
"https://ente.io/terms",
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
TextSpan(
|
||||
text: "terms of service",
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const WebPage(
|
||||
"terms",
|
||||
"https://ente.io/terms",
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
'u-policy': StyledTextActionTag(
|
||||
(String? text, Map<String?, String?> attrs) => {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return WebPage(
|
||||
context.l10n.privacyPolicyTitle,
|
||||
"https://ente.io/privacy",
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
const TextSpan(text: " and "),
|
||||
TextSpan(
|
||||
text: "privacy policy",
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const WebPage(
|
||||
"privacy",
|
||||
"https://ente.io/privacy",
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.left,
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/services/user_service.dart';
|
||||
|
@ -15,7 +15,7 @@ class OTTVerificationPage extends StatefulWidget {
|
|||
this.email, {
|
||||
this.isChangeEmail = false,
|
||||
this.isCreateAccountScreen = false,
|
||||
Key key,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -29,7 +29,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
|
|||
Widget build(BuildContext context) {
|
||||
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
|
||||
|
||||
FloatingActionButtonLocation fabLocation() {
|
||||
FloatingActionButtonLocation? fabLocation() {
|
||||
if (isKeypadOpen) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -114,7 +114,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
|
|||
text: TextSpan(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.subtitle1!
|
||||
.copyWith(fontSize: 14),
|
||||
children: [
|
||||
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',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.subtitle1!
|
||||
.copyWith(fontSize: 14),
|
||||
),
|
||||
],
|
||||
|
@ -187,7 +187,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
|
|||
},
|
||||
child: Text(
|
||||
"Resend email",
|
||||
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
style: Theme.of(context).textTheme.subtitle1!.copyWith(
|
||||
fontSize: 14,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
|
@ -24,7 +24,7 @@ enum PasswordEntryMode {
|
|||
class PasswordEntryPage extends StatefulWidget {
|
||||
final PasswordEntryMode mode;
|
||||
|
||||
const PasswordEntryPage({this.mode = PasswordEntryMode.set, Key key})
|
||||
const PasswordEntryPage({this.mode = PasswordEntryMode.set, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -39,7 +39,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
final _passwordController1 = TextEditingController(),
|
||||
_passwordController2 = TextEditingController();
|
||||
final Color _validFieldValueColor = const Color.fromRGBO(45, 194, 98, 0.2);
|
||||
String _volatilePassword;
|
||||
String? _volatilePassword;
|
||||
String _passwordInInputBox = '';
|
||||
String _passwordInInputConfirmationBox = '';
|
||||
double _passwordStrength = 0.0;
|
||||
|
@ -60,7 +60,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
if (_volatilePassword != null) {
|
||||
Future.delayed(
|
||||
Duration.zero,
|
||||
() => _showRecoveryCodeDialog(_volatilePassword),
|
||||
() => _showRecoveryCodeDialog(_volatilePassword!),
|
||||
);
|
||||
}
|
||||
_password1FocusNode.addListener(() {
|
||||
|
@ -79,7 +79,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
Widget build(BuildContext context) {
|
||||
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
|
||||
|
||||
FloatingActionButtonLocation fabLocation() {
|
||||
FloatingActionButtonLocation? fabLocation() {
|
||||
if (isKeypadOpen) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -165,7 +165,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
textAlign: TextAlign.start,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.subtitle1!
|
||||
.copyWith(fontSize: 14),
|
||||
),
|
||||
),
|
||||
|
@ -176,7 +176,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
text: TextSpan(
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.subtitle1!
|
||||
.copyWith(fontSize: 14),
|
||||
children: [
|
||||
const TextSpan(
|
||||
|
@ -185,7 +185,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
),
|
||||
TextSpan(
|
||||
text: "we cannot decrypt your data",
|
||||
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
style: Theme.of(context).textTheme.subtitle1!.copyWith(
|
||||
fontSize: 14,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
|
@ -243,7 +243,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
Icons.check,
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
)
|
||||
|
@ -305,7 +305,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
Icons.check,
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
)
|
||||
|
@ -362,7 +362,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "How it works",
|
||||
style: Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
style: Theme.of(context).textTheme.subtitle1!.copyWith(
|
||||
fontSize: 14,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
|
@ -396,7 +396,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
} catch (e, s) {
|
||||
_logger.severe(e, s);
|
||||
await dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
Configuration.instance.setVolatilePassword(null);
|
||||
await dialog.hide();
|
||||
onDone() async {
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
await UserService.instance.setAttributes(result);
|
||||
|
@ -426,7 +426,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|||
} catch (e, s) {
|
||||
_logger.severe(e, s);
|
||||
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.",
|
||||
);
|
||||
} else {
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
// @dart=2.9
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/core/errors.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/common/dialogs.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/utils/dialog_util.dart';
|
||||
import 'package:ente_auth/utils/email_util.dart';
|
||||
|
@ -14,7 +13,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
|
||||
class PasswordReentryPage extends StatefulWidget {
|
||||
const PasswordReentryPage({Key key}) : super(key: key);
|
||||
const PasswordReentryPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<PasswordReentryPage> createState() => _PasswordReentryPageState();
|
||||
|
@ -24,7 +23,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
final _logger = Logger((_PasswordReentryPageState).toString());
|
||||
final _passwordController = TextEditingController();
|
||||
final FocusNode _passwordFocusNode = FocusNode();
|
||||
String email;
|
||||
String? email;
|
||||
bool _passwordInFocus = false;
|
||||
bool _passwordVisible = false;
|
||||
|
||||
|
@ -41,10 +40,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
|
||||
|
||||
FloatingActionButtonLocation fabLocation() {
|
||||
FloatingActionButtonLocation? fabLocation() {
|
||||
if (isKeypadOpen) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -68,29 +66,26 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
floatingActionButton: DynamicFAB(
|
||||
isKeypadOpen: isKeypadOpen,
|
||||
isFormValid: _passwordController.text.isNotEmpty,
|
||||
buttonText: l10n.verifyPassword,
|
||||
buttonText: context.l10n.verifyPassword,
|
||||
onPressedFunction: () async {
|
||||
FocusScope.of(context).unfocus();
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, context.l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
await Configuration.instance.decryptAndSaveSecrets(
|
||||
_passwordController.text,
|
||||
Configuration.instance.getKeyAttributes(),
|
||||
Configuration.instance.getKeyAttributes()!,
|
||||
);
|
||||
} on KeyDerivationError catch (e, s) {
|
||||
_logger.severe("Password verification failed", e, s);
|
||||
await dialog.hide();
|
||||
final dialogUserChoice = await showChoiceDialog(
|
||||
final dialogChoice = await showChoiceDialog(
|
||||
context,
|
||||
l10n.recreatePassword,
|
||||
l10n.recreatePasswordMessage,
|
||||
firstAction: l10n.cancel,
|
||||
firstActionColor: Theme.of(context).colorScheme.primary,
|
||||
secondAction: l10n.useRecoveryKeyAction,
|
||||
secondActionColor: Theme.of(context).colorScheme.primary,
|
||||
title: context.l10n.recreatePasswordTitle,
|
||||
body: context.l10n.recreatePasswordBody,
|
||||
firstButtonLabel: context.l10n.useRecoveryKey,
|
||||
);
|
||||
if (dialogUserChoice == DialogUserChoice.secondChoice) {
|
||||
if (dialogChoice!.action == ButtonAction.first) {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
|
@ -103,20 +98,17 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
} catch (e, s) {
|
||||
_logger.severe("Password verification failed", e, s);
|
||||
await dialog.hide();
|
||||
|
||||
final dialogUserChoice = await showChoiceDialog(
|
||||
final dialogChoice = await showChoiceDialog(
|
||||
context,
|
||||
l10n.incorrectPassword,
|
||||
l10n.tryAgainMessage,
|
||||
firstAction: l10n.contactSupport,
|
||||
firstActionColor: Theme.of(context).colorScheme.primary,
|
||||
secondAction: l10n.ok,
|
||||
secondActionColor: Theme.of(context).colorScheme.primary,
|
||||
title: context.l10n.incorrectPasswordTitle,
|
||||
body: context.l10n.pleaseTryAgain,
|
||||
firstButtonLabel: context.l10n.contactSupport,
|
||||
secondButtonLabel: context.l10n.ok,
|
||||
);
|
||||
if (dialogUserChoice == DialogUserChoice.firstChoice) {
|
||||
if (dialogChoice!.action == ButtonAction.first) {
|
||||
await sendLogs(
|
||||
context,
|
||||
l10n.contactSupport,
|
||||
context.l10n.contactSupport,
|
||||
"support@ente.io",
|
||||
postShare: () {},
|
||||
);
|
||||
|
@ -124,13 +116,15 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
return;
|
||||
}
|
||||
await dialog.hide();
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const HomePage();
|
||||
},
|
||||
unawaited(
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const HomePage();
|
||||
},
|
||||
),
|
||||
(route) => false,
|
||||
),
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -140,7 +134,6 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
}
|
||||
|
||||
Widget _getBody() {
|
||||
final l10n = context.l10n;
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
|
@ -151,7 +144,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
|
||||
child: Text(
|
||||
l10n.welcomeBackTitle,
|
||||
context.l10n.welcomeBack,
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
),
|
||||
|
@ -174,7 +167,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
child: TextFormField(
|
||||
autofillHints: const [AutofillHints.password],
|
||||
decoration: InputDecoration(
|
||||
hintText: l10n.enterYourPasswordHint,
|
||||
hintText: context.l10n.enterYourPasswordHint,
|
||||
filled: true,
|
||||
contentPadding: const EdgeInsets.all(20),
|
||||
border: UnderlineInputBorder(
|
||||
|
@ -236,9 +229,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
l10n.forgotPassword,
|
||||
context.l10n.forgotPassword,
|
||||
style:
|
||||
Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
Theme.of(context).textTheme.subtitle1!.copyWith(
|
||||
fontSize: 14,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
|
@ -250,7 +243,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
onTap: () async {
|
||||
final dialog = createProgressDialog(
|
||||
context,
|
||||
l10n.pleaseWaitTitle,
|
||||
context.l10n.pleaseWait,
|
||||
);
|
||||
await dialog.show();
|
||||
await Configuration.instance.logout();
|
||||
|
@ -260,9 +253,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
|
|||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
l10n.changeEmail,
|
||||
context.l10n.changeEmail,
|
||||
style:
|
||||
Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
Theme.of(context).textTheme.subtitle1!.copyWith(
|
||||
fontSize: 14,
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
|
@ -10,7 +10,7 @@ import 'package:ente_auth/utils/toast_util.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class RecoveryPage extends StatefulWidget {
|
||||
const RecoveryPage({Key key}) : super(key: key);
|
||||
const RecoveryPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RecoveryPage> createState() => _RecoveryPageState();
|
||||
|
@ -22,7 +22,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
|
||||
FloatingActionButtonLocation fabLocation() {
|
||||
FloatingActionButtonLocation? fabLocation() {
|
||||
if (isKeypadOpen) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -140,7 +140,7 @@ class _RecoveryPageState extends State<RecoveryPage> {
|
|||
child: Text(
|
||||
"No recovery key?",
|
||||
style:
|
||||
Theme.of(context).textTheme.subtitle1.copyWith(
|
||||
Theme.of(context).textTheme.subtitle1!.copyWith(
|
||||
fontSize: 14,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
|
@ -13,14 +13,14 @@ import 'package:flutter/material.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
|
||||
class SessionsPage extends StatefulWidget {
|
||||
const SessionsPage({Key key}) : super(key: key);
|
||||
const SessionsPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SessionsPage> createState() => _SessionsPageState();
|
||||
}
|
||||
|
||||
class _SessionsPageState extends State<SessionsPage> {
|
||||
Sessions _sessions;
|
||||
Sessions? _sessions;
|
||||
final Logger _logger = Logger("SessionsPageState");
|
||||
|
||||
@override
|
||||
|
@ -46,7 +46,7 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
}
|
||||
final List<Widget> rows = [];
|
||||
rows.add(const Padding(padding: EdgeInsets.all(4)));
|
||||
for (final session in _sessions.sessions) {
|
||||
for (final session in _sessions!.sessions) {
|
||||
rows.add(_getSessionWidget(session));
|
||||
}
|
||||
return SingleChildScrollView(
|
||||
|
@ -113,7 +113,7 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
|
||||
Future<void> _terminateSession(Session session) async {
|
||||
final l10n = context.l10n;
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
await UserService.instance.terminateSession(session.token);
|
||||
|
@ -133,11 +133,11 @@ class _SessionsPageState extends State<SessionsPage> {
|
|||
Future<void> _fetchActiveSessions() async {
|
||||
_sessions = await UserService.instance
|
||||
.getActiveSessions()
|
||||
.onError((error, stackTrace) {
|
||||
.onError((dynamic error, stackTrace) {
|
||||
showToast(context, "Failed to fetch active sessions");
|
||||
throw error;
|
||||
});
|
||||
_sessions.sessions.sort((first, second) {
|
||||
_sessions!.sessions.sort((first, second) {
|
||||
return second.lastUsedTime.compareTo(first.lastUsedTime);
|
||||
});
|
||||
setState(() {});
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
// ignore_for_file: import_of_legacy_library_into_null_safe
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
import 'package:dio/dio.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/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/user_remote_flag_service.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/components/buttons/button_widget.dart';
|
||||
import 'package:ente_auth/utils/dialog_util.dart';
|
||||
import 'package:ente_auth/utils/navigation_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -31,7 +28,8 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
final Logger _logger = Logger((_VerifyRecoveryPageState).toString());
|
||||
|
||||
void _verifyRecoveryKey() async {
|
||||
final dialog = createProgressDialog(context, "Verifying recovery key...");
|
||||
final dialog =
|
||||
createProgressDialog(context, context.l10n.verifyingRecoveryKey);
|
||||
await dialog.show();
|
||||
try {
|
||||
final String inputKey = _recoveryKey.text.trim();
|
||||
|
@ -50,19 +48,17 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
"Please check your internet connection and try again.",
|
||||
);
|
||||
} else {
|
||||
await showGenericErrorDialog(context);
|
||||
await showGenericErrorDialog(context: context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Bus.instance.fire(NotificationEvent());
|
||||
|
||||
await dialog.hide();
|
||||
// todo: change this as per figma once the component is ready
|
||||
await showErrorDialog(
|
||||
context,
|
||||
"Recovery key verified",
|
||||
"Great! Your recovery key is valid. Thank you for verifying.\n"
|
||||
"\nPlease"
|
||||
" remember to keep your recovery key safely backed up.",
|
||||
context.l10n.recoveryKeyVerified,
|
||||
context.l10n.recoveryKeySuccessBody,
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
} else {
|
||||
|
@ -71,18 +67,16 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
} catch (e, s) {
|
||||
_logger.severe("failed to verify recovery key", e, s);
|
||||
await dialog.hide();
|
||||
const String errMessage =
|
||||
"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 String errMessage = context.l10n.invalidRecoveryKey;
|
||||
final result = await showChoiceDialog(
|
||||
context,
|
||||
"Invalid key",
|
||||
errMessage,
|
||||
firstAction: "Try again",
|
||||
secondAction: "View recovery key",
|
||||
title: context.l10n.invalidKey,
|
||||
body: errMessage,
|
||||
firstButtonLabel: context.l10n.tryAgain,
|
||||
secondButtonLabel: context.l10n.viewRecoveryKey,
|
||||
secondButtonAction: ButtonAction.second,
|
||||
);
|
||||
if (result == DialogUserChoice.secondChoice) {
|
||||
if (result!.action == ButtonAction.second) {
|
||||
await _onViewRecoveryKeyClick();
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +96,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
context,
|
||||
RecoveryKeyPage(
|
||||
recoveryKey,
|
||||
"OK",
|
||||
context.l10n.ok,
|
||||
showAppBar: true,
|
||||
onDone: () {
|
||||
Navigator.of(context).pop();
|
||||
|
@ -110,7 +104,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
),
|
||||
);
|
||||
} catch (e) {
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -147,16 +141,14 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Text(
|
||||
'Verify recovery key',
|
||||
context.l10n.confirmRecoveryKey,
|
||||
style: enteTheme.textTheme.h3Bold,
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Text(
|
||||
"If you forget your password, your recovery key is the "
|
||||
"only way to recover your photos.\n\nPlease verify that "
|
||||
"you have safely backed up your 24 word recovery key by re-entering it.",
|
||||
context.l10n.recoveryKeyVerifyReason,
|
||||
style: enteTheme.textTheme.small
|
||||
.copyWith(color: enteTheme.colorScheme.textMuted),
|
||||
),
|
||||
|
@ -164,7 +156,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
hintText: "Enter your recovery key",
|
||||
hintText: context.l10n.enterYourRecoveryKey,
|
||||
contentPadding: const EdgeInsets.all(20),
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
|
@ -186,12 +178,6 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
},
|
||||
),
|
||||
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(
|
||||
child: Container(
|
||||
alignment: Alignment.bottomCenter,
|
||||
|
@ -203,8 +189,7 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
|
|||
children: [
|
||||
GradientButton(
|
||||
onTap: _verifyRecoveryKey,
|
||||
text: "Verify",
|
||||
iconData: Icons.shield_outlined,
|
||||
text: context.l10n.confirm,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DividerWithPadding extends StatelessWidget {
|
||||
final double left, top, right, bottom, thinckness;
|
||||
const DividerWithPadding({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.left = 0,
|
||||
this.top = 0,
|
||||
this.right = 0,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BottomShadowWidget extends StatelessWidget {
|
||||
final double offsetDy;
|
||||
final Color shadowColor;
|
||||
const BottomShadowWidget({this.offsetDy = 28, this.shadowColor, Key key})
|
||||
final Color? shadowColor;
|
||||
const BottomShadowWidget({this.offsetDy = 28, this.shadowColor, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// @dart=2.9
|
||||
|
||||
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/widgets.dart';
|
||||
|
||||
enum DialogUserChoice { firstChoice, secondChoice }
|
||||
|
||||
|
@ -12,14 +14,14 @@ enum ActionType {
|
|||
}
|
||||
|
||||
// if dialog is dismissed by tapping outside, this will return null
|
||||
Future<DialogUserChoice> showChoiceDialog<T>(
|
||||
Future<DialogUserChoice?> showChoiceDialogOld<T>(
|
||||
BuildContext context,
|
||||
String title,
|
||||
String content, {
|
||||
String firstAction = 'Ok',
|
||||
Color firstActionColor,
|
||||
Color? firstActionColor,
|
||||
String secondAction = 'Cancel',
|
||||
Color secondActionColor,
|
||||
Color? secondActionColor,
|
||||
ActionType actionType = ActionType.confirm,
|
||||
}) {
|
||||
final AlertDialog alert = AlertDialog(
|
||||
|
@ -69,7 +71,7 @@ Future<DialogUserChoice> showChoiceDialog<T>(
|
|||
],
|
||||
);
|
||||
|
||||
return showDialog(
|
||||
return showDialog<DialogUserChoice>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return alert;
|
||||
|
@ -77,3 +79,46 @@ Future<DialogUserChoice> showChoiceDialog<T>(
|
|||
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,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
|
@ -6,13 +6,13 @@ import 'package:ente_auth/ente_theme_data.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class DynamicFAB extends StatelessWidget {
|
||||
final bool isKeypadOpen;
|
||||
final bool isFormValid;
|
||||
final String buttonText;
|
||||
final Function onPressedFunction;
|
||||
final bool? isKeypadOpen;
|
||||
final bool? isFormValid;
|
||||
final String? buttonText;
|
||||
final Function? onPressedFunction;
|
||||
|
||||
const DynamicFAB({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.isKeypadOpen,
|
||||
this.buttonText,
|
||||
this.isFormValid,
|
||||
|
@ -21,7 +21,7 @@ class DynamicFAB extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (isKeypadOpen) {
|
||||
if (isKeypadOpen!) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
|
@ -43,13 +43,13 @@ class DynamicFAB extends StatelessWidget {
|
|||
Theme.of(context).colorScheme.dynamicFABBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.dynamicFABTextColor,
|
||||
onPressed: isFormValid
|
||||
? onPressedFunction
|
||||
onPressed: isFormValid!
|
||||
? onPressedFunction as void Function()?
|
||||
: () {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
child: Transform.rotate(
|
||||
angle: isFormValid ? 0 : math.pi / 2,
|
||||
angle: isFormValid! ? 0 : math.pi / 2,
|
||||
child: const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 36,
|
||||
|
@ -65,8 +65,8 @@ class DynamicFAB extends StatelessWidget {
|
|||
height: 56,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: OutlinedButton(
|
||||
onPressed: isFormValid ? onPressedFunction : null,
|
||||
child: Text(buttonText),
|
||||
onPressed: isFormValid! ? onPressedFunction as void Function()? : null,
|
||||
child: Text(buttonText!),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -75,17 +75,17 @@ class DynamicFAB extends StatelessWidget {
|
|||
|
||||
class NoScalingAnimation extends FloatingActionButtonAnimator {
|
||||
@override
|
||||
Offset getOffset({Offset begin, Offset end, double progress}) {
|
||||
Offset getOffset({Offset? begin, required Offset end, double? progress}) {
|
||||
return end;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientButton extends StatelessWidget {
|
||||
final List<Color> linearGradientColors;
|
||||
final Function onTap;
|
||||
final Function? onTap;
|
||||
|
||||
// text is ignored if child is specified
|
||||
final String text;
|
||||
|
||||
// nullable
|
||||
final IconData iconData;
|
||||
final IconData? iconData;
|
||||
|
||||
// padding between the text and icon
|
||||
final double paddingValue;
|
||||
|
||||
const GradientButton({
|
||||
Key key,
|
||||
Key? key,
|
||||
this.linearGradientColors = const [
|
||||
Color.fromARGB(255, 133, 44, 210),
|
||||
Color.fromARGB(255, 187, 26, 93),
|
||||
|
@ -64,7 +64,7 @@ class GradientButton extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
onTap: onTap as void Function()?,
|
||||
child: Container(
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -6,14 +6,14 @@ import 'package:flutter/material.dart';
|
|||
class LinearProgressDialog extends StatefulWidget {
|
||||
final String message;
|
||||
|
||||
const LinearProgressDialog(this.message, {Key key}) : super(key: key);
|
||||
const LinearProgressDialog(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
LinearProgressDialogState createState() => LinearProgressDialogState();
|
||||
}
|
||||
|
||||
class LinearProgressDialogState extends State<LinearProgressDialog> {
|
||||
double _progress;
|
||||
double? _progress;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum ProgressDialogType { normal, download }
|
||||
|
@ -7,7 +5,7 @@ enum ProgressDialogType { normal, download }
|
|||
String _dialogMessage = "Loading...";
|
||||
double _progress = 0.0, _maxProgress = 100.0;
|
||||
|
||||
Widget _customBody;
|
||||
Widget? _customBody;
|
||||
|
||||
TextAlign _textAlign = TextAlign.left;
|
||||
Alignment _progressWidgetAlignment = Alignment.centerLeft;
|
||||
|
@ -15,10 +13,10 @@ Alignment _progressWidgetAlignment = Alignment.centerLeft;
|
|||
TextDirection _direction = TextDirection.ltr;
|
||||
|
||||
bool _isShowing = false;
|
||||
BuildContext _context, _dismissingContext;
|
||||
ProgressDialogType _progressDialogType;
|
||||
BuildContext? _context, _dismissingContext;
|
||||
ProgressDialogType? _progressDialogType;
|
||||
bool _barrierDismissible = true, _showLogs = false;
|
||||
Color _barrierColor;
|
||||
Color? _barrierColor;
|
||||
|
||||
TextStyle _progressTextStyle = const TextStyle(
|
||||
color: Colors.black,
|
||||
|
@ -42,16 +40,16 @@ Widget _progressWidget = Image.asset(
|
|||
);
|
||||
|
||||
class ProgressDialog {
|
||||
_Body _dialog;
|
||||
_Body? _dialog;
|
||||
|
||||
ProgressDialog(
|
||||
BuildContext context, {
|
||||
ProgressDialogType type,
|
||||
bool isDismissible,
|
||||
bool showLogs,
|
||||
TextDirection textDirection,
|
||||
Widget customBody,
|
||||
Color barrierColor,
|
||||
ProgressDialogType? type,
|
||||
bool? isDismissible,
|
||||
bool? showLogs,
|
||||
TextDirection? textDirection,
|
||||
Widget? customBody,
|
||||
Color? barrierColor,
|
||||
}) {
|
||||
_context = context;
|
||||
_progressDialogType = type ?? ProgressDialogType.normal;
|
||||
|
@ -63,20 +61,20 @@ class ProgressDialog {
|
|||
}
|
||||
|
||||
void style({
|
||||
Widget child,
|
||||
double progress,
|
||||
double maxProgress,
|
||||
String message,
|
||||
Widget progressWidget,
|
||||
Color backgroundColor,
|
||||
TextStyle progressTextStyle,
|
||||
TextStyle messageTextStyle,
|
||||
double elevation,
|
||||
TextAlign textAlign,
|
||||
double borderRadius,
|
||||
Curve insetAnimCurve,
|
||||
EdgeInsets padding,
|
||||
Alignment progressWidgetAlignment,
|
||||
Widget? child,
|
||||
double? progress,
|
||||
double? maxProgress,
|
||||
String? message,
|
||||
Widget? progressWidget,
|
||||
Color? backgroundColor,
|
||||
TextStyle? progressTextStyle,
|
||||
TextStyle? messageTextStyle,
|
||||
double? elevation,
|
||||
TextAlign? textAlign,
|
||||
double? borderRadius,
|
||||
Curve? insetAnimCurve,
|
||||
EdgeInsets? padding,
|
||||
Alignment? progressWidgetAlignment,
|
||||
}) {
|
||||
if (_isShowing) return;
|
||||
if (_progressDialogType == ProgressDialogType.download) {
|
||||
|
@ -100,12 +98,12 @@ class ProgressDialog {
|
|||
}
|
||||
|
||||
void update({
|
||||
double progress,
|
||||
double maxProgress,
|
||||
String message,
|
||||
Widget progressWidget,
|
||||
TextStyle progressTextStyle,
|
||||
TextStyle messageTextStyle,
|
||||
double? progress,
|
||||
double? maxProgress,
|
||||
String? message,
|
||||
Widget? progressWidget,
|
||||
TextStyle? progressTextStyle,
|
||||
TextStyle? messageTextStyle,
|
||||
}) {
|
||||
if (_progressDialogType == ProgressDialogType.download) {
|
||||
_progress = progress ?? _progress;
|
||||
|
@ -117,7 +115,7 @@ class ProgressDialog {
|
|||
_messageStyle = messageTextStyle ?? _messageStyle;
|
||||
_progressTextStyle = progressTextStyle ?? _progressTextStyle;
|
||||
|
||||
if (_isShowing) _dialog.update();
|
||||
if (_isShowing) _dialog!.update();
|
||||
}
|
||||
|
||||
bool isShowing() {
|
||||
|
@ -128,7 +126,9 @@ class ProgressDialog {
|
|||
try {
|
||||
if (_isShowing) {
|
||||
_isShowing = false;
|
||||
Navigator.of(_dismissingContext).pop();
|
||||
if (_dismissingContext != null) {
|
||||
Navigator.of(_dismissingContext!).pop();
|
||||
}
|
||||
if (_showLogs) debugPrint('ProgressDialog dismissed');
|
||||
return Future.value(true);
|
||||
} else {
|
||||
|
@ -147,7 +147,7 @@ class ProgressDialog {
|
|||
if (!_isShowing) {
|
||||
_dialog = _Body();
|
||||
showDialog<dynamic>(
|
||||
context: _context,
|
||||
context: _context!,
|
||||
barrierDismissible: _barrierDismissible,
|
||||
barrierColor: _barrierColor,
|
||||
builder: (BuildContext context) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/utils/dialog_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -8,7 +8,7 @@ class RenameDialog extends StatefulWidget {
|
|||
final String type;
|
||||
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);
|
||||
|
||||
@override
|
||||
|
@ -16,7 +16,7 @@ class RenameDialog extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _RenameDialogState extends State<RenameDialog> {
|
||||
String _newName;
|
||||
String? _newName;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -74,7 +74,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
|||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (_newName.trim().isEmpty) {
|
||||
if (_newName!.trim().isEmpty) {
|
||||
showErrorDialog(
|
||||
context,
|
||||
"Empty name",
|
||||
|
@ -82,7 +82,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
|||
);
|
||||
return;
|
||||
}
|
||||
if (_newName.trim().length > widget.maxLength) {
|
||||
if (_newName!.trim().length > widget.maxLength) {
|
||||
showErrorDialog(
|
||||
context,
|
||||
"Name too large",
|
||||
|
@ -90,7 +90,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
|||
);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop(_newName.trim());
|
||||
Navigator.of(context).pop(_newName!.trim());
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/ui/common/loading_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
|
@ -8,7 +6,7 @@ class WebPage extends StatefulWidget {
|
|||
final String title;
|
||||
final String url;
|
||||
|
||||
const WebPage(this.title, this.url, {Key key}) : super(key: key);
|
||||
const WebPage(this.title, this.url, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<WebPage> createState() => _WebPageState();
|
||||
|
|
221
lib/ui/components/action_sheet_widget.dart
Normal file
221
lib/ui/components/action_sheet_widget.dart
Normal 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)),
|
||||
);
|
||||
}
|
||||
}
|
526
lib/ui/components/buttons/button_widget.dart
Normal file
526
lib/ui/components/buttons/button_widget.dart
Normal file
|
@ -0,0 +1,526 @@
|
|||
import 'package:ente_auth/models/execution_states.dart';
|
||||
import 'package:ente_auth/models/typedefs.dart';
|
||||
import 'package:ente_auth/theme/colors.dart';
|
||||
import 'package:ente_auth/theme/ente_theme.dart';
|
||||
import 'package:ente_auth/theme/text_style.dart';
|
||||
import 'package:ente_auth/ui/common/loading_widget.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/models/custom_button_style.dart';
|
||||
import 'package:ente_auth/utils/debouncer.dart';
|
||||
import "package:ente_auth/utils/dialog_util.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
enum ButtonSize { small, large }
|
||||
|
||||
enum ButtonAction { first, second, third, fourth, cancel, error }
|
||||
|
||||
class ButtonWidget extends StatelessWidget {
|
||||
final IconData? icon;
|
||||
final String? labelText;
|
||||
final ButtonType buttonType;
|
||||
final FutureVoidCallback? onTap;
|
||||
final bool isDisabled;
|
||||
final ButtonSize buttonSize;
|
||||
|
||||
///Setting this flag to true will show a success confirmation as a 'check'
|
||||
///icon once the onTap(). This is expected to be used only if time taken to
|
||||
///execute onTap() takes less than debouce time.
|
||||
final bool shouldShowSuccessConfirmation;
|
||||
|
||||
///Setting this flag to false will restrict the loading and success states of
|
||||
///the button from surfacing on the UI. The ExecutionState of the button will
|
||||
///change irrespective of the value of this flag. Only that it won't be
|
||||
///surfaced on the UI
|
||||
final bool shouldSurfaceExecutionStates;
|
||||
|
||||
/// iconColor should only be specified when we do not want to honor the default
|
||||
/// iconColor based on buttonType. Most of the items, default iconColor is what
|
||||
/// we need unless we want to pop out the icon in a non-primary button type
|
||||
final Color? iconColor;
|
||||
|
||||
///Button action will only work if isInAlert is true
|
||||
final ButtonAction? buttonAction;
|
||||
|
||||
///setting this flag to true will make the button appear like how it would
|
||||
///on dark theme irrespective of the app's theme.
|
||||
final bool shouldStickToDarkTheme;
|
||||
|
||||
///isInAlert is to dismiss the alert if the action on the button is completed.
|
||||
///This should be set to true if the alert which uses this button needs to
|
||||
///return the Button's action.
|
||||
final bool isInAlert;
|
||||
|
||||
/// progressStatus can be used to display information about the action
|
||||
/// progress when ExecutionState is in Progress.
|
||||
final ValueNotifier<String>? progressStatus;
|
||||
|
||||
const ButtonWidget({
|
||||
Key? key,
|
||||
required this.buttonType,
|
||||
this.buttonSize = ButtonSize.large,
|
||||
this.icon,
|
||||
this.labelText,
|
||||
this.onTap,
|
||||
this.shouldStickToDarkTheme = false,
|
||||
this.isDisabled = false,
|
||||
this.buttonAction,
|
||||
this.isInAlert = false,
|
||||
this.iconColor,
|
||||
this.shouldSurfaceExecutionStates = true,
|
||||
this.progressStatus,
|
||||
this.shouldShowSuccessConfirmation = false,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme =
|
||||
shouldStickToDarkTheme ? darkScheme : getEnteColorScheme(context);
|
||||
final inverseColorScheme = shouldStickToDarkTheme
|
||||
? lightScheme
|
||||
: getEnteColorScheme(context, inverse: true);
|
||||
final textTheme =
|
||||
shouldStickToDarkTheme ? darkTextTheme : getEnteTextTheme(context);
|
||||
final inverseTextTheme = shouldStickToDarkTheme
|
||||
? lightTextTheme
|
||||
: getEnteTextTheme(context, inverse: true);
|
||||
final buttonStyle = CustomButtonStyle(
|
||||
//Dummy default values since we need to keep these properties non-nullable
|
||||
defaultButtonColor: Colors.transparent,
|
||||
defaultBorderColor: Colors.transparent,
|
||||
defaultIconColor: Colors.transparent,
|
||||
defaultLabelStyle: textTheme.body,
|
||||
);
|
||||
buttonStyle.defaultButtonColor = buttonType.defaultButtonColor(colorScheme);
|
||||
buttonStyle.pressedButtonColor = buttonType.pressedButtonColor(colorScheme);
|
||||
buttonStyle.disabledButtonColor =
|
||||
buttonType.disabledButtonColor(colorScheme, buttonSize);
|
||||
buttonStyle.defaultBorderColor =
|
||||
buttonType.defaultBorderColor(colorScheme, buttonSize);
|
||||
buttonStyle.pressedBorderColor = buttonType.pressedBorderColor(
|
||||
colorScheme: colorScheme,
|
||||
buttonSize: buttonSize,
|
||||
);
|
||||
buttonStyle.disabledBorderColor =
|
||||
buttonType.disabledBorderColor(colorScheme, buttonSize);
|
||||
buttonStyle.defaultIconColor = iconColor ??
|
||||
buttonType.defaultIconColor(
|
||||
colorScheme: colorScheme,
|
||||
inverseColorScheme: inverseColorScheme,
|
||||
);
|
||||
buttonStyle.pressedIconColor =
|
||||
buttonType.pressedIconColor(colorScheme, buttonSize);
|
||||
buttonStyle.disabledIconColor =
|
||||
buttonType.disabledIconColor(colorScheme, buttonSize);
|
||||
buttonStyle.defaultLabelStyle = buttonType.defaultLabelStyle(
|
||||
textTheme: textTheme,
|
||||
inverseTextTheme: inverseTextTheme,
|
||||
);
|
||||
buttonStyle.pressedLabelStyle =
|
||||
buttonType.pressedLabelStyle(textTheme, colorScheme, buttonSize);
|
||||
buttonStyle.disabledLabelStyle =
|
||||
buttonType.disabledLabelStyle(textTheme, colorScheme);
|
||||
buttonStyle.checkIconColor = buttonType.checkIconColor(colorScheme);
|
||||
|
||||
return ButtonChildWidget(
|
||||
buttonStyle: buttonStyle,
|
||||
buttonType: buttonType,
|
||||
isDisabled: isDisabled,
|
||||
buttonSize: buttonSize,
|
||||
isInAlert: isInAlert,
|
||||
onTap: onTap,
|
||||
labelText: labelText,
|
||||
icon: icon,
|
||||
buttonAction: buttonAction,
|
||||
shouldSurfaceExecutionStates: shouldSurfaceExecutionStates,
|
||||
progressStatus: progressStatus,
|
||||
shouldShowSuccessConfirmation: shouldShowSuccessConfirmation,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ButtonChildWidget extends StatefulWidget {
|
||||
final CustomButtonStyle buttonStyle;
|
||||
final FutureVoidCallback? onTap;
|
||||
final ButtonType buttonType;
|
||||
final String? labelText;
|
||||
final IconData? icon;
|
||||
final bool isDisabled;
|
||||
final ButtonSize buttonSize;
|
||||
final ButtonAction? buttonAction;
|
||||
final bool isInAlert;
|
||||
final bool shouldSurfaceExecutionStates;
|
||||
final ValueNotifier<String>? progressStatus;
|
||||
final bool shouldShowSuccessConfirmation;
|
||||
|
||||
const ButtonChildWidget({
|
||||
Key? key,
|
||||
required this.buttonStyle,
|
||||
required this.buttonType,
|
||||
required this.isDisabled,
|
||||
required this.buttonSize,
|
||||
required this.isInAlert,
|
||||
required this.shouldSurfaceExecutionStates,
|
||||
required this.shouldShowSuccessConfirmation,
|
||||
this.progressStatus,
|
||||
this.onTap,
|
||||
this.labelText,
|
||||
this.icon,
|
||||
this.buttonAction,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ButtonChildWidget> createState() => _ButtonChildWidgetState();
|
||||
}
|
||||
|
||||
class _ButtonChildWidgetState extends State<ButtonChildWidget> {
|
||||
late Color buttonColor;
|
||||
late Color borderColor;
|
||||
late Color iconColor;
|
||||
late TextStyle labelStyle;
|
||||
late Color checkIconColor;
|
||||
late Color loadingIconColor;
|
||||
ValueNotifier<String>? progressStatus;
|
||||
|
||||
///This is used to store the width of the button in idle state (small button)
|
||||
///to be used as width for the button when the loading/succes states comes.
|
||||
double? widthOfButton;
|
||||
final _debouncer = Debouncer(const Duration(milliseconds: 300));
|
||||
ExecutionState executionState = ExecutionState.idle;
|
||||
Exception? _exception;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_setButtonTheme();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant ButtonChildWidget oldWidget) {
|
||||
_setButtonTheme();
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (executionState == ExecutionState.successful) {
|
||||
Future.delayed(Duration(seconds: widget.isInAlert ? 1 : 2), () {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
});
|
||||
});
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: _shouldRegisterGestures ? _onTap : null,
|
||||
onTapDown: _shouldRegisterGestures ? _onTapDown : null,
|
||||
onTapUp: _shouldRegisterGestures ? _onTapUp : null,
|
||||
onTapCancel: _shouldRegisterGestures ? _onTapCancel : null,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||
border: widget.buttonType == ButtonType.tertiaryCritical
|
||||
? Border.all(color: borderColor)
|
||||
: null,
|
||||
),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 16),
|
||||
width: widget.buttonSize == ButtonSize.large ? double.infinity : null,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||
color: buttonColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 175),
|
||||
switchInCurve: Curves.easeInOutExpo,
|
||||
switchOutCurve: Curves.easeInOutExpo,
|
||||
child: executionState == ExecutionState.idle ||
|
||||
!widget.shouldSurfaceExecutionStates
|
||||
? widget.buttonType.hasTrailingIcon
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
widget.labelText == null
|
||||
? const SizedBox.shrink()
|
||||
: Flexible(
|
||||
child: Padding(
|
||||
padding: widget.icon == null
|
||||
? const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
)
|
||||
: const EdgeInsets.only(right: 16),
|
||||
child: Text(
|
||||
widget.labelText!,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 2,
|
||||
style: labelStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
widget.icon == null
|
||||
? const SizedBox.shrink()
|
||||
: Icon(
|
||||
widget.icon,
|
||||
size: 20,
|
||||
color: iconColor,
|
||||
),
|
||||
],
|
||||
)
|
||||
: Builder(
|
||||
builder: (context) {
|
||||
SchedulerBinding.instance.addPostFrameCallback(
|
||||
(timeStamp) {
|
||||
final box =
|
||||
context.findRenderObject() as RenderBox;
|
||||
widthOfButton = box.size.width;
|
||||
},
|
||||
);
|
||||
return Row(
|
||||
mainAxisSize:
|
||||
widget.buttonSize == ButtonSize.large
|
||||
? MainAxisSize.max
|
||||
: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
widget.icon == null
|
||||
? const SizedBox.shrink()
|
||||
: Icon(
|
||||
widget.icon,
|
||||
size: 20,
|
||||
color: iconColor,
|
||||
),
|
||||
widget.icon == null || widget.labelText == null
|
||||
? const SizedBox.shrink()
|
||||
: const SizedBox(width: 8),
|
||||
widget.labelText == null
|
||||
? const SizedBox.shrink()
|
||||
: Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
),
|
||||
child: Text(
|
||||
widget.labelText!,
|
||||
style: labelStyle,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
)
|
||||
: executionState == ExecutionState.inProgress
|
||||
? SizedBox(
|
||||
width: widthOfButton,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
progressStatus == null
|
||||
? const SizedBox.shrink()
|
||||
: ValueListenableBuilder<String>(
|
||||
valueListenable: progressStatus!,
|
||||
builder: (
|
||||
BuildContext context,
|
||||
String value,
|
||||
Widget? child,
|
||||
) {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(right: 8.0),
|
||||
child: Text(
|
||||
value,
|
||||
style: lightTextTheme.smallBold,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
EnteLoadingWidget(
|
||||
padding: 3,
|
||||
color: loadingIconColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: executionState == ExecutionState.successful
|
||||
? SizedBox(
|
||||
width: widthOfButton,
|
||||
child: Icon(
|
||||
Icons.check_outlined,
|
||||
size: 20,
|
||||
color: checkIconColor,
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(), //fallback
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _setButtonTheme() {
|
||||
progressStatus = widget.progressStatus;
|
||||
checkIconColor = widget.buttonStyle.checkIconColor ??
|
||||
widget.buttonStyle.defaultIconColor;
|
||||
loadingIconColor = widget.buttonStyle.defaultIconColor;
|
||||
if (widget.isDisabled) {
|
||||
buttonColor = widget.buttonStyle.disabledButtonColor ??
|
||||
widget.buttonStyle.defaultButtonColor;
|
||||
borderColor = widget.buttonStyle.disabledBorderColor ??
|
||||
widget.buttonStyle.defaultBorderColor;
|
||||
iconColor = widget.buttonStyle.disabledIconColor ??
|
||||
widget.buttonStyle.defaultIconColor;
|
||||
labelStyle = widget.buttonStyle.disabledLabelStyle ??
|
||||
widget.buttonStyle.defaultLabelStyle;
|
||||
} else {
|
||||
buttonColor = widget.buttonStyle.defaultButtonColor;
|
||||
borderColor = widget.buttonStyle.defaultBorderColor;
|
||||
iconColor = widget.buttonStyle.defaultIconColor;
|
||||
labelStyle = widget.buttonStyle.defaultLabelStyle;
|
||||
}
|
||||
}
|
||||
|
||||
bool get _shouldRegisterGestures =>
|
||||
!widget.isDisabled && executionState == ExecutionState.idle;
|
||||
|
||||
void _onTap() async {
|
||||
if (widget.onTap != null) {
|
||||
_debouncer.run(
|
||||
() => Future(() {
|
||||
setState(() {
|
||||
executionState = ExecutionState.inProgress;
|
||||
});
|
||||
}),
|
||||
);
|
||||
await widget.onTap!.call().then(
|
||||
(value) {
|
||||
_exception = null;
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
executionState = ExecutionState.error;
|
||||
_exception = error as Exception;
|
||||
_debouncer.cancelDebounce();
|
||||
},
|
||||
);
|
||||
widget.shouldShowSuccessConfirmation && _debouncer.isActive()
|
||||
? executionState = ExecutionState.successful
|
||||
: null;
|
||||
_debouncer.cancelDebounce();
|
||||
if (executionState == ExecutionState.successful) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
// when the time taken by widget.onTap is approximately equal to the debounce
|
||||
// time, the callback is getting executed when/after the if condition
|
||||
// below is executing/executed which results in execution state stuck at
|
||||
// idle state. This Future is for delaying the execution of the if
|
||||
// condition so that the calback in the debouncer finishes execution before.
|
||||
await Future.delayed(const Duration(milliseconds: 5));
|
||||
}
|
||||
if (executionState == ExecutionState.inProgress ||
|
||||
executionState == ExecutionState.error) {
|
||||
if (executionState == ExecutionState.inProgress) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
executionState = ExecutionState.successful;
|
||||
Future.delayed(
|
||||
Duration(
|
||||
seconds: widget.shouldSurfaceExecutionStates
|
||||
? (widget.isInAlert ? 1 : 2)
|
||||
: 0,
|
||||
), () {
|
||||
widget.isInAlert
|
||||
? _popWithButtonAction(
|
||||
context,
|
||||
buttonAction: widget.buttonAction,
|
||||
)
|
||||
: null;
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
if (executionState == ExecutionState.error) {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
widget.isInAlert
|
||||
? Future.delayed(
|
||||
const Duration(seconds: 0),
|
||||
() => _popWithButtonAction(
|
||||
context,
|
||||
buttonAction: ButtonAction.error,
|
||||
exception: _exception,
|
||||
),
|
||||
)
|
||||
: null;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (widget.isInAlert) {
|
||||
Future.delayed(
|
||||
Duration(seconds: widget.shouldShowSuccessConfirmation ? 1 : 0),
|
||||
() =>
|
||||
_popWithButtonAction(context, buttonAction: widget.buttonAction),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _popWithButtonAction(
|
||||
BuildContext context, {
|
||||
required ButtonAction? buttonAction,
|
||||
Exception? exception,
|
||||
}) {
|
||||
if (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop(ButtonResult(widget.buttonAction, exception));
|
||||
} else if (exception != null) {
|
||||
//This is to show the execution was unsuccessful if the dialog is manually
|
||||
//closed before the execution completes.
|
||||
showGenericErrorDialog(context: context);
|
||||
}
|
||||
}
|
||||
|
||||
void _onTapDown(details) {
|
||||
setState(() {
|
||||
buttonColor = widget.buttonStyle.pressedButtonColor ??
|
||||
widget.buttonStyle.defaultButtonColor;
|
||||
borderColor = widget.buttonStyle.pressedBorderColor ??
|
||||
widget.buttonStyle.defaultBorderColor;
|
||||
iconColor = widget.buttonStyle.pressedIconColor ??
|
||||
widget.buttonStyle.defaultIconColor;
|
||||
labelStyle = widget.buttonStyle.pressedLabelStyle ??
|
||||
widget.buttonStyle.defaultLabelStyle;
|
||||
});
|
||||
}
|
||||
|
||||
void _onTapUp(details) {
|
||||
Future.delayed(
|
||||
const Duration(milliseconds: 84),
|
||||
() => setState(() {
|
||||
setAllStylesToDefault();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
void _onTapCancel() {
|
||||
setState(() {
|
||||
setAllStylesToDefault();
|
||||
});
|
||||
}
|
||||
|
||||
void setAllStylesToDefault() {
|
||||
buttonColor = widget.buttonStyle.defaultButtonColor;
|
||||
borderColor = widget.buttonStyle.defaultBorderColor;
|
||||
iconColor = widget.buttonStyle.defaultIconColor;
|
||||
labelStyle = widget.buttonStyle.defaultLabelStyle;
|
||||
}
|
||||
}
|
4
lib/ui/components/components_constants.dart
Normal file
4
lib/ui/components/components_constants.dart
Normal 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;
|
286
lib/ui/components/dialog_widget.dart
Normal file
286
lib/ui/components/dialog_widget.dart
Normal file
|
@ -0,0 +1,286 @@
|
|||
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';
|
||||
|
||||
///Will return null if dismissed by tapping outside
|
||||
Future<ButtonResult?> showDialogWidget({
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
String? body,
|
||||
required List<ButtonWidget> buttons,
|
||||
IconData? icon,
|
||||
bool isDismissible = true,
|
||||
}) {
|
||||
return showDialog(
|
||||
barrierDismissible: isDismissible,
|
||||
barrierColor: backdropFaintDark,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
final widthOfScreen = MediaQuery.of(context).size.width;
|
||||
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: isMobileSmall ? 8 : 0),
|
||||
child: Dialog(
|
||||
insetPadding: EdgeInsets.zero,
|
||||
child: DialogWidget(
|
||||
title: title,
|
||||
body: body,
|
||||
buttons: buttons,
|
||||
icon: icon,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class DialogWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String? body;
|
||||
final List<ButtonWidget> buttons;
|
||||
final IconData? icon;
|
||||
const DialogWidget({
|
||||
required this.title,
|
||||
this.body,
|
||||
required this.buttons,
|
||||
this.icon,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final widthOfScreen = MediaQuery.of(context).size.width;
|
||||
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
|
||||
final colorScheme = getEnteColorScheme(context);
|
||||
return Container(
|
||||
width: min(widthOfScreen, 320),
|
||||
padding: isMobileSmall
|
||||
? const EdgeInsets.all(0)
|
||||
: const EdgeInsets.fromLTRB(6, 8, 6, 6),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.backgroundElevated,
|
||||
boxShadow: shadowFloatLight,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ContentContainer(
|
||||
title: title,
|
||||
body: body,
|
||||
icon: icon,
|
||||
),
|
||||
const SizedBox(height: 36),
|
||||
Actions(buttons),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ContentContainer extends StatelessWidget {
|
||||
final String title;
|
||||
final String? body;
|
||||
final IconData? icon;
|
||||
const ContentContainer({
|
||||
required this.title,
|
||||
this.body,
|
||||
this.icon,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textTheme = getEnteTextTheme(context);
|
||||
final colorScheme = getEnteColorScheme(context);
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
icon == null
|
||||
? const SizedBox.shrink()
|
||||
: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 32,
|
||||
),
|
||||
],
|
||||
),
|
||||
icon == null ? const SizedBox.shrink() : const SizedBox(height: 19),
|
||||
Text(title, style: textTheme.largeBold),
|
||||
body != null ? const SizedBox(height: 19) : const SizedBox.shrink(),
|
||||
body != null
|
||||
? Text(
|
||||
body!,
|
||||
style: textTheme.body.copyWith(color: colorScheme.textMuted),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Actions extends StatelessWidget {
|
||||
final List<ButtonWidget> buttons;
|
||||
const Actions(this.buttons, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: addSeparators(
|
||||
buttons,
|
||||
const SizedBox(
|
||||
// In figma this white space is of height 8pts. But the Button
|
||||
// component has 1pts of invisible border by default in code. So two
|
||||
// 1pts borders will visually make the whitespace 8pts.
|
||||
// Height of button component in figma = 48, in code = 50 (2pts for
|
||||
// top + bottom border)
|
||||
height: 6,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TextInputDialog extends StatefulWidget {
|
||||
final String title;
|
||||
final String? body;
|
||||
final String submitButtonLabel;
|
||||
final IconData? icon;
|
||||
final String? label;
|
||||
final String? message;
|
||||
final FutureVoidCallbackParamStr onSubmit;
|
||||
final String? hintText;
|
||||
final IconData? prefixIcon;
|
||||
final String? initialValue;
|
||||
final Alignment? alignMessage;
|
||||
final int? maxLength;
|
||||
final bool showOnlyLoadingState;
|
||||
final TextCapitalization? textCapitalization;
|
||||
final bool alwaysShowSuccessState;
|
||||
final bool isPasswordInput;
|
||||
const TextInputDialog({
|
||||
required this.title,
|
||||
this.body,
|
||||
required this.submitButtonLabel,
|
||||
required this.onSubmit,
|
||||
this.icon,
|
||||
this.label,
|
||||
this.message,
|
||||
this.hintText,
|
||||
this.prefixIcon,
|
||||
this.initialValue,
|
||||
this.alignMessage,
|
||||
this.maxLength,
|
||||
this.textCapitalization,
|
||||
this.showOnlyLoadingState = false,
|
||||
this.alwaysShowSuccessState = false,
|
||||
this.isPasswordInput = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TextInputDialog> createState() => _TextInputDialogState();
|
||||
}
|
||||
|
||||
class _TextInputDialogState extends State<TextInputDialog> {
|
||||
//the value of this ValueNotifier has no significance
|
||||
final _submitNotifier = ValueNotifier(false);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_submitNotifier.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final widthOfScreen = MediaQuery.of(context).size.width;
|
||||
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
|
||||
final colorScheme = getEnteColorScheme(context);
|
||||
return Container(
|
||||
width: min(widthOfScreen, 320),
|
||||
padding: isMobileSmall
|
||||
? const EdgeInsets.all(0)
|
||||
: const EdgeInsets.fromLTRB(6, 8, 6, 6),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.backgroundElevated,
|
||||
boxShadow: shadowFloatLight,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ContentContainer(
|
||||
title: widget.title,
|
||||
body: widget.body,
|
||||
icon: widget.icon,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 19),
|
||||
child: TextInputWidget(
|
||||
label: widget.label,
|
||||
message: widget.message,
|
||||
hintText: widget.hintText,
|
||||
prefixIcon: widget.prefixIcon,
|
||||
initialValue: widget.initialValue,
|
||||
alignMessage: widget.alignMessage,
|
||||
autoFocus: true,
|
||||
maxLength: widget.maxLength,
|
||||
submitNotifier: _submitNotifier,
|
||||
onSubmit: widget.onSubmit,
|
||||
popNavAfterSubmission: true,
|
||||
showOnlyLoadingState: widget.showOnlyLoadingState,
|
||||
textCapitalization: widget.textCapitalization,
|
||||
alwaysShowSuccessState: widget.alwaysShowSuccessState,
|
||||
isPasswordInput: widget.isPasswordInput,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 36),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ButtonWidget(
|
||||
buttonType: ButtonType.secondary,
|
||||
buttonSize: ButtonSize.small,
|
||||
labelText: context.l10n.cancel,
|
||||
isInAlert: true,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: ButtonWidget(
|
||||
buttonSize: ButtonSize.small,
|
||||
buttonType: ButtonType.neutral,
|
||||
labelText: widget.submitButtonLabel,
|
||||
onTap: () async {
|
||||
_submitNotifier.value = !_submitNotifier.value;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -69,7 +69,7 @@ class _ExpandableMenuItemWidgetState extends State<ExpandableMenuItemWidget> {
|
|||
),
|
||||
collapsed: const SizedBox.shrink(),
|
||||
expanded: widget.selectionOptionsWidget,
|
||||
theme: getExpandableTheme(context),
|
||||
theme: getExpandableTheme(),
|
||||
controller: expandableController,
|
||||
),
|
||||
),
|
||||
|
|
11
lib/ui/components/models/button_result.dart
Normal file
11
lib/ui/components/models/button_result.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
|
||||
|
||||
class ButtonResult {
|
||||
///action can be null when action for the button that is returned when popping
|
||||
///the widget (dialog, actionSheet) which uses a ButtonWidget isn't
|
||||
///relevant/useful and so is not assigned a value when an instance of
|
||||
///ButtonWidget is created.
|
||||
final ButtonAction? action;
|
||||
final Exception? exception;
|
||||
ButtonResult([this.action, this.exception]);
|
||||
}
|
205
lib/ui/components/models/button_type.dart
Normal file
205
lib/ui/components/models/button_type.dart
Normal file
|
@ -0,0 +1,205 @@
|
|||
import 'package:ente_auth/theme/colors.dart';
|
||||
import 'package:ente_auth/theme/text_style.dart';
|
||||
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum ButtonType {
|
||||
primary,
|
||||
secondary,
|
||||
neutral,
|
||||
trailingIcon,
|
||||
critical,
|
||||
tertiaryCritical,
|
||||
trailingIconPrimary,
|
||||
trailingIconSecondary,
|
||||
tertiary;
|
||||
|
||||
bool get isPrimary =>
|
||||
this == ButtonType.primary || this == ButtonType.trailingIconPrimary;
|
||||
|
||||
bool get hasTrailingIcon =>
|
||||
this == ButtonType.trailingIcon ||
|
||||
this == ButtonType.trailingIconPrimary ||
|
||||
this == ButtonType.trailingIconSecondary;
|
||||
|
||||
bool get isSecondary =>
|
||||
this == ButtonType.secondary || this == ButtonType.trailingIconSecondary;
|
||||
|
||||
bool get isCritical =>
|
||||
this == ButtonType.critical || this == ButtonType.tertiaryCritical;
|
||||
|
||||
bool get isNeutral =>
|
||||
this == ButtonType.neutral || this == ButtonType.trailingIcon;
|
||||
|
||||
Color defaultButtonColor(EnteColorScheme colorScheme) {
|
||||
if (isPrimary) {
|
||||
return colorScheme.primary500;
|
||||
}
|
||||
if (isSecondary) {
|
||||
return colorScheme.fillFaint;
|
||||
}
|
||||
if (this == ButtonType.neutral || this == ButtonType.trailingIcon) {
|
||||
return colorScheme.fillBase;
|
||||
}
|
||||
if (this == ButtonType.critical) {
|
||||
return colorScheme.warning700;
|
||||
}
|
||||
if (this == ButtonType.tertiaryCritical) {
|
||||
return Colors.transparent;
|
||||
}
|
||||
return Colors.transparent;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? pressedButtonColor(EnteColorScheme colorScheme) {
|
||||
if (isPrimary) {
|
||||
return colorScheme.primary700;
|
||||
}
|
||||
if (isSecondary) {
|
||||
return colorScheme.fillFaintPressed;
|
||||
}
|
||||
if (isNeutral) {
|
||||
return colorScheme.fillBasePressed;
|
||||
}
|
||||
if (this == ButtonType.critical) {
|
||||
return colorScheme.warning800;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? disabledButtonColor(
|
||||
EnteColorScheme colorScheme,
|
||||
ButtonSize buttonSize,
|
||||
) {
|
||||
if (buttonSize == ButtonSize.small &&
|
||||
(this == ButtonType.primary ||
|
||||
this == ButtonType.neutral ||
|
||||
this == ButtonType.critical)) {
|
||||
return colorScheme.fillMuted;
|
||||
}
|
||||
if (isPrimary || this == ButtonType.critical || isNeutral) {
|
||||
return colorScheme.fillFaint;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Color defaultBorderColor(EnteColorScheme colorScheme, ButtonSize buttonSize) {
|
||||
if (this == ButtonType.tertiaryCritical && buttonSize == ButtonSize.large) {
|
||||
return colorScheme.warning700;
|
||||
}
|
||||
return Colors.transparent;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? pressedBorderColor({
|
||||
required EnteColorScheme colorScheme,
|
||||
required ButtonSize buttonSize,
|
||||
}) {
|
||||
if (this == ButtonType.tertiaryCritical && buttonSize == ButtonSize.large) {
|
||||
return colorScheme.warning700;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? disabledBorderColor(
|
||||
EnteColorScheme colorScheme,
|
||||
ButtonSize buttonSize,
|
||||
) {
|
||||
if (this == ButtonType.tertiaryCritical && buttonSize == ButtonSize.large) {
|
||||
return colorScheme.strokeMuted;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Color defaultIconColor({
|
||||
required EnteColorScheme colorScheme,
|
||||
required EnteColorScheme inverseColorScheme,
|
||||
}) {
|
||||
if (isPrimary || this == ButtonType.critical) {
|
||||
return strokeBaseDark;
|
||||
}
|
||||
if (this == ButtonType.neutral || this == ButtonType.trailingIcon) {
|
||||
return inverseColorScheme.strokeBase;
|
||||
}
|
||||
if (this == ButtonType.tertiaryCritical) {
|
||||
return colorScheme.warning500;
|
||||
}
|
||||
//fallback
|
||||
return colorScheme.strokeBase;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? pressedIconColor(EnteColorScheme colorScheme, ButtonSize buttonSize) {
|
||||
if (this == ButtonType.tertiaryCritical) {
|
||||
return colorScheme.warning700;
|
||||
}
|
||||
if (this == ButtonType.tertiary && buttonSize == ButtonSize.small) {
|
||||
return colorScheme.fillBasePressed;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? disabledIconColor(EnteColorScheme colorScheme, ButtonSize buttonSize) {
|
||||
if (isPrimary ||
|
||||
isSecondary ||
|
||||
isNeutral ||
|
||||
buttonSize == ButtonSize.small) {
|
||||
return colorScheme.strokeMuted;
|
||||
}
|
||||
if (isCritical) {
|
||||
return colorScheme.strokeFaint;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
TextStyle defaultLabelStyle({
|
||||
required EnteTextTheme textTheme,
|
||||
required EnteTextTheme inverseTextTheme,
|
||||
}) {
|
||||
if (isPrimary || this == ButtonType.critical) {
|
||||
return textTheme.bodyBold.copyWith(color: textBaseDark);
|
||||
}
|
||||
if (this == ButtonType.neutral || this == ButtonType.trailingIcon) {
|
||||
return inverseTextTheme.bodyBold;
|
||||
}
|
||||
if (this == ButtonType.tertiaryCritical) {
|
||||
return textTheme.bodyBold.copyWith(color: warning500);
|
||||
}
|
||||
//fallback
|
||||
return textTheme.bodyBold;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
TextStyle? pressedLabelStyle(
|
||||
EnteTextTheme textTheme,
|
||||
EnteColorScheme colorScheme,
|
||||
ButtonSize buttonSize,
|
||||
) {
|
||||
if (this == ButtonType.tertiaryCritical) {
|
||||
return textTheme.bodyBold.copyWith(color: colorScheme.warning700);
|
||||
}
|
||||
if (this == ButtonType.tertiary && buttonSize == ButtonSize.small) {
|
||||
return textTheme.bodyBold.copyWith(color: colorScheme.fillBasePressed);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
TextStyle? disabledLabelStyle(
|
||||
EnteTextTheme textTheme,
|
||||
EnteColorScheme colorScheme,
|
||||
) {
|
||||
return textTheme.bodyBold.copyWith(color: colorScheme.textFaint);
|
||||
}
|
||||
|
||||
//Returning null to fallback to default color
|
||||
Color? checkIconColor(EnteColorScheme colorScheme) {
|
||||
if (isSecondary) {
|
||||
return colorScheme.primary500;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
33
lib/ui/components/models/custom_button_style.dart
Normal file
33
lib/ui/components/models/custom_button_style.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomButtonStyle {
|
||||
Color defaultButtonColor;
|
||||
Color? pressedButtonColor;
|
||||
Color? disabledButtonColor;
|
||||
Color defaultBorderColor;
|
||||
Color? pressedBorderColor;
|
||||
Color? disabledBorderColor;
|
||||
Color defaultIconColor;
|
||||
Color? pressedIconColor;
|
||||
Color? disabledIconColor;
|
||||
TextStyle defaultLabelStyle;
|
||||
TextStyle? pressedLabelStyle;
|
||||
TextStyle? disabledLabelStyle;
|
||||
Color? checkIconColor;
|
||||
|
||||
CustomButtonStyle({
|
||||
required this.defaultButtonColor,
|
||||
this.pressedButtonColor,
|
||||
this.disabledButtonColor,
|
||||
required this.defaultBorderColor,
|
||||
this.pressedBorderColor,
|
||||
this.disabledBorderColor,
|
||||
required this.defaultIconColor,
|
||||
this.pressedIconColor,
|
||||
this.disabledIconColor,
|
||||
required this.defaultLabelStyle,
|
||||
this.pressedLabelStyle,
|
||||
this.disabledLabelStyle,
|
||||
this.checkIconColor,
|
||||
});
|
||||
}
|
382
lib/ui/components/text_input_widget.dart
Normal file
382
lib/ui/components/text_input_widget.dart
Normal file
|
@ -0,0 +1,382 @@
|
|||
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/services.dart';
|
||||
|
||||
class TextInputWidget extends StatefulWidget {
|
||||
final String? label;
|
||||
final String? message;
|
||||
final String? hintText;
|
||||
final IconData? prefixIcon;
|
||||
final String? initialValue;
|
||||
final Alignment? alignMessage;
|
||||
final bool? autoFocus;
|
||||
final int? maxLength;
|
||||
|
||||
///TextInputWidget will listen to this notifier and executes onSubmit when
|
||||
///notified.
|
||||
final ValueNotifier? submitNotifier;
|
||||
final bool alwaysShowSuccessState;
|
||||
final bool showOnlyLoadingState;
|
||||
final FutureVoidCallbackParamStr? onSubmit;
|
||||
final VoidCallbackParamStr? onChange;
|
||||
final bool popNavAfterSubmission;
|
||||
final bool shouldSurfaceExecutionStates;
|
||||
final TextCapitalization? textCapitalization;
|
||||
final bool isPasswordInput;
|
||||
final bool cancellable;
|
||||
final bool shouldUnfocusOnCancelOrSubmit;
|
||||
const TextInputWidget({
|
||||
this.onSubmit,
|
||||
this.onChange,
|
||||
this.label,
|
||||
this.message,
|
||||
this.hintText,
|
||||
this.prefixIcon,
|
||||
this.initialValue,
|
||||
this.alignMessage,
|
||||
this.autoFocus,
|
||||
this.maxLength,
|
||||
this.submitNotifier,
|
||||
this.alwaysShowSuccessState = false,
|
||||
this.showOnlyLoadingState = false,
|
||||
this.popNavAfterSubmission = false,
|
||||
this.shouldSurfaceExecutionStates = true,
|
||||
this.textCapitalization = TextCapitalization.none,
|
||||
this.isPasswordInput = false,
|
||||
this.cancellable = false,
|
||||
this.shouldUnfocusOnCancelOrSubmit = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TextInputWidget> createState() => _TextInputWidgetState();
|
||||
}
|
||||
|
||||
class _TextInputWidgetState extends State<TextInputWidget> {
|
||||
ExecutionState executionState = ExecutionState.idle;
|
||||
final _textController = TextEditingController();
|
||||
final _debouncer = Debouncer(const Duration(milliseconds: 300));
|
||||
late final ValueNotifier<bool> _obscureTextNotifier;
|
||||
|
||||
///This is to pass if the TextInputWidget is in a dialog and an error is
|
||||
///thrown in executing onSubmit by passing it as arg in Navigator.pop()
|
||||
Exception? _exception;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
widget.submitNotifier?.addListener(_onSubmit);
|
||||
|
||||
if (widget.initialValue != null) {
|
||||
_textController.value = TextEditingValue(
|
||||
text: widget.initialValue!,
|
||||
selection: TextSelection.collapsed(offset: widget.initialValue!.length),
|
||||
);
|
||||
}
|
||||
if (widget.onChange != null) {
|
||||
_textController.addListener(() {
|
||||
widget.onChange!.call(_textController.text);
|
||||
});
|
||||
}
|
||||
_obscureTextNotifier = ValueNotifier(widget.isPasswordInput);
|
||||
_obscureTextNotifier.addListener(_safeRefresh);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
widget.submitNotifier?.removeListener(_onSubmit);
|
||||
_obscureTextNotifier.dispose();
|
||||
_textController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (executionState == ExecutionState.successful) {
|
||||
Future.delayed(Duration(seconds: widget.popNavAfterSubmission ? 1 : 2),
|
||||
() {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
});
|
||||
});
|
||||
}
|
||||
final colorScheme = getEnteColorScheme(context);
|
||||
final textTheme = getEnteTextTheme(context);
|
||||
var textInputChildren = <Widget>[];
|
||||
if (widget.label != null) {
|
||||
textInputChildren.add(Text(widget.label!));
|
||||
}
|
||||
textInputChildren.add(
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Material(
|
||||
child: TextFormField(
|
||||
textCapitalization: widget.textCapitalization!,
|
||||
autofocus: widget.autoFocus ?? false,
|
||||
controller: _textController,
|
||||
inputFormatters: widget.maxLength != null
|
||||
? [LengthLimitingTextInputFormatter(50)]
|
||||
: null,
|
||||
obscureText: _obscureTextNotifier.value,
|
||||
decoration: InputDecoration(
|
||||
hintText: widget.hintText,
|
||||
hintStyle: textTheme.body.copyWith(color: colorScheme.textMuted),
|
||||
filled: true,
|
||||
fillColor: colorScheme.fillFaint,
|
||||
contentPadding: const EdgeInsets.fromLTRB(
|
||||
12,
|
||||
12,
|
||||
0,
|
||||
12,
|
||||
),
|
||||
border: const UnderlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: colorScheme.strokeFaint),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
suffixIcon: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 175),
|
||||
switchInCurve: Curves.easeInExpo,
|
||||
switchOutCurve: Curves.easeOutExpo,
|
||||
child: SuffixIconWidget(
|
||||
key: ValueKey(executionState),
|
||||
executionState: executionState,
|
||||
shouldSurfaceExecutionStates:
|
||||
widget.shouldSurfaceExecutionStates,
|
||||
obscureTextNotifier: _obscureTextNotifier,
|
||||
isPasswordInput: widget.isPasswordInput,
|
||||
textController: _textController,
|
||||
isCancellable: widget.cancellable,
|
||||
shouldUnfocusOnCancelOrSubmit:
|
||||
widget.shouldUnfocusOnCancelOrSubmit,
|
||||
),
|
||||
),
|
||||
),
|
||||
prefixIconConstraints: const BoxConstraints(
|
||||
maxHeight: 44,
|
||||
maxWidth: 44,
|
||||
minHeight: 44,
|
||||
minWidth: 44,
|
||||
),
|
||||
suffixIconConstraints: const BoxConstraints(
|
||||
maxHeight: 24,
|
||||
maxWidth: 48,
|
||||
minHeight: 24,
|
||||
minWidth: 48,
|
||||
),
|
||||
prefixIcon: widget.prefixIcon != null
|
||||
? Icon(
|
||||
widget.prefixIcon,
|
||||
color: colorScheme.strokeMuted,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
onEditingComplete: () {
|
||||
_onSubmit();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (widget.message != null) {
|
||||
textInputChildren.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Align(
|
||||
alignment: widget.alignMessage ?? Alignment.centerLeft,
|
||||
child: Text(
|
||||
widget.message!,
|
||||
style: textTheme.small.copyWith(color: colorScheme.textMuted),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
textInputChildren =
|
||||
addSeparators(textInputChildren, const SizedBox(height: 4));
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: textInputChildren,
|
||||
);
|
||||
}
|
||||
|
||||
void _safeRefresh() {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void _onSubmit() async {
|
||||
_debouncer.run(
|
||||
() => Future(() {
|
||||
setState(() {
|
||||
executionState = ExecutionState.inProgress;
|
||||
});
|
||||
}),
|
||||
);
|
||||
if (widget.shouldUnfocusOnCancelOrSubmit) {
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
try {
|
||||
await widget.onSubmit!.call(_textController.text);
|
||||
} catch (e) {
|
||||
executionState = ExecutionState.error;
|
||||
_debouncer.cancelDebounce();
|
||||
_exception = e as Exception;
|
||||
if (!widget.popNavAfterSubmission) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
widget.alwaysShowSuccessState && _debouncer.isActive()
|
||||
? executionState = ExecutionState.successful
|
||||
: null;
|
||||
_debouncer.cancelDebounce();
|
||||
if (executionState == ExecutionState.successful) {
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
// when the time taken by widget.onSubmit is approximately equal to the debounce
|
||||
// time, the callback is getting executed when/after the if condition
|
||||
// below is executing/executed which results in execution state stuck at
|
||||
// idle state. This Future is for delaying the execution of the if
|
||||
// condition so that the calback in the debouncer finishes execution before.
|
||||
await Future.delayed(const Duration(milliseconds: 5));
|
||||
if (executionState == ExecutionState.inProgress ||
|
||||
executionState == ExecutionState.error) {
|
||||
if (executionState == ExecutionState.inProgress) {
|
||||
if (mounted) {
|
||||
if (widget.showOnlyLoadingState) {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
});
|
||||
_popNavigatorStack(context);
|
||||
} else {
|
||||
setState(() {
|
||||
executionState = ExecutionState.successful;
|
||||
Future.delayed(
|
||||
Duration(
|
||||
seconds: widget.shouldSurfaceExecutionStates
|
||||
? (widget.popNavAfterSubmission ? 1 : 2)
|
||||
: 0,
|
||||
), () {
|
||||
widget.popNavAfterSubmission
|
||||
? _popNavigatorStack(context)
|
||||
: null;
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (executionState == ExecutionState.error) {
|
||||
setState(() {
|
||||
executionState = ExecutionState.idle;
|
||||
widget.popNavAfterSubmission
|
||||
? Future.delayed(
|
||||
const Duration(seconds: 0),
|
||||
() => _popNavigatorStack(context, e: _exception),
|
||||
)
|
||||
: null;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (widget.popNavAfterSubmission) {
|
||||
Future.delayed(
|
||||
Duration(seconds: widget.alwaysShowSuccessState ? 1 : 0),
|
||||
() => _popNavigatorStack(context),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _popNavigatorStack(BuildContext context, {Exception? e}) {
|
||||
Navigator.of(context).canPop() ? Navigator.of(context).pop(e) : null;
|
||||
}
|
||||
}
|
||||
|
||||
//todo: Add clear and custom icon for suffic icon
|
||||
class SuffixIconWidget extends StatelessWidget {
|
||||
final ExecutionState executionState;
|
||||
final bool shouldSurfaceExecutionStates;
|
||||
final TextEditingController textController;
|
||||
final ValueNotifier? obscureTextNotifier;
|
||||
final bool isPasswordInput;
|
||||
final bool isCancellable;
|
||||
final bool shouldUnfocusOnCancelOrSubmit;
|
||||
|
||||
const SuffixIconWidget({
|
||||
required this.executionState,
|
||||
required this.shouldSurfaceExecutionStates,
|
||||
required this.textController,
|
||||
this.obscureTextNotifier,
|
||||
this.isPasswordInput = false,
|
||||
this.isCancellable = false,
|
||||
this.shouldUnfocusOnCancelOrSubmit = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Widget trailingWidget;
|
||||
final colorScheme = getEnteColorScheme(context);
|
||||
if (executionState == ExecutionState.idle ||
|
||||
!shouldSurfaceExecutionStates) {
|
||||
if (isCancellable) {
|
||||
trailingWidget = GestureDetector(
|
||||
onTap: () {
|
||||
textController.clear();
|
||||
if (shouldUnfocusOnCancelOrSubmit) {
|
||||
FocusScope.of(context).unfocus();
|
||||
}
|
||||
},
|
||||
child: Icon(
|
||||
Icons.cancel_rounded,
|
||||
color: colorScheme.strokeMuted,
|
||||
),
|
||||
);
|
||||
} else if (isPasswordInput) {
|
||||
assert(obscureTextNotifier != null);
|
||||
trailingWidget = GestureDetector(
|
||||
onTap: () {
|
||||
obscureTextNotifier!.value = !obscureTextNotifier!.value;
|
||||
},
|
||||
child: Icon(
|
||||
obscureTextNotifier!.value
|
||||
? Icons.visibility_off_outlined
|
||||
: Icons.visibility,
|
||||
color: obscureTextNotifier!.value ? colorScheme.strokeMuted : null,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
trailingWidget = const SizedBox.shrink();
|
||||
}
|
||||
} else if (executionState == ExecutionState.inProgress) {
|
||||
trailingWidget = EnteLoadingWidget(
|
||||
color: colorScheme.strokeMuted,
|
||||
);
|
||||
} else if (executionState == ExecutionState.successful) {
|
||||
trailingWidget = Icon(
|
||||
Icons.check_outlined,
|
||||
size: 22,
|
||||
color: colorScheme.primary500,
|
||||
);
|
||||
} else {
|
||||
trailingWidget = const SizedBox.shrink();
|
||||
}
|
||||
return trailingWidget;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class LifecycleEventHandler extends WidgetsBindingObserver {
|
||||
final AsyncCallback resumeCallBack;
|
||||
final AsyncCallback suspendingCallBack;
|
||||
final AsyncCallback? resumeCallBack;
|
||||
final AsyncCallback? suspendingCallBack;
|
||||
|
||||
LifecycleEventHandler({
|
||||
this.resumeCallBack,
|
||||
|
@ -17,14 +17,14 @@ class LifecycleEventHandler extends WidgetsBindingObserver {
|
|||
switch (state) {
|
||||
case AppLifecycleState.resumed:
|
||||
if (resumeCallBack != null) {
|
||||
await resumeCallBack();
|
||||
await resumeCallBack!();
|
||||
}
|
||||
break;
|
||||
case AppLifecycleState.inactive:
|
||||
case AppLifecycleState.paused:
|
||||
case AppLifecycleState.detached:
|
||||
if (suspendingCallBack != null) {
|
||||
await suspendingCallBack();
|
||||
await suspendingCallBack!();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,153 +0,0 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:ente_auth/core/network.dart';
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/ui/common/loading_widget.dart';
|
||||
import 'package:expansion_tile_card/expansion_tile_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BillingQuestionsWidget extends StatelessWidget {
|
||||
const BillingQuestionsWidget({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: Network.instance
|
||||
.getDio()
|
||||
.get("https://static.ente.io/faq.json")
|
||||
.then((response) {
|
||||
final faqItems = <FaqItem>[];
|
||||
for (final item in response.data as List) {
|
||||
faqItems.add(FaqItem.fromMap(item));
|
||||
}
|
||||
return faqItems;
|
||||
}),
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final faqs = <Widget>[];
|
||||
faqs.add(
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(24),
|
||||
child: Text(
|
||||
"FAQs",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
for (final faq in snapshot.data) {
|
||||
faqs.add(FaqWidget(faq: faq));
|
||||
}
|
||||
faqs.add(
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
),
|
||||
);
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: faqs,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const EnteLoadingWidget();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FaqWidget extends StatelessWidget {
|
||||
const FaqWidget({
|
||||
Key key,
|
||||
@required this.faq,
|
||||
}) : super(key: key);
|
||||
|
||||
final FaqItem faq;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: ExpansionTileCard(
|
||||
elevation: 0,
|
||||
title: Text(faq.q),
|
||||
expandedTextColor: Theme.of(context).colorScheme.alternativeColor,
|
||||
baseColor: Theme.of(context).cardColor,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 12,
|
||||
),
|
||||
child: Text(
|
||||
faq.a,
|
||||
style: const TextStyle(
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FaqItem {
|
||||
final String q;
|
||||
final String a;
|
||||
FaqItem({
|
||||
this.q,
|
||||
this.a,
|
||||
});
|
||||
|
||||
FaqItem copyWith({
|
||||
String q,
|
||||
String a,
|
||||
}) {
|
||||
return FaqItem(
|
||||
q: q ?? this.q,
|
||||
a: a ?? this.a,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'q': q,
|
||||
'a': a,
|
||||
};
|
||||
}
|
||||
|
||||
factory FaqItem.fromMap(Map<String, dynamic> map) {
|
||||
if (map == null) return null;
|
||||
|
||||
return FaqItem(
|
||||
q: map['q'],
|
||||
a: map['a'],
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
factory FaqItem.fromJson(String source) =>
|
||||
FaqItem.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() => 'FaqItem(q: $q, a: $a)';
|
||||
|
||||
@override
|
||||
bool operator ==(Object o) {
|
||||
if (identical(this, o)) return true;
|
||||
|
||||
return o is FaqItem && o.q == q && o.a == a;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => q.hashCode ^ a.hashCode;
|
||||
}
|
|
@ -1,149 +0,0 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
import 'package:ente_auth/models/user_details.dart';
|
||||
import 'package:ente_auth/services/user_service.dart';
|
||||
import 'package:ente_auth/ui/common/dialogs.dart';
|
||||
import 'package:ente_auth/utils/dialog_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ChildSubscriptionWidget extends StatelessWidget {
|
||||
const ChildSubscriptionWidget({
|
||||
Key key,
|
||||
@required this.userDetails,
|
||||
}) : super(key: key);
|
||||
|
||||
final UserDetails userDetails;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final String familyAdmin = userDetails.familyData.members
|
||||
.firstWhere((element) => element.isAdmin)
|
||||
.email;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 32),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
l10n.inFamilyPlanMessage,
|
||||
style: Theme.of(context).textTheme.bodyText1,
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
children: [
|
||||
const TextSpan(
|
||||
text: "Please contact ",
|
||||
),
|
||||
TextSpan(
|
||||
text: familyAdmin,
|
||||
style:
|
||||
const TextStyle(color: Color.fromRGBO(29, 185, 84, 1)),
|
||||
),
|
||||
const TextSpan(
|
||||
text: " to manage your subscription",
|
||||
),
|
||||
],
|
||||
style: Theme.of(context).textTheme.bodyText1,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 8),
|
||||
),
|
||||
Image.asset(
|
||||
"assets/family_plan_leave.png",
|
||||
height: 256,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 0),
|
||||
),
|
||||
InkWell(
|
||||
child: OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 18, horizontal: 100),
|
||||
backgroundColor: Colors.red[500],
|
||||
),
|
||||
child: Text(
|
||||
l10n.leaveFamily,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
color: Colors.white, // same for both themes
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
onPressed: () async => {await _leaveFamilyPlan(context)},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Please contact ",
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
),
|
||||
TextSpan(
|
||||
text: "support@ente.io",
|
||||
style: Theme.of(context).textTheme.bodyText2.copyWith(
|
||||
color: const Color.fromRGBO(29, 185, 84, 1),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: " for help",
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _leaveFamilyPlan(BuildContext context) async {
|
||||
final l10n = context.l10n;
|
||||
final choice = await showChoiceDialog(
|
||||
context,
|
||||
l10n.leaveFamily,
|
||||
l10n.leaveFamilyMessage,
|
||||
firstAction: l10n.no,
|
||||
secondAction: l10n.yes,
|
||||
firstActionColor: Theme.of(context).colorScheme.alternativeColor,
|
||||
secondActionColor: Theme.of(context).colorScheme.onSurface,
|
||||
);
|
||||
if (choice != DialogUserChoice.secondChoice) {
|
||||
return;
|
||||
}
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
await dialog.show();
|
||||
try {
|
||||
await UserService.instance.leaveFamilyPlan();
|
||||
dialog.hide();
|
||||
Navigator.of(context).pop('');
|
||||
} catch (e) {
|
||||
dialog.hide();
|
||||
showGenericErrorDialog(context);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
import 'package:ente_auth/models/subscription.dart';
|
||||
import 'package:ente_auth/services/billing_service.dart';
|
||||
import 'package:ente_auth/services/user_service.dart';
|
||||
import 'package:ente_auth/ui/common/loading_widget.dart';
|
||||
import 'package:ente_auth/ui/common/progress_dialog.dart';
|
||||
import 'package:ente_auth/utils/dialog_util.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
class PaymentWebPage extends StatefulWidget {
|
||||
final String planId;
|
||||
final String actionType;
|
||||
|
||||
const PaymentWebPage({Key key, this.planId, this.actionType})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _PaymentWebPageState();
|
||||
}
|
||||
|
||||
class _PaymentWebPageState extends State<PaymentWebPage> {
|
||||
final _logger = Logger("PaymentWebPageState");
|
||||
final UserService userService = UserService.instance;
|
||||
final BillingService billingService = BillingService.instance;
|
||||
final String basePaymentUrl = kWebPaymentBaseEndpoint;
|
||||
ProgressDialog _dialog;
|
||||
InAppWebViewController webView;
|
||||
double progress = 0;
|
||||
Uri initPaymentUrl;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
userService.getPaymentToken().then((token) {
|
||||
initPaymentUrl = _getPaymentUrl(token);
|
||||
setState(() {});
|
||||
});
|
||||
if (Platform.isAndroid && kDebugMode) {
|
||||
AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
_dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
if (initPaymentUrl == null) {
|
||||
return const EnteLoadingWidget();
|
||||
}
|
||||
return WillPopScope(
|
||||
onWillPop: () async => _buildPageExitWidget(context),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Subscription'),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
(progress != 1.0)
|
||||
? LinearProgressIndicator(value: progress)
|
||||
: Container(),
|
||||
Expanded(
|
||||
child: InAppWebView(
|
||||
initialUrlRequest: URLRequest(url: initPaymentUrl),
|
||||
onProgressChanged:
|
||||
(InAppWebViewController controller, int progress) {
|
||||
setState(() {
|
||||
this.progress = progress / 100;
|
||||
});
|
||||
},
|
||||
initialOptions: InAppWebViewGroupOptions(
|
||||
crossPlatform: InAppWebViewOptions(
|
||||
useShouldOverrideUrlLoading: true,
|
||||
),
|
||||
),
|
||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||
final loadingUri = navigationAction.request.url;
|
||||
_logger.info("Loading url $loadingUri");
|
||||
// handle the payment response
|
||||
if (_isPaymentActionComplete(loadingUri)) {
|
||||
await _handlePaymentResponse(loadingUri);
|
||||
return NavigationActionPolicy.CANCEL;
|
||||
}
|
||||
return NavigationActionPolicy.ALLOW;
|
||||
},
|
||||
onConsoleMessage: (controller, consoleMessage) {
|
||||
_logger.info(consoleMessage);
|
||||
},
|
||||
onLoadStart: (controller, navigationAction) async {
|
||||
if (!_dialog.isShowing()) {
|
||||
await _dialog.show();
|
||||
}
|
||||
},
|
||||
onLoadError: (controller, navigationAction, code, msg) async {
|
||||
if (_dialog.isShowing()) {
|
||||
await _dialog.hide();
|
||||
}
|
||||
},
|
||||
onLoadHttpError:
|
||||
(controller, navigationAction, code, msg) async {
|
||||
_logger.info("onHttpError with $code and msg = $msg");
|
||||
},
|
||||
onLoadStop: (controller, navigationAction) async {
|
||||
_logger.info("loadStart" + navigationAction.toString());
|
||||
if (_dialog.isShowing()) {
|
||||
await _dialog.hide();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
].where((Object o) => o != null).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_dialog.hide();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Uri _getPaymentUrl(String paymentToken) {
|
||||
final queryParameters = {
|
||||
'productID': widget.planId,
|
||||
'paymentToken': paymentToken,
|
||||
'action': widget.actionType,
|
||||
'redirectURL': kWebPaymentRedirectUrl,
|
||||
};
|
||||
final tryParse = Uri.tryParse(kWebPaymentBaseEndpoint);
|
||||
if (kDebugMode && kWebPaymentBaseEndpoint.startsWith("http://")) {
|
||||
return Uri.http(tryParse.authority, tryParse.path, queryParameters);
|
||||
} else {
|
||||
return Uri.https(tryParse.authority, tryParse.path, queryParameters);
|
||||
}
|
||||
}
|
||||
|
||||
// show dialog to handle accidental back press.
|
||||
Future<bool> _buildPageExitWidget(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Are you sure you want to exit?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text(
|
||||
'Yes',
|
||||
style: TextStyle(
|
||||
color: Colors.redAccent,
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
'No',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.alternativeColor,
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool _isPaymentActionComplete(Uri loadingUri) {
|
||||
return loadingUri.toString().startsWith(kWebPaymentRedirectUrl);
|
||||
}
|
||||
|
||||
Future<void> _handlePaymentResponse(Uri uri) async {
|
||||
final queryParams = uri.queryParameters;
|
||||
final paymentStatus = uri.queryParameters['status'] ?? '';
|
||||
_logger.fine('handle payment response with status $paymentStatus');
|
||||
if (paymentStatus == 'success') {
|
||||
await _handlePaymentSuccess(queryParams);
|
||||
} else if (paymentStatus == 'fail') {
|
||||
final reason = queryParams['reason'] ?? '';
|
||||
await _handlePaymentFailure(reason);
|
||||
} else {
|
||||
// should never reach here
|
||||
_logger.severe("unexpected status", uri.toString());
|
||||
showGenericErrorDialog(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handlePaymentFailure(String reason) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Payment failed'),
|
||||
content: Text("Unfortunately your payment failed due to $reason"),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop('dialog');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
|
||||
// return true if verifySubscription didn't throw any exceptions
|
||||
Future<void> _handlePaymentSuccess(Map<String, String> queryParams) async {
|
||||
final checkoutSessionID = queryParams['session_id'] ?? '';
|
||||
await _dialog.show();
|
||||
try {
|
||||
final response = await billingService.verifySubscription(
|
||||
widget.planId,
|
||||
checkoutSessionID,
|
||||
paymentProvider: stripe,
|
||||
);
|
||||
await _dialog.hide();
|
||||
if (response != null) {
|
||||
final content = widget.actionType == 'buy'
|
||||
? 'Your purchase was successful'
|
||||
: 'Your subscription was updated successfully';
|
||||
await _showExitPageDialog(title: 'Thank you', content: content);
|
||||
} else {
|
||||
throw Exception("verifySubscription api failed");
|
||||
}
|
||||
} catch (error) {
|
||||
_logger.severe(error);
|
||||
await _dialog.hide();
|
||||
await _showExitPageDialog(
|
||||
title: 'Failed to verify payment status',
|
||||
content: 'Please wait for sometime before retrying',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// warn the user to wait for sometime before trying another payment
|
||||
Future<dynamic> _showExitPageDialog({String title, String content}) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text(
|
||||
'Ok',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.alternativeColor,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop('dialog');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
).then((val) => Navigator.pop(context, true));
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
import 'package:ente_auth/models/subscription.dart';
|
||||
import 'package:ente_auth/ui/payment/billing_questions_widget.dart';
|
||||
import 'package:ente_auth/utils/data_util.dart';
|
||||
import 'package:ente_auth/utils/date_time_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SubscriptionHeaderWidget extends StatefulWidget {
|
||||
final bool isOnboarding;
|
||||
final int currentUsage;
|
||||
|
||||
const SubscriptionHeaderWidget({
|
||||
Key key,
|
||||
this.isOnboarding,
|
||||
this.currentUsage,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _SubscriptionHeaderWidgetState();
|
||||
}
|
||||
}
|
||||
|
||||
class _SubscriptionHeaderWidgetState extends State<SubscriptionHeaderWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.isOnboarding) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"Select your plan",
|
||||
style: Theme.of(context).textTheme.headline4,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Ente preserves your memories, so they're always available to you, even if you lose your device ",
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 72,
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "Current usage is ",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
TextSpan(
|
||||
text: formatBytes(widget.currentUsage),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1
|
||||
.copyWith(fontWeight: FontWeight.bold),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ValidityWidget extends StatelessWidget {
|
||||
final Subscription currentSubscription;
|
||||
|
||||
const ValidityWidget({Key key, this.currentSubscription}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (currentSubscription == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final endDate = getDateAndMonthAndYear(
|
||||
DateTime.fromMicrosecondsSinceEpoch(currentSubscription.expiryTime),
|
||||
);
|
||||
var message = "Renews on $endDate";
|
||||
if (currentSubscription.productID == freeProductID) {
|
||||
message = "Free plan valid till $endDate";
|
||||
} else if (currentSubscription.attributes?.isCancelled ?? false) {
|
||||
message = "Your subscription will be cancelled on $endDate";
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
message,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SubFaqWidget extends StatelessWidget {
|
||||
const SubFaqWidget({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
showModalBottomSheet<void>(
|
||||
backgroundColor: Theme.of(context).colorScheme.bgColorForQuestions,
|
||||
barrierColor: Colors.black87,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const BillingQuestionsWidget();
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: "Questions?",
|
||||
style: Theme.of(context).textTheme.overline,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/utils/data_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SubscriptionPlanWidget extends StatelessWidget {
|
||||
const SubscriptionPlanWidget({
|
||||
Key key,
|
||||
@required this.storage,
|
||||
@required this.price,
|
||||
@required this.period,
|
||||
this.isActive = false,
|
||||
}) : super(key: key);
|
||||
|
||||
final int storage;
|
||||
final String price;
|
||||
final String period;
|
||||
final bool isActive;
|
||||
|
||||
String _displayPrice() {
|
||||
final result = price + (period.isNotEmpty ? " / " + period : "");
|
||||
return result.isNotEmpty ? result : "Trial plan";
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color textColor = isActive ? Colors.white : Colors.black;
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
padding: EdgeInsets.symmetric(horizontal: isActive ? 8 : 16, vertical: 4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: isActive
|
||||
? const Color(0xFF22763F)
|
||||
: const Color.fromRGBO(240, 240, 240, 1.0),
|
||||
gradient: isActive
|
||||
? const LinearGradient(
|
||||
begin: Alignment.centerLeft,
|
||||
end: Alignment.centerRight,
|
||||
colors: [
|
||||
Color(0xFF2CD267),
|
||||
Color(0xFF1DB954),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
),
|
||||
// color: Colors.yellow,
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: isActive ? 22 : 20, vertical: 18),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
convertBytesToReadableFormat(storage),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headline6
|
||||
.copyWith(color: textColor),
|
||||
),
|
||||
Text(
|
||||
_displayPrice(),
|
||||
style: Theme.of(context).textTheme.headline6.copyWith(
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/services/update_service.dart';
|
||||
import 'package:ente_auth/theme/ente_theme.dart';
|
||||
import 'package:ente_auth/ui/common/web_page.dart';
|
||||
|
@ -14,7 +12,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class AboutSectionWidget extends StatelessWidget {
|
||||
const AboutSectionWidget({Key key}) : super(key: key);
|
||||
const AboutSectionWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -95,12 +93,13 @@ class AboutSectionWidget extends StatelessWidget {
|
|||
class AboutMenuItemWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final String url;
|
||||
final String webPageTitle;
|
||||
final String? webPageTitle;
|
||||
|
||||
const AboutMenuItemWidget({
|
||||
@required this.title,
|
||||
@required this.url,
|
||||
required this.title,
|
||||
required this.url,
|
||||
this.webPageTitle,
|
||||
Key key,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/app/view/app.dart';
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
|
@ -20,7 +20,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_sodium/flutter_sodium.dart';
|
||||
|
||||
class AccountSectionWidget extends StatelessWidget {
|
||||
AccountSectionWidget({Key key}) : super(key: key);
|
||||
AccountSectionWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -56,7 +56,7 @@ class AccountSectionWidget extends StatelessWidget {
|
|||
recoveryKey =
|
||||
Sodium.bin2hex(Configuration.instance.getRecoveryKey());
|
||||
} catch (e) {
|
||||
showGenericErrorDialog(context);
|
||||
showGenericErrorDialog(context: context);
|
||||
return;
|
||||
}
|
||||
routeToPage(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/core/network.dart';
|
||||
|
@ -9,9 +9,9 @@ import 'package:logging/logging.dart';
|
|||
import 'package:open_filex/open_filex.dart';
|
||||
|
||||
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
|
||||
State<AppUpdateDialog> createState() => _AppUpdateDialogState();
|
||||
|
@ -21,13 +21,13 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> changelog = [];
|
||||
for (final log in widget.latestVersionInfo.changelog) {
|
||||
for (final log in widget.latestVersionInfo!.changelog) {
|
||||
changelog.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 0, 4),
|
||||
child: Text(
|
||||
"- " + log,
|
||||
style: Theme.of(context).textTheme.caption.copyWith(
|
||||
style: Theme.of(context).textTheme.caption!.copyWith(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
|
@ -39,7 +39,7 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
widget.latestVersionInfo.name,
|
||||
widget.latestVersionInfo!.name!,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
@ -62,8 +62,8 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
width: double.infinity,
|
||||
height: 64,
|
||||
child: OutlinedButton(
|
||||
style: Theme.of(context).outlinedButtonTheme.style.copyWith(
|
||||
textStyle: MaterialStateProperty.resolveWith<TextStyle>(
|
||||
style: Theme.of(context).outlinedButtonTheme.style!.copyWith(
|
||||
textStyle: MaterialStateProperty.resolveWith<TextStyle?>(
|
||||
(Set<MaterialState> states) {
|
||||
return Theme.of(context).textTheme.subtitle1;
|
||||
},
|
||||
|
@ -101,24 +101,24 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
}
|
||||
|
||||
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
|
||||
State<ApkDownloaderDialog> createState() => _ApkDownloaderDialogState();
|
||||
}
|
||||
|
||||
class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> {
|
||||
String _saveUrl;
|
||||
double _downloadProgress;
|
||||
String? _saveUrl;
|
||||
double? _downloadProgress;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_saveUrl = Configuration.instance.getTempDirectory() +
|
||||
"ente-" +
|
||||
widget.versionInfo.name +
|
||||
widget.versionInfo!.name! +
|
||||
".apk";
|
||||
_downloadApk();
|
||||
}
|
||||
|
@ -148,11 +148,11 @@ class _ApkDownloaderDialogState extends State<ApkDownloaderDialog> {
|
|||
Future<void> _downloadApk() async {
|
||||
try {
|
||||
await Network.instance.getDio().download(
|
||||
widget.versionInfo.url,
|
||||
widget.versionInfo!.url!,
|
||||
_saveUrl,
|
||||
onReceiveProgress: (count, _) {
|
||||
setState(() {
|
||||
_downloadProgress = count / widget.versionInfo.size;
|
||||
_downloadProgress = count / widget.versionInfo!.size!;
|
||||
});
|
||||
},
|
||||
);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/utils/dialog_util.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class AppVersionWidget extends StatefulWidget {
|
||||
const AppVersionWidget({
|
||||
Key key,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -18,7 +16,7 @@ class _AppVersionWidgetState extends State<AppVersionWidget> {
|
|||
static const kConsecutiveTapTimeWindowInMilliseconds = 2000;
|
||||
static const kDummyDelayDurationInMilliseconds = 1500;
|
||||
|
||||
int _lastTap;
|
||||
int? _lastTap;
|
||||
int _consecutiveTaps = 0;
|
||||
|
||||
@override
|
||||
|
@ -43,14 +41,14 @@ class _AppVersionWidgetState extends State<AppVersionWidget> {
|
|||
}
|
||||
_lastTap = now;
|
||||
},
|
||||
child: FutureBuilder(
|
||||
child: FutureBuilder<String>(
|
||||
future: _getAppVersion(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Text(
|
||||
"Version: " + snapshot.data,
|
||||
"Version: " + snapshot.data!,
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:expandable/expandable.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Widget sectionOptionDivider = Padding(
|
||||
padding: EdgeInsets.all(Platform.isIOS ? 4 : 2),
|
||||
);
|
||||
|
||||
Widget sectionOptionSpacing = const SizedBox(height: 6);
|
||||
|
||||
ExpandableThemeData getExpandableTheme(BuildContext context) {
|
||||
ExpandableThemeData getExpandableTheme() {
|
||||
return const ExpandableThemeData(
|
||||
hasIcon: false,
|
||||
useInkWell: false,
|
||||
|
|
|
@ -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/theme/ente_theme.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';
|
||||
|
||||
class DangerSectionWidget extends StatelessWidget {
|
||||
const DangerSectionWidget({Key key}) : super(key: key);
|
||||
const DangerSectionWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ExpandableMenuItemWidget(
|
||||
title: "Exit",
|
||||
title: context.l10n.exit,
|
||||
selectionOptionsWidget: _getSectionOptions(context),
|
||||
leadingIcon: Icons.logout_outlined,
|
||||
);
|
||||
|
@ -27,25 +28,25 @@ class DangerSectionWidget extends StatelessWidget {
|
|||
children: [
|
||||
sectionOptionSpacing,
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: const CaptionedTextWidget(
|
||||
title: "Logout",
|
||||
captionedTextWidget: CaptionedTextWidget(
|
||||
title: context.l10n.logout,
|
||||
),
|
||||
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||
trailingIcon: Icons.chevron_right_outlined,
|
||||
trailingIconIsMuted: true,
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
_onLogoutTapped(context);
|
||||
},
|
||||
),
|
||||
sectionOptionSpacing,
|
||||
MenuItemWidget(
|
||||
captionedTextWidget: const CaptionedTextWidget(
|
||||
title: "Delete account",
|
||||
captionedTextWidget: CaptionedTextWidget(
|
||||
title: context.l10n.deleteAccount,
|
||||
),
|
||||
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||
trailingIcon: Icons.chevron_right_outlined,
|
||||
trailingIconIsMuted: true,
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
routeToPage(context, const DeleteAccountPage());
|
||||
},
|
||||
),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
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/theme/ente_theme.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/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/utils/dialog_util.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
|
@ -29,7 +31,7 @@ class DataSectionWidget extends StatelessWidget {
|
|||
Configuration.instance.getTempDirectory() + "ente-authenticator-codes.txt",
|
||||
);
|
||||
|
||||
DataSectionWidget({Key key}) : super(key: key);
|
||||
DataSectionWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -216,14 +218,14 @@ class DataSectionWidget extends StatelessWidget {
|
|||
|
||||
Future<void> _pickImportFile(BuildContext context) async {
|
||||
final l10n = context.l10n;
|
||||
FilePickerResult result = await FilePicker.platform.pickFiles();
|
||||
FilePickerResult? result = await FilePicker.platform.pickFiles();
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWaitTitle);
|
||||
final dialog = createProgressDialog(context, l10n.pleaseWait);
|
||||
await dialog.show();
|
||||
try {
|
||||
File file = File(result.files.single.path);
|
||||
File file = File(result.files.single.path!);
|
||||
final codes = await file.readAsString();
|
||||
List<String> splitCodes = codes.split(",");
|
||||
if (splitCodes.length == 1) {
|
||||
|
@ -241,34 +243,20 @@ class DataSectionWidget extends StatelessWidget {
|
|||
await CodeStore.instance.addCode(code, shouldSync: false);
|
||||
}
|
||||
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(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
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');
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
dialogBuilder: (BuildContext context) {
|
||||
return dialog;
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/core/configuration.dart';
|
||||
import 'package:ente_auth/l10n/l10n.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';
|
||||
|
||||
class DebugSectionWidget extends StatelessWidget {
|
||||
const DebugSectionWidget({Key key}) : super(key: key);
|
||||
const DebugSectionWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 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"),
|
||||
collapsed: Container(),
|
||||
expanded: _getSectionOptions(context),
|
||||
theme: getExpandableTheme(context),
|
||||
theme: getExpandableTheme(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -42,7 +41,7 @@ class DebugSectionWidget extends StatelessWidget {
|
|||
|
||||
void _showKeyAttributesDialog(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final keyAttributes = Configuration.instance.getKeyAttributes();
|
||||
final keyAttributes = Configuration.instance.getKeyAttributes()!;
|
||||
final AlertDialog alert = AlertDialog(
|
||||
title: const Text("key attributes"),
|
||||
content: SingleChildScrollView(
|
||||
|
@ -52,7 +51,7 @@ class DebugSectionWidget extends StatelessWidget {
|
|||
"Key",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(Sodium.bin2base64(Configuration.instance.getKey())),
|
||||
Text(Sodium.bin2base64(Configuration.instance.getKey()!)),
|
||||
const Padding(padding: EdgeInsets.all(12)),
|
||||
const Text(
|
||||
"Encrypted Key",
|
||||
|
|
|
@ -54,7 +54,7 @@ class LanguageSelectorPage extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
// MenuSectionDescriptionWidget(
|
||||
// content: S.of(context).maxDeviceLimitSpikeHandling(50),
|
||||
// content: context.l10n.maxDeviceLimitSpikeHandling(50),
|
||||
// )
|
||||
],
|
||||
),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/core/configuration.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';
|
||||
|
||||
class SecuritySectionWidget extends StatefulWidget {
|
||||
const SecuritySectionWidget({Key key}) : super(key: key);
|
||||
const SecuritySectionWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SecuritySectionWidget> createState() => _SecuritySectionWidgetState();
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsSectionTitle extends StatelessWidget {
|
||||
final String title;
|
||||
final Color color;
|
||||
final Color? color;
|
||||
|
||||
const SettingsSectionTitle(
|
||||
this.title, {
|
||||
Key key,
|
||||
Key? key,
|
||||
this.color,
|
||||
}) : super(key: key);
|
||||
|
||||
|
@ -24,7 +24,7 @@ class SettingsSectionTitle extends StatelessWidget {
|
|||
style: color != null
|
||||
? Theme.of(context)
|
||||
.textTheme
|
||||
.headline6
|
||||
.headline6!
|
||||
.merge(TextStyle(color: color))
|
||||
: Theme.of(context).textTheme.headline6,
|
||||
),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -8,9 +8,9 @@ class SettingsTextItem extends StatelessWidget {
|
|||
final String text;
|
||||
final IconData icon;
|
||||
const SettingsTextItem({
|
||||
Key key,
|
||||
@required this.text,
|
||||
@required this.icon,
|
||||
Key? key,
|
||||
required this.text,
|
||||
required this.icon,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/l10n/l10n.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';
|
||||
|
||||
class SocialSectionWidget extends StatelessWidget {
|
||||
const SocialSectionWidget({Key key}) : super(key: key);
|
||||
const SocialSectionWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -39,7 +39,7 @@ class SocialSectionWidget extends StatelessWidget {
|
|||
class SocialsMenuItemWidget extends StatelessWidget {
|
||||
final String text;
|
||||
final String urlSring;
|
||||
const SocialsMenuItemWidget(this.text, this.urlSring, {Key key})
|
||||
const SocialsMenuItemWidget(this.text, this.urlSring, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -53,7 +53,7 @@ class SocialsMenuItemWidget extends StatelessWidget {
|
|||
trailingIconIsMuted: true,
|
||||
onTap: () {
|
||||
launchUrlString(urlSring);
|
||||
},
|
||||
} as Future<void> Function()?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/core/constants.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';
|
||||
|
||||
class SupportSectionWidget extends StatefulWidget {
|
||||
const SupportSectionWidget({Key key}) : super(key: key);
|
||||
const SupportSectionWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<SupportSectionWidget> createState() => _SupportSectionWidgetState();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:adaptive_theme/adaptive_theme.dart';
|
||||
import 'package:ente_auth/ente_theme_data.dart';
|
||||
|
@ -11,14 +11,14 @@ import 'package:flutter/material.dart';
|
|||
import 'package:intl/intl.dart';
|
||||
|
||||
class ThemeSwitchWidget extends StatefulWidget {
|
||||
const ThemeSwitchWidget({Key key}) : super(key: key);
|
||||
const ThemeSwitchWidget({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ThemeSwitchWidget> createState() => _ThemeSwitchWidgetState();
|
||||
}
|
||||
|
||||
class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
|
||||
AdaptiveThemeMode currentThemeMode;
|
||||
AdaptiveThemeMode? currentThemeMode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -67,7 +67,7 @@ class _ThemeSwitchWidgetState extends State<ThemeSwitchWidget> {
|
|||
Widget _menuItem(BuildContext context, AdaptiveThemeMode themeMode) {
|
||||
return MenuItemWidget(
|
||||
captionedTextWidget: CaptionedTextWidget(
|
||||
title: toBeginningOfSentenceCase(themeMode.name),
|
||||
title: toBeginningOfSentenceCase(themeMode.name)!,
|
||||
textStyle: Theme.of(context).colorScheme.enteTheme.textTheme.body,
|
||||
),
|
||||
pressedColor: getEnteColorScheme(context).fillFaint,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ente_auth/theme/colors.dart';
|
||||
|
@ -19,8 +17,8 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class SettingsPage extends StatelessWidget {
|
||||
final ValueNotifier<String> emailNotifier;
|
||||
const SettingsPage({Key key, @required this.emailNotifier}) : super(key: key);
|
||||
final ValueNotifier<String?> emailNotifier;
|
||||
const SettingsPage({Key? key, required this.emailNotifier}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -44,9 +42,9 @@ class SettingsPage extends StatelessWidget {
|
|||
child: AnimatedBuilder(
|
||||
// [AnimatedBuilder] accepts any [Listenable] subtype.
|
||||
animation: emailNotifier,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Text(
|
||||
emailNotifier.value,
|
||||
emailNotifier.value!,
|
||||
style: enteTextTheme.body.copyWith(
|
||||
color: colorScheme.textMuted,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
import 'package:ente_auth/locale.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
/// A widget which handles app lifecycle events for showing and hiding a lock screen.
|
||||
/// This should wrap around a `MyApp` widget (or equivalent).
|
||||
|
@ -30,26 +27,28 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
|||
|
||||
// ignore_for_file: unnecessary_this, library_private_types_in_public_api
|
||||
class AppLock extends StatefulWidget {
|
||||
final Widget Function(Object) builder;
|
||||
final Widget Function(Object?) builder;
|
||||
final Widget lockScreen;
|
||||
final bool enabled;
|
||||
final Duration backgroundLockLatency;
|
||||
final ThemeData darkTheme;
|
||||
final ThemeData lightTheme;
|
||||
final ThemeData? darkTheme;
|
||||
final ThemeData? lightTheme;
|
||||
final ThemeMode savedThemeMode;
|
||||
final Locale locale;
|
||||
|
||||
const AppLock({
|
||||
Key key,
|
||||
@required this.builder,
|
||||
@required this.lockScreen,
|
||||
Key? key,
|
||||
required this.builder,
|
||||
required this.lockScreen,
|
||||
required this.savedThemeMode,
|
||||
this.enabled = true,
|
||||
this.locale = const Locale('en', 'US'),
|
||||
this.backgroundLockLatency = const Duration(seconds: 0),
|
||||
this.darkTheme,
|
||||
this.lightTheme,
|
||||
this.locale,
|
||||
}) : super(key: key);
|
||||
|
||||
static _AppLockState of(BuildContext context) =>
|
||||
static _AppLockState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<_AppLockState>();
|
||||
|
||||
@override
|
||||
|
@ -59,11 +58,11 @@ class AppLock extends StatefulWidget {
|
|||
class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
||||
static final GlobalKey<NavigatorState> _navigatorKey = GlobalKey();
|
||||
|
||||
bool _didUnlockForAppLaunch;
|
||||
bool _isLocked;
|
||||
bool _enabled;
|
||||
late bool _didUnlockForAppLaunch;
|
||||
late bool _isLocked;
|
||||
late bool _enabled;
|
||||
|
||||
Timer _backgroundLockLatencyTimer;
|
||||
Timer? _backgroundLockLatencyTimer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -109,17 +108,14 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
|||
return MaterialApp(
|
||||
home: this.widget.enabled ? this._lockScreen : this.widget.builder(null),
|
||||
navigatorKey: _navigatorKey,
|
||||
themeMode: ThemeMode.system,
|
||||
themeMode: widget.savedThemeMode,
|
||||
theme: widget.lightTheme,
|
||||
darkTheme: widget.darkTheme,
|
||||
locale: widget.locale,
|
||||
supportedLocales: appSupportedLocales,
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
...AppLocalizations.localizationsDelegates,
|
||||
],
|
||||
onGenerateRoute: (settings) {
|
||||
switch (settings.name) {
|
||||
|
@ -153,7 +149,7 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
|||
/// when built. Use this when you want to inject objects created from the
|
||||
/// [lockScreen] in to the rest of your app so you can better guarantee that some
|
||||
/// objects, services or databases are already instantiated before using them.
|
||||
void didUnlock([Object args]) {
|
||||
void didUnlock([Object? args]) {
|
||||
if (this._didUnlockForAppLaunch) {
|
||||
this._didUnlockOnAppPaused();
|
||||
} else {
|
||||
|
@ -192,17 +188,17 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
|||
/// Manually show the [lockScreen].
|
||||
Future<void> showLockScreen() {
|
||||
this._isLocked = true;
|
||||
return _navigatorKey.currentState.pushNamed('/lock-screen');
|
||||
return _navigatorKey.currentState!.pushNamed('/lock-screen');
|
||||
}
|
||||
|
||||
void _didUnlockOnAppLaunch(Object args) {
|
||||
void _didUnlockOnAppLaunch(Object? args) {
|
||||
this._didUnlockForAppLaunch = true;
|
||||
_navigatorKey.currentState
|
||||
_navigatorKey.currentState!
|
||||
.pushReplacementNamed('/unlocked', arguments: args);
|
||||
}
|
||||
|
||||
void _didUnlockOnAppPaused() {
|
||||
this._isLocked = false;
|
||||
_navigatorKey.currentState.pop();
|
||||
_navigatorKey.currentState!.pop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
|
@ -8,14 +6,14 @@ import 'package:flutter/material.dart';
|
|||
|
||||
class LogFileViewer extends StatefulWidget {
|
||||
final File file;
|
||||
const LogFileViewer(this.file, {Key key}) : super(key: key);
|
||||
const LogFileViewer(this.file, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LogFileViewer> createState() => _LogFileViewerState();
|
||||
}
|
||||
|
||||
class _LogFileViewerState extends State<LogFileViewer> {
|
||||
String _logs;
|
||||
String? _logs;
|
||||
@override
|
||||
void initState() {
|
||||
widget.file.readAsString().then((logs) {
|
||||
|
@ -45,7 +43,7 @@ class _LogFileViewerState extends State<LogFileViewer> {
|
|||
padding: const EdgeInsets.only(left: 12, top: 8, right: 12),
|
||||
child: SingleChildScrollView(
|
||||
child: Text(
|
||||
_logs,
|
||||
_logs!,
|
||||
style: const TextStyle(
|
||||
fontFeatures: [
|
||||
FontFeature.tabularFigures(),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
|
||||
import 'package:ente_auth/ui/common/gradient_button.dart';
|
||||
import 'package:ente_auth/ui/tools/app_lock.dart';
|
||||
|
@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
|
||||
class LockScreen extends StatefulWidget {
|
||||
const LockScreen({Key key}) : super(key: key);
|
||||
const LockScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<LockScreen> createState() => _LockScreenState();
|
||||
|
@ -62,7 +62,7 @@ class _LockScreenState extends State<LockScreen> {
|
|||
"Please authenticate to view your secrets",
|
||||
);
|
||||
if (result) {
|
||||
AppLock.of(context).didUnlock();
|
||||
AppLock.of(context)!.didUnlock();
|
||||
}
|
||||
} catch (e, s) {
|
||||
_logger.severe(e, s);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
import 'package:ente_auth/services/user_service.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 {
|
||||
final String sessionID;
|
||||
|
||||
const TwoFactorAuthenticationPage(this.sessionID, {Key key})
|
||||
const TwoFactorAuthenticationPage(this.sessionID, {Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -22,7 +20,7 @@ class _TwoFactorAuthenticationPageState
|
|||
extends State<TwoFactorAuthenticationPage> {
|
||||
final _pinController = TextEditingController();
|
||||
String _code = "";
|
||||
LifecycleEventHandler _lifecycleEventHandler;
|
||||
late LifecycleEventHandler _lifecycleEventHandler;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -30,8 +28,8 @@ class _TwoFactorAuthenticationPageState
|
|||
resumeCallBack: () async {
|
||||
if (mounted) {
|
||||
final data = await Clipboard.getData(Clipboard.kTextPlain);
|
||||
if (data != null && data.text != null && data.text.length == 6) {
|
||||
_pinController.text = data.text;
|
||||
if (data != null && data.text != null && data.text!.length == 6) {
|
||||
_pinController.text = data.text!;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -65,7 +63,7 @@ class _TwoFactorAuthenticationPageState
|
|||
border: Border.all(
|
||||
color: Theme.of(context)
|
||||
.inputDecorationTheme
|
||||
.focusedBorder
|
||||
.focusedBorder!
|
||||
.borderSide
|
||||
.color,
|
||||
),
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:ente_auth/l10n/l10n.dart';
|
||||
|
@ -16,7 +14,7 @@ class TwoFactorRecoveryPage extends StatefulWidget {
|
|||
this.sessionID,
|
||||
this.encryptedSecret,
|
||||
this.secretDecryptionNonce, {
|
||||
Key key,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,24 +1,230 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:confetti/confetti.dart';
|
||||
import "package:dio/dio.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/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';
|
||||
|
||||
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(
|
||||
context,
|
||||
type: ProgressDialogType.normal,
|
||||
isDismissible: false,
|
||||
isDismissible: isDismissible,
|
||||
barrierColor: Colors.black12,
|
||||
);
|
||||
dialog.style(
|
||||
message: message,
|
||||
messageTextStyle:
|
||||
Theme.of(context).textTheme.caption.copyWith(fontSize: 14),
|
||||
messageTextStyle: Theme.of(context).textTheme.caption,
|
||||
backgroundColor: Theme.of(context).dialogTheme.backgroundColor,
|
||||
progressWidget: const EnteLoadingWidget(),
|
||||
borderRadius: 10,
|
||||
|
@ -28,61 +234,20 @@ ProgressDialog createProgressDialog(BuildContext context, String message) {
|
|||
return dialog;
|
||||
}
|
||||
|
||||
Future<dynamic> showErrorDialog(
|
||||
BuildContext context,
|
||||
String title,
|
||||
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,
|
||||
Future<ButtonResult?> showConfettiDialog<T>({
|
||||
required BuildContext context,
|
||||
required DialogBuilder dialogBuilder,
|
||||
bool barrierDismissible = true,
|
||||
Color barrierColor,
|
||||
Color? barrierColor,
|
||||
bool useSafeArea = true,
|
||||
bool useRootNavigator = true,
|
||||
RouteSettings routeSettings,
|
||||
RouteSettings? routeSettings,
|
||||
Alignment confettiAlignment = Alignment.center,
|
||||
}) {
|
||||
final widthOfScreen = MediaQuery.of(context).size.width;
|
||||
final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
|
||||
final pageBuilder = Builder(
|
||||
builder: builder,
|
||||
builder: dialogBuilder,
|
||||
);
|
||||
final ConfettiController confettiController =
|
||||
ConfettiController(duration: const Duration(seconds: 1));
|
||||
|
@ -90,22 +255,25 @@ Future<T> showConfettiDialog<T>({
|
|||
return showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext buildContext) {
|
||||
return Stack(
|
||||
children: [
|
||||
pageBuilder,
|
||||
Align(
|
||||
alignment: confettiAlignment,
|
||||
child: ConfettiWidget(
|
||||
confettiController: confettiController,
|
||||
blastDirection: pi / 2,
|
||||
emissionFrequency: 0,
|
||||
numberOfParticles: 100,
|
||||
// a lot of particles at once
|
||||
gravity: 1,
|
||||
blastDirectionality: BlastDirectionality.explosive,
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: isMobileSmall ? 8 : 0),
|
||||
child: Stack(
|
||||
children: [
|
||||
Align(alignment: Alignment.center, child: pageBuilder),
|
||||
Align(
|
||||
alignment: confettiAlignment,
|
||||
child: ConfettiWidget(
|
||||
confettiController: confettiController,
|
||||
blastDirection: pi / 2,
|
||||
emissionFrequency: 0,
|
||||
numberOfParticles: 100,
|
||||
// a lot of particles at once
|
||||
gravity: 1,
|
||||
blastDirectionality: BlastDirectionality.explosive,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
barrierDismissible: barrierDismissible,
|
||||
|
@ -115,3 +283,56 @@ Future<T> showConfettiDialog<T>({
|
|||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
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/ente_theme_data.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/utils/dialog_util.dart';
|
||||
import 'package:ente_auth/utils/toast_util.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_email_sender/flutter_email_sender.dart';
|
||||
|
@ -34,9 +33,9 @@ Future<void> sendLogs(
|
|||
BuildContext context,
|
||||
String title,
|
||||
String toEmail, {
|
||||
Function postShare,
|
||||
String subject,
|
||||
String body,
|
||||
Function? postShare,
|
||||
String? subject,
|
||||
String? body,
|
||||
}) async {
|
||||
final l10n = context.l10n;
|
||||
final List<Widget> actions = [
|
||||
|
@ -46,7 +45,7 @@ Future<void> sendLogs(
|
|||
children: [
|
||||
Icon(
|
||||
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)),
|
||||
Text(
|
||||
|
@ -64,7 +63,7 @@ Future<void> sendLogs(
|
|||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return LogFileViewer(SuperLogging.logFile);
|
||||
return LogFileViewer(SuperLogging.logFile!);
|
||||
},
|
||||
barrierColor: Colors.black87,
|
||||
barrierDismissible: false,
|
||||
|
@ -128,14 +127,14 @@ Future<void> sendLogs(
|
|||
Future<void> _sendLogs(
|
||||
BuildContext context,
|
||||
String toEmail,
|
||||
String subject,
|
||||
String body,
|
||||
String? subject,
|
||||
String? body,
|
||||
) async {
|
||||
final String zipFilePath = await getZippedLogsFile(context);
|
||||
final Email email = Email(
|
||||
recipients: [toEmail],
|
||||
subject: subject,
|
||||
body: body,
|
||||
subject: subject ?? '',
|
||||
body: body ?? '',
|
||||
attachmentPaths: [zipFilePath],
|
||||
isHTML: false,
|
||||
);
|
||||
|
@ -169,29 +168,49 @@ Future<void> shareLogs(
|
|||
String toEmail,
|
||||
String zipFilePath,
|
||||
) async {
|
||||
final l10n = context.l10n;
|
||||
final result = await showChoiceDialog(
|
||||
context,
|
||||
l10n.emailLogsTitle,
|
||||
l10n.emailLogsMessage(toEmail),
|
||||
firstAction: l10n.copyEmailAction,
|
||||
secondAction: l10n.exportLogsAction,
|
||||
final result = await showDialogWidget(
|
||||
context: context,
|
||||
title: context.l10n.emailYourLogs,
|
||||
body: context.l10n.pleaseSendTheLogsTo(toEmail),
|
||||
buttons: [
|
||||
ButtonWidget(
|
||||
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) {
|
||||
await Clipboard.setData(ClipboardData(text: toEmail));
|
||||
if (result?.action != null && result!.action == ButtonAction.second) {
|
||||
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(
|
||||
BuildContext context, {
|
||||
@required String to,
|
||||
String subject,
|
||||
String body,
|
||||
required String to,
|
||||
String? subject,
|
||||
String? body,
|
||||
}) async {
|
||||
try {
|
||||
final String clientDebugInfo = await _clientInfo();
|
||||
|
|
|
@ -790,6 +790,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
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:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -4,7 +4,7 @@ version: 1.0.36+36
|
|||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
sdk: '>=2.17.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
adaptive_theme: ^3.1.0 # done
|
||||
|
@ -48,6 +48,7 @@ dependencies:
|
|||
json_annotation: ^4.5.0
|
||||
local_auth: ^1.1.5
|
||||
logging: ^1.0.1
|
||||
modal_bottom_sheet: ^3.0.0-pre
|
||||
move_to_background: ^1.0.2
|
||||
open_filex: ^4.3.2
|
||||
otp: ^3.1.1
|
||||
|
|
|
@ -6,7 +6,7 @@ import "package:flutter_test/flutter_test.dart";
|
|||
void main() {
|
||||
group("App", () {
|
||||
testWidgets("renders CounterPage", (tester) async {
|
||||
await tester.pumpWidget(const App(Locale("en")));
|
||||
await tester.pumpWidget(const App(locale: Locale("en")));
|
||||
// expect(find.byType(CounterPage), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue