@bsv/expo-wallet-toolbox 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +255 -0
  2. package/README.md +19 -0
  3. package/core/amountFormatHelpers.ts +238 -34
  4. package/core/backup/RemoteSyncReader.ts +2 -5
  5. package/core/backup/codec.ts +2 -2
  6. package/core/backup/push.ts +1 -1
  7. package/core/config.tsx +12 -5
  8. package/core/contacts/contactActivity.ts +153 -0
  9. package/core/contacts/contactCache.ts +41 -0
  10. package/core/contacts/contactsStore.ts +183 -0
  11. package/core/context/WalletContext.tsx +55 -10
  12. package/core/demo/demoAssets.ts +60 -0
  13. package/core/demo/demoLedger.ts +240 -0
  14. package/core/demo/demoMandalaRuntime.ts +96 -0
  15. package/core/demo/demoMode.ts +38 -0
  16. package/core/demo/demoWallet.ts +25 -0
  17. package/core/demo/index.ts +26 -0
  18. package/core/demo/useDemo.ts +59 -0
  19. package/core/headers/OfflineFirstChaintracks.ts +52 -14
  20. package/core/headers/headerStore.ts +7 -10
  21. package/core/i18n/translations.tsx +1234 -74
  22. package/core/identity/contactLink.ts +36 -0
  23. package/core/identity/handleRegistry/client.ts +285 -0
  24. package/core/identity/handleRegistry/profileCert.ts +254 -0
  25. package/core/identity/handleRegistry/registration.ts +559 -0
  26. package/core/identity/handleRegistry/resolver.ts +247 -0
  27. package/core/identity/handleRegistry/rules.ts +104 -0
  28. package/core/index.ts +20 -2
  29. package/core/localpay/pendingAborts.ts +5 -1
  30. package/core/monitor/MonitorSupervisor.ts +121 -0
  31. package/core/monitor/TaskBackupPush.ts +1 -1
  32. package/core/monitor/TaskCreditInbox.ts +1 -1
  33. package/core/monitor/TaskDrainOutbox.ts +1 -1
  34. package/core/monitor/TaskSendOffline.ts +1 -1
  35. package/core/net/online.ts +49 -0
  36. package/core/numberFormat.ts +19 -0
  37. package/core/offline/plan.ts +1 -1
  38. package/core/pay/recordProof.ts +2 -6
  39. package/core/services/arcadeBroadcastProvider.ts +1 -4
  40. package/core/services/exchangeRate.ts +1 -1
  41. package/core/services/externalOrigin.ts +5 -2
  42. package/core/services/vault/transfers.ts +2 -2
  43. package/core/services/walletServiceConfig.ts +31 -20
  44. package/core/storage/StorageExpoSQLite.ts +41 -34
  45. package/core/storage/methods/findSql.ts +3 -0
  46. package/core/storage/methods/listActionsSql.ts +8 -5
  47. package/core/storage/methods/listOutputsSql.ts +2 -2
  48. package/core/storage/methods/processOfflineActions.ts +2 -3
  49. package/core/storage/methods/reviewStatusSql.ts +7 -2
  50. package/core/storage/schema/createTables.ts +29 -0
  51. package/core/toolboxConfig.ts +70 -0
  52. package/core/toolboxTypes.ts +40 -0
  53. package/core/userAvatar.ts +79 -0
  54. package/core/walletMonitor.ts +8 -3
  55. package/package.json +7 -7
  56. package/ui/activityFilter.ts +115 -0
  57. package/ui/components/pay/PaymentSuccessOverlay.tsx +46 -6
  58. package/ui/components/pay/RecipientField.tsx +84 -70
  59. package/ui/components/pay/StepBar.tsx +32 -0
  60. package/ui/components/pay/UniversalSend.tsx +677 -149
  61. package/ui/components/ui/PencilEditField.tsx +109 -0
  62. package/ui/components/ui/SlideOverFromRight.tsx +86 -0
  63. package/ui/components/wallet/ActivityRow.tsx +222 -120
  64. package/ui/components/wallet/AmountInput.tsx +18 -6
  65. package/ui/components/wallet/ContactActivityList.tsx +149 -0
  66. package/ui/components/wallet/ContactSigil.tsx +49 -0
  67. package/ui/components/wallet/EditPictureSheet.tsx +99 -0
  68. package/ui/components/wallet/FitAmount.tsx +148 -0
  69. package/ui/components/wallet/IconPickerSheet.tsx +168 -0
  70. package/ui/components/wallet/IdentifierRow.tsx +69 -0
  71. package/ui/components/wallet/ImportFromBackupPrompt.tsx +35 -13
  72. package/ui/components/wallet/ProfileButton.tsx +62 -0
  73. package/ui/components/wallet/UserAvatar.tsx +85 -0
  74. package/ui/components/wallet/avatarIcons.ts +122 -0
  75. package/ui/hooks/useContactsStore.ts +10 -0
  76. package/ui/hooks/useMandala.ts +18 -1
  77. package/ui/hooks/useOnline.ts +65 -20
  78. package/ui/index.ts +26 -1
  79. package/ui/screens/ContactScreen.tsx +289 -0
  80. package/ui/screens/ContactsScreen.tsx +373 -0
  81. package/ui/screens/IdentifierScreen.tsx +234 -0
  82. package/ui/screens/NewContactScreen.tsx +362 -0
  83. package/ui/screens/PayScreen.tsx +20 -7
  84. package/ui/screens/ProfileScreen.tsx +783 -0
  85. package/ui/screens/TransactionDetailScreen.tsx +419 -0
  86. package/ui/screens/TrustScreen.tsx +1 -1
  87. package/ui/screens/WalletConfigScreen.tsx +42 -0
  88. package/ui/screens/WalletHomeScreen.tsx +528 -83
  89. package/ui/tokenStatus.ts +21 -0
  90. package/ui/txStatus.ts +43 -5
@@ -17,12 +17,14 @@
17
17
  * the screen is a shallow gradient with cards lifted off it, which is what makes
18
18
  * the balance read as the focal point in both appearances.
19
19
  */
