diff --git a/catalyst_voices/lib/common/ext/account_role_ext.dart b/catalyst_voices/lib/common/ext/account_role_ext.dart new file mode 100644 index 0000000000..070bc36808 --- /dev/null +++ b/catalyst_voices/lib/common/ext/account_role_ext.dart @@ -0,0 +1,16 @@ +import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; +import 'package:catalyst_voices_models/catalyst_voices_models.dart'; +import 'package:flutter/material.dart'; + +extension AccountRoleExt on AccountRole { + String getName(BuildContext context) { + switch (this) { + case AccountRole.voter: + return context.l10n.voter; + case AccountRole.proposer: + return context.l10n.proposer; + case AccountRole.drep: + return context.l10n.drep; + } + } +} diff --git a/catalyst_voices/lib/pages/account/account_page.dart b/catalyst_voices/lib/pages/account/account_page.dart index 0716aaa2c8..f591404d9f 100644 --- a/catalyst_voices/lib/pages/account/account_page.dart +++ b/catalyst_voices/lib/pages/account/account_page.dart @@ -1,8 +1,10 @@ +import 'package:catalyst_voices/common/ext/account_role_ext.dart'; import 'package:catalyst_voices/widgets/buttons/voices_icon_button.dart'; import 'package:catalyst_voices/widgets/buttons/voices_text_button.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_models/catalyst_voices_models.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -240,29 +242,10 @@ class _KeychainCard extends StatelessWidget { ) { String label; if (role == defaultRole) { - label = '${role.name(context)} (${context.l10n.defaultRole})'; + label = '${role.getName(context)} (${context.l10n.defaultRole})'; } else { - label = role.name(context); + label = role.getName(context); } return ' • $label'; } } - -enum AccountRole { - voter, - proposer, - drep, -} - -extension on AccountRole { - String name(BuildContext context) { - switch (this) { - case AccountRole.voter: - return context.l10n.voter; - case AccountRole.proposer: - return context.l10n.proposer; - case AccountRole.drep: - return context.l10n.drep; - } - } -} diff --git a/catalyst_voices/lib/routes/routing/account_route.g.dart b/catalyst_voices/lib/routes/routing/account_route.g.dart new file mode 100644 index 0000000000..c6fd453950 --- /dev/null +++ b/catalyst_voices/lib/routes/routing/account_route.g.dart @@ -0,0 +1,33 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'account_route.dart'; + +// ************************************************************************** +// GoRouterGenerator +// ************************************************************************** + +List get $appRoutes => [ + $accountRoute, + ]; + +RouteBase get $accountRoute => GoRouteData.$route( + path: '/m4/account', + factory: $AccountRouteExtension._fromState, + ); + +extension $AccountRouteExtension on AccountRoute { + static AccountRoute _fromState(GoRouterState state) => const AccountRoute(); + + String get location => GoRouteData.$location( + '/m4/account', + ); + + void go(BuildContext context) => context.go(location); + + Future push(BuildContext context) => context.push(location); + + void pushReplacement(BuildContext context) => + context.pushReplacement(location); + + void replace(BuildContext context) => context.replace(location); +} diff --git a/catalyst_voices/packages/catalyst_voices_models/lib/src/account/account_role.dart b/catalyst_voices/packages/catalyst_voices_models/lib/src/account/account_role.dart new file mode 100644 index 0000000000..bdeafd803e --- /dev/null +++ b/catalyst_voices/packages/catalyst_voices_models/lib/src/account/account_role.dart @@ -0,0 +1,5 @@ +enum AccountRole { + voter, + proposer, + drep, +} diff --git a/catalyst_voices/packages/catalyst_voices_models/lib/src/catalyst_voices_models.dart b/catalyst_voices/packages/catalyst_voices_models/lib/src/catalyst_voices_models.dart index 072d1267fe..3afed13082 100644 --- a/catalyst_voices/packages/catalyst_voices_models/lib/src/catalyst_voices_models.dart +++ b/catalyst_voices/packages/catalyst_voices_models/lib/src/catalyst_voices_models.dart @@ -1,5 +1,6 @@ library catalyst_voices_models; +export 'account/account_role.dart'; export 'auth/authentication_status.dart'; export 'auth/password_strength.dart'; export 'errors/errors.dart';