|
@@ -1,5 +1,3 @@
|
|
|
-
|
|
|
-
|
|
|
import 'package:ente_auth/core/configuration.dart';
|
|
|
import 'package:ente_auth/l10n/l10n.dart';
|
|
|
import 'package:ente_auth/services/user_service.dart';
|
|
@@ -14,6 +12,7 @@ import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:logging/logging.dart';
|
|
|
import 'package:password_strength/password_strength.dart';
|
|
|
+import 'package:styled_text/styled_text.dart';
|
|
|
|
|
|
enum PasswordEntryMode {
|
|
|
set,
|
|
@@ -87,13 +86,13 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String title = "Set password";
|
|
|
+ String title = context.l10n.setPasswordTitle;
|
|
|
if (widget.mode == PasswordEntryMode.update) {
|
|
|
- title = "Change password";
|
|
|
+ title = context.l10n.changePasswordTitle;
|
|
|
} else if (widget.mode == PasswordEntryMode.reset) {
|
|
|
- title = "Reset password";
|
|
|
+ title = context.l10n.resetPasswordTitle;
|
|
|
} else if (_volatilePassword != null) {
|
|
|
- title = "Encryption keys";
|
|
|
+ title = context.l10n.encryptionKeys;
|
|
|
}
|
|
|
return Scaffold(
|
|
|
resizeToAvoidBottomInset: isKeypadOpen,
|
|
@@ -130,13 +129,13 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
|
|
|
Widget _getBody(String buttonTextAndHeading) {
|
|
|
final email = Configuration.instance.getEmail();
|
|
|
- var passwordStrengthText = 'Weak';
|
|
|
+ var passwordStrengthText = context.l10n.weakStrength;
|
|
|
var passwordStrengthColor = Colors.redAccent;
|
|
|
if (_passwordStrength > kStrongPasswordStrengthThreshold) {
|
|
|
- passwordStrengthText = 'Strong';
|
|
|
+ passwordStrengthText = context.l10n.strongStrength;
|
|
|
passwordStrengthColor = Colors.greenAccent;
|
|
|
} else if (_passwordStrength > kMildPasswordStrengthThreshold) {
|
|
|
- passwordStrengthText = 'Moderate';
|
|
|
+ passwordStrengthText = context.l10n.moderateStrength;
|
|
|
passwordStrengthColor = Colors.orangeAccent;
|
|
|
}
|
|
|
if (_volatilePassword != null) {
|
|
@@ -159,9 +158,9 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
child: Text(
|
|
|
- "Enter a" +
|
|
|
- (widget.mode != PasswordEntryMode.set ? " new " : " ") +
|
|
|
- "password we can use to encrypt your data",
|
|
|
+ widget.mode == PasswordEntryMode.set
|
|
|
+ ? context.l10n.enterPasswordToEncrypt
|
|
|
+ : context.l10n.enterNewPasswordToEncrypt,
|
|
|
textAlign: TextAlign.start,
|
|
|
style: Theme.of(context)
|
|
|
.textTheme
|
|
@@ -172,26 +171,20 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
const Padding(padding: EdgeInsets.all(8)),
|
|
|
Padding(
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
- child: RichText(
|
|
|
- text: TextSpan(
|
|
|
- style: Theme.of(context)
|
|
|
- .textTheme
|
|
|
- .subtitle1!
|
|
|
- .copyWith(fontSize: 14),
|
|
|
- children: [
|
|
|
- const TextSpan(
|
|
|
- text:
|
|
|
- "We don't store this password, so if you forget, ",
|
|
|
- ),
|
|
|
- TextSpan(
|
|
|
- text: "we cannot decrypt your data",
|
|
|
- style: Theme.of(context).textTheme.subtitle1!.copyWith(
|
|
|
- fontSize: 14,
|
|
|
- decoration: TextDecoration.underline,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
+ child: StyledText(
|
|
|
+ text: context.l10n.passwordWarning,
|
|
|
+ style: Theme.of(context)
|
|
|
+ .textTheme
|
|
|
+ .subtitle1!
|
|
|
+ .copyWith(fontSize: 14),
|
|
|
+ tags: {
|
|
|
+ 'underline': StyledTextTag(
|
|
|
+ style: Theme.of(context).textTheme.subtitle1!.copyWith(
|
|
|
+ fontSize: 14,
|
|
|
+ decoration: TextDecoration.underline,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ },
|
|
|
),
|
|
|
),
|
|
|
const Padding(padding: EdgeInsets.all(12)),
|
|
@@ -217,7 +210,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
fillColor:
|
|
|
_isPasswordValid ? _validFieldValueColor : null,
|
|
|
filled: true,
|
|
|
- hintText: "Password",
|
|
|
+ hintText: context.l10n.password,
|
|
|
contentPadding: const EdgeInsets.all(20),
|
|
|
border: UnderlineInputBorder(
|
|
|
borderSide: BorderSide.none,
|
|
@@ -280,7 +273,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
decoration: InputDecoration(
|
|
|
fillColor: _passwordsMatch ? _validFieldValueColor : null,
|
|
|
filled: true,
|
|
|
- hintText: "Confirm password",
|
|
|
+ hintText: context.l10n.confirmPassword,
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
horizontal: 20,
|
|
|
vertical: 20,
|
|
@@ -335,7 +328,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
padding:
|
|
|
const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
|
|
|
child: Text(
|
|
|
- 'Password Strength: $passwordStrengthText',
|
|
|
+ context.l10n.passwordStrength(passwordStrengthText),
|
|
|
style: TextStyle(
|
|
|
color: passwordStrengthColor,
|
|
|
),
|
|
@@ -349,8 +342,8 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
Navigator.of(context).push(
|
|
|
MaterialPageRoute(
|
|
|
builder: (BuildContext context) {
|
|
|
- return const WebPage(
|
|
|
- "How it works",
|
|
|
+ return WebPage(
|
|
|
+ context.l10n.howItWorks,
|
|
|
"https://ente.io/architecture",
|
|
|
);
|
|
|
},
|
|
@@ -361,7 +354,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
child: RichText(
|
|
|
text: TextSpan(
|
|
|
- text: "How it works",
|
|
|
+ text: context.l10n.howItWorks,
|
|
|
style: Theme.of(context).textTheme.subtitle1!.copyWith(
|
|
|
fontSize: 14,
|
|
|
decoration: TextDecoration.underline,
|
|
@@ -381,14 +374,14 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
|
|
|
void _updatePassword() async {
|
|
|
final dialog =
|
|
|
- createProgressDialog(context, "Generating encryption keys...");
|
|
|
+ createProgressDialog(context, context.l10n.generatingEncryptionKeys);
|
|
|
await dialog.show();
|
|
|
try {
|
|
|
final keyAttributes = await Configuration.instance
|
|
|
.updatePassword(_passwordController1.text);
|
|
|
await UserService.instance.updateKeyAttributes(keyAttributes);
|
|
|
await dialog.hide();
|
|
|
- showShortToast(context, "Password changed successfully");
|
|
|
+ showShortToast(context, context.l10n.passwordChangedSuccessfully);
|
|
|
Navigator.of(context).pop();
|
|
|
if (widget.mode == PasswordEntryMode.reset) {
|
|
|
Navigator.of(context).popUntil((route) => route.isFirst);
|
|
@@ -434,7 +427,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
context,
|
|
|
RecoveryKeyPage(
|
|
|
result.privateKeyAttributes.recoveryKey,
|
|
|
- "Continue",
|
|
|
+ context.l10n.continueLabel,
|
|
|
showAppBar: false,
|
|
|
isDismissible: false,
|
|
|
onDone: onDone,
|
|
@@ -447,8 +440,8 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
|
|
|
if (e is UnsupportedError) {
|
|
|
showErrorDialog(
|
|
|
context,
|
|
|
- "Insecure device",
|
|
|
- "Sorry, we could not generate secure keys on this device.\n\nplease sign up from a different device.",
|
|
|
+ context.l10n.insecureDevice,
|
|
|
+ context.l10n.sorryWeCouldNotGenerateSecureKeysOnThisDevicennplease,
|
|
|
);
|
|
|
} else {
|
|
|
showGenericErrorDialog(context: context);
|