-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cat-voices): unlock password stage (#930)
* chore: wip * chore: wip * feat: mocked create keychain method * feat: info panel password picture types * chore: remove autofill group * feat: clear password on back * fix: formatting * refactor: use password from constructor data --------- Co-authored-by: Dominik Toton <[email protected]>
- Loading branch information
1 parent
a2e8665
commit 0f060ac
Showing
23 changed files
with
518 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'package:flutter/services.dart'; | ||
|
||
/// Removes any whitespaces. | ||
final class NoWhitespacesFormatter extends FilteringTextInputFormatter { | ||
NoWhitespacesFormatter() : super.deny(RegExp(r'\s+')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
catalyst_voices/lib/pages/registration/create_keychain/stage/unlock_password_panel.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import 'package:catalyst_voices/pages/registration/registration_stage_navigation.dart'; | ||
import 'package:catalyst_voices/widgets/indicators/voices_password_strength_indicator.dart'; | ||
import 'package:catalyst_voices/widgets/text_field/voices_password_text_field.dart'; | ||
import 'package:catalyst_voices/widgets/text_field/voices_text_field.dart'; | ||
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart'; | ||
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class UnlockPasswordPanel extends StatefulWidget { | ||
final UnlockPasswordState data; | ||
|
||
const UnlockPasswordPanel({ | ||
super.key, | ||
required this.data, | ||
}); | ||
|
||
@override | ||
State<UnlockPasswordPanel> createState() => _UnlockPasswordPanelState(); | ||
} | ||
|
||
class _UnlockPasswordPanelState extends State<UnlockPasswordPanel> { | ||
late final TextEditingController _passwordController; | ||
late final TextEditingController _confirmPasswordController; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
final password = widget.data.password; | ||
final confirmPassword = widget.data.confirmPassword; | ||
|
||
_passwordController = TextEditingController(text: password) | ||
..addListener(_onPasswordChanged); | ||
_confirmPasswordController = TextEditingController(text: confirmPassword) | ||
..addListener(_onConfirmPasswordChanged); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_passwordController.dispose(); | ||
_confirmPasswordController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
const SizedBox(height: 24), | ||
const SizedBox(height: 12), | ||
_EnterPasswordTextField( | ||
controller: _passwordController, | ||
), | ||
const SizedBox(height: 12), | ||
_ConfirmPasswordTextField( | ||
controller: _confirmPasswordController, | ||
showError: widget.data.showPasswordMisMatch, | ||
minimumLength: widget.data.minPasswordLength, | ||
), | ||
const Spacer(), | ||
const SizedBox(height: 22), | ||
if (widget.data.showPasswordStrength) | ||
VoicesPasswordStrengthIndicator( | ||
passwordStrength: widget.data.passwordStrength, | ||
), | ||
const SizedBox(height: 22), | ||
RegistrationBackNextNavigation( | ||
isNextEnabled: widget.data.isNextEnabled, | ||
onNextTap: _createKeychain, | ||
onBackTap: _clearPasswordAndGoBack, | ||
), | ||
], | ||
); | ||
} | ||
|
||
void _onPasswordChanged() { | ||
final password = _passwordController.text; | ||
RegistrationCubit.of(context).setPassword(password); | ||
} | ||
|
||
void _onConfirmPasswordChanged() { | ||
final confirmPassword = _confirmPasswordController.text; | ||
RegistrationCubit.of(context).setConfirmPassword(confirmPassword); | ||
} | ||
|
||
void _clearPasswordAndGoBack() { | ||
RegistrationCubit.of(context) | ||
..setPassword('') | ||
..setConfirmPassword('') | ||
..previousStep(); | ||
} | ||
|
||
Future<void> _createKeychain() async { | ||
final registrationCubit = RegistrationCubit.of(context); | ||
|
||
await registrationCubit.createKeychain(); | ||
registrationCubit.nextStep(); | ||
} | ||
} | ||
|
||
class _EnterPasswordTextField extends StatelessWidget { | ||
final TextEditingController controller; | ||
|
||
const _EnterPasswordTextField({ | ||
required this.controller, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return VoicesPasswordTextField( | ||
controller: controller, | ||
textInputAction: TextInputAction.next, | ||
decoration: VoicesTextFieldDecoration( | ||
labelText: context.l10n.enterPassword, | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _ConfirmPasswordTextField extends StatelessWidget { | ||
final TextEditingController controller; | ||
final bool showError; | ||
final int minimumLength; | ||
|
||
const _ConfirmPasswordTextField({ | ||
required this.controller, | ||
this.showError = false, | ||
required this.minimumLength, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return VoicesPasswordTextField( | ||
controller: controller, | ||
decoration: VoicesTextFieldDecoration( | ||
labelText: context.l10n.confirmPassword, | ||
helperText: context.l10n.xCharactersMinimum(minimumLength), | ||
errorText: showError ? context.l10n.passwordDoNotMatch : null, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.