20
- import React, { useState, useEffect, useCallback, useRef, useMemo, useContext } from 'react'
20
+ import React, { useState, useEffect, useCallback, useRef, useMemo, useContext, useDeferredValue } from 'react'
21
21
  import {
22
22
  View,
23
23
  Text,
24
24
  FlatList,
25
+ ScrollView,
25
26
  StyleSheet,
27
+ TextInput,
26
28
  TouchableOpacity,
27
29
  ActivityIndicator,
28
30
  Linking,
@@ -42,8 +44,7 @@ import {
42
44
  useWallet,
43
45
  ExchangeRateContext,
44
46
  formatAmountParts,
45
- formatAmount,
46
- formatSatoshisAsBsvDecimal,
47
+ isFiatCurrency,
47
48
  findOfflineActions,
48
49
  type OfflineActionRow,
49
50
  TaskSendOffline,
@@ -75,6 +76,13 @@ import {
75
76
  type PendingResend
76
77
  } from '@bsv/expo-wallet-toolbox'
77
78
  import ActivityRow, { type ActivityAction } from '../components/wallet/ActivityRow'
79
+ import { FitAmount } from '../components/wallet/FitAmount'
80
+ import SlideOverFromRight from '../components/ui/SlideOverFromRight'
81
+ import TransactionDetailScreen, {
82
+ type TransactionAction,
83
+ type TransactionDetailParams
84
+ } from './TransactionDetailScreen'
85
+ import { useContactsStore } from '../hooks/useContactsStore'
78
86
  import { BackupReminderSheet } from '../components/wallet/BackupReminderSheet'
79
87
  import { BiometricAdvisoryModal } from '../components/wallet/BiometricAdvisoryModal'
80
88
  import { ImportFromBackupPrompt } from '../components/wallet/ImportFromBackupPrompt'
@@ -89,10 +97,20 @@ import { tokenRowTitle } from './tokenRowTitle'
89
97
  import { useMandala, useMandalaRuntime, useTokenActivity, tokenActivityByTxid } from '../hooks/useMandala'
90
98
  import { announceEviction, evictionsFrom } from '../components/wallet/tokenEviction'
91
99
  import { SEEN_EVICTIONS_KEY, useSeenSet } from '../tokenSeen'
92
- import { tokenStatusKey } from '../tokenStatus'
100
+ import { tokenRowStatusView } from '../tokenStatus'
93
101
  import { formatTokenAmount, tokenAmountParts } from '../tokenFormat'
94
102
  import AssetSwitcherDropdown, { BSV_LABEL } from '../components/wallet/AssetSwitcherDropdown'
95
103
  import { exportTransactionsAsCsv } from '../exportTransactions'
104
+ import {
105
+ ACTIVITY_KIND_FILTERS,
106
+ contactNamesByKey,
107
+ isActivityFilterActive,
108
+ kindFilterLabelKey,
109
+ matchesActivity,
110
+ searchTerms,
111
+ type ActivityKindFilter,
112
+ type ContactNames
113
+ } from '../activityFilter'
96
114
  import PressableScale from '../components/ui/PressableScale'
97
115
  import ScreenGradient from '../components/ui/ScreenGradient'
98
116
  import ScrollFade, { sampleScreenGradient } from '../components/ui/ScrollFade'
@@ -119,6 +137,22 @@ async function readMessageBoxUrl(): Promise<string | undefined> {
119
137
  * pattern as this package's other native-module-boundary fixes (expo-router,
120
138
  * expo-blur).
121
139
  */
140
+ /**
141
+ * Demo mode, or inert constants in anything but a dev bundle.
142
+ *
143
+ * Required at module scope behind `__DEV__` so the demo folder reaches only a
144
+ * dev bundle — a release build inlines `__DEV__` as false and folds the
145
+ * require and everything under it out. Same pattern as
146
+ * `utils/AgentationGate.tsx`. `useDemoLedgerVersion` is a hook, so it is
147
+ * called unconditionally below and its identity must never change.
148
+ */
149
+ type DemoModule = typeof import('../../core/demo')
150
+ const demoMod: DemoModule | null = __DEV__
151
+ ? // eslint-disable-next-line @typescript-eslint/no-require-imports
152
+ (require('../../core/demo') as DemoModule)
153
+ : null
154
+ const useDemoLedgerVersion: () => number = demoMod ? demoMod.useDemoLedgerVersion : () => 0
155
+
122
156
  type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
123
157
  type MaterialCommunityIconsComponent = typeof import('@expo/vector-icons').MaterialCommunityIcons
124
158
  let ioniconsComponent: IoniconsComponent | undefined
@@ -185,6 +219,14 @@ const PAGE_SIZE = 30
185
219
  * the whole thing stays one FlatList — a SectionList would re-measure every
186
220
  * section on each status poll. */
187
221
  type DayHeader = { kind: 'day'; id: string; label: string }
222
+ /**
223
+ * Statuses whose transaction is still local and therefore abortable — the same
224
+ * set `ActivityRow` gates its own Cancel chip on. Duplicated as a constant
225
+ * rather than imported so the row keeps owning its own copy while both
226
+ * surfaces exist.
227
+ */
228
+ const ABORTABLE_DETAIL_STATUSES = new Set(['unsigned', 'nosend', 'nonfinal', 'failed'])
229
+
188
230
  type Row = DayHeader | (ActivityAction & { kind?: undefined })
189
231
 
190
232
  const DAY_MS = 86_400_000
@@ -236,6 +278,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
236
278
  const insets = useSafeAreaInsets()
237
279
  const { router, useFocusEffect } = loadExpoRouter()
238
280
  const Ionicons = loadIonicons()
281
+ // Repaints the screen on every demo write; 0 and no-op in a release bundle.
282
+ useDemoLedgerVersion()
283
+ const demoOn = demoMod?.isDemoModeEnabled() ?? false
239
284
  const MaterialCommunityIcons = loadMaterialCommunityIcons()
240
285
  const {
241
286
  managers,
@@ -254,6 +299,33 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
254
299
  const { createMnemonic, hasStoredIdentity, secretsReady } = useLocalStorage()
255
300
  const { satoshisPerUSD, usdToFiat = {} } = useContext(ExchangeRateContext)
256
301
  const currency = settings?.currency || 'BSV'
302
+ /**
303
+ * Tapping the balance flips which denomination the hero figure is in.
304
+ *
305
+ * View state, not a setting: the display-currency setting chooses WHICH
306
+ * fiat this wallet speaks, and a tap on the figure should not silently
307
+ * rewrite a stored preference that also governs every activity row. Resets
308
+ * to the setting's own answer on relaunch.
309
+ */
310
+ const [flipped, setFlipped] = useState(false)
311
+ /** The row whose detail view is open, or null. Holds the ACTION, so the
312
+ * detail view keeps drawing the row it was opened from even if a refresh
313
+ * reorders the list underneath it. */
314
+ const [openTx, setOpenTx] = useState<ActivityAction | null>(null)
315
+ /** The row still being drawn while the detail view slides back out. */
316
+ const [closedTx, setClosedTx] = useState<ActivityAction | null>(null)
317
+ // Render-phase adjustment rather than an effect: the outgoing surface must
318
+ // already have its content on the frame the close starts.
319
+ if (openTx && openTx !== closedTx) setClosedTx(openTx)
320
+ /** The setting's opposite: BSV when it names a fiat, else the default fiat. */
321
+ const displayCurrency = useMemo(() => {
322
+ if (!flipped) return currency
323
+ return isFiatCurrency(currency) ? 'BSV' : 'USD'
324
+ }, [flipped, currency])
325
+ // Built once here and passed down to every row (with `walletUserId`) so an
326
+ // expanded row's tappable-contact check never has to call `useWallet()`
327
+ // itself — the whole reason `ActivityRow` takes `currency` as a prop too.
328
+ const contactsStore = useContactsStore()
257
329
  const online = useOnline()
258
330
  // For the token Resend below. Read here rather than off `useMandala()` (which
259
331
  // mounts further down) so the handler can close over it without a
@@ -389,6 +461,46 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
389
461
  const [loadingMore, setLoadingMore] = useState(false)
390
462
  const [refreshing, setRefreshing] = useState(false)
391
463
  const [exporting, setExporting] = useState(false)
464
+ // ── activity filter ──────────────────────────────────────────────────
465
+ /**
466
+ * The filter lives only while its panel is open: closing it puts every row
467
+ * back, so a closed panel can never be the reason a payment is missing.
468
+ */
469
+ const [filterOpen, setFilterOpen] = useState(false)
470
+ const [filterQuery, setFilterQuery] = useState('')
471
+ const [filterKind, setFilterKind] = useState<ActivityKindFilter>('all')
472
+ // Typing stays responsive on a long history: the list catches up a beat
473
+ // behind the keystroke instead of every keystroke waiting on the list.
474
+ const deferredQuery = useDeferredValue(filterQuery)
475
+ const activityFilter = useMemo(
476
+ () => ({ kind: filterKind, terms: searchTerms(deferredQuery) }),
477
+ [filterKind, deferredQuery]
478
+ )
479
+ const filterActive = isActivityFilterActive(activityFilter)
480
+ const toggleFilter = useCallback(() => {
481
+ setFilterOpen(open => !open)
482
+ setFilterQuery('')
483
+ setFilterKind('all')
484
+ }, [])
485
+ /** Saved contacts' names and handles, so a search can name who a row was with. */
486
+ const [contactNames, setContactNames] = useState<ReadonlyMap<string, ContactNames>>(new Map())
487
+ // Re-read on every open: a contact saved or renamed since the last search
488
+ // should be findable by the name it has now.
489
+ useEffect(() => {
490
+ if (!filterOpen || !contactsStore || walletUserId == null) return
491
+ let cancelled = false
492
+ contactsStore.listContacts(walletUserId).then(
493
+ contacts => {
494
+ if (!cancelled) setContactNames(contactNamesByKey(contacts))
495
+ },
496
+ () => {
497
+ // A search that cannot name contacts still searches every note.
498
+ }
499
+ )
500
+ return () => {
501
+ cancelled = true
502
+ }
503
+ }, [filterOpen, contactsStore, walletUserId])
392
504
  const [offlineByTxid, setOfflineByTxid] = useState<Map<string, OfflineActionRow>>(new Map())
393
505
  /** What the row's spinner is currently waiting on. */
394
506
  const [busyLabel, setBusyLabel] = useState<string | undefined>(undefined)
@@ -418,6 +530,16 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
418
530
  /** Set once the server has no more rows, so onEndReached stops re-querying at
419
531
  * the bottom of the list. Cleared whenever the list is refetched from 0. */
420
532
  const exhaustedRef = useRef(false)
533
+ /** The same fact as state, for render: a filtered list that is empty has
534
+ * only found nothing once there is no older history left to search. */
535
+ const [historyExhausted, setHistoryExhausted] = useState(false)
536
+ const markExhausted = useCallback((exhausted: boolean) => {
537
+ exhaustedRef.current = exhausted
538
+ setHistoryExhausted(exhausted)
539
+ }, [])
540
+ /** An older page failed to load. Stops the automatic paging below from
541
+ * retrying in a loop; the next refetch from 0 clears it. */
542
+ const [olderPageFailed, setOlderPageFailed] = useState(false)
421
543
  /** Synchronous in-flight latch for loadMore (state updates are async). */
422
544
  const inFlightRef = useRef(false)
423
545
 
@@ -462,6 +584,14 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
462
584
  if (inFlightBalanceRef.current) return await inFlightBalanceRef.current
463
585
  const read = (async () => {
464
586
  try {
587
+ // Demo mode owns the figure outright — no storage, no wallet, and so
588
+ // no dependency on either having been built. Read through `demoOn`
589
+ // rather than calling the gate again, so the dependency below is the
590
+ // real one: it is what re-runs this read when the switch flips.
591
+ if (demoOn && demoMod) {
592
+ setBalance(demoMod.demoWalletBalance())
593
+ return
594
+ }
465
595
  // Straight to our own SQLite, deliberately NOT through the wallet's
466
596
  // listOutputs: every call through WalletStorageManager queues on one
467
597
  // FIFO reader lock, and the monitor holds that lock across network
@@ -518,7 +648,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
518
648
  adminOriginator,
519
649
  balanceCacheKey,
520
650
  onThisNetwork,
521
- knownNoStoredIdentity
651
+ knownNoStoredIdentity,
652
+ demoOn
522
653
  ])
523
654
 
524
655
  /**
@@ -536,6 +667,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
536
667
  useEffect(() => {
537
668
  refreshBalanceRef.current = refreshBalance
538
669
  }, [refreshBalance])
670
+ /** Set once `mandala` exists, below; a no-op until then. */
671
+ const mandalaRefreshRef = useRef<() => void>(() => {})
539
672
  // Either route to a figure counts: the direct read needs storage and the user
540
673
  // id, the fallback needs the permissions manager.
541
674
  const hasWallet = (storage != null && walletUserId != null) || managers.permissionsManager != null
@@ -548,8 +681,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
548
681
  setActions([])
549
682
  setOfflineByTxid(new Map())
550
683
  offsetRef.current = 0
551
- exhaustedRef.current = false
552
- }, [selectedNetwork])
684
+ markExhausted(false)
685
+ setOlderPageFailed(false)
686
+ }, [selectedNetwork, markExhausted])
553
687
 
