Skip to content

Commit

Permalink
Merge branch 'main' into feat/cip509-metadata-indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenj authored Sep 23, 2024
2 parents e2e2001 + 53f122c commit 3258ac9
Show file tree
Hide file tree
Showing 31 changed files with 1,030 additions and 94 deletions.
1 change: 1 addition & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
aapt
aarch
abnf
addr
addrr
adminer
afinet
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
if: always()
continue-on-error: true
with:
earthfile: ./catalyst_voices_packages/catalyst_cardano/catalyst_cardano/test/wallet-automation/
earthfile: ./catalyst_voices_packages/catalyst_cardano/catalyst_cardano/wallet-automation/
flags: --allow-privileged
targets: nightly-test
target_flags:
Expand Down
253 changes: 253 additions & 0 deletions catalyst_voices/lib/pages/account/account_popup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_assets/catalyst_voices_assets.dart';
import 'package:catalyst_voices_brands/catalyst_voices_brands.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class AccountPopup extends StatelessWidget {
final String avatarLetter;
final VoidCallback? onProfileKeychainTap;
final VoidCallback? onLockAccountTap;

const AccountPopup({
super.key,
required this.avatarLetter,
this.onProfileKeychainTap,
this.onLockAccountTap,
});

@override
Widget build(BuildContext context) {
return PopupMenuButton<_MenuItemValue>(
color: Theme.of(context).colors.elevationsOnSurfaceNeutralLv1White,
onSelected: (_MenuItemValue value) {
switch (value) {
case _MenuItemValue.profileAndKeychain:
onProfileKeychainTap?.call();
break;
case _MenuItemValue.lock:
onLockAccountTap?.call();
break;
}
},
itemBuilder: (BuildContext bc) {
return [
PopupMenuItem(
padding: EdgeInsets.zero,
enabled: false,
value: null,
child: _Header(
accountLetter: avatarLetter,
walletName: 'Wallet name',
walletBalance: '₳ 1,750,000',
accountType: 'Basis',
walletAddress: 'addr1_H4543...45GH',
),
),
const PopupMenuItem(
height: 48,
padding: EdgeInsets.zero,
enabled: false,
value: null,
child: _Section('My account'),
),
PopupMenuItem(
padding: EdgeInsets.zero,
value: _MenuItemValue.profileAndKeychain,
child: _MenuItem(
'Profile & Keychain',
VoicesAssets.icons.userCircle,
),
),
PopupMenuItem(
padding: EdgeInsets.zero,
value: _MenuItemValue.lock,
child: _MenuItem(
'Lock account',
VoicesAssets.icons.lockClosed,
showDivider: false,
),
),
];
},
offset: const Offset(0, kToolbarHeight),
child: IgnorePointer(
child: VoicesAvatar(
icon: Text(avatarLetter),
),
),
);
}
}

class _Header extends StatelessWidget {
final String accountLetter;
final String walletName;
final String walletBalance;
final String accountType;
final String walletAddress;

const _Header({
required this.accountLetter,
required this.walletName,
required this.walletBalance,
required this.accountType,
required this.walletAddress,
});

@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: _padding),
child: Row(
children: [
VoicesAvatar(
icon: Text(accountLetter),
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(_padding),
child: Wrap(
children: [
Text(
walletName,
style: Theme.of(context).textTheme.bodyLarge,
),
Text(
walletBalance,
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
),
),
VoicesChip.rectangular(
content: Text(
accountType,
style: TextStyle(
color: Theme.of(context).colors.successContainer,
),
),
backgroundColor: Theme.of(context).colors.success,
),
],
),
),
Padding(
padding: const EdgeInsets.only(
left: _padding,
right: _padding,
bottom: _padding,
top: 8,
),
child: Row(
children: [
Expanded(
child: Text(
walletAddress,
style: Theme.of(context).textTheme.bodyLarge,
),
),
InkWell(
onTap: () async {
await Clipboard.setData(
ClipboardData(text: walletAddress),
);
},
child: VoicesAssets.icons.clipboardCopy.buildIcon(),
),
],
),
),
VoicesDivider(
height: 1,
color: Theme.of(context).colors.outlineBorder,
indent: 0,
endIndent: 0,
),
],
);
}
}

class _MenuItem extends StatelessWidget {
final String text;
final SvgGenImage icon;
final bool showDivider;

const _MenuItem(
this.text,
this.icon, {
this.showDivider = true,
});

@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 47,
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: _padding),
child: Row(
children: [
icon.buildIcon(),
const SizedBox(width: _padding),
Text(
text,
style: Theme.of(context).textTheme.bodyLarge,
),
],
),
),
if (showDivider)
VoicesDivider(
height: 1,
color: Theme.of(context).colors.outlineBorderVariant,
indent: 0,
endIndent: 0,
),
],
);
}
}

class _Section extends StatelessWidget {
final String text;

const _Section(
this.text,
);

@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 47,
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: _padding),
child: Text(
text,
style: Theme.of(context).textTheme.titleSmall,
),
),
VoicesDivider(
height: 1,
color: Theme.of(context).colors.outlineBorderVariant,
indent: 0,
endIndent: 0,
),
],
);
}
}

const _padding = 12.0;

enum _MenuItemValue {
profileAndKeychain,
lock,
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:catalyst_voices/pages/account/account_popup.dart';
import 'package:catalyst_voices/widgets/widgets.dart';
import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart';
import 'package:catalyst_voices_localization/catalyst_voices_localization.dart';
Expand All @@ -15,8 +16,11 @@ class SessionStateHeader extends StatelessWidget {
return switch (state) {
VisitorSessionState() => const _VisitorButton(),
GuestSessionState() => const _GuestButton(),
ActiveUserSessionState(:final user) =>
_ActiveUserAvatar(letter: user.acronym ?? 'A'),
ActiveUserSessionState(:final user) => AccountPopup(
avatarLetter: user.acronym ?? 'A',
onLockAccountTap: () => debugPrint('Lock account'),
onProfileKeychainTap: () => debugPrint('Open Profile screen'),
),
};
},
);
Expand Down Expand Up @@ -46,18 +50,3 @@ class _VisitorButton extends StatelessWidget {
);
}
}

class _ActiveUserAvatar extends StatelessWidget {
final String letter;

const _ActiveUserAvatar({
required this.letter,
});

@override
Widget build(BuildContext context) {
return VoicesAvatar(
icon: Text(letter),
);
}
}
Loading

0 comments on commit 3258ac9

Please sign in to comment.