Skip to content

Commit 02cc9f5

Browse files
authored
Merge pull request #318 from chainapsis/Thunnini/VZR-112
Align mobile account menu actions
2 parents 16e5948 + 52fbced commit 02cc9f5

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

lib/src/features/accounts/screens/mobile/mobile_accounts_screen.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ class _MobileAccountsScreenState extends ConsumerState<MobileAccountsScreen> {
102102
if (wasOpenForAccount) return;
103103
}
104104

105-
final accounts = ref.read(accountProvider).value?.accounts ?? const [];
105+
final accountState = ref.read(accountProvider).value;
106+
final accounts = accountState?.accounts ?? const [];
107+
final isCurrentAccount = accountState?.activeAccountUuid == account.uuid;
106108
final canRemove = _canRemove(account, accounts);
107109

108110
final overlay = Overlay.of(context, rootOverlay: true);
@@ -123,7 +125,12 @@ class _MobileAccountsScreenState extends ConsumerState<MobileAccountsScreen> {
123125
horizontal: AppSpacing.xxs,
124126
vertical: AppSpacing.sm,
125127
);
126-
final menuHeight = canRemove ? 173.0 : 126.0;
128+
final menuHeight = switch ((isCurrentAccount, canRemove)) {
129+
(true, true) => 139.0,
130+
(true, false) => 92.0,
131+
(false, true) => 173.0,
132+
(false, false) => 126.0,
133+
};
127134
const bottomNavClearance = kMobileTabBarHeight + AppSpacing.lg;
128135
final colors = context.colors;
129136
final menuMaxTop = math.max(
@@ -215,12 +222,13 @@ class _MobileAccountsScreenState extends ConsumerState<MobileAccountsScreen> {
215222
label: 'Copy address',
216223
action: _AccountAction.copy,
217224
),
218-
item(
219-
key: const ValueKey('mobile_account_menu_send'),
220-
iconName: AppIcons.plane,
221-
label: 'Send ZEC',
222-
action: _AccountAction.send,
223-
),
225+
if (!isCurrentAccount)
226+
item(
227+
key: const ValueKey('mobile_account_menu_send'),
228+
iconName: AppIcons.plane,
229+
label: 'Send ZEC',
230+
action: _AccountAction.send,
231+
),
224232
item(
225233
key: const ValueKey('mobile_account_menu_edit'),
226234
iconName: AppIcons.edit,

test/features/accounts/mobile_accounts_screen_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ void main() {
269269
);
270270
await tester.pump();
271271

272-
// Imported account: edit + remove.
272+
// Other imported account: send + edit + remove.
273273
await tester.tap(find.byKey(const ValueKey('mobile_accounts_menu_b')));
274274
await tester.pumpAndSettle();
275+
expect(find.text('Send ZEC'), findsOneWidget);
275276
expect(find.text('Edit account'), findsOneWidget);
276277
expect(find.text('Remove account'), findsOneWidget);
277278
final openMenuButton = tester.widget<DecoratedBox>(
@@ -292,11 +293,16 @@ void main() {
292293
await tester.tapAt(const Offset(10, 10));
293294
await tester.pumpAndSettle();
294295

295-
// Seed anchor with another account: edit + remove.
296+
// Current seed anchor with another account: edit + remove, but no send.
296297
await tester.tap(find.byKey(const ValueKey('mobile_accounts_menu_a')));
297298
await tester.pumpAndSettle();
299+
expect(find.text('Send ZEC'), findsNothing);
298300
expect(find.text('Edit account'), findsOneWidget);
299301
expect(find.text('Remove account'), findsOneWidget);
302+
expect(
303+
tester.getSize(find.byKey(const ValueKey('mobile_account_menu_card'))),
304+
const Size(173, 139),
305+
);
300306
});
301307

302308
testWidgets('the last remaining seed account resets the app on removal', (

0 commit comments

Comments
 (0)