Skip to content

Commit

Permalink
feat(cat-voices): My account, extract AccountRole model and fix build (
Browse files Browse the repository at this point in the history
…#883)

* feat: My account, account page, extract model and fix build

* feat: My account, account page, extract model and fix build, repackage
  • Loading branch information
digitalheartxs committed Sep 25, 2024
1 parent 7c707d0 commit 0af0b2b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
16 changes: 16 additions & 0 deletions catalyst_voices/lib/common/ext/account_role_ext.dart
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
25 changes: 4 additions & 21 deletions catalyst_voices/lib/pages/account/account_page.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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;
}
}
}
33 changes: 33 additions & 0 deletions catalyst_voices/lib/routes/routing/account_route.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enum AccountRole {
voter,
proposer,
drep,
}
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit 0af0b2b

Please sign in to comment.