Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] update: Photos login components (#11009)

Aman Raj064919299e63
diff --git a/mobile/apps/photos/changes/login-signup-components.md b/mobile/apps/photos/changes/login-signup-components.md
new file mode 100644
index 0000000000..b8f1a2c61a
--- /dev/null
+++ b/mobile/apps/photos/changes/login-signup-components.md
@@ -0,0 +1 @@
+- Update the Photos login and signup flow components and keyboard handling.
diff --git a/mobile/apps/photos/lib/ui/account/email_entry_page.dart b/mobile/apps/photos/lib/ui/account/email_entry_page.dart
index 6bf4dab852..ab20c0a41e 100644
--- a/mobile/apps/photos/lib/ui/account/email_entry_page.dart
+++ b/mobile/apps/photos/lib/ui/account/email_entry_page.dart
@@ -1,20 +1,15 @@
import 'dart:async';
import 'package:email_validator/email_validator.dart';
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import 'package:password_strength/password_strength.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import "package:photos/ui/account/login_page.dart";
import 'package:photos/ui/common/web_page.dart';
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/models/text_input_type_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import "package:photos/ui/settings/developer_settings_tap_area.dart";
import "package:styled_text/styled_text.dart";
@@ -86,19 +81,18 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isKeyboardOpen = MediaQuery.of(context).viewInsets.bottom > 0;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
@@ -107,61 +101,44 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
behavior: HitTestBehavior.translucent,
child: Text(
AppLocalizations.of(context).createAccountTitle,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("createAccountButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).createAccountTitle,
+ label: AppLocalizations.of(context).createAccountTitle,
isDisabled: !_isFormValid(),
- onTap: _isFormValid()
- ? () async {
- _config.setVolatilePassword(_passwordController1.text);
- await UserService.instance.setEmail(_email!);
- await UserService.instance.setRefSource(
- await _referralSourceForSubmission(),
- );
- await UserService.instance.sendOtt(
- context,
- _email!,
- isCreateAccountScreen: true,
- purpose: "signup",
- );
- FocusScope.of(context).unfocus();
- }
- : null,
+ onTap: _isFormValid() ? _submitCreateAccount : null,
),
),
- bottomNavigationBar: isKeyboardOpen
- ? null
- : _getLoginPrompt(colorScheme, textTheme),
+ bottomNavigationBar: isKeyboardOpen ? null : _getLoginPrompt(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
String? passwordMessage;
- TextInputMessageType passwordMessageType = TextInputMessageType.guide;
+ TextInputComponentMessageType passwordMessageType =
+ TextInputComponentMessageType.helper;
if (_password != null && _password!.isNotEmpty && _showPasswordStrength) {
if (_passwordStrength > kStrongPasswordStrengthThreshold) {
passwordMessage = AppLocalizations.of(context).strongPassword;
- passwordMessageType = TextInputMessageType.success;
+ passwordMessageType = TextInputComponentMessageType.success;
} else if (_passwordStrength <= kMildPasswordStrengthThreshold) {
passwordMessage = AppLocalizations.of(context).weakStrength;
- passwordMessageType = TextInputMessageType.alert;
+ passwordMessageType = TextInputComponentMessageType.alert;
}
}
String? confirmPasswordMessage;
- TextInputMessageType confirmPasswordMessageType =
- TextInputMessageType.guide;
+ TextInputComponentMessageType confirmPasswordMessageType =
+ TextInputComponentMessageType.helper;
if (_cnfPassword.isNotEmpty &&
_password != null &&
@@ -169,12 +146,12 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
_showConfirmPasswordValidation) {
if (_passwordsMatch) {
confirmPasswordMessage = AppLocalizations.of(context).passwordsMatch;
- confirmPasswordMessageType = TextInputMessageType.success;
+ confirmPasswordMessageType = TextInputComponentMessageType.success;
} else {
confirmPasswordMessage = AppLocalizations.of(
context,
).passwordsDontMatch;
- confirmPasswordMessageType = TextInputMessageType.error;
+ confirmPasswordMessageType = TextInputComponentMessageType.error;
}
}
@@ -188,34 +165,34 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 24),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).email,
hintText: AppLocalizations.of(context).email,
- textEditingController: _emailController,
+ controller: _emailController,
keyboardType: TextInputType.emailAddress,
autofillHints: const [AutofillHints.email],
- autoCorrect: false,
+ autocorrect: false,
isRequired: true,
- onChange: _onEmailChanged,
+ onChanged: _onEmailChanged,
message: _showEmailValidation && !_emailIsValid
? AppLocalizations.of(context).invalidEmailAddress
: null,
messageType: _showEmailValidation && !_emailIsValid
- ? TextInputMessageType.alert
- : TextInputMessageType.guide,
+ ? TextInputComponentMessageType.alert
+ : TextInputComponentMessageType.helper,
),
const SizedBox(height: 24),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).password,
hintText: AppLocalizations.of(context).password,
- textEditingController: _passwordController1,
+ controller: _passwordController1,
isPasswordInput: true,
isRequired: true,
- autoCorrect: false,
+ autocorrect: false,
autofillHints: const [AutofillHints.newPassword],
message: passwordMessage,
messageType: passwordMessageType,
- onChange: (password) {
+ onChanged: (password) {
if (password != _password) {
_passwordStrengthTimer?.cancel();
setState(() {
@@ -243,18 +220,22 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
},
),
const SizedBox(height: 24),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).confirmPassword,
hintText: AppLocalizations.of(context).confirmPassword,
- textEditingController: _passwordController2,
+ controller: _passwordController2,
isPasswordInput: true,
isRequired: true,
- autoCorrect: false,
+ autocorrect: false,
autofillHints: const [],
finishAutofillContextOnEditingComplete: true,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: _isFormValid()
+ ? (_) => _submitCreateAccount()
+ : null,
message: confirmPasswordMessage,
messageType: confirmPasswordMessageType,
- onChange: (cnfPassword) {
+ onChanged: (cnfPassword) {
_confirmPasswordTimer?.cancel();
setState(() {
_cnfPassword = cnfPassword;
@@ -277,16 +258,20 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
),
if (_showReferralSourceField) ...[
const SizedBox(height: 24),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).hearUsWhereTitle,
- autoCorrect: false,
- onChange: (value) {
+ autocorrect: false,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: _isFormValid()
+ ? (_) => _submitCreateAccount()
+ : null,
+ onChanged: (value) {
_referralSource = value.trim();
},
),
],
const SizedBox(height: 16),
- _getTOSAgreement(colorScheme, textTheme),
+ _getTOSAgreement(),
],
),
),
@@ -313,6 +298,24 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
String get _routeSource => widget.referralSource?.trim() ?? '';
+ Future<void> _submitCreateAccount() async {
+ if (!_isFormValid()) {
+ return;
+ }
+ _config.setVolatilePassword(_passwordController1.text);
+ await UserService.instance.setEmail(_email!);
+ await UserService.instance.setRefSource(
+ await _referralSourceForSubmission(),
+ );
+ await UserService.instance.sendOtt(
+ context,
+ _email!,
+ isCreateAccountScreen: true,
+ purpose: "signup",
+ );
+ FocusScope.of(context).unfocus();
+ }
+
Future<void> _updateReferralSourceFieldVisibility() async {
final hasInstallSource = await installSourceService.hasInstallSource();
_setHasInstallSource(hasInstallSource);
@@ -338,7 +341,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
}
}
- Widget _getLoginPrompt(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getLoginPrompt() {
+ final colors = context.componentColors;
return SafeArea(
top: false,
child: Padding(
@@ -348,12 +352,13 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
children: [
Text(
AppLocalizations.of(context).alreadyHaveAnAccount,
- style: textTheme.bodyMuted,
+ style: TextStyles.body.copyWith(color: colors.textLight),
),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).logInLabel,
- buttonSize: ButtonSizeV2.small,
+ const SizedBox(width: 4),
+ ButtonComponent(
+ label: AppLocalizations.of(context).logInLabel,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
shouldSurfaceExecutionStates: false,
onTap: _goToLoginPage,
),
@@ -386,10 +391,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
}
}
- Widget _getTOSAgreement(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
+ Widget _getTOSAgreement() {
+ final colors = context.componentColors;
return GestureDetector(
onTap: () {
setState(() {
@@ -402,7 +405,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
Checkbox(
fillColor: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.selected)) {
- return colorScheme.greenBase;
+ return colors.primary;
}
return null;
}),
@@ -422,7 +425,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
Expanded(
child: StyledText(
text: AppLocalizations.of(context).signUpTerms,
- style: textTheme.small.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.mini.copyWith(color: colors.textLight),
tags: {
'u-terms': StyledTextActionTag(
(String? text, Map<String?, String?> attrs) =>
@@ -438,7 +441,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
),
style: TextStyle(
decoration: TextDecoration.underline,
- color: colorScheme.textMuted,
+ color: colors.textLight,
),
),
'u-policy': StyledTextActionTag(
@@ -455,7 +458,7 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
),
style: TextStyle(
decoration: TextDecoration.underline,
- color: colorScheme.textMuted,
+ color: colors.textLight,
),
),
},
diff --git a/mobile/apps/photos/lib/ui/account/login_page.dart b/mobile/apps/photos/lib/ui/account/login_page.dart
index ceca190c16..208dc17eed 100644
--- a/mobile/apps/photos/lib/ui/account/login_page.dart
+++ b/mobile/apps/photos/lib/ui/account/login_page.dart
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:email_validator/email_validator.dart';
+import "package:ente_components/ente_components.dart";
import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
@@ -9,14 +10,8 @@ import "package:photos/core/errors.dart";
import "package:photos/gateways/users/models/srp.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import "package:photos/ui/account/email_entry_page.dart";
import "package:photos/ui/account/login_pwd_verification_page.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/models/text_input_type_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import "package:photos/ui/settings/developer_settings_tap_area.dart";
class LoginPage extends StatefulWidget {
@@ -36,8 +31,8 @@ class _LoginPageState extends State<LoginPage> {
final Logger _logger = Logger('_LoginPageState');
@override
- void didChangeDependencies() {
- super.didChangeDependencies();
+ void initState() {
+ super.initState();
if ((_config.getEmail() ?? '').isNotEmpty) {
_updateEmail(_config.getEmail()!);
} else if (kDebugMode) {
@@ -61,19 +56,18 @@ class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isKeyboardOpen = MediaQuery.of(context).viewInsets.bottom > 0;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
@@ -82,30 +76,27 @@ class _LoginPageState extends State<LoginPage> {
behavior: HitTestBehavior.translucent,
child: Text(
AppLocalizations.of(context).loginToEnte,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("logInButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).continueLabel,
+ label: AppLocalizations.of(context).continueLabel,
isDisabled: !_emailIsValid,
- onTap: _emailIsValid ? _onLoginPressed : null,
+ onTap: _emailIsValid ? _submitLoginEmail : null,
),
),
- bottomNavigationBar: isKeyboardOpen
- ? null
- : _getSignUpPrompt(colorScheme, textTheme),
+ bottomNavigationBar: isKeyboardOpen ? null : _getSignUpPrompt(),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
return AutofillGroup(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
@@ -113,23 +104,25 @@ class _LoginPageState extends State<LoginPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 20),
- TextInputWidgetV2(
+ TextInputComponent(
key: const ValueKey("emailInputField"),
label: AppLocalizations.of(context).email,
hintText: AppLocalizations.of(context).enterYourEmailAddress,
- textEditingController: _emailController,
+ controller: _emailController,
keyboardType: TextInputType.emailAddress,
autofillHints: const [AutofillHints.email],
- autoCorrect: false,
- autoFocus: true,
+ autocorrect: false,
+ autofocus: true,
isRequired: true,
- onChange: _onEmailChanged,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: (_) => _submitLoginEmail(),
+ onChanged: _onEmailChanged,
message: _showValidationMessage && !_emailIsValid
? AppLocalizations.of(context).invalidEmailAddress
: null,
messageType: _showValidationMessage && !_emailIsValid
- ? TextInputMessageType.alert
- : TextInputMessageType.guide,
+ ? TextInputComponentMessageType.alert
+ : TextInputComponentMessageType.helper,
),
const SizedBox(height: 24),
const Expanded(child: DeveloperSettingsTapArea()),
@@ -139,10 +132,8 @@ class _LoginPageState extends State<LoginPage> {
);
}
- Widget _getSignUpPrompt(
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
+ Widget _getSignUpPrompt() {
+ final colors = context.componentColors;
return SafeArea(
top: false,
child: Padding(
@@ -150,11 +141,16 @@ class _LoginPageState extends State<LoginPage> {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
- Text("Don't have an account?", style: textTheme.bodyMuted),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).signUp,
- buttonSize: ButtonSizeV2.small,
+ Text(
+ AppLocalizations.of(context).dontHaveAnAccount,
+ style: TextStyles.body.copyWith(color: colors.textLight),
+ ),
+ const SizedBox(width: 4),
+
+ ButtonComponent(
+ label: AppLocalizations.of(context).signUp,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
shouldSurfaceExecutionStates: false,
onTap: _goToSignUpPage,
),
@@ -187,6 +183,21 @@ class _LoginPageState extends State<LoginPage> {
}
}
+ Future<void> _submitLoginEmail() async {
+ final trimmed = _emailController.text.trim();
+ final isValid = EmailValidator.validate(trimmed);
+ if (!isValid) {
+ setState(() {
+ _email = trimmed;
+ _emailIsValid = false;
+ _showValidationMessage = true;
+ });
+ return;
+ }
+ _email = trimmed;
+ await _onLoginPressed();
+ }
+
Future<void> _onLoginPressed() async {
await UserService.instance.setEmail(_email!);
Configuration.instance.resetVolatilePassword();
diff --git a/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart b/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart
index 89185533b4..43dadb7e51 100644
--- a/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart
+++ b/mobile/apps/photos/lib/ui/account/login_pwd_verification_page.dart
@@ -1,4 +1,5 @@
import "package:dio/dio.dart";
+import "package:ente_components/ente_components.dart";
import "package:ente_crypto/ente_crypto.dart";
import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
@@ -7,13 +8,8 @@ import 'package:photos/core/configuration.dart';
import "package:photos/gateways/users/models/srp.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/services/account/user_service.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import "package:photos/ui/components/buttons/button_widget.dart"
show ButtonAction;
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import "package:photos/utils/dialog_util.dart";
import "package:photos/utils/email_util.dart";
@@ -57,50 +53,51 @@ class _LoginPasswordVerificationPageState
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).logInLabel,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("verifyPasswordButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).logInLabel,
+ label: AppLocalizations.of(context).logInLabel,
isDisabled: !_hasPassword,
- onTap: _hasPassword
- ? () async {
- FocusScope.of(context).unfocus();
- await verifyPassword(context, _passwordController.text);
- }
- : null,
+ onTap: _verifyEnteredPassword,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Future<void> _verifyEnteredPassword() async {
+ if (!_hasPassword) {
+ return;
+ }
+ FocusScope.of(context).unfocus();
+ await verifyPassword(context, _passwordController.text);
+ }
+
+ Widget _getBody() {
return AutofillGroup(
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16),
@@ -116,16 +113,18 @@ class _LoginPasswordVerificationPageState
textInputAction: TextInputAction.next,
),
),
- TextInputWidgetV2(
+ TextInputComponent(
key: const ValueKey("passwordInputField"),
label: AppLocalizations.of(context).password,
hintText: AppLocalizations.of(context).enterYourPassword,
- textEditingController: _passwordController,
+ controller: _passwordController,
isPasswordInput: true,
isRequired: true,
- autoCorrect: false,
- autoFocus: true,
- onChange: (value) {
+ autocorrect: false,
+ autofocus: true,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: (_) => _verifyEnteredPassword(),
+ onChanged: (value) {
final hasPassword = value.isNotEmpty;
if (_hasPassword != hasPassword) {
setState(() {
@@ -137,10 +136,10 @@ class _LoginPasswordVerificationPageState
const SizedBox(height: 12),
Align(
alignment: Alignment.centerRight,
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).forgotPassword,
- buttonSize: ButtonSizeV2.small,
+ child: ButtonComponent(
+ variant: ButtonComponentVariant.link,
+ label: AppLocalizations.of(context).forgotPassword,
+ size: ButtonComponentSize.small,
onTap: () async {
await UserService.instance.sendOtt(
context,
diff --git a/mobile/apps/photos/lib/ui/account/ott_verification_page.dart b/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
index 54b542609e..b66a4b7c38 100644
--- a/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
+++ b/mobile/apps/photos/lib/ui/account/ott_verification_page.dart
@@ -1,10 +1,7 @@
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import "package:photos/generated/l10n.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import "package:pinput/pinput.dart";
class OTTVerificationPage extends StatefulWidget {
@@ -72,37 +69,35 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isFormValid = _code.length == 6 && !_isSubmitting;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).verifyEmail,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("verifyOttButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).verify,
+ label: AppLocalizations.of(context).verify,
isDisabled: !isFormValid,
onTap: isFormValid ? _onVerifyPressed : null,
),
@@ -111,29 +106,30 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
+ final colors = context.componentColors;
final defaultPinTheme = PinTheme(
height: 52,
width: 48,
- textStyle: textTheme.body.copyWith(color: colorScheme.textBase),
+ textStyle: TextStyles.body.copyWith(color: colors.textBase),
decoration: BoxDecoration(
- border: Border.all(color: colorScheme.strokeMuted),
+ border: Border.all(color: colors.strokeFaint),
borderRadius: BorderRadius.circular(20),
),
);
final focusedPinTheme = defaultPinTheme.copyWith(
decoration: BoxDecoration(
- border: Border.all(color: colorScheme.greenBase, width: 2),
+ border: Border.all(color: colors.primary, width: 2),
borderRadius: BorderRadius.circular(20),
),
);
final submittedPinTheme = defaultPinTheme.copyWith(
- textStyle: textTheme.h3Bold.copyWith(color: colorScheme.greenBase),
+ textStyle: TextStyles.h1.copyWith(color: colors.primary),
decoration: BoxDecoration(
- color: colorScheme.greenLight,
- border: Border.all(color: colorScheme.greenBase, width: 2),
+ color: colors.primaryLight,
+ border: Border.all(color: colors.primary, width: 2),
borderRadius: BorderRadius.circular(20),
),
);
@@ -149,7 +145,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
AppLocalizations.of(
context,
).weHaveSentCodeTo(email: widget.email),
- style: textTheme.body.copyWith(color: colorScheme.textBase),
+ style: TextStyles.body.copyWith(color: colors.textBase),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
@@ -157,7 +153,7 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
widget.isResetPasswordScreen
? AppLocalizations.of(context).toResetVerifyEmail
: AppLocalizations.of(context).checkInboxAndSpamFolder,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.body.copyWith(color: colors.textLight),
textAlign: TextAlign.center,
),
const SizedBox(height: 32),
@@ -186,10 +182,10 @@ class _OTTVerificationPageState extends State<OTTVerificationPage> {
const SizedBox(height: 24),
Align(
alignment: Alignment.centerRight,
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).resendCode,
- buttonSize: ButtonSizeV2.small,
+ child: ButtonComponent(
+ label: AppLocalizations.of(context).resendCode,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
onTap: () async {
// ignore: unawaited_futures
UserService.instance.sendOtt(
diff --git a/mobile/apps/photos/lib/ui/account/passkey_page.dart b/mobile/apps/photos/lib/ui/account/passkey_page.dart
index f32220fd28..257cca0299 100644
--- a/mobile/apps/photos/lib/ui/account/passkey_page.dart
+++ b/mobile/apps/photos/lib/ui/account/passkey_page.dart
@@ -2,6 +2,7 @@ import "dart:async";
import 'dart:convert';
import "package:app_links/app_links.dart";
+import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
@@ -11,12 +12,8 @@ import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/models/account/two_factor.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import "package:photos/ui/account/two_factor_authentication_page.dart";
import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import "package:photos/ui/notification/toast.dart";
import "package:photos/utils/dialog_util.dart";
import 'package:url_launcher/url_launcher_string.dart';
@@ -148,33 +145,33 @@ class _PasskeyPageState extends State<PasskeyPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
return Scaffold(
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).passkey,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
+ final colors = context.componentColors;
return SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
@@ -183,19 +180,18 @@ class _PasskeyPageState extends State<PasskeyPage> {
const Spacer(),
Text(
context.l10n.waitingForVerification,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.body.copyWith(color: colors.textLight),
textAlign: TextAlign.center,
),
const Spacer(),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: context.l10n.tryAgain,
+ ButtonComponent(
+ label: context.l10n.tryAgain,
onTap: () => launchPasskey(),
),
const SizedBox(height: 16),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.secondary,
- labelText: context.l10n.checkStatus,
+ ButtonComponent(
+ label: context.l10n.checkStatus,
+ variant: ButtonComponentVariant.secondary,
shouldSurfaceExecutionStates: true,
onTap: () async {
try {
@@ -211,10 +207,10 @@ class _PasskeyPageState extends State<PasskeyPage> {
),
if (widget.totp2FASessionID.isNotEmpty) ...[
const SizedBox(height: 16),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: context.l10n.loginWithTOTP,
- buttonSize: ButtonSizeV2.small,
+ ButtonComponent(
+ label: context.l10n.loginWithTOTP,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
onTap: () async {
// ignore: unawaited_futures
routeToPage(
@@ -225,10 +221,10 @@ class _PasskeyPageState extends State<PasskeyPage> {
),
],
const SizedBox(height: 12),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: context.l10n.recoverAccount,
- buttonSize: ButtonSizeV2.small,
+ ButtonComponent(
+ label: context.l10n.recoverAccount,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
onTap: () async {
// ignore: unawaited_futures
UserService.instance.recoverTwoFactor(
diff --git a/mobile/apps/photos/lib/ui/account/password_entry_page.dart b/mobile/apps/photos/lib/ui/account/password_entry_page.dart
index 0ef289ff51..6ad09601b1 100644
--- a/mobile/apps/photos/lib/ui/account/password_entry_page.dart
+++ b/mobile/apps/photos/lib/ui/account/password_entry_page.dart
@@ -1,5 +1,6 @@
import "dart:async";
+import "package:ente_components/ente_components.dart";
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
@@ -12,16 +13,10 @@ import "package:photos/gateways/users/models/key_gen_result.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import 'package:photos/ui/account/recovery_key_page.dart';
import 'package:photos/ui/common/web_page.dart';
import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import "package:photos/ui/components/models/button_type.dart";
-import "package:photos/ui/components/models/text_input_type_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/ui/payment/subscription.dart';
import 'package:photos/utils/dialog_util.dart';
@@ -80,8 +75,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
String title = AppLocalizations.of(context).setPasswordTitle;
if (widget.mode == PasswordEntryMode.update) {
@@ -96,86 +90,89 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: widget.mode == PasswordEntryMode.reset
? const SizedBox.shrink()
: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
- title: Text(title, style: textTheme.largeBold),
+ title: Text(
+ title,
+ style: TextStyles.large.copyWith(color: colors.textBase),
+ ),
centerTitle: true,
),
- body: _volatilePassword != null
- ? const SizedBox.shrink()
- : _getBody(colorScheme, textTheme),
+ body: _volatilePassword != null ? const SizedBox.shrink() : _getBody(),
floatingActionButton: _volatilePassword != null
? null
: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: title,
+ child: ButtonComponent(
+ label: title,
isDisabled: !isFormValid,
- onTap: isFormValid
- ? () async {
- if (widget.mode == PasswordEntryMode.set) {
- await _showRecoveryCodeDialog(
- _passwordController1.text,
- );
- } else {
- _updatePassword();
- }
- FocusScope.of(context).unfocus();
- }
- : null,
+ onTap: isFormValid ? _submitPassword : null,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Future<void> _submitPassword() async {
+ if (!_passwordsMatch || !_isPasswordValid) {
+ return;
+ }
+ if (widget.mode == PasswordEntryMode.set) {
+ await _showRecoveryCodeDialog(_passwordController1.text);
+ } else {
+ _updatePassword();
+ }
+ FocusScope.of(context).unfocus();
+ }
+
+ Widget _getBody() {
+ final colors = context.componentColors;
final email = Configuration.instance.getEmail();
String? passwordMessage;
- TextInputMessageType passwordMessageType = TextInputMessageType.guide;
+ TextInputComponentMessageType passwordMessageType =
+ TextInputComponentMessageType.helper;
if (_passwordInInputBox.isNotEmpty && _showPasswordStrength) {
if (_passwordStrength > kStrongPasswordStrengthThreshold) {
passwordMessage = AppLocalizations.of(context).strongPassword;
- passwordMessageType = TextInputMessageType.success;
+ passwordMessageType = TextInputComponentMessageType.success;
} else if (_passwordStrength > kMildPasswordStrengthThreshold) {
passwordMessage = AppLocalizations.of(context).moderateStrength;
- passwordMessageType = TextInputMessageType.alert;
+ passwordMessageType = TextInputComponentMessageType.alert;
} else {
passwordMessage = AppLocalizations.of(context).weakStrength;
- passwordMessageType = TextInputMessageType.alert;
+ passwordMessageType = TextInputComponentMessageType.alert;
}
}
String? confirmPasswordMessage;
- TextInputMessageType confirmPasswordMessageType =
- TextInputMessageType.guide;
+ TextInputComponentMessageType confirmPasswordMessageType =
+ TextInputComponentMessageType.helper;
if (_passwordInInputConfirmationBox.isNotEmpty &&
_passwordInInputBox.isNotEmpty &&
_showConfirmPasswordValidation) {
if (_passwordsMatch) {
confirmPasswordMessage = AppLocalizations.of(context).passwordsMatch;
- confirmPasswordMessageType = TextInputMessageType.success;
+ confirmPasswordMessageType = TextInputComponentMessageType.success;
} else {
confirmPasswordMessage = AppLocalizations.of(
context,
).passwordsDontMatch;
- confirmPasswordMessageType = TextInputMessageType.error;
+ confirmPasswordMessageType = TextInputComponentMessageType.error;
}
}
@@ -191,16 +188,16 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
widget.mode == PasswordEntryMode.set
? AppLocalizations.of(context).enterPasswordToEncrypt
: AppLocalizations.of(context).enterNewPasswordToEncrypt,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.body.copyWith(color: colors.textLight),
),
const SizedBox(height: 8),
StyledText(
text: AppLocalizations.of(context).passwordWarning,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.body.copyWith(color: colors.textLight),
tags: {
'underline': StyledTextTag(
- style: textTheme.body.copyWith(
- color: colorScheme.textMuted,
+ style: TextStyles.body.copyWith(
+ color: colors.textLight,
decoration: TextDecoration.underline,
),
),
@@ -217,17 +214,17 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
textInputAction: TextInputAction.next,
),
),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).password,
hintText: AppLocalizations.of(context).password,
- textEditingController: _passwordController1,
+ controller: _passwordController1,
isPasswordInput: true,
isRequired: true,
- autoCorrect: false,
+ autocorrect: false,
autofillHints: const [AutofillHints.newPassword],
message: passwordMessage,
messageType: passwordMessageType,
- onChange: (password) {
+ onChanged: (password) {
_passwordStrengthTimer?.cancel();
setState(() {
_passwordInInputBox = password;
@@ -251,18 +248,22 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
},
),
const SizedBox(height: 16),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).confirmPassword,
hintText: AppLocalizations.of(context).confirmPassword,
- textEditingController: _passwordController2,
+ controller: _passwordController2,
isPasswordInput: true,
isRequired: true,
- autoCorrect: false,
+ autocorrect: false,
autofillHints: const [],
finishAutofillContextOnEditingComplete: true,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: _passwordsMatch && _isPasswordValid
+ ? (_) => _submitPassword()
+ : null,
message: confirmPasswordMessage,
messageType: confirmPasswordMessageType,
- onChange: (cnfPassword) {
+ onChanged: (cnfPassword) {
_confirmPasswordTimer?.cancel();
setState(() {
_passwordInInputConfirmationBox = cnfPassword;
@@ -285,10 +286,10 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
const SizedBox(height: 16),
Align(
alignment: Alignment.centerRight,
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).howItWorks,
- buttonSize: ButtonSizeV2.small,
+ child: ButtonComponent(
+ variant: ButtonComponentVariant.link,
+ label: AppLocalizations.of(context).howItWorks,
+ size: ButtonComponentSize.small,
onTap: () async {
await Navigator.of(context).push(
MaterialPageRoute(
diff --git a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
index afd9e68489..911c33689d 100644
--- a/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
+++ b/mobile/apps/photos/lib/ui/account/password_reentry_page.dart
@@ -1,6 +1,7 @@
import 'dart:async';
import "dart:typed_data";
+import "package:ente_components/ente_components.dart";
import "package:ente_crypto/ente_crypto.dart";
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
@@ -11,14 +12,9 @@ import 'package:photos/events/subscription_purchased_event.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/account/user_service.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import 'package:photos/ui/account/recovery_page.dart';
import 'package:photos/ui/components/buttons/button_widget.dart'
show ButtonAction;
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import 'package:photos/ui/tabs/home_widget.dart';
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/email_util.dart';
@@ -55,50 +51,51 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isFormValid = _passwordController.text.isNotEmpty;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).enterPassword,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("verifyPasswordButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).logInLabel,
+ label: AppLocalizations.of(context).logInLabel,
isDisabled: !isFormValid,
- onTap: isFormValid
- ? () async {
- FocusScope.of(context).unfocus();
- await verifyPassword(_passwordController.text);
- }
- : null,
+ onTap: isFormValid ? _onVerifyPasswordPressed : null,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
+ Future<void> _onVerifyPasswordPressed() async {
+ if (_passwordController.text.isEmpty) {
+ return;
+ }
+ FocusScope.of(context).unfocus();
+ await verifyPassword(_passwordController.text);
+ }
+
Future<void> verifyPassword(String password) async {
FocusScope.of(context).unfocus();
final dialog = createProgressDialog(
@@ -189,7 +186,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
}
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
return SafeArea(
child: AutofillGroup(
child: Padding(
@@ -210,15 +207,19 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
textInputAction: TextInputAction.next,
),
),
- TextInputWidgetV2(
+ TextInputComponent(
key: const ValueKey("passwordInputField"),
label: AppLocalizations.of(context).password,
isRequired: true,
hintText: AppLocalizations.of(context).enterYourPassword,
- textEditingController: _passwordController,
+ controller: _passwordController,
isPasswordInput: true,
- autoCorrect: false,
- onChange: (value) {
+ autocorrect: false,
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: _passwordController.text.isNotEmpty
+ ? (_) => _onVerifyPasswordPressed()
+ : null,
+ onChanged: (value) {
setState(() {});
},
),
@@ -226,10 +227,10 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).changeEmail,
- buttonSize: ButtonSizeV2.small,
+ ButtonComponent(
+ variant: ButtonComponentVariant.link,
+ label: AppLocalizations.of(context).changeEmail,
+ size: ButtonComponentSize.small,
onTap: () async {
final dialog = createProgressDialog(
context,
@@ -241,10 +242,10 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
Navigator.of(context).popUntil((route) => route.isFirst);
},
),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).forgotPassword,
- buttonSize: ButtonSizeV2.small,
+ ButtonComponent(
+ variant: ButtonComponentVariant.link,
+ label: AppLocalizations.of(context).forgotPassword,
+ size: ButtonComponentSize.small,
onTap: () async {
// ignore: unawaited_futures
Navigator.of(context).push(
diff --git a/mobile/apps/photos/lib/ui/account/recovery_key_page.dart b/mobile/apps/photos/lib/ui/account/recovery_key_page.dart
index 069ba30167..06ea1125f3 100644
--- a/mobile/apps/photos/lib/ui/account/recovery_key_page.dart
+++ b/mobile/apps/photos/lib/ui/account/recovery_key_page.dart
@@ -2,16 +2,13 @@ import 'dart:async';
import 'dart:io';
import 'package:bip39/bip39.dart' as bip39;
+import 'package:ente_components/ente_components.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hugeicons/hugeicons.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/constants.dart';
import "package:photos/generated/l10n.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/utils/share_util.dart';
import 'package:share_plus/share_plus.dart';
@@ -47,8 +44,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final String recoveryKey = bip39.entropyToMnemonic(widget.recoveryKey);
if (recoveryKey.split(' ').length != mnemonicKeyWordCount) {
@@ -58,35 +54,35 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
}
return Scaffold(
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
title: Text(
widget.title ?? AppLocalizations.of(context).recoveryKey,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: widget.isOnboarding
? const SizedBox.shrink()
: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
),
- body: SafeArea(child: _getBody(recoveryKey, colorScheme, textTheme)),
+ body: SafeArea(child: _getBody(recoveryKey)),
);
}
- Widget _getBody(
- String recoveryKey,
- EnteColorScheme colorScheme,
- EnteTextTheme textTheme,
- ) {
+ Widget _getBody(String recoveryKey) {
+ final colors = context.componentColors;
+ final lightComponentTheme = ComponentTheme.lightTheme(
+ app: ComponentApp.photos,
+ );
return Column(
children: [
Expanded(
@@ -107,19 +103,19 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
widget.text ??
AppLocalizations.of(context).recoveryKeyOnForgotPassword,
textAlign: TextAlign.center,
- style: textTheme.body.copyWith(color: colorScheme.textBase),
+ style: TextStyles.body.copyWith(color: colors.textBase),
),
const SizedBox(height: 20),
Text(
widget.subText ??
AppLocalizations.of(context).recoveryKeySaveDescription,
textAlign: TextAlign.center,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.body.copyWith(color: colors.textLight),
),
const SizedBox(height: 20),
Container(
decoration: BoxDecoration(
- color: colorScheme.greenBase,
+ color: colors.primary,
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.all(20),
@@ -132,8 +128,8 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
Expanded(
child: Text(
recoveryKey,
- style: textTheme.body.copyWith(
- color: Colors.white,
+ style: TextStyles.body.copyWith(
+ color: colors.specialWhite,
height: 24 / 14,
),
),
@@ -151,23 +147,25 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
).recoveryKeyCopiedToClipboard,
);
},
- child: const HugeIcon(
+ child: HugeIcon(
icon: HugeIcons.strokeRoundedCopy01,
- color: Colors.white,
+ color: colors.specialWhite,
size: 24,
),
),
],
),
const SizedBox(height: 12),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.secondary,
- shouldStickToLightTheme: true,
- shouldSurfaceExecutionStates: false,
- labelText: AppLocalizations.of(context).shareKey,
- onTap: () async {
- unawaited(_shareRecoveryKey(recoveryKey));
- },
+ Theme(
+ data: lightComponentTheme,
+ child: ButtonComponent(
+ variant: ButtonComponentVariant.secondary,
+ shouldSurfaceExecutionStates: false,
+ label: AppLocalizations.of(context).shareKey,
+ onTap: () async {
+ unawaited(_shareRecoveryKey(recoveryKey));
+ },
+ ),
),
],
),
@@ -179,13 +177,7 @@ class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
if (widget.isOnboarding)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 18),
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: widget.doneText,
- onTap: () async {
- await _saveKeys();
- },
- ),
+ child: ButtonComponent(label: widget.doneText, onTap: _saveKeys),
),
],
);
diff --git a/mobile/apps/photos/lib/ui/account/recovery_page.dart b/mobile/apps/photos/lib/ui/account/recovery_page.dart
index ffb20f0f2c..aa1f11f27f 100644
--- a/mobile/apps/photos/lib/ui/account/recovery_page.dart
+++ b/mobile/apps/photos/lib/ui/account/recovery_page.dart
@@ -1,11 +1,9 @@
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/generated/l10n.dart";
-import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/account/password_entry_page.dart';
import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/utils/dialog_util.dart';
@@ -27,37 +25,35 @@ class _RecoveryPageState extends State<RecoveryPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isFormValid = _recoveryKeyController.text.isNotEmpty;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).recoverAccount,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("recoveryButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).logInLabel,
+ label: AppLocalizations.of(context).logInLabel,
isDisabled: !isFormValid,
onTap: isFormValid ? _onRecoverPressed : null,
),
@@ -72,24 +68,26 @@ class _RecoveryPageState extends State<RecoveryPage> {
padding: const EdgeInsets.symmetric(horizontal: 16),
children: [
const SizedBox(height: 12),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).recoveryKey,
hintText: AppLocalizations.of(context).enterYourRecoveryKey,
- textEditingController: _recoveryKeyController,
+ controller: _recoveryKeyController,
+ keyboardType: TextInputType.multiline,
maxLines: null,
minLines: 5,
- autoCorrect: false,
- onChange: (value) {
+ autocorrect: false,
+ onChanged: (value) {
setState(() {});
},
),
const SizedBox(height: 16),
Align(
alignment: Alignment.centerRight,
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).noRecoveryKey,
- buttonSize: ButtonSizeV2.small,
+ child: ButtonComponent(
+ label: AppLocalizations.of(context).noRecoveryKey,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
+ shouldSurfaceExecutionStates: false,
onTap: () async {
// ignore: unawaited_futures
showAlertBottomSheet(
diff --git a/mobile/apps/photos/lib/ui/account/request_pwd_verification_page.dart b/mobile/apps/photos/lib/ui/account/request_pwd_verification_page.dart
index 781a742c3c..eb75175819 100644
--- a/mobile/apps/photos/lib/ui/account/request_pwd_verification_page.dart
+++ b/mobile/apps/photos/lib/ui/account/request_pwd_verification_page.dart
@@ -1,14 +1,13 @@
import "dart:convert";
import "dart:typed_data";
+import "package:ente_components/ente_components.dart";
import "package:ente_crypto/ente_crypto.dart";
import 'package:flutter/material.dart';
import "package:logging/logging.dart";
import 'package:photos/core/configuration.dart';
import "package:photos/l10n/l10n.dart";
-import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import "package:photos/utils/dialog_util.dart";
typedef OnPasswordVerifiedFn = Future<void> Function(Uint8List bytes);
@@ -32,105 +31,96 @@ class _RequestPasswordVerificationPageState
extends State<RequestPasswordVerificationPage> {
final _logger = Logger((_RequestPasswordVerificationPageState).toString());
final _passwordController = TextEditingController();
- final FocusNode _passwordFocusNode = FocusNode();
String? email;
- bool _passwordInFocus = false;
- bool _passwordVisible = false;
@override
void initState() {
super.initState();
email = Configuration.instance.getEmail();
- _passwordFocusNode.addListener(() {
- setState(() {
- _passwordInFocus = _passwordFocusNode.hasFocus;
- });
- });
}
@override
void dispose() {
_passwordController.dispose();
- _passwordFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
+ final colors = context.componentColors;
final isFormValid = _passwordController.text.isNotEmpty;
return Scaffold(
resizeToAvoidBottomInset: true,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: Theme.of(context).iconTheme.color,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
),
- body: _getBody(),
+ body: _getBody(isFormValid),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("verifyPasswordButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: context.l10n.verifyPassword,
+ label: context.l10n.verifyPassword,
isDisabled: !isFormValid,
- onTap: isFormValid
- ? () async {
- FocusScope.of(context).unfocus();
- final dialog = createProgressDialog(
- context,
- context.l10n.pleaseWait,
- );
- await dialog.show();
- try {
- final attributes = Configuration.instance
- .getKeyAttributes()!;
- final Uint8List keyEncryptionKey =
- await CryptoUtil.deriveKey(
- utf8.encode(_passwordController.text),
- CryptoUtil.base642bin(attributes.kekSalt),
- attributes.memLimit!,
- attributes.opsLimit!,
- );
- CryptoUtil.decryptSync(
- CryptoUtil.base642bin(attributes.encryptedKey),
- keyEncryptionKey,
- CryptoUtil.base642bin(attributes.keyDecryptionNonce),
- );
- await dialog.show();
- // pop
- await widget.onPasswordVerified(keyEncryptionKey);
- await dialog.hide();
- Navigator.of(context).pop(true);
- } catch (e, s) {
- _logger.severe("Error while verifying password", e, s);
- await dialog.hide();
- if (widget.onPasswordError != null) {
- widget.onPasswordError!();
- } else {
- // ignore: unawaited_futures
- showAlertBottomSheet(
- context,
- title: context.l10n.incorrectPasswordTitle,
- message: context.l10n.pleaseTryAgain,
- assetPath: 'assets/warning-grey.png',
- );
- }
- }
- }
- : null,
+ onTap: isFormValid ? _verifyPassword : null,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
}
- Widget _getBody() {
+ Future<void> _verifyPassword() async {
+ if (_passwordController.text.isEmpty) {
+ return;
+ }
+ FocusScope.of(context).unfocus();
+ final dialog = createProgressDialog(context, context.l10n.pleaseWait);
+ await dialog.show();
+ try {
+ final attributes = Configuration.instance.getKeyAttributes()!;
+ final Uint8List keyEncryptionKey = await CryptoUtil.deriveKey(
+ utf8.encode(_passwordController.text),
+ CryptoUtil.base642bin(attributes.kekSalt),
+ attributes.memLimit!,
+ attributes.opsLimit!,
+ );
+ CryptoUtil.decryptSync(
+ CryptoUtil.base642bin(attributes.encryptedKey),
+ keyEncryptionKey,
+ CryptoUtil.base642bin(attributes.keyDecryptionNonce),
+ );
+ await dialog.show();
+ // pop
+ await widget.onPasswordVerified(keyEncryptionKey);
+ await dialog.hide();
+ Navigator.of(context).pop(true);
+ } catch (e, s) {
+ _logger.severe("Error while verifying password", e, s);
+ await dialog.hide();
+ if (widget.onPasswordError != null) {
+ widget.onPasswordError!();
+ } else {
+ // ignore: unawaited_futures
+ showAlertBottomSheet(
+ context,
+ title: context.l10n.incorrectPasswordTitle,
+ message: context.l10n.pleaseTryAgain,
+ assetPath: 'assets/warning-grey.png',
+ );
+ }
+ }
+ }
+
+ Widget _getBody(bool isFormValid) {
return Column(
children: [
Expanded(
@@ -141,7 +131,9 @@ class _RequestPasswordVerificationPageState
padding: const EdgeInsets.only(top: 30, left: 20, right: 20),
child: Text(
context.l10n.enterPassword,
- style: Theme.of(context).textTheme.headlineMedium,
+ style: TextStyles.display2.copyWith(
+ color: context.componentColors.textBase,
+ ),
),
),
Padding(
@@ -152,7 +144,9 @@ class _RequestPasswordVerificationPageState
),
child: Text(
email ?? '',
- style: getEnteTextTheme(context).smallMuted,
+ style: TextStyles.mini.copyWith(
+ color: context.componentColors.textLight,
+ ),
),
),
Visibility(
@@ -168,43 +162,18 @@ class _RequestPasswordVerificationPageState
),
),
Padding(
- padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
- child: TextFormField(
+ padding: const EdgeInsets.fromLTRB(16, 24, 16, 0),
+ child: TextInputComponent(
key: const ValueKey("passwordInputField"),
- autofillHints: const [AutofillHints.password],
- decoration: InputDecoration(
- hintText: context.l10n.enterYourPassword,
- filled: true,
- fillColor: getEnteColorScheme(context).fillFaint,
- contentPadding: const EdgeInsets.all(20),
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(6),
- ),
- suffixIcon: _passwordInFocus
- ? IconButton(
- icon: Icon(
- _passwordVisible
- ? Icons.visibility
- : Icons.visibility_off,
- color: Theme.of(context).iconTheme.color,
- size: 20,
- ),
- onPressed: () {
- setState(() {
- _passwordVisible = !_passwordVisible;
- });
- },
- )
- : null,
- ),
- style: const TextStyle(fontSize: 14),
controller: _passwordController,
+ hintText: context.l10n.enterYourPassword,
autofocus: true,
autocorrect: false,
- obscureText: !_passwordVisible,
+ isPasswordInput: true,
keyboardType: TextInputType.visiblePassword,
- focusNode: _passwordFocusNode,
+ autofillHints: const [AutofillHints.password],
+ shouldUnfocusOnClearOrSubmit: true,
+ onSubmit: isFormValid ? (_) => _verifyPassword() : null,
onChanged: (_) {
setState(() {});
},
@@ -214,7 +183,7 @@ class _RequestPasswordVerificationPageState
padding: const EdgeInsets.symmetric(vertical: 18),
child: Divider(
thickness: 1,
- color: getEnteColorScheme(context).strokeFaint,
+ color: context.componentColors.strokeFaint,
),
),
],
diff --git a/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart b/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart
index 0e99dd21ba..f0b6a4e638 100644
--- a/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart
+++ b/mobile/apps/photos/lib/ui/account/two_factor_authentication_page.dart
@@ -1,12 +1,9 @@
+import 'package:ente_components/ente_components.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/models/account/two_factor.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
import 'package:photos/ui/lifecycle_event_handler.dart';
import "package:pinput/pinput.dart";
@@ -51,55 +48,55 @@ class _TwoFactorAuthenticationPageState
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
return Scaffold(
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).twoFAVerification,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
+ final colors = context.componentColors;
final defaultPinTheme = PinTheme(
height: 52,
width: 48,
- textStyle: textTheme.body.copyWith(color: colorScheme.textBase),
+ textStyle: TextStyles.body.copyWith(color: colors.textBase),
decoration: BoxDecoration(
- border: Border.all(color: colorScheme.strokeMuted),
+ border: Border.all(color: colors.strokeFaint),
borderRadius: BorderRadius.circular(20),
),
);
final focusedPinTheme = defaultPinTheme.copyWith(
decoration: BoxDecoration(
- border: Border.all(color: colorScheme.greenBase, width: 2),
+ border: Border.all(color: colors.primary, width: 2),
borderRadius: BorderRadius.circular(20),
),
);
final submittedPinTheme = defaultPinTheme.copyWith(
- textStyle: textTheme.h3Bold.copyWith(color: colorScheme.greenBase),
+ textStyle: TextStyles.h1.copyWith(color: colors.primary),
decoration: BoxDecoration(
- color: colorScheme.greenLight,
- border: Border.all(color: colorScheme.greenBase, width: 2),
+ color: colors.primaryLight,
+ border: Border.all(color: colors.primary, width: 2),
borderRadius: BorderRadius.circular(20),
),
);
@@ -112,7 +109,7 @@ class _TwoFactorAuthenticationPageState
const SizedBox(height: 24),
Text(
AppLocalizations.of(context).twoFAVerification,
- style: textTheme.body.copyWith(color: colorScheme.textBase),
+ style: TextStyles.body.copyWith(color: colors.textBase),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
@@ -120,7 +117,7 @@ class _TwoFactorAuthenticationPageState
AppLocalizations.of(
context,
).enterThe6digitCodeFromnyourAuthenticatorApp,
- style: textTheme.body.copyWith(color: colorScheme.textMuted),
+ style: TextStyles.body.copyWith(color: colors.textLight),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
@@ -144,20 +141,19 @@ class _TwoFactorAuthenticationPageState
),
),
const Spacer(),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).verify,
+ ButtonComponent(
+ label: AppLocalizations.of(context).verify,
isDisabled: _code.length != 6,
- onTap: () async {
- await _verifyTwoFactorCode(_code);
- },
+ onTap: _code.length == 6
+ ? () => _verifyTwoFactorCode(_code)
+ : null,
),
const SizedBox(height: 16),
Center(
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).lostDevice,
- buttonSize: ButtonSizeV2.small,
+ child: ButtonComponent(
+ label: AppLocalizations.of(context).lostDevice,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
onTap: () async {
// ignore: unawaited_futures
UserService.instance.recoverTwoFactor(
diff --git a/mobile/apps/photos/lib/ui/account/two_factor_recovery_page.dart b/mobile/apps/photos/lib/ui/account/two_factor_recovery_page.dart
index ebc2001858..1bf884856b 100644
--- a/mobile/apps/photos/lib/ui/account/two_factor_recovery_page.dart
+++ b/mobile/apps/photos/lib/ui/account/two_factor_recovery_page.dart
@@ -1,13 +1,9 @@
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/models/account/two_factor.dart";
import 'package:photos/services/account/user_service.dart';
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
class TwoFactorRecoveryPage extends StatefulWidget {
final String sessionID;
@@ -39,37 +35,35 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
+ final colors = context.componentColors;
final isFormValid = _recoveryKey.isNotEmpty;
return Scaffold(
resizeToAvoidBottomInset: true,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
scrolledUnderElevation: 0,
- backgroundColor: colorScheme.backgroundColour,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: colorScheme.content,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
AppLocalizations.of(context).recoverAccount,
- style: textTheme.largeBold,
+ style: TextStyles.large.copyWith(color: colors.textBase),
),
centerTitle: true,
),
- body: _getBody(colorScheme, textTheme),
+ body: _getBody(),
floatingActionButton: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
+ child: ButtonComponent(
key: const ValueKey("recover2FAButton"),
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).recover,
+ label: AppLocalizations.of(context).recover,
isDisabled: !isFormValid,
onTap: isFormValid
? () async {
@@ -90,21 +84,22 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
);
}
- Widget _getBody(EnteColorScheme colorScheme, EnteTextTheme textTheme) {
+ Widget _getBody() {
return SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
const SizedBox(height: 24),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).recoveryKey,
hintText: AppLocalizations.of(context).enterYourRecoveryKey,
- textEditingController: _recoveryKeyController,
- autoCorrect: false,
+ controller: _recoveryKeyController,
+ autocorrect: false,
keyboardType: TextInputType.multiline,
minLines: 4,
- onChange: (value) {
+ maxLines: null,
+ onChanged: (value) {
final hasKey = value.isNotEmpty;
if ((_recoveryKey.isNotEmpty) != hasKey) {
setState(() {
@@ -118,10 +113,11 @@ class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
const SizedBox(height: 12),
Align(
alignment: Alignment.centerRight,
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.link,
- labelText: AppLocalizations.of(context).noRecoveryKey,
- buttonSize: ButtonSizeV2.small,
+ child: ButtonComponent(
+ label: AppLocalizations.of(context).noRecoveryKey,
+ variant: ButtonComponentVariant.link,
+ size: ButtonComponentSize.small,
+ shouldSurfaceExecutionStates: false,
onTap: () async {
// ignore: unawaited_futures
showAlertBottomSheet(
diff --git a/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart b/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart
index 79c4bdcef1..d45db56517 100644
--- a/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart
+++ b/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart
@@ -1,19 +1,17 @@
import 'package:bip39/bip39.dart' as bip39;
import 'package:dio/dio.dart';
+import "package:ente_components/ente_components.dart";
import 'package:ente_crypto/ente_crypto.dart';
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:photos/core/event_bus.dart';
-import 'package:photos/ente_theme_data.dart';
import 'package:photos/events/notification_event.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import 'package:photos/services/account/user_service.dart';
import 'package:photos/services/local_authentication_service.dart';
-import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/account/recovery_key_page.dart';
-import 'package:photos/ui/common/gradient_button.dart';
import "package:photos/ui/components/alert_bottom_sheet.dart";
import 'package:photos/ui/components/buttons/button_widget.dart';
import 'package:photos/utils/dialog_util.dart';
@@ -129,13 +127,15 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
@override
Widget build(BuildContext context) {
- final enteTheme = Theme.of(context).colorScheme.enteTheme;
+ final colors = context.componentColors;
return Scaffold(
+ backgroundColor: colors.backgroundBase,
appBar: AppBar(
elevation: 0,
+ backgroundColor: colors.backgroundBase,
leading: IconButton(
icon: const Icon(Icons.arrow_back),
- color: Theme.of(context).iconTheme.color,
+ color: colors.iconColor,
onPressed: () {
Navigator.of(context).pop();
},
@@ -159,37 +159,23 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
width: double.infinity,
child: Text(
AppLocalizations.of(context).confirmRecoveryKey,
- style: enteTheme.textTheme.h3Bold,
+ style: TextStyles.h1.copyWith(color: colors.textBase),
textAlign: TextAlign.left,
),
),
const SizedBox(height: 18),
Text(
AppLocalizations.of(context).recoveryKeyVerifyReason,
- style: enteTheme.textTheme.small.copyWith(
- color: enteTheme.colorScheme.textMuted,
+ style: TextStyles.mini.copyWith(
+ color: colors.textLight,
),
),
const SizedBox(height: 12),
- TextFormField(
- decoration: InputDecoration(
- filled: true,
- fillColor: getEnteColorScheme(context).fillFaint,
- hintText: AppLocalizations.of(
- context,
- ).enterYourRecoveryKey,
- contentPadding: const EdgeInsets.all(20),
- border: UnderlineInputBorder(
- borderSide: BorderSide.none,
- borderRadius: BorderRadius.circular(6),
- ),
- ),
- style: const TextStyle(
- fontSize: 14,
- fontFeatures: [FontFeature.tabularFigures()],
- ),
+ TextInputComponent(
controller: _recoveryKey,
- autofocus: false,
+ hintText: AppLocalizations.of(
+ context,
+ ).enterYourRecoveryKey,
autocorrect: false,
keyboardType: TextInputType.multiline,
minLines: 4,
@@ -208,9 +194,9 @@ class _VerifyRecoveryPageState extends State<VerifyRecoveryPage> {
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- GradientButton(
+ ButtonComponent(
+ label: AppLocalizations.of(context).confirm,
onTap: _verifyRecoveryKey,
- text: AppLocalizations.of(context).confirm,
),
const SizedBox(height: 8),
],
diff --git a/mobile/apps/photos/lib/ui/home/landing_page_widget.dart b/mobile/apps/photos/lib/ui/home/landing_page_widget.dart
index 0adfcbdba2..5db8c428f1 100644
--- a/mobile/apps/photos/lib/ui/home/landing_page_widget.dart
+++ b/mobile/apps/photos/lib/ui/home/landing_page_widget.dart
@@ -1,6 +1,7 @@
import "dart:async";
import 'package:dots_indicator/dots_indicator.dart';
+import "package:ente_components/ente_components.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
@@ -18,7 +19,6 @@ import 'package:photos/ui/account/login_page.dart';
import 'package:photos/ui/account/password_entry_page.dart';
import 'package:photos/ui/account/password_reentry_page.dart';
import 'package:photos/ui/components/buttons/button_widget.dart';
-import 'package:photos/ui/components/buttons/button_widget_v2.dart';
import 'package:photos/ui/components/dialog_widget.dart';
import 'package:photos/ui/components/models/button_type.dart';
import 'package:photos/ui/payment/subscription.dart';
@@ -107,6 +107,9 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
final colorScheme = getEnteColorScheme(context);
+ final lightComponentTheme = ComponentTheme.lightTheme(
+ app: ComponentApp.photos,
+ );
return Scaffold(
appBar: AppBar(
backgroundColor: colorScheme.greenBase,
@@ -147,32 +150,35 @@ class _LandingPageWidgetState extends State<LandingPageWidget> {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
children: [
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.neutral,
- labelText: AppLocalizations.of(
- context,
- ).createAnEnteAccount,
- onTap: _navigateToSignUpPage,
- shouldSurfaceExecutionStates: false,
- shouldStickToLightTheme: true,
- ),
- if (localSettings.showLocalGalleryModeOption) ...[
- const SizedBox(height: 12),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.secondary,
- labelText: AppLocalizations.of(
- context,
- ).continueWithoutAccount,
- onTap: _navigateWithoutAccount,
- shouldSurfaceExecutionStates: false,
- shouldStickToLightTheme: true,
+ Theme(
+ data: lightComponentTheme,
+ child: Column(
+ children: [
+ ButtonComponent(
+ variant: ButtonComponentVariant.neutral,
+ label: AppLocalizations.of(
+ context,
+ ).createAnEnteAccount,
+ onTap: _navigateToSignUpPage,
+ shouldSurfaceExecutionStates: false,
+ ),
+ if (localSettings.showLocalGalleryModeOption) ...[
+ const SizedBox(height: 12),
+ ButtonComponent(
+ variant: ButtonComponentVariant.secondary,
+ label: AppLocalizations.of(
+ context,
+ ).continueWithoutAccount,
+ onTap: _navigateWithoutAccount,
+ shouldSurfaceExecutionStates: false,
+ ),
+ ],
+ ],
),
- ],
+ ),
const SizedBox(height: 12),
TextButton(
- onPressed: () {
- _navigateToSignInPage();
- },
+ onPressed: _navigateToSignInPage,
child: Text(
AppLocalizations.of(context).loginToExistingAccount,
style: textTheme.body.copyWith(
@@ -404,12 +410,8 @@ class FeatureItemWidget extends StatelessWidget {
color: Colors.white,
);
- const subTextStyle = TextStyle(
- fontFamily: "Inter",
- fontWeight: FontWeight.w500,
- fontSize: 14,
- height: 20 / 14,
- color: Color(0xFFAAFFB8),
+ final subTextStyle = TextStyles.body.copyWith(
+ color: const Color(0xFFAAFFB8),
);
return Column(
diff --git a/mobile/apps/photos/lib/ui/settings/developer_settings_page.dart b/mobile/apps/photos/lib/ui/settings/developer_settings_page.dart
index b7cb3bd723..b3756d8a58 100644
--- a/mobile/apps/photos/lib/ui/settings/developer_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/developer_settings_page.dart
@@ -1,3 +1,4 @@
+import "package:ente_components/ente_components.dart";
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import "package:photos/core/event_bus.dart";
@@ -7,8 +8,6 @@ import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/theme/ente_theme.dart";
import "package:photos/ui/components/alert_bottom_sheet.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/text_input_widget_v2.dart";
import "package:photos/ui/notification/toast.dart";
class DeveloperSettingsPage extends StatefulWidget {
@@ -61,18 +60,17 @@ class _DeveloperSettingsPageState extends State<DeveloperSettingsPage> {
child: Column(
children: [
const SizedBox(height: 20),
- TextInputWidgetV2(
+ TextInputComponent(
label: AppLocalizations.of(context).serverEndpoint,
hintText: endpoint,
- textEditingController: _urlController,
- autoCorrect: false,
- autoFocus: true,
+ controller: _urlController,
+ autocorrect: false,
+ autofocus: true,
keyboardType: TextInputType.url,
),
const SizedBox(height: 20),
- ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).save,
+ ButtonComponent(
+ label: AppLocalizations.of(context).save,
onTap: () async {
final url = _urlController.text.trim();
_logger.info("Entered endpoint: $url");