554
688
  useEffect(() => {
555
689
  let cancelled = false
@@ -650,6 +784,10 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
650
784
  // ── activity ────────────────────────────────────────────────────────
651
785
  const fetchActions = useCallback(
652
786
  async (offset: number) => {
787
+ if (demoOn && demoMod) {
788
+ setLoadError(false)
789
+ return demoMod.demoListActions({ limit: PAGE_SIZE, offset })
790
+ }
653
791
  if (!managers.permissionsManager) return null
654
792
  try {
655
793
  const result = await managers.permissionsManager.listActions(
@@ -663,7 +801,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
663
801
  throw e
664
802
  }
665
803
  },
666
- [managers.permissionsManager, adminOriginator]
804
+ [managers.permissionsManager, adminOriginator, demoOn]
667
805
  )
668
806
 
669
807
  const fetchOfflineRows = useCallback(async () => {
@@ -702,7 +840,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
702
840
  // storage (no wallet created yet) also fails this gate, and has
703
841
  // nothing to load — settle the spinner instead of leaving it spinning
704
842
  // until a wallet exists.
705
- if (!onThisNetwork) {
843
+ // Demo mode has no storage and no wallet by design, so it can never
844
+ // satisfy the network gate below — and must not be asked to.
845
+ if (!demoOn && !onThisNetwork) {
706
846
  if (!storage) setLoading(false)
707
847
  return
708
848
  }
@@ -720,7 +860,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
720
860
  setActions(result.actions as ActivityAction[])
721
861
  offsetRef.current = result.actions.length
722
862
  // A fresh first page may have more behind it again.
723
- exhaustedRef.current = result.actions.length < PAGE_SIZE || result.actions.length >= (result.totalActions ?? 0)
863
+ markExhausted(result.actions.length < PAGE_SIZE || result.actions.length >= (result.totalActions ?? 0))
864
+ setOlderPageFailed(false)
724
865
  setLoading(false)
725
866
  } catch {
726
867
  if (cancelled) return
@@ -739,7 +880,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
739
880
  cancelled = true
740
881
  }
741
882
  // eslint-disable-next-line react-hooks/exhaustive-deps
742
- }, [fetchActions, txStatusVersion, focusVersion, fetchOfflineRows, storage, onThisNetwork])
883
+ }, [fetchActions, txStatusVersion, focusVersion, fetchOfflineRows, storage, onThisNetwork, demoOn])
743
884
 
744
885
  const loadMore = useCallback(async () => {
745
886
  // Three guards, all load-bearing:
@@ -762,19 +903,25 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
762
903
  }
763
904
  // A short page means the end; so does reaching the reported total.
764
905
  if (page.length < PAGE_SIZE || offsetRef.current >= (result?.totalActions ?? 0)) {
765
- exhaustedRef.current = true
906
+ markExhausted(true)
766
907
  }
767
908
  } catch {
768
909
  // Keep existing rows; a failed page is not the end of the list.
910
+ setOlderPageFailed(true)
769
911
  } finally {
770
912
  inFlightRef.current = false
771
913
  setLoadingMore(false)
772
914
  }
773
- }, [fetchActions, loading])
915
+ }, [fetchActions, loading, markExhausted])
774
916
 
