Skip to content

feat: wire bottom snack bar to wallet buy button with translations#110

Open
ice-selene wants to merge 5 commits into
masterfrom
feat/wallet-buy-snack-bar
Open

feat: wire bottom snack bar to wallet buy button with translations#110
ice-selene wants to merge 5 commits into
masterfrom
feat/wallet-buy-snack-bar

Conversation

@ice-selene

@ice-selene ice-selene commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

What

Wires the BottomSnackBar component to the Wallet Buy button. Tapping "Buy" shows "Buy crypto easily. Coming soon." for 3 seconds.

Changes

  • Export BottomSnackBar from @ion/ui
  • Add onPress prop to ActionButton
  • Pass onBuyPress through ActionButtonsRow
  • Show BottomSnackBar in WalletScreen on Buy press
  • Add buyCryptoComingSoon translation key (en, de, fr)

Summary by CodeRabbit

  • New Features
    • Exposed a bottom snackbar component in the UI package.
    • Added "Buy crypto coming soon" copy with EN/DE/FR translations.
  • Improvements
    • Action buttons now accept press callbacks for caller-provided handling.
    • Introduced a centralized wallet actions hook (balance visibility, sheet opening, snackbar control) and wired the wallet screen to use it, allowing the buy snackbar to be shown conditionally.

Copilot AI review requested due to automatic review settings April 10, 2026 11:43
@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Exports and UI wiring were added: BottomSnackBar exported from the UI package; ActionButton and ActionButtonsRow accept optional press handlers; WalletScreen uses a new useWalletActions hook and renders a BottomSnackBar; English/French/German buyCryptoComingSoon translations added.

Changes

Cohort / File(s) Summary
UI Export
frontend/packages/ui/src/index.ts
Added public exports: BottomSnackBar, BottomSnackBarProps.
Action Button APIs
frontend/packages/wallet-ui/src/components/ActionButton.tsx, frontend/packages/wallet-ui/src/components/ActionButtonsRow.tsx
ActionButtonProps gains optional onPress?: () => void. ActionButtonsRow now accepts ActionButtonsRowProps with optional onBuyPress?: () => void and conditionally forwards it to the buy ActionButton.
Wallet Screen & Hook
frontend/packages/wallet-ui/src/screens/WalletScreen.tsx, frontend/packages/wallet-ui/src/screens/useWalletActions.ts
Added exported useWalletActions hook (manages balance/snackbar state and actions). WalletScreen consumes the hook, passes onBuyPress when available, and renders an absolutely positioned BottomSnackBar wired to show/hide actions.
Translations
frontend/packages/wallet-ui/src/translations/en.ts, frontend/packages/wallet-ui/src/translations/fr.ts, frontend/packages/wallet-ui/src/translations/de.ts
Added buyCryptoComingSoon translation key in English, French, and German.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant AB as ActionButton
    participant ABRow as ActionButtonsRow
    participant WS as WalletScreen
    participant Hook as useWalletActions
    participant SN as BottomSnackBar

    User->>AB: tap Buy
    AB->>ABRow: onPress()
    ABRow->>WS: call onBuyPress()
    WS->>Hook: showSnackBar()
    Hook-->>WS: isSnackBarVisible = true
    WS->>SN: render(message, onDismiss)
    SN->>User: display "Buy crypto easily. Coming soon."
    User->>SN: dismiss
    SN->>WS: onDismiss -> hideSnackBar()
    WS->>Hook: hideSnackBar()
    Hook-->>WS: isSnackBarVisible = false
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ice-brontes
  • ice-damocles

Poem

🐰 A tiny snack hops into view below,
Tap the button, watch the little banner flow.
Hooks wiggle, translations softly croon,
A humble pop proclaims "coming soon."
Hoppity-hop — UI joys in tune.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: wiring the BottomSnackBar component to the wallet buy button with multi-language translations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wallet-buy-snack-bar

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
frontend/packages/wallet-ui/src/screens/WalletScreen.tsx (2)

40-42: Consider memoizing the inline style object.

The style object { paddingHorizontal: scaleSize(16), paddingBottom: scaleSize(16) } is recreated on every render. While not a major performance concern, memoizing it with useMemo would be more consistent with the patterns used elsewhere in the codebase (e.g., useWalletScreenStyles, the useMemo patterns in ActionButton).

✨ Suggested improvement
+  const snackBarPadding = useMemo(
+    () => ({ paddingHorizontal: scaleSize(16), paddingBottom: scaleSize(16) }),
+    [scaleSize],
+  );
+
   return (
     <View style={s.screen}>
       ...
-      <View style={[styles.snackBarWrapper, { paddingHorizontal: scaleSize(16), paddingBottom: scaleSize(16) }]}>
+      <View style={[styles.snackBarWrapper, snackBarPadding]}>
         <BottomSnackBar message={translate("walletUi:buyCryptoComingSoon")} isVisible={actions.isSnackBarVisible} onDismiss={actions.hideSnackBar} />
       </View>
     </View>
   );

You'll also need to add useMemo to the imports on line 1.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/packages/wallet-ui/src/screens/WalletScreen.tsx` around lines 40 -
42, The inline style object passed to the View in WalletScreen
(styles.snackBarWrapper) is recreated each render; wrap the object `{
paddingHorizontal: scaleSize(16), paddingBottom: scaleSize(16) }` in a useMemo
and replace the inline literal with that memoized variable, adding useMemo to
the imports; keep the dependency array minimal (e.g., [] or include scaleSize if
it can change) and reuse the memoized style in the View to avoid allocating a
new object each render.

