-
Notifications
You must be signed in to change notification settings - Fork 7
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): recover flow scaffloding (#971)
* feat: recover stages * feat: info panel recover seed phrase * chore: wip * feat: recovery methods and recovery seed phrase instructions panels * feat: keychain status indicators * feat: navigation * feat: recover state data * RecoverManager * fix: remove unused import * fix: PR review adjustments
- Loading branch information
1 parent
041af7f
commit 9d886f6
Showing
46 changed files
with
830 additions
and
157 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
catalyst_voices/lib/pages/registration/create_keychain/stage/instructions_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
4 changes: 2 additions & 2 deletions
4
...es/lib/pages/registration/create_keychain/stage/seed_phrase_check_instructions_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
2 changes: 1 addition & 1 deletion
2
catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_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
6 changes: 3 additions & 3 deletions
6
...t_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_result_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
2 changes: 1 addition & 1 deletion
2
catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_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
2 changes: 1 addition & 1 deletion
2
catalyst_voices/lib/pages/registration/create_keychain/stage/splash_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
4 changes: 2 additions & 2 deletions
4
...ices/lib/pages/registration/create_keychain/stage/unlock_password_instructions_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
2 changes: 1 addition & 1 deletion
2
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
4 changes: 2 additions & 2 deletions
4
catalyst_voices/lib/pages/registration/finish_account/finish_account_creation_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
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
16 changes: 16 additions & 0 deletions
16
catalyst_voices/lib/pages/registration/recover/bloc_recover_builder.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,16 @@ | ||
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
class BlocRecoverBuilder<T> | ||
extends BlocSelector<RegistrationCubit, RegistrationState, T> { | ||
BlocRecoverBuilder({ | ||
super.key, | ||
required BlocWidgetSelector<RecoverStateData, T> selector, | ||
required super.builder, | ||
super.bloc, | ||
}) : super( | ||
selector: (state) { | ||
return selector(state.recoverStateData); | ||
}, | ||
); | ||
} |
173 changes: 173 additions & 0 deletions
173
catalyst_voices/lib/pages/registration/recover/recover_method_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,173 @@ | ||
import 'package:catalyst_voices/pages/registration/recover/bloc_recover_builder.dart'; | ||
import 'package:catalyst_voices/pages/registration/widgets/registration_tile.dart'; | ||
import 'package:catalyst_voices/widgets/widgets.dart'; | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart'; | ||
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; | ||
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; | ||
import 'package:catalyst_voices_models/catalyst_voices_models.dart'; | ||
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class RecoverMethodPanel extends StatelessWidget { | ||
const RecoverMethodPanel({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
|
||
final colorLvl0 = theme.colors.textOnPrimaryLevel0; | ||
final colorLvl1 = theme.colors.textOnPrimaryLevel1; | ||
|
||
return SingleChildScrollView( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
const SizedBox(height: 24), | ||
Text( | ||
context.l10n.recoverKeychainMethodsTitle, | ||
style: theme.textTheme.titleMedium?.copyWith(color: colorLvl1), | ||
), | ||
const SizedBox(height: 12), | ||
_BlocOnDeviceKeychains(onUnlockTap: _unlockKeychain), | ||
const SizedBox(height: 12), | ||
Text( | ||
context.l10n.recoverKeychainMethodsSubtitle, | ||
style: theme.textTheme.bodyMedium?.copyWith(color: colorLvl1), | ||
), | ||
const SizedBox(height: 32), | ||
Text( | ||
context.l10n.recoverKeychainMethodsListTitle, | ||
style: theme.textTheme.titleSmall?.copyWith(color: colorLvl0), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: RegistrationRecoverMethod.values | ||
.map<Widget>( | ||
(method) { | ||
return RegistrationTile( | ||
key: ValueKey(method), | ||
icon: method._icon, | ||
title: method._getTitle(context.l10n), | ||
subtitle: method._getSubtitle(context.l10n), | ||
onTap: () { | ||
switch (method) { | ||
case RegistrationRecoverMethod.seedPhrase: | ||
RegistrationCubit.of(context) | ||
.recoverWithSeedPhrase(); | ||
} | ||
}, | ||
); | ||
}, | ||
) | ||
.separatedBy(const SizedBox(height: 12)) | ||
.toList(), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
void _unlockKeychain() { | ||
// | ||
} | ||
} | ||
|
||
class _BlocOnDeviceKeychains extends StatelessWidget { | ||
final VoidCallback onUnlockTap; | ||
|
||
const _BlocOnDeviceKeychains({ | ||
required this.onUnlockTap, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return BlocRecoverBuilder<bool>( | ||
selector: (state) => state.foundKeychain, | ||
builder: (context, state) { | ||
return _OnDeviceKeychains( | ||
foundKeychain: state, | ||
onUnlockTap: onUnlockTap, | ||
); | ||
}, | ||
); | ||
} | ||
} | ||
|
||
class _OnDeviceKeychains extends StatelessWidget { | ||
final bool foundKeychain; | ||
final VoidCallback onUnlockTap; | ||
|
||
const _OnDeviceKeychains({ | ||
this.foundKeychain = false, | ||
required this.onUnlockTap, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return DefaultTextStyle( | ||
style: TextStyle(color: Theme.of(context).colors.textOnPrimaryLevel1), | ||
child: foundKeychain | ||
? _KeychainFoundIndicator(onUnlockTap: onUnlockTap) | ||
: const _KeychainNotFoundIndicator(), | ||
); | ||
} | ||
} | ||
|
||
class _KeychainFoundIndicator extends StatelessWidget { | ||
final VoidCallback onUnlockTap; | ||
|
||
const _KeychainFoundIndicator({ | ||
required this.onUnlockTap, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return VoicesIndicator( | ||
type: VoicesIndicatorType.success, | ||
icon: VoicesAssets.icons.check, | ||
message: Text( | ||
context.l10n.recoverKeychainFound, | ||
style: DefaultTextStyle.of(context).style, | ||
), | ||
action: VoicesTextButton( | ||
onTap: onUnlockTap, | ||
leading: VoicesAssets.icons.lockOpen.buildIcon(), | ||
child: Text(context.l10n.unlock), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _KeychainNotFoundIndicator extends StatelessWidget { | ||
const _KeychainNotFoundIndicator(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return VoicesIndicator( | ||
type: VoicesIndicatorType.error, | ||
icon: VoicesAssets.icons.exclamation, | ||
message: Text( | ||
context.l10n.recoverKeychainNonFound, | ||
style: DefaultTextStyle.of(context).style, | ||
), | ||
); | ||
} | ||
} | ||
|
||
extension _RegistrationRecoverMethodExt on RegistrationRecoverMethod { | ||
SvgGenImage get _icon => switch (this) { | ||
RegistrationRecoverMethod.seedPhrase => VoicesAssets.icons.colorSwatch, | ||
}; | ||
|
||
String _getTitle(VoicesLocalizations l10n) => switch (this) { | ||
RegistrationRecoverMethod.seedPhrase => l10n.seedPhrase12Words, | ||
}; | ||
|
||
String? _getSubtitle(VoicesLocalizations l10n) => switch (this) { | ||
RegistrationRecoverMethod.seedPhrase => null, | ||
}; | ||
} |
Oops, something went wrong.