775
917
  const onRefresh = useCallback(async () => {
776
918
  setRefreshing(true)
777
919
  try {
920
+ // Rides along because the balance tap no longer refreshes anything —
921
+ // without it, a held token would have no refresh path left. Through a
922
+ // ref because `mandala` is built further down this component than this
923
+ // callback is.
924
+ mandalaRefreshRef.current()
778
925
  const [result, , , entries] = await Promise.all([
779
926
  fetchActions(0),
780
927
  refreshBalance(),
@@ -784,7 +931,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
784
931
  if (result) {
785
932
  setActions(result.actions as ActivityAction[])
786
933
  offsetRef.current = result.actions.length
787
- exhaustedRef.current = result.actions.length < PAGE_SIZE || result.actions.length >= (result.totalActions ?? 0)
934
+ markExhausted(result.actions.length < PAGE_SIZE || result.actions.length >= (result.totalActions ?? 0))
935
+ setOlderPageFailed(false)
788
936
  }
789
937
  setAttentionCount(TaskCreditInbox.lastAttentionCount)
790
938
  setUnsentCount(unsentEntries(entries).length)
@@ -793,7 +941,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
793
941
  } finally {
794
942
  setRefreshing(false)
795
943
  }
796
- }, [fetchActions, refreshBalance, fetchOfflineRows, storage])
944
+ }, [fetchActions, refreshBalance, fetchOfflineRows, storage, markExhausted])
797
945
 
798
946
  const onExport = useCallback(async () => {
799
947
  if (exporting || actions.length === 0 || !managers.permissionsManager) return
@@ -1091,6 +1239,11 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1091
1239
  // first fact is "you hold one": with no runtime and no balances this screen
1092
1240
  // renders exactly what it rendered before any of this existed.
1093
1241
  const mandala = useMandala()
1242
+ // Assigned in an effect, not during render: a render-phase ref mutation is
1243
+ // impure and React is entitled to discard or replay the render around it.
1244
+ useEffect(() => {
1245
+ mandalaRefreshRef.current = mandala.refresh
1246
+ }, [mandala.refresh])
1094
1247
  const tokenActivity = useTokenActivity()
1095
1248
  const tokenByTxid = useMemo(() => tokenActivityByTxid(tokenActivity.rows), [tokenActivity.rows])
1096
1249
  const seenEvictions = useSeenSet(SEEN_EVICTIONS_KEY)
@@ -1197,16 +1350,6 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1197
1350
  }
1198
1351
  return actions.filter(a => !a.labels?.includes('mandala'))
1199
1352
  }, [actions, hasTokens, heldAsset, tokenByTxid])
1200
- const rows = useMemo(() => withDayHeaders(visibleActions, t), [visibleActions, t])
1201
-
1202
- // A filtered page can come up short — or empty — while the server still has
1203
- // more, and a list too short to scroll never fires onEndReached. Keep
1204
- // paging until the visible list is a page long or the history is spent.
1205
- useEffect(() => {
1206
- if (!hasTokens || loading || loadingMore || actions.length === 0) return
1207
- if (visibleActions.length >= PAGE_SIZE || exhaustedRef.current) return
1208
- void loadMore()
1209
- }, [hasTokens, loading, loadingMore, actions.length, visibleActions.length, loadMore])
1210
1353
 