33-33: Simplify the conditional prop passing.

Same pattern as in ActionButtonsRow - the conditional spread is unnecessarily verbose since onBuyPress is optional.

✨ Suggested simplification
-            <ActionButtonsRow {...(actions.showSnackBar ? { onBuyPress: actions.showSnackBar } : {})} />
+            <ActionButtonsRow onBuyPress={actions.showSnackBar} />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/packages/wallet-ui/src/screens/WalletScreen.tsx` at line 33, The
conditional spread around ActionButtonsRow is unnecessary—replace the spread
logic with a direct optional prop by passing onBuyPress={actions.showSnackBar}
to ActionButtonsRow (since onBuyPress is already optional) instead of using the
{...(actions.showSnackBar ? { onBuyPress: actions.showSnackBar } : {})} pattern;
update the component invocation where ActionButtonsRow is used to remove the
spread and supply onBuyPress directly.
frontend/packages/wallet-ui/src/screens/useWalletActions.ts (1)

10-10: Use full word instead of abbreviation.

The parameter p in the functional update should use a full word like previous per coding guidelines that discourage abbreviations.

✨ Suggested fix
-  const toggleBalance = useCallback(() => setIsBalanceVisible((p) => !p), []);
+  const toggleBalance = useCallback(() => setIsBalanceVisible((previous) => !previous), []);

As per coding guidelines: "Use full words in naming; no abbreviations".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/packages/wallet-ui/src/screens/useWalletActions.ts` at line 10,
Rename the abbreviated functional-update parameter in toggleBalance to a full
word: change the arrow callback passed to setIsBalanceVisible inside the
toggleBalance function so the parameter `p` uses a descriptive name like
`previous` (e.g., in the toggleBalance const and its use of setIsBalanceVisible)
to comply with naming guidelines.
frontend/packages/wallet-ui/src/components/ActionButtonsRow.tsx (1)

21-21: Simplify the conditional prop passing.

The conditional spread {...(onBuyPress ? { onPress: onBuyPress } : {})} is unnecessarily verbose. Since onPress is optional in ActionButton, you can pass undefined directly.

✨ Suggested simplification
-      <ActionButton iconName="wallet-buycrypto" label={translate("walletUi:buyAction")} filled {...(onBuyPress ? { onPress: onBuyPress } : {})} />
+      <ActionButton iconName="wallet-buycrypto" label={translate("walletUi:buyAction")} filled onPress={onBuyPress} />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/packages/wallet-ui/src/components/ActionButtonsRow.tsx` at line 21,
Replace the verbose conditional prop spread in ActionButtonsRow.tsx: instead of
using {...(onBuyPress ? { onPress: onBuyPress } : {})} when rendering
ActionButton, pass the optional handler directly as onPress={onBuyPress}; this
leverages the fact that onPress is optional on ActionButton and will be
undefined when onBuyPress is not provided.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@frontend/packages/wallet-ui/src/components/ActionButtonsRow.tsx`:
- Line 21: Replace the verbose conditional prop spread in ActionButtonsRow.tsx:
instead of using {...(onBuyPress ? { onPress: onBuyPress } : {})} when rendering
ActionButton, pass the optional handler directly as onPress={onBuyPress}; this
leverages the fact that onPress is optional on ActionButton and will be
undefined when onBuyPress is not provided.

In `@frontend/packages/wallet-ui/src/screens/useWalletActions.ts`:
- Line 10: Rename the abbreviated functional-update parameter in toggleBalance
to a full word: change the arrow callback passed to setIsBalanceVisible inside
the toggleBalance function so the parameter `p` uses a descriptive name like
`previous` (e.g., in the toggleBalance const and its use of setIsBalanceVisible)
to comply with naming guidelines.

In `@frontend/packages/wallet-ui/src/screens/WalletScreen.tsx`:
- Around line 40-42: The inline style object passed to the View in WalletScreen
(styles.snackBarWrapper) is recreated each render; wrap the object `{
paddingHorizontal: scaleSize(16), paddingBottom: scaleSize(16) }` in a useMemo
and replace the inline literal with that memoized variable, adding useMemo to
the imports; keep the dependency array minimal (e.g., [] or include scaleSize if
it can change) and reuse the memoized style in the View to avoid allocating a
new object each render.
- Line 33: The conditional spread around ActionButtonsRow is unnecessary—replace
the spread logic with a direct optional prop by passing
onBuyPress={actions.showSnackBar} to ActionButtonsRow (since onBuyPress is
already optional) instead of using the {...(actions.showSnackBar ? { onBuyPress:
actions.showSnackBar } : {})} pattern; update the component invocation where
ActionButtonsRow is used to remove the spread and supply onBuyPress directly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d62b6948-87e5-447c-86c9-6168a55b7e77

📥 Commits

Reviewing files that changed from the base of the PR and between 8ec24ba and 008ddac.

📒 Files selected for processing (8)
  • frontend/packages/ui/src/index.ts
  • frontend/packages/wallet-ui/src/components/ActionButton.tsx
  • frontend/packages/wallet-ui/src/components/ActionButtonsRow.tsx
  • frontend/packages/wallet-ui/src/screens/WalletScreen.tsx
  • frontend/packages/wallet-ui/src/screens/useWalletActions.ts
  • frontend/packages/wallet-ui/src/translations/de.ts
  • frontend/packages/wallet-ui/src/translations/en.ts
  • frontend/packages/wallet-ui/src/translations/fr.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant