-
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): account creation type dialog (#881)
* wip * feat: localization + rename dialog * fix: missing comma * refactor: extract learn more button --------- Co-authored-by: Dominik Toton <[email protected]>
- Loading branch information
1 parent
e75eab9
commit a14909c
Showing
8 changed files
with
320 additions
and
21 deletions.
There are no files selected for viewing
187 changes: 187 additions & 0 deletions
187
catalyst_voices/lib/pages/account/creation/get_started/account_create_dialog.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,187 @@ | ||
import 'package:catalyst_voices/pages/account/creation/task_picture.dart'; | ||
import 'package:catalyst_voices/widgets/buttons/voices_buttons.dart'; | ||
import 'package:catalyst_voices/widgets/modals/voices_desktop_dialog.dart'; | ||
import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; | ||
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; | ||
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; | ||
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; | ||
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
enum AccountCreateType { | ||
createNew, | ||
recover; | ||
|
||
SvgGenImage get _icon => switch (this) { | ||
AccountCreateType.createNew => VoicesAssets.icons.colorSwatch, | ||
AccountCreateType.recover => VoicesAssets.icons.download, | ||
}; | ||
|
||
String _getTitle(VoicesLocalizations l10n) => switch (this) { | ||
AccountCreateType.createNew => l10n.accountCreationCreate, | ||
AccountCreateType.recover => l10n.accountCreationRecover, | ||
}; | ||
|
||
String _getSubtitle(VoicesLocalizations l10n) { | ||
return l10n.accountCreationOnThisDevice; | ||
} | ||
} | ||
|
||
class AccountCreateDialog extends StatelessWidget { | ||
const AccountCreateDialog._(); | ||
|
||
static Future<AccountCreateType?> show(BuildContext context) { | ||
return VoicesDialog.show( | ||
context: context, | ||
builder: (context) => const AccountCreateDialog._(), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const VoicesDesktopPanelsDialog( | ||
left: _LeftPanel(), | ||
right: _RightPanel(), | ||
); | ||
} | ||
} | ||
|
||
class _LeftPanel extends StatelessWidget { | ||
const _LeftPanel(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
|
||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
context.l10n.getStarted, | ||
style: theme.textTheme.titleLarge?.copyWith( | ||
color: theme.colors.textOnPrimaryLevel0, | ||
), | ||
), | ||
const SizedBox(height: 12), | ||
const Expanded(child: Center(child: TaskKeychainPicture())), | ||
const SizedBox(height: 32), | ||
// TODO(damian-molinski): External url redirect | ||
VoicesLearnMoreButton(onTap: () {}), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _RightPanel extends StatelessWidget { | ||
const _RightPanel(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
|
||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
const SizedBox(height: 24), | ||
Text( | ||
context.l10n.accountCreationGetStartedTitle, | ||
style: theme.textTheme.titleMedium?.copyWith( | ||
color: theme.colors.textOnPrimaryLevel1, | ||
), | ||
), | ||
const SizedBox(height: 12), | ||
Text( | ||
context.l10n.accountCreationGetStatedDesc, | ||
style: theme.textTheme.bodyMedium?.copyWith( | ||
color: theme.colors.textOnPrimaryLevel1, | ||
), | ||
), | ||
const SizedBox(height: 32), | ||
Text( | ||
context.l10n.accountCreationGetStatedWhatNext, | ||
style: theme.textTheme.titleSmall?.copyWith( | ||
color: theme.colors.textOnPrimaryLevel0, | ||
), | ||
), | ||
const SizedBox(height: 24), | ||
Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: AccountCreateType.values | ||
.map<Widget>((type) { | ||
return _AccountCreateTypeTile( | ||
key: ValueKey(type), | ||
type: type, | ||
onTap: () => Navigator.of(context).pop(type), | ||
); | ||
}) | ||
.separatedBy(const SizedBox(height: 12)) | ||
.toList(), | ||
), | ||
], | ||
); | ||
} | ||
} | ||
|
||
class _AccountCreateTypeTile extends StatelessWidget { | ||
final AccountCreateType type; | ||
final VoidCallback? onTap; | ||
|
||
const _AccountCreateTypeTile({ | ||
super.key, | ||
required this.type, | ||
this.onTap, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = Theme.of(context); | ||
|
||
return ConstrainedBox( | ||
constraints: const BoxConstraints.tightFor(height: 80), | ||
child: Material( | ||
color: theme.colorScheme.primary, | ||
borderRadius: BorderRadius.circular(12), | ||
child: InkWell( | ||
onTap: onTap, | ||
borderRadius: BorderRadius.circular(12), | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 20), | ||
child: Row( | ||
children: [ | ||
type._icon.buildIcon( | ||
size: 48, | ||
color: theme.colorScheme.onPrimary, | ||
), | ||
const SizedBox(width: 10), | ||
Expanded( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
type._getTitle(context.l10n), | ||
maxLines: 2, | ||
overflow: TextOverflow.ellipsis, | ||
style: theme.textTheme.titleSmall?.copyWith( | ||
color: theme.colorScheme.onPrimary, | ||
), | ||
), | ||
Text( | ||
type._getSubtitle(context.l10n), | ||
maxLines: 1, | ||
overflow: TextOverflow.clip, | ||
style: theme.textTheme.bodySmall?.copyWith( | ||
color: theme.colorScheme.onPrimary, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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.