1211
1354
  /** Cancel a parked payment: abort the action so the inputs come back, and
1212
1355
  * retire its queue row. Refuses once the counterparty has broadcast. */
@@ -1281,12 +1424,120 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1281
1424
  // by design (spec D2): the image differs on every payment from the
1282
1425
  // same payer, which is the point of the blinding, not a bug in it.
1283
1426
  counterpartyKey: row.counterpartyKey,
1284
- statusText: t(tokenStatusKey(row.status))
1427
+ status: tokenRowStatusView(row.status, row.role === 'received'),
1428
+ statusText: t(tokenRowStatusView(row.status, row.role === 'received').key)
1285
1429
  })
1286
1430
  }
1287
1431
  return map
1288
1432
  }, [tokenByTxid, actions, t])
1289
1433
 
1434
+ /** The coin's rows, narrowed further while the activity filter is in use. */
1435
+ const filteredActions = useMemo(() => {
1436
+ if (!filterActive) return visibleActions
1437
+ return visibleActions.filter(action => {
1438
+ // Same token lookup as `renderItem`: the filter reads the row it draws.
1439
+ const key = action.txid || action.reference || ''
1440
+ const token = action.labels?.includes('mandala') ? tokenProps.get(key) : undefined
1441
+ return matchesActivity(action, token, activityFilter, contactNames)
1442
+ })
1443
+ }, [visibleActions, filterActive, activityFilter, contactNames, tokenProps])
1444
+ const rows = useMemo(() => withDayHeaders(filteredActions, t), [filteredActions, t])
1445
+
1446
+ // A filtered page can come up short — or empty — while the server still has
1447
+ // more, and a list too short to scroll never fires onEndReached. Keep
1448
+ // paging until the visible list is a page long or the history is spent.
1449
+ // A search pages the same way, so a note from months back is still found.
1450
+ useEffect(() => {
1451
+ if ((!hasTokens && !filterActive) || loading || loadingMore || actions.length === 0) return
1452
+ if (filteredActions.length >= PAGE_SIZE || historyExhausted || olderPageFailed) return
1453
+ void loadMore()
1454
+ }, [
1455
+ hasTokens,
1456
+ filterActive,
1457
+ loading,
1458
+ loadingMore,
1459
+ actions.length,
1460
+ filteredActions.length,
1461
+ historyExhausted,
1462
+ olderPageFailed,
1463
+ loadMore
1464
+ ])
1465
+
1466
+ /** The row's own display fields, in the shape the detail view draws from. */
1467
+ // Plain functions, not `useCallback`: each runs at most once per render (only
1468
+ // when a row is open) and memoizing them buys nothing, while calling a
1469
+ // memoized callback during render trips the compiler's purity rule.
1470
+ const detailParams = (action: ActivityAction): TransactionDetailParams => {
1471
+ const key = action.txid || action.reference || ''
1472
+ const token = action.labels?.includes('mandala') ? tokenProps.get(key) : undefined
1473
+ return {
1474
+ txid: action.txid,
1475
+ satoshis: action.satoshis,
1476
+ status: action.status,
1477
+ description: action.description,
1478
+ isOutgoing: action.isOutgoing,
1479
+ createdAt: action.created_at ? new Date(action.created_at).toISOString() : undefined,
1480
+ counterpartyKey: token?.counterpartyKey ?? action.senderIdentityKey,
1481
+ ...(token
1482
+ ? {
1483
+ token: {
1484
+ title: token.title,
1485
+ amount: token.amount,
1486
+ incoming: token.incoming,
1487
+ statusText: token.statusText
1488
+ }
1489
+ }
1490
+ : {})
1491
+ }
1492
+ }
1493
+
1494
+ /**
1495
+ * The utilities that used to unfold inside an expanded row, as the detail
1496
+ * view's overflow menu. Same handlers, same guards — only the surface moved.
1497
+ */
1498
+ const detailActions = (action: ActivityAction): TransactionAction[] => {
1499
+ const out: TransactionAction[] = []
1500
+ const offline = action.txid ? offlineByTxid.get(action.txid) : undefined
1501
+ const parked = offline?.status === 'parked'
1502
+ if (action.txid && !parked && offline?.status !== 'queued' && offline?.status !== 'posting') {
1503
+ out.push({
1504
+ key: 'refresh',
1505
+ label: t('tx_action_refresh'),
1506
+ icon: 'refresh-outline',
1507
+ onPress: () => void onRefreshTx(action.txid)
1508
+ })
1509
+ }
1510
+ if (action.txid && !parked) {
1511
+ out.push({
1512
+ key: 'explorer',
1513
+ label: t('tx_action_explorer'),
1514
+ icon: 'link-outline',
1515
+ onPress: () => onExplorer(action.txid)
1516
+ })
1517
+ }
1518
+ if (action.reference && ABORTABLE_DETAIL_STATUSES.has(action.status)) {
1519
+ out.push({
1520
+ key: 'abort',
1521
+ label: t('tx_action_abort'),
1522
+ icon: 'close-circle-outline',
1523
+ danger: true,
1524
+ onPress: () => void onAbort(action.reference!)
1525
+ })
1526
+ }
1527
+ if (parked && action.txid) {
1528
+ out.push({
1529
+ key: 'cancel-parked',
1530
+ label: t('pay_parked_cancel'),
1531
+ icon: 'close-circle-outline',
1532
+ danger: true,
1533
+ onPress: () => void onCancelParked(action.txid)
1534
+ })
1535
+ }
1536
+ return out
1537
+ }
1538
+
1539
+
1540
+
1290
1541
  const renderItem: ListRenderItem<Row> = useCallback(
1291
1542
  ({ item, index }) => {
1292
1543
  if (item.kind === 'day') {
@@ -1302,6 +1553,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1302
1553
  return (
1303
1554
  <ActivityRow
1304
1555
  currency={currency}
1556
+ walletUserId={walletUserId}
1557
+ contactsStore={contactsStore}
1305
1558
  action={item}
1306
1559
  rowKey={key}
1307
1560
  token={token}
@@ -1310,6 +1563,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1310
1563
  busy={busy}
1311
1564
  busyLabel={busyLabel}
1312
1565
  onToggle={toggleRow}
1566
+ onOpen={setOpenTx}
1313
1567
  onExplorer={onExplorer}
1314
1568
  onRefreshTx={onRefreshTx}
1315
1569
  onAbort={onAbort}
@@ -1322,6 +1576,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1322
1576
  [
1323
1577
  colors,
1324
1578
  currency,
1579
+ walletUserId,
1580
+ contactsStore,
1325
1581
  offlineByTxid,
1326
1582
  tokenProps,
1327
1583
  busyRow,
@@ -1340,22 +1596,12 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1340
1596
  // ── header (balance + the three destinations + activity heading) ─────
1341
1597
  const balanceParts = useMemo(
1342
1598
  () =>
1343
- balance === null ? null : formatAmountParts(balance, currency, satoshisPerUSD, { abbreviate: true, usdToFiat }),
1344
- [balance, currency, satoshisPerUSD, usdToFiat]
1599
+ balance === null
1600
+ ? null
1601
+ : formatAmountParts(balance, displayCurrency, satoshisPerUSD, { abbreviate: true, usdToFiat }),
1602
+ [balance, displayCurrency, satoshisPerUSD, usdToFiat]
1345
1603
  )
1346
1604
 
1347
- /** The line under the figure: the same money in the denominations the figure
1348
- * is not using, so the user never has to convert in their head. */
1349
- const balanceContext = useMemo(() => {
1350
- if (balance === null) return ''
1351
- const bsv = `${formatSatoshisAsBsvDecimal(balance)} BSV`
1352
- const other = formatAmount(balance, currency === 'BSV' ? 'USD' : 'BSV', satoshisPerUSD, {
1353
- abbreviate: true,
1354
- usdToFiat
1355
- })
1356
- return `${bsv} · ${other}`
1357
- }, [balance, currency, satoshisPerUSD, usdToFiat])
1358
-
1359
1605
  /**
1360
1606
  * Pinned above the list, not part of it.
1361
1607
  *
@@ -1372,13 +1618,26 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1372
1618
  () => (
1373
1619
  <View>
1374
1620
  <TouchableOpacity
1375
- onPress={() => {
1376
- void refreshBalance()
1377
- if (heldAsset) mandala.refresh()
1378
- }}
1621
+ /**
1622
+ * Flips the denomination. Refreshing moved to the list's own
1623
+ * pull gesture, so this tap means exactly one thing.
1624
+ *
1625
+ * A token has no price the wallet can stand behind (ux §6.1), so
1626
+ * there is nothing to flip TO while one is on screen — the tap is
1627
+ * inert rather than converting a stablecoin into an invented
1628
+ * fiat figure.
1629
+ */
1630
+ onPress={heldAsset ? undefined : () => setFlipped(f => !f)}
1631
+ disabled={Boolean(heldAsset)}
1379
1632
  activeOpacity={0.7}
1380
1633
  style={styles.balanceBlock}
1381
- accessibilityLabel={t('wallet_balance_refresh')}
1634
+ accessibilityLabel={
1635
+ heldAsset
1636
+ ? undefined
1637
+ : t('wallet_balance_show_in', {
1638
+ unit: displayCurrency === 'BSV' ? (isFiatCurrency(currency) ? currency : 'USD') : 'BSV'
1639
+ })
1640
+ }
1382
1641
  accessibilityValue={heroText ? { text: heroText } : undefined}
1383
1642
  >
1384
1643
  {/* With a token held, the coin switcher pill in the top bar IS the
@@ -1393,19 +1652,25 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1393
1652
  <ActivityIndicator color={colors.textSecondary} style={styles.balanceSpinner} />
1394
1653
  ) : (
1395
1654
  <>
1396
- <Text style={[styles.balance, { color: colors.textPrimary }]}>
1397
- {heroParts.value}
1398
- {heroParts.unit ? (
1399
- <Text style={[styles.balanceUnit, { color: colors.textSecondary }]}> {heroParts.unit}</Text>
1400
- ) : null}
1401
- </Text>
1402
- {/* Conversions are BSV's alone: the wallet has no price for a
1403
- token, and a converted figure would be invented (ux §6.1).
1404
- A token uses the line for its full name instead, so "1,240.00
1405
- USDX" is never a ticker the holder has to decode. */}
1406
- <Text style={[styles.balanceContext, { color: colors.textSecondary }]}>
1407
- {heldAsset ? heldAsset.asset.label || heldAsset.asset.issuerName || '' : balanceContext}
1408
- </Text>
1655
+ {/* However long the figure, it stays on one line: the type shrinks
1656
+ to fit (see FitAmount for why this is not adjustsFontSizeToFit). */}
1657
+ <FitAmount
1658
+ value={heroParts.value}
1659
+ unit={heroParts.unit}
1660
+ style={[styles.balance, { color: colors.textPrimary }]}
1661
+ unitStyle={[styles.balanceUnit, { color: colors.textSecondary }]}
1662
+ fractionStyle={[styles.balanceFraction, { color: colors.textPrimary }]}
1663
+ />
1664
+ {/* A token keeps this line for its full name, so "1,240.00 USDX"
1665
+ is never a ticker the holder has to decode. BSV no longer
1666
+ carries a conversion line: the same money in the other
1667
+ denomination is one tap on the figure away, and printing
1668
+ both at once was two figures competing to be THE balance. */}
1669
+ {heldAsset ? (
1670
+ <Text style={[styles.balanceContext, { color: colors.textSecondary }]}>
1671
+ {heldAsset.asset.label || heldAsset.asset.issuerName || ''}
1672
+ </Text>
1673
+ ) : null}
1409
1674
  </>
1410
1675
  )}
1411
1676
  </TouchableOpacity>
@@ -1456,15 +1721,12 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1456
1721
  [
1457
1722
  heroParts,
1458
1723
  heroText,
1459
- balanceContext,
1460
1724
  colors,
1461
1725
  t,
1462
- refreshBalance,
1463
1726
  router,
1464
1727
  selectedNetwork,
1465
1728
  hasTokens,
1466
1729
  heldAsset,
1467
- mandala,
1468
1730
  payDestination,
1469
1731
  destinationPress,
1470
1732
  MaterialCommunityIcons
@@ -1575,30 +1837,133 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1575
1837
 
1576
1838
  <View style={styles.activityHead}>
1577
1839
  <Text style={[styles.activityTitle, { color: colors.textPrimary }]}>{t('wallet_activity')}</Text>
1578
- <TouchableOpacity
1579
- onPress={onExport}
1580
- disabled={exporting || actions.length === 0}
1581
- hitSlop={8}
1582
- style={[styles.exportBtn, { borderColor: colors.surfaceRaisedBorder }]}
1583
- accessibilityRole="button"
1584
- accessibilityLabel={t('tx_export_csv')}
1585
- >
1586
- {exporting ? (
1587
- <ActivityIndicator size="small" color={colors.textSecondary} />
1588
- ) : (
1840
+ <View style={styles.activityTools}>
1841
+ {/* Filled while open, like a selected chip below it: the panel it
1842
+ controls is on screen, so the button says it is on. */}
1843
+ <TouchableOpacity
1844
+ onPress={toggleFilter}
1845
+ // Never disabled while open: an emptied list (a network switch)
1846
+ // must not strand the panel with no way to close it.
1847
+ disabled={actions.length === 0 && !filterOpen}
1848
+ hitSlop={8}
1849
+ style={[
1850
+ styles.filterBtn,
1851
+ filterOpen
1852
+ ? { backgroundColor: colors.accent, borderColor: colors.accent }
1853
+ : { borderColor: colors.surfaceRaisedBorder }
1854
+ ]}
1855
+ accessibilityRole="button"
1856
+ accessibilityLabel={t('activity_filter')}
1857
+ accessibilityState={{ expanded: filterOpen }}
1858
+ >
1589
1859
  <Ionicons
1590
- name="download-outline"
1591
- size={12}
1592
- color={actions.length === 0 ? colors.textTertiary : colors.textSecondary}
1860
+ name="filter-outline"
1861
+ size={14}
1862
+ color={
1863
+ filterOpen ? colors.textOnAccent : actions.length === 0 ? colors.textTertiary : colors.textSecondary
1864
+ }
1593
1865
  />
1594
- )}
1595
- <Text
1596
- style={[styles.exportLabel, { color: actions.length === 0 ? colors.textTertiary : colors.textSecondary }]}
1866
+ </TouchableOpacity>
1867
+ {/* "Export", not "Export CSV", to leave the filter room beside it;
1868
+ a screen reader still hears the format. */}
1869
+ <TouchableOpacity
1870
+ onPress={onExport}
1871
+ disabled={exporting || actions.length === 0}
1872
+ hitSlop={8}
1873
+ style={[styles.exportBtn, { borderColor: colors.surfaceRaisedBorder }]}
1874
+ accessibilityRole="button"
1875
+ accessibilityLabel={t('tx_export_csv')}
1597
1876
  >
1598
- {t('tx_export_csv')}
1599
- </Text>
1600
- </TouchableOpacity>
1877
+ {exporting ? (
1878
+ <ActivityIndicator size="small" color={colors.textSecondary} />
1879
+ ) : (
1880
+ <Ionicons
1881
+ name="download-outline"
1882
+ size={12}
1883
+ color={actions.length === 0 ? colors.textTertiary : colors.textSecondary}
1884
+ />
1885
+ )}
1886
+ <Text
1887
+ style={[
1888
+ styles.exportLabel,
1889
+ { color: actions.length === 0 ? colors.textTertiary : colors.textSecondary }
1890
+ ]}
1891
+ >
1892
+ {t('tx_export')}
1893
+ </Text>
1894
+ </TouchableOpacity>
1895
+ </View>
1601
1896
  </View>
1897
+
1898
+ {filterOpen ? (
1899
+ <View style={styles.filterPanel}>
1900
+ <View
1901
+ style={[
1902
+ styles.searchRow,
1903
+ { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }
1904
+ ]}
1905
+ >
1906
+ <Ionicons name="search" size={16} color={colors.textSecondary} />
1907
+ <TextInput
1908
+ value={filterQuery}
1909
+ onChangeText={setFilterQuery}
1910
+ placeholder={t('activity_search_placeholder')}
1911
+ placeholderTextColor={colors.textTertiary}
1912
+ autoFocus
1913
+ autoCapitalize="none"
1914
+ autoCorrect={false}
1915
+ returnKeyType="search"
1916
+ style={[styles.searchInput, { color: colors.textPrimary }]}
1917
+ />
1918
+ {filterQuery.length > 0 && (
1919
+ <TouchableOpacity
1920
+ onPress={() => setFilterQuery('')}
1921
+ style={styles.clearBtn}
1922
+ hitSlop={8}
1923
+ accessibilityRole="button"
1924
+ accessibilityLabel={t('activity_search_clear')}
1925
+ >
1926
+ <Ionicons name="close-circle" size={18} color={colors.textTertiary} />
1927
+ </TouchableOpacity>
1928
+ )}
1929
+ </View>
1930
+ {/* Scrolls sideways rather than wrapping: five chips in a longer
1931
+ language run past a phone's width, and a second row of them
1932
+ would push the list down further than the filter is worth. */}
1933
+ <ScrollView
1934
+ horizontal
1935
+ showsHorizontalScrollIndicator={false}
1936
+ keyboardShouldPersistTaps="handled"
1937
+ contentContainerStyle={styles.kindChips}
1938
+ >
1939
+ {ACTIVITY_KIND_FILTERS.map(kind => {
1940
+ const selected = filterKind === kind
1941
+ const label = t(kindFilterLabelKey(kind))
1942
+ return (
1943
+ <TouchableOpacity
1944
+ key={kind}
1945
+ onPress={() => setFilterKind(kind)}
1946
+ style={[
1947
+ styles.kindChip,
1948
+ selected
1949
+ ? { backgroundColor: colors.accent, borderColor: colors.accent }
1950
+ : { borderColor: colors.surfaceRaisedBorder }
1951
+ ]}
1952
+ accessibilityRole="button"
1953
+ accessibilityLabel={label}
1954
+ accessibilityState={{ selected }}
1955
+ >
1956
+ <Text
1957
+ style={[styles.kindChipLabel, { color: selected ? colors.textOnAccent : colors.textSecondary }]}
1958
+ >
1959
+ {label}
1960
+ </Text>
1961
+ </TouchableOpacity>
1962
+ )
1963
+ })}
1964
+ </ScrollView>
1965
+ </View>
1966
+ ) : null}
1602
1967
  </View>
1603
1968
  ),
1604
1969
  [
@@ -1607,6 +1972,10 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1607
1972
  onExport,
1608
1973
  exporting,
1609
1974
  actions.length,
1975
+ filterOpen,
1976
+ filterQuery,
1977
+ filterKind,
1978
+ toggleFilter,
1610
1979
  pendingResends.length,
1611
1980
  stuckBadges,
1612
1981
  resending,
@@ -1712,6 +2081,14 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1712
2081
  <Text style={[styles.emptyRetryLabel, { color: colors.accent }]}>{t('activity_load_retry')}</Text>
1713
2082
  </PressableScale>
1714
2083
  </View>
2084
+ ) : filterActive ? (
2085
+ // Nothing found YET is not nothing found: until older history
2086
+ // is spent, the search is still paging through it.
2087
+ historyExhausted || olderPageFailed ? (
2088
+ <Text style={[styles.empty, { color: colors.textSecondary }]}>{t('activity_filter_no_match')}</Text>
2089
+ ) : (
2090
+ <ActivityIndicator style={styles.pad} color={colors.textSecondary} />
2091
+ )
1715
2092
  ) : (
1716
2093
  <Text style={[styles.empty, { color: colors.textSecondary }]}>
1717
2094
  {heldAsset
@@ -1720,6 +2097,10 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1720
2097
  </Text>
1721
2098
  )
1722
2099
  }
2100
+ // The filter's search field lives in the header: a tap on a chip
2101
+ // or a row must land the first time, not just drop the keyboard.
2102
+ keyboardShouldPersistTaps="handled"
2103
+ keyboardDismissMode="on-drag"
1723
2104
  onEndReached={loadMore}
1724
2105
  onEndReachedThreshold={0.3}
1725
2106
  refreshing={refreshing}
@@ -1779,6 +2160,20 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
1779
2160
  }}
1780
2161
  />
1781
2162
 
2163
+ {/* One transaction, full screen. Rendered here rather than behind its
2164
+ own route so the overflow menu can reach the very handlers the rows
2165
+ use — including the overlay-authoritative cancel — instead of a
2166
+ duplicate of them. */}
2167
+ <SlideOverFromRight visible={openTx !== null} onClosed={() => setClosedTx(null)}>
2168
+ {(openTx ?? closedTx) ? (
2169
+ <TransactionDetailScreen
2170
+ tx={detailParams((openTx ?? closedTx)!)}
2171
+ getActions={() => detailActions((openTx ?? closedTx)!)}
2172
+ onBack={() => setOpenTx(null)}
2173
+ />
2174
+ ) : null}
2175
+ </SlideOverFromRight>
2176
+
1782
2177
  <ImportFromBackupPrompt
1783
2178
  visible={!hasWallet && secretsReady && !walletBuilding && knownNoStoredIdentity}
1784
2179
  onImport={() => router.push('/auth/mnemonic?flow=import')}
@@ -1865,6 +2260,19 @@ const styles = StyleSheet.create({
1865
2260
  marginTop: 10,
1866
2261
  fontVariant: ['tabular-nums']
1867
2262
  },
2263
+ /**
2264
+ * Roughly 55% of the display size — smaller than the major unit, larger than
2265
+ * a true superscript, which at 44pt would be unreadable. `marginTop` matches
2266
+ * the major run's so the two line boxes start together.
2267
+ */
2268
+ balanceFraction: {
2269
+ fontSize: 24,
2270
+ lineHeight: 28,
2271
+ fontWeight: '700',
2272
+ letterSpacing: -0.4,
2273
+ marginTop: 10,
2274
+ fontVariant: ['tabular-nums']
2275
+ },
1868
2276
  balanceUnit: { fontSize: 19, fontWeight: '600', letterSpacing: 0 },
1869
2277
  balanceContext: { fontSize: 13, lineHeight: 18, marginTop: 10, fontVariant: ['tabular-nums'] },
1870
2278
 
@@ -1879,10 +2287,13 @@ const styles = StyleSheet.create({
1879
2287
  listWrap: { flex: 1 },
1880
2288
  dest: {
1881
2289
  flex: 1,
2290
+ // Icon sits beside the label, not above it, so all three destinations read
2291
+ // as one horizontal row of controls.
2292
+ flexDirection: 'row',
1882
2293
  alignItems: 'center',
1883
2294
  justifyContent: 'center',
1884
2295
  gap: spacing.sm,
1885
- borderRadius: 16,
2296
+ borderRadius: radii.pill,
1886
2297
  paddingTop: 15,
1887
2298
  paddingBottom: 13,
1888
2299
  borderWidth: StyleSheet.hairlineWidth,
@@ -1913,17 +2324,51 @@ const styles = StyleSheet.create({
1913
2324
  paddingBottom: 10
1914
2325
  },
1915
2326
  activityTitle: { fontSize: 15, fontWeight: '700', letterSpacing: -0.2 },
2327
+ activityTools: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
2328
+ // Same height as the Export pill beside it, so the two read as one set.
2329
+ filterBtn: {
2330
+ width: 28,
2331
+ height: 28,
2332
+ borderRadius: radii.pill,
2333
+ borderWidth: StyleSheet.hairlineWidth,
2334
+ alignItems: 'center',
2335
+ justifyContent: 'center'
2336
+ },
1916
2337
  exportBtn: {
1917
2338
  flexDirection: 'row',
1918
2339
  alignItems: 'center',
1919
2340
  gap: 6,
2341
+ height: 28,
1920
2342
  paddingHorizontal: 11,
1921
- paddingVertical: 6,
1922
2343
  borderRadius: radii.pill,
1923
2344
  borderWidth: StyleSheet.hairlineWidth
1924
2345
  },
1925
2346
  exportLabel: { fontSize: 12, fontWeight: '600' },
1926
2347
 
2348
+ // The chip row scrolls edge to edge, so only the search field is inset.
2349
+ filterPanel: { gap: spacing.md, paddingBottom: spacing.sm },
2350
+ searchRow: {
2351
+ flexDirection: 'row',
2352
+ alignItems: 'center',
2353
+ gap: spacing.sm,
2354
+ marginHorizontal: spacing.xl,
2355
+ minHeight: 40,
2356
+ paddingHorizontal: spacing.md,
2357
+ borderRadius: radii.pill,
2358
+ borderWidth: StyleSheet.hairlineWidth
2359
+ },
2360
+ searchInput: { ...typography.subhead, flex: 1, paddingVertical: spacing.sm, paddingHorizontal: 0 },
2361
+ clearBtn: { width: 28, height: 28, alignItems: 'center', justifyContent: 'center' },
2362
+ kindChips: { gap: spacing.sm, paddingHorizontal: spacing.xl },
2363
+ kindChip: {
2364
+ height: 30,
2365
+ paddingHorizontal: spacing.md,
2366
+ borderRadius: radii.pill,
2367
+ borderWidth: StyleSheet.hairlineWidth,
2368
+ justifyContent: 'center'
2369
+ },
2370
+ kindChipLabel: { fontSize: 13, fontWeight: '600' },
2371
+
1927
2372
  dayHeader: {
1928
2373
  fontSize: 10.5,
1929
2374
  fontWeight: '700',