@bsv/expo-wallet-toolbox 0.4.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.
- package/CHANGELOG.md +547 -0
- package/README.md +19 -1
- package/assets/sounds/vault-deposit.wav +0 -0
- package/assets/sounds/vault-withdraw.wav +0 -0
- package/core/amountFormatHelpers.ts +238 -34
- package/core/backup/RemoteSyncReader.ts +2 -5
- package/core/backup/codec.ts +2 -2
- package/core/backup/push.ts +1 -1
- package/core/config.tsx +16 -1
- package/core/contacts/contactActivity.ts +153 -0
- package/core/contacts/contactCache.ts +41 -0
- package/core/contacts/contactsStore.ts +183 -0
- package/core/context/VaultContext.tsx +8 -11
- package/core/context/WalletConnectionContext.tsx +137 -52
- package/core/context/WalletContext.tsx +464 -30
- package/core/demo/demoAssets.ts +60 -0
- package/core/demo/demoLedger.ts +240 -0
- package/core/demo/demoMandalaRuntime.ts +96 -0
- package/core/demo/demoMode.ts +38 -0
- package/core/demo/demoWallet.ts +25 -0
- package/core/demo/index.ts +26 -0
- package/core/demo/useDemo.ts +59 -0
- package/core/headers/OfflineFirstChaintracks.ts +52 -14
- package/core/headers/headerStore.ts +7 -10
- package/core/hooks/useConfirmationSound.ts +14 -8
- package/core/i18n/translations.tsx +4562 -986
- package/core/identity/contactLink.ts +36 -0
- package/core/identity/handleRegistry/client.ts +285 -0
- package/core/identity/handleRegistry/profileCert.ts +254 -0
- package/core/identity/handleRegistry/registration.ts +559 -0
- package/core/identity/handleRegistry/resolver.ts +247 -0
- package/core/identity/handleRegistry/rules.ts +104 -0
- package/core/index.ts +116 -15
- package/core/localpay/build.ts +674 -37
- package/core/localpay/codec.ts +68 -5
- package/core/localpay/pending.ts +240 -22
- package/core/localpay/pendingAborts.ts +5 -1
- package/core/localpay/settlementAck.ts +149 -0
- package/core/localpay/types.ts +14 -1
- package/core/localpay/verify.ts +118 -69
- package/core/mandala/abortGuard.ts +134 -0
- package/core/mandala/basketMigration.ts +166 -0
- package/core/mandala/bundle.ts +244 -0
- package/core/mandala/createRuntime.ts +2437 -0
- package/core/mandala/drain.ts +670 -0
- package/core/mandala/permissionModule.ts +642 -0
- package/core/mandala/resendTransfer.ts +175 -0
- package/core/mandala/runtime.ts +357 -0
- package/core/mandala/settlementStore.ts +412 -0
- package/core/mandala/types.ts +290 -0
- package/core/monitor/MonitorSupervisor.ts +121 -0
- package/core/monitor/TaskBackupPush.ts +1 -1
- package/core/monitor/TaskCreditInbox.ts +1 -1
- package/core/monitor/TaskDrainOutbox.ts +1 -1
- package/core/monitor/TaskSendOffline.ts +1 -1
- package/core/net/online.ts +49 -0
- package/core/numberFormat.ts +19 -0
- package/core/offline/cancelParked.ts +94 -1
- package/core/offline/payerHold.ts +152 -12
- package/core/offline/plan.ts +1 -1
- package/core/offline/tokenFrames.ts +197 -0
- package/core/parsePeerPayURI.ts +70 -17
- package/core/pay/rails/address.ts +51 -3
- package/core/pay/rails/handle.ts +88 -9
- package/core/pay/rails/index.ts +16 -6
- package/core/pay/rails/nearby.ts +114 -4
- package/core/pay/recordProof.ts +2 -6
- package/core/services/arcadeBroadcastProvider.ts +1 -4
- package/core/services/capWalletArgs.ts +8 -9
- package/core/services/exchangeRate.ts +1 -1
- package/core/services/externalOrigin.ts +42 -0
- package/core/services/vault/VaultKeyService.ts +912 -251
- package/core/services/vault/ceremony.ts +435 -367
- package/core/services/vault/ceremonyHost.ts +27 -21
- package/core/services/vault/devMock.ts +30 -7
- package/core/services/vault/driver.ts +95 -41
- package/core/services/vault/guard.ts +514 -56
- package/core/services/vault/hardwareLease.ts +22 -0
- package/core/services/vault/mockYubiKey.ts +258 -90
- package/core/services/vault/pivReset.ts +145 -0
- package/core/services/vault/r1comb.ts +976 -0
- package/core/services/vault/session.ts +93 -26
- package/core/services/vault/transfers.ts +2617 -747
- package/core/services/vault/types.ts +100 -43
- package/core/services/vault/vaultStore.ts +991 -74
- package/core/services/walletConnectionValidation.ts +293 -0
- package/core/services/walletServiceConfig.ts +31 -20
- package/core/storage/StorageExpoSQLite.ts +420 -87
- package/core/storage/dbImage.ts +48 -0
- package/core/storage/methods/findSql.ts +3 -54
- package/core/storage/methods/listActionsSql.ts +8 -5
- package/core/storage/methods/listOutputsSql.ts +9 -5
- package/core/storage/methods/offlineActions.ts +15 -0
- package/core/storage/methods/processOfflineActions.ts +265 -9
- package/core/storage/methods/reviewStatusSql.ts +7 -2
- package/core/storage/methods/walletBalanceSql.ts +16 -4
- package/core/storage/schema/createTables.ts +152 -0
- package/core/storage/sqlUpdateValue.ts +24 -0
- package/core/toolboxConfig.ts +182 -1
- package/core/toolboxTypes.ts +40 -0
- package/core/userAvatar.ts +79 -0
- package/core/walletMonitor.ts +8 -3
- package/core/walletRepair/runWalletCheck.ts +19 -2
- package/package.json +31 -30
- package/ui/activityFilter.ts +115 -0
- package/ui/components/QRScanner.tsx +1 -1
- package/ui/components/pay/AdmissionNotice.tsx +99 -0
- package/ui/components/pay/AssetPicker.tsx +184 -0
- package/ui/components/pay/AvailableBalance.tsx +33 -2
- package/ui/components/pay/HandleReceive.tsx +213 -50
- package/ui/components/pay/NearbyFlow.tsx +616 -69
- package/ui/components/pay/PayForm.tsx +73 -8
- package/ui/components/pay/PaymentSuccessOverlay.tsx +89 -8
- package/ui/components/pay/RecipientField.tsx +132 -73
- package/ui/components/pay/RequestHub.tsx +68 -8
- package/ui/components/pay/ResultBanner.tsx +41 -4
- package/ui/components/pay/StepBar.tsx +32 -0
- package/ui/components/pay/UniversalSend.tsx +1118 -86
- package/ui/components/pay/tokenSendCopy.ts +116 -0
- package/ui/components/pay/useRecipientInput.ts +36 -7
- package/ui/components/ui/PencilEditField.tsx +109 -0
- package/ui/components/ui/PermissionSheet.tsx +65 -4
- package/ui/components/ui/Sheet.tsx +9 -2
- package/ui/components/ui/SlideOverFromRight.tsx +86 -0
- package/ui/components/vault/EnrollWizard.tsx +1432 -488
- package/ui/components/vault/KeyChooser.tsx +96 -0
- package/ui/components/vault/VaultCeremonySheet.tsx +107 -43
- package/ui/components/vault/vaultErrorCopy.ts +145 -0
- package/ui/components/wallet/ActivityRow.tsx +283 -97
- package/ui/components/wallet/AmountInput.tsx +92 -28
- package/ui/components/wallet/AssetAmount.tsx +95 -0
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +261 -0
- package/ui/components/wallet/ContactActivityList.tsx +149 -0
- package/ui/components/wallet/ContactSigil.tsx +49 -0
- package/ui/components/wallet/EditPictureSheet.tsx +99 -0
- package/ui/components/wallet/FitAmount.tsx +148 -0
- package/ui/components/wallet/IconPickerSheet.tsx +168 -0
- package/ui/components/wallet/IdentifierRow.tsx +69 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +35 -13
- package/ui/components/wallet/ProfileButton.tsx +62 -0
- package/ui/components/wallet/UserAvatar.tsx +85 -0
- package/ui/components/wallet/avatarIcons.ts +122 -0
- package/ui/components/wallet/tokenEviction.ts +65 -0
- package/ui/hooks/useContactsStore.ts +10 -0
- package/ui/hooks/useExportWalletData.ts +39 -0
- package/ui/hooks/useMandala.ts +320 -0
- package/ui/hooks/useOnline.ts +65 -20
- package/ui/hooks/useVaultBalance.ts +105 -7
- package/ui/hooks/useVaultCoverage.ts +52 -0
- package/ui/importDatabases.ts +7 -3
- package/ui/index.ts +75 -7
- package/ui/screens/ConnectionsScreen.tsx +46 -29
- package/ui/screens/ContactScreen.tsx +289 -0
- package/ui/screens/ContactsScreen.tsx +373 -0
- package/ui/screens/IdentifierScreen.tsx +234 -0
- package/ui/screens/NewContactScreen.tsx +362 -0
- package/ui/screens/PairScreen.tsx +12 -12
- package/ui/screens/PayScreen.tsx +145 -12
- package/ui/screens/ProfileScreen.tsx +783 -0
- package/ui/screens/SettingsScreen.tsx +18 -9
- package/ui/screens/TransactionDetailScreen.tsx +419 -0
- package/ui/screens/TrustScreen.tsx +1 -1
- package/ui/screens/VaultScreen.tsx +925 -171
- package/ui/screens/VaultTransferScreen.tsx +376 -123
- package/ui/screens/WalletCheckScreen.tsx +10 -1
- package/ui/screens/WalletConfigScreen.tsx +80 -16
- package/ui/screens/WalletHomeScreen.tsx +915 -139
- package/ui/screens/homeBadges.ts +9 -1
- package/ui/screens/tokenRowTitle.ts +68 -0
- package/ui/tokenFormat.ts +108 -0
- package/ui/tokenSeen.ts +75 -0
- package/ui/tokenStatus.ts +100 -0
- package/ui/txStatus.ts +43 -5
- package/assets/sounds/vault-close.wav +0 -0
- package/assets/sounds/vault-open.wav +0 -0
- package/core/services/vault/k1.ts +0 -75
- package/core/services/vault/sealing.ts +0 -84
- package/core/services/vault/vaultDerivation.ts +0 -152
- package/core/services/vault/vaultPassphrase.ts +0 -287
- package/ui/components/vault/PassphraseField.tsx +0 -306
- package/ui/components/vault/PhraseBackupSheet.tsx +0 -227
- package/ui/screens/VaultRecoverScreen.tsx +0 -226
|
@@ -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
|
-
|
|
46
|
-
formatSatoshisAsBsvDecimal,
|
|
47
|
+
isFiatCurrency,
|
|
47
48
|
findOfflineActions,
|
|
48
49
|
type OfflineActionRow,
|
|
49
50
|
TaskSendOffline,
|
|
@@ -71,9 +72,17 @@ import {
|
|
|
71
72
|
isMessageBoxNetworkError,
|
|
72
73
|
generateMnemonicWallet,
|
|
73
74
|
backupAttestation,
|
|
75
|
+
isVaultAvailable,
|
|
74
76
|
type PendingResend
|
|
75
77
|
} from '@bsv/expo-wallet-toolbox'
|
|
76
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'
|
|
77
86
|
import { BackupReminderSheet } from '../components/wallet/BackupReminderSheet'
|
|
78
87
|
import { BiometricAdvisoryModal } from '../components/wallet/BiometricAdvisoryModal'
|
|
79
88
|
import { ImportFromBackupPrompt } from '../components/wallet/ImportFromBackupPrompt'
|
|
@@ -84,7 +93,24 @@ import { storageMatchesNetwork } from '../../core/net/chainMatch'
|
|
|
84
93
|
import { makeMetadataDecryptor } from '../../core/peerpay/metadataDecryptor'
|
|
85
94
|
import { getPendingCorruptNotice, readUnprocessedPending } from '../../core/localpay/pending'
|
|
86
95
|
import { homeBadges } from './homeBadges'
|
|
96
|
+
import { tokenRowTitle } from './tokenRowTitle'
|
|
97
|
+
import { useMandala, useMandalaRuntime, useTokenActivity, tokenActivityByTxid } from '../hooks/useMandala'
|
|
98
|
+
import { announceEviction, evictionsFrom } from '../components/wallet/tokenEviction'
|
|
99
|
+
import { SEEN_EVICTIONS_KEY, useSeenSet } from '../tokenSeen'
|
|
100
|
+
import { tokenRowStatusView } from '../tokenStatus'
|
|
101
|
+
import { formatTokenAmount, tokenAmountParts } from '../tokenFormat'
|
|
102
|
+
import AssetSwitcherDropdown, { BSV_LABEL } from '../components/wallet/AssetSwitcherDropdown'
|
|
87
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'
|
|
88
114
|
import PressableScale from '../components/ui/PressableScale'
|
|
89
115
|
import ScreenGradient from '../components/ui/ScreenGradient'
|
|
90
116
|
import ScrollFade, { sampleScreenGradient } from '../components/ui/ScrollFade'
|
|
@@ -111,6 +137,22 @@ async function readMessageBoxUrl(): Promise<string | undefined> {
|
|
|
111
137
|
* pattern as this package's other native-module-boundary fixes (expo-router,
|
|
112
138
|
* expo-blur).
|
|
113
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
|
+
|
|
114
156
|
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
115
157
|
type MaterialCommunityIconsComponent = typeof import('@expo/vector-icons').MaterialCommunityIcons
|
|
116
158
|
let ioniconsComponent: IoniconsComponent | undefined
|
|
@@ -177,6 +219,14 @@ const PAGE_SIZE = 30
|
|
|
177
219
|
* the whole thing stays one FlatList — a SectionList would re-measure every
|
|
178
220
|
* section on each status poll. */
|
|
179
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
|
+
|
|
180
230
|
type Row = DayHeader | (ActivityAction & { kind?: undefined })
|
|
181
231
|
|
|
182
232
|
const DAY_MS = 86_400_000
|
|
@@ -228,6 +278,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
228
278
|
const insets = useSafeAreaInsets()
|
|
229
279
|
const { router, useFocusEffect } = loadExpoRouter()
|
|
230
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
|
|
231
284
|
const MaterialCommunityIcons = loadMaterialCommunityIcons()
|
|
232
285
|
const {
|
|
233
286
|
managers,
|
|
@@ -240,12 +293,44 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
240
293
|
settings,
|
|
241
294
|
walletBuilt,
|
|
242
295
|
walletBuilding,
|
|
243
|
-
buildWalletFromMnemonic
|
|
296
|
+
buildWalletFromMnemonic,
|
|
297
|
+
mandalaSettlement
|
|
244
298
|
} = useWallet()
|
|
245
299
|
const { createMnemonic, hasStoredIdentity, secretsReady } = useLocalStorage()
|
|
246
300
|
const { satoshisPerUSD, usdToFiat = {} } = useContext(ExchangeRateContext)
|
|
247
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()
|
|
248
329
|
const online = useOnline()
|
|
330
|
+
// For the token Resend below. Read here rather than off `useMandala()` (which
|
|
331
|
+
// mounts further down) so the handler can close over it without a
|
|
332
|
+
// use-before-declaration.
|
|
333
|
+
const mandalaRuntime = useMandalaRuntime()
|
|
249
334
|
|
|
250
335
|
// ── lazy wallet creation ────────────────────────────────────────────
|
|
251
336
|
/**
|
|
@@ -296,7 +381,15 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
296
381
|
} finally {
|
|
297
382
|
creatingWalletRef.current = false
|
|
298
383
|
}
|
|
299
|
-
}, [
|
|
384
|
+
}, [
|
|
385
|
+
managers.permissionsManager,
|
|
386
|
+
secretsReady,
|
|
387
|
+
walletBuilding,
|
|
388
|
+
hasStoredIdentity,
|
|
389
|
+
createMnemonic,
|
|
390
|
+
buildWalletFromMnemonic,
|
|
391
|
+
router
|
|
392
|
+
])
|
|
300
393
|
|
|
301
394
|
const [pendingDestination, setPendingDestination] = useState<string | null>(null)
|
|
302
395
|
const [showBiometricAdvisory, setShowBiometricAdvisory] = useState(false)
|
|
@@ -368,6 +461,46 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
368
461
|
const [loadingMore, setLoadingMore] = useState(false)
|
|
369
462
|
const [refreshing, setRefreshing] = useState(false)
|
|
370
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])
|
|
371
504
|
const [offlineByTxid, setOfflineByTxid] = useState<Map<string, OfflineActionRow>>(new Map())
|
|
372
505
|
/** What the row's spinner is currently waiting on. */
|
|
373
506
|
const [busyLabel, setBusyLabel] = useState<string | undefined>(undefined)
|
|
@@ -381,6 +514,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
381
514
|
/** Where the pinned block ends, so the fade below it can be painted in the
|
|
382
515
|
* backdrop's colour at exactly that point rather than a guess. */
|
|
383
516
|
const [pinnedHeight, setPinnedHeight] = useState(0)
|
|
517
|
+
/** Where the top bar ends, so the switcher dropdown (design 4a) can anchor
|
|
518
|
+
* itself right under it instead of guessing a fixed offset. */
|
|
519
|
+
const [headerHeight, setHeaderHeight] = useState(0)
|
|
384
520
|
const [pendingCorrupt, setPendingCorrupt] = useState(false)
|
|
385
521
|
// Per-row in-flight action, keyed by txid (or reference for abort) so only
|
|
386
522
|
// the tapped row shows a spinner rather than the whole list.
|
|
@@ -394,6 +530,16 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
394
530
|
/** Set once the server has no more rows, so onEndReached stops re-querying at
|
|
395
531
|
* the bottom of the list. Cleared whenever the list is refetched from 0. */
|
|
396
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)
|
|
397
543
|
/** Synchronous in-flight latch for loadMore (state updates are async). */
|
|
398
544
|
const inFlightRef = useRef(false)
|
|
399
545
|
|
|
@@ -438,6 +584,14 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
438
584
|
if (inFlightBalanceRef.current) return await inFlightBalanceRef.current
|
|
439
585
|
const read = (async () => {
|
|
440
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
|
+
}
|
|
441
595
|
// Straight to our own SQLite, deliberately NOT through the wallet's
|
|
442
596
|
// listOutputs: every call through WalletStorageManager queues on one
|
|
443
597
|
// FIFO reader lock, and the monitor holds that lock across network
|
|
@@ -494,7 +648,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
494
648
|
adminOriginator,
|
|
495
649
|
balanceCacheKey,
|
|
496
650
|
onThisNetwork,
|
|
497
|
-
knownNoStoredIdentity
|
|
651
|
+
knownNoStoredIdentity,
|
|
652
|
+
demoOn
|
|
498
653
|
])
|
|
499
654
|
|
|
500
655
|
/**
|
|
@@ -512,6 +667,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
512
667
|
useEffect(() => {
|
|
513
668
|
refreshBalanceRef.current = refreshBalance
|
|
514
669
|
}, [refreshBalance])
|
|
670
|
+
/** Set once `mandala` exists, below; a no-op until then. */
|
|
671
|
+
const mandalaRefreshRef = useRef<() => void>(() => {})
|
|
515
672
|
// Either route to a figure counts: the direct read needs storage and the user
|
|
516
673
|
// id, the fallback needs the permissions manager.
|
|
517
674
|
const hasWallet = (storage != null && walletUserId != null) || managers.permissionsManager != null
|
|
@@ -524,8 +681,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
524
681
|
setActions([])
|
|
525
682
|
setOfflineByTxid(new Map())
|
|
526
683
|
offsetRef.current = 0
|
|
527
|
-
|
|
528
|
-
|
|
684
|
+
markExhausted(false)
|
|
685
|
+
setOlderPageFailed(false)
|
|
686
|
+
}, [selectedNetwork, markExhausted])
|
|
529
687
|
|
|
530
688
|
useEffect(() => {
|
|
531
689
|
let cancelled = false
|
|
@@ -626,6 +784,10 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
626
784
|
// ── activity ────────────────────────────────────────────────────────
|
|
627
785
|
const fetchActions = useCallback(
|
|
628
786
|
async (offset: number) => {
|
|
787
|
+
if (demoOn && demoMod) {
|
|
788
|
+
setLoadError(false)
|
|
789
|
+
return demoMod.demoListActions({ limit: PAGE_SIZE, offset })
|
|
790
|
+
}
|
|
629
791
|
if (!managers.permissionsManager) return null
|
|
630
792
|
try {
|
|
631
793
|
const result = await managers.permissionsManager.listActions(
|
|
@@ -639,7 +801,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
639
801
|
throw e
|
|
640
802
|
}
|
|
641
803
|
},
|
|
642
|
-
[managers.permissionsManager, adminOriginator]
|
|
804
|
+
[managers.permissionsManager, adminOriginator, demoOn]
|
|
643
805
|
)
|
|
644
806
|
|
|
645
807
|
const fetchOfflineRows = useCallback(async () => {
|
|
@@ -678,7 +840,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
678
840
|
// storage (no wallet created yet) also fails this gate, and has
|
|
679
841
|
// nothing to load — settle the spinner instead of leaving it spinning
|
|
680
842
|
// until a wallet exists.
|
|
681
|
-
|
|
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) {
|
|
682
846
|
if (!storage) setLoading(false)
|
|
683
847
|
return
|
|
684
848
|
}
|
|
@@ -696,7 +860,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
696
860
|
setActions(result.actions as ActivityAction[])
|
|
697
861
|
offsetRef.current = result.actions.length
|
|
698
862
|
// A fresh first page may have more behind it again.
|
|
699
|
-
|
|
863
|
+
markExhausted(result.actions.length < PAGE_SIZE || result.actions.length >= (result.totalActions ?? 0))
|
|
864
|
+
setOlderPageFailed(false)
|
|
700
865
|
setLoading(false)
|
|
701
866
|
} catch {
|
|
702
867
|
if (cancelled) return
|
|
@@ -715,7 +880,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
715
880
|
cancelled = true
|
|
716
881
|
}
|
|
717
882
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
718
|
-
}, [fetchActions, txStatusVersion, focusVersion, fetchOfflineRows, storage, onThisNetwork])
|
|
883
|
+
}, [fetchActions, txStatusVersion, focusVersion, fetchOfflineRows, storage, onThisNetwork, demoOn])
|
|
719
884
|
|
|
720
885
|
const loadMore = useCallback(async () => {
|
|
721
886
|
// Three guards, all load-bearing:
|
|
@@ -738,19 +903,25 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
738
903
|
}
|
|
739
904
|
// A short page means the end; so does reaching the reported total.
|
|
740
905
|
if (page.length < PAGE_SIZE || offsetRef.current >= (result?.totalActions ?? 0)) {
|
|
741
|
-
|
|
906
|
+
markExhausted(true)
|
|
742
907
|
}
|
|
743
908
|
} catch {
|
|
744
909
|
// Keep existing rows; a failed page is not the end of the list.
|
|
910
|
+
setOlderPageFailed(true)
|
|
745
911
|
} finally {
|
|
746
912
|
inFlightRef.current = false
|
|
747
913
|
setLoadingMore(false)
|
|
748
914
|
}
|
|
749
|
-
}, [fetchActions, loading])
|
|
915
|
+
}, [fetchActions, loading, markExhausted])
|
|
750
916
|
|
|
751
917
|
const onRefresh = useCallback(async () => {
|
|
752
918
|
setRefreshing(true)
|
|
753
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()
|
|
754
925
|
const [result, , , entries] = await Promise.all([
|
|
755
926
|
fetchActions(0),
|
|
756
927
|
refreshBalance(),
|
|
@@ -760,7 +931,8 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
760
931
|
if (result) {
|
|
761
932
|
setActions(result.actions as ActivityAction[])
|
|
762
933
|
offsetRef.current = result.actions.length
|
|
763
|
-
|
|
934
|
+
markExhausted(result.actions.length < PAGE_SIZE || result.actions.length >= (result.totalActions ?? 0))
|
|
935
|
+
setOlderPageFailed(false)
|
|
764
936
|
}
|
|
765
937
|
setAttentionCount(TaskCreditInbox.lastAttentionCount)
|
|
766
938
|
setUnsentCount(unsentEntries(entries).length)
|
|
@@ -769,7 +941,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
769
941
|
} finally {
|
|
770
942
|
setRefreshing(false)
|
|
771
943
|
}
|
|
772
|
-
}, [fetchActions, refreshBalance, fetchOfflineRows, storage])
|
|
944
|
+
}, [fetchActions, refreshBalance, fetchOfflineRows, storage, markExhausted])
|
|
773
945
|
|
|
774
946
|
const onExport = useCallback(async () => {
|
|
775
947
|
if (exporting || actions.length === 0 || !managers.permissionsManager) return
|
|
@@ -891,31 +1063,46 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
891
1063
|
try {
|
|
892
1064
|
const pm = managers.permissionsManager
|
|
893
1065
|
if (!pm || !storage) throw new Error(t('unknown_error'))
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
walletClient: pm as never,
|
|
902
|
-
originator: adminOriginator
|
|
1066
|
+
// Network first for a fresh proof; this device's own copy when the
|
|
1067
|
+
// network has never heard of the transaction — a nearby payment whose
|
|
1068
|
+
// code was never scanned is `nosend`, and that is the case a resend
|
|
1069
|
+
// most needs to cover.
|
|
1070
|
+
const refetch = makeResendBeef({
|
|
1071
|
+
refetch: makeBeefRepair({ woc: wocConfigFor(selectedNetwork), online: getOnline }),
|
|
1072
|
+
storage
|
|
903
1073
|
})
|
|
904
|
-
const
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1074
|
+
const decryptMetadata = makeMetadataDecryptor(pm, adminOriginator)
|
|
1075
|
+
// Every resend goes over the message box, whatever rail the payment
|
|
1076
|
+
// first took. What differs is the body: a token row re-sends the
|
|
1077
|
+
// Mandala transfer notification (the runtime rebuilds it from the
|
|
1078
|
+
// blinding journal and the payee output's marker); a BSV row rebuilds
|
|
1079
|
+
// its BRC-29 PeerPay token. Identification is by LABEL, like every
|
|
1080
|
+
// other token decision on this screen.
|
|
1081
|
+
const isToken = actions.find(a => a.txid === txid)?.labels?.includes('mandala') ?? false
|
|
1082
|
+
let outcome: Awaited<ReturnType<typeof resendPaymentDetails>>
|
|
1083
|
+
if (isToken) {
|
|
1084
|
+
if (!mandalaRuntime) throw new Error(t('unknown_error'))
|
|
1085
|
+
outcome = await mandalaRuntime.resendTransfer(txid, { refetch, decryptMetadata })
|
|
1086
|
+
} else {
|
|
1087
|
+
const url = await readMessageBoxUrl()
|
|
1088
|
+
if (!url) {
|
|
1089
|
+
showToast(t('message_box_unreachable'), { type: 'error' })
|
|
1090
|
+
return
|
|
1091
|
+
}
|
|
1092
|
+
const client = new PeerPayClient({
|
|
1093
|
+
messageBoxHost: url,
|
|
1094
|
+
walletClient: pm as never,
|
|
1095
|
+
originator: adminOriginator
|
|
917
1096
|
})
|
|
918
|
-
|
|
1097
|
+
outcome = await resendPaymentDetails({
|
|
1098
|
+
client,
|
|
1099
|
+
storage,
|
|
1100
|
+
txid,
|
|
1101
|
+
listPeerPayAction: makeListPeerPayAction(pm, adminOriginator),
|
|
1102
|
+
decryptMetadata,
|
|
1103
|
+
refetch
|
|
1104
|
+
})
|
|
1105
|
+
}
|
|
919
1106
|
if (outcome.ok) {
|
|
920
1107
|
// A parked payment has now been handed over for real, over a rail
|
|
921
1108
|
// that confirms delivery. Release it so this wallet broadcasts it
|
|
@@ -944,7 +1131,18 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
944
1131
|
setBusyLabel(undefined)
|
|
945
1132
|
}
|
|
946
1133
|
},
|
|
947
|
-
[
|
|
1134
|
+
[
|
|
1135
|
+
busyRow,
|
|
1136
|
+
managers.permissionsManager,
|
|
1137
|
+
storage,
|
|
1138
|
+
adminOriginator,
|
|
1139
|
+
selectedNetwork,
|
|
1140
|
+
offlineByTxid,
|
|
1141
|
+
onRefresh,
|
|
1142
|
+
t,
|
|
1143
|
+
actions,
|
|
1144
|
+
mandalaRuntime
|
|
1145
|
+
]
|
|
948
1146
|
)
|
|
949
1147
|
|
|
950
1148
|
const onFailedSendAgain = useCallback(
|
|
@@ -1019,10 +1217,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1019
1217
|
// The rest pass through the grace filter: online, a payment the drain is
|
|
1020
1218
|
// about to post says nothing worth reading, and the banner appearing for the
|
|
1021
1219
|
// half second before it lands reads as a fault that is not there.
|
|
1022
|
-
const queued = useMemo(
|
|
1023
|
-
() => offlineRows.filter(r => r.status !== 'rejected' && r.status !== 'parked'),
|
|
1024
|
-
[offlineRows]
|
|
1025
|
-
)
|
|
1220
|
+
const queued = useMemo(() => offlineRows.filter(r => r.status !== 'rejected' && r.status !== 'parked'), [offlineRows])
|
|
1026
1221
|
const { shown: queuedShown, nextCheckMs } = useMemo(
|
|
1027
1222
|
// graceNonce is a dependency only: it carries no value into the call, it
|
|
1028
1223
|
// just re-runs it once a young row has aged past the grace.
|
|
@@ -1039,15 +1234,78 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1039
1234
|
}, [nextCheckMs])
|
|
1040
1235
|
const queuedCount = queuedShown.length
|
|
1041
1236
|
const queuedSent = useMemo(() => queuedShown.filter(r => r.role === 'sent'), [queuedShown])
|
|
1237
|
+
// ── stablecoins ─────────────────────────────────────────────────────
|
|
1238
|
+
// Every token surface below is conditional on a fact being true, and the
|
|
1239
|
+
// first fact is "you hold one": with no runtime and no balances this screen
|
|
1240
|
+
// renders exactly what it rendered before any of this existed.
|
|
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])
|
|
1247
|
+
const tokenActivity = useTokenActivity()
|
|
1248
|
+
const tokenByTxid = useMemo(() => tokenActivityByTxid(tokenActivity.rows), [tokenActivity.rows])
|
|
1249
|
+
const seenEvictions = useSeenSet(SEEN_EVICTIONS_KEY)
|
|
1250
|
+
/** True the moment any token balance exists — the gate for the coin switcher. */
|
|
1251
|
+
const hasTokens = (mandala.balances?.length ?? 0) > 0
|
|
1252
|
+
|
|
1253
|
+
// ── the coin on screen ──────────────────────────────────────────────
|
|
1254
|
+
/**
|
|
1255
|
+
* Which money the screen is showing (design 1b, 2026-09-15): `null` is BSV,
|
|
1256
|
+
* the default and the only coin a wallet with no token ever shows. Picked in
|
|
1257
|
+
* the switcher the hero label opens; it decides the hero figure, which
|
|
1258
|
+
* activity rows are listed, and what Pay / Get paid are armed with — so the
|
|
1259
|
+
* Pay screen never asks the asset question a second time.
|
|
1260
|
+
*/
|
|
1261
|
+
const [selectedAssetId, setSelectedAssetId] = useState<string | null>(null)
|
|
1262
|
+
const [switcherOpen, setSwitcherOpen] = useState(false)
|
|
1263
|
+
const heldAsset = useMemo(
|
|
1264
|
+
() => (selectedAssetId ? (mandala.balances?.find(b => b.asset.assetId === selectedAssetId) ?? null) : null),
|
|
1265
|
+
[selectedAssetId, mandala.balances]
|
|
1266
|
+
)
|
|
1267
|
+
// A coin that is no longer held (spent to zero, or a wallet switch) falls
|
|
1268
|
+
// back to BSV. `balances === null` is UNKNOWN, not "holds nothing", and
|
|
1269
|
+
// decides nothing.
|
|
1270
|
+
useEffect(() => {
|
|
1271
|
+
if (selectedAssetId && mandala.balances && !heldAsset) setSelectedAssetId(null)
|
|
1272
|
+
}, [selectedAssetId, mandala.balances, heldAsset])
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Money that left without a sentence. `showAlert`, once per transaction —
|
|
1276
|
+
* the one modal this feature spends, because a balance that simply drops is
|
|
1277
|
+
* the worst failure in the system on a phone.
|
|
1278
|
+
*/
|
|
1279
|
+
useEffect(() => {
|
|
1280
|
+
const pending = evictionsFrom(tokenActivity.rows, seenEvictions.seen)
|
|
1281
|
+
if (pending.length === 0) return
|
|
1282
|
+
let live = true
|
|
1283
|
+
void (async () => {
|
|
1284
|
+
for (const notice of pending) {
|
|
1285
|
+
if (!live) return
|
|
1286
|
+
// Marked before the await resolves: an alert the user dismisses by
|
|
1287
|
+
// backgrounding the app must not re-fire on every foreground after.
|
|
1288
|
+
seenEvictions.see(notice.txid)
|
|
1289
|
+
await announceEviction(t, notice)
|
|
1290
|
+
}
|
|
1291
|
+
})()
|
|
1292
|
+
return () => {
|
|
1293
|
+
live = false
|
|
1294
|
+
}
|
|
1295
|
+
// `seenEvictions.see` is stable; `seen` is the gate and belongs here.
|
|
1296
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1297
|
+
}, [tokenActivity.rows, seenEvictions.seen, t])
|
|
1298
|
+
|
|
1042
1299
|
const stuckBadges = useMemo(
|
|
1043
1300
|
() =>
|
|
1044
1301
|
homeBadges({
|
|
1045
1302
|
attention: attentionCount,
|
|
1046
1303
|
unsent: unsentCount,
|
|
1047
1304
|
offlineQueued: queuedCount,
|
|
1048
|
-
offlineRejected: rejected.length + sentRejected.length
|
|
1305
|
+
offlineRejected: rejected.length + sentRejected.length,
|
|
1306
|
+
tokenAttention: mandala.stuck.length
|
|
1049
1307
|
}).filter(b => b.kind !== 'offline'),
|
|
1050
|
-
[attentionCount, unsentCount, queuedCount, rejected.length, sentRejected.length]
|
|
1308
|
+
[attentionCount, unsentCount, queuedCount, rejected.length, sentRejected.length, mandala.stuck.length]
|
|
1051
1309
|
)
|
|
1052
1310
|
const reloadOffline = useCallback(() => {
|
|
1053
1311
|
void fetchOfflineRows()
|
|
@@ -1055,6 +1313,15 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1055
1313
|
const pushPay = useCallback((sats?: number) => {
|
|
1056
1314
|
router.push(sats && sats > 0 ? `/pay?sats=${sats}` : '/pay')
|
|
1057
1315
|
}, [])
|
|
1316
|
+
/** `/pay` for the coin on screen: a token rides along as `?asset=`, BSV needs nothing. */
|
|
1317
|
+
const payDestination = useCallback(
|
|
1318
|
+
(direction: 'pay' | 'get') => {
|
|
1319
|
+
const base = direction === 'get' ? '/pay?direction=get' : '/pay'
|
|
1320
|
+
if (!heldAsset) return base
|
|
1321
|
+
return `${base}${direction === 'get' ? '&' : '?'}asset=${encodeURIComponent(heldAsset.asset.assetId)}`
|
|
1322
|
+
},
|
|
1323
|
+
[heldAsset]
|
|
1324
|
+
)
|
|
1058
1325
|
const { onRequestAgain, onCopyDetails, onDismiss, onSendAgain } = useOfflineNoticeActions({
|
|
1059
1326
|
storage,
|
|
1060
1327
|
permissionsManager: managers.permissionsManager,
|
|
@@ -1067,7 +1334,22 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1067
1334
|
})
|
|
1068
1335
|
|
|
1069
1336
|
// ── rows ────────────────────────────────────────────────────────────
|
|
1070
|
-
|
|
1337
|
+
/**
|
|
1338
|
+
* The activity list follows the coin on screen. A token shows only its own
|
|
1339
|
+
* transfers; BSV, once a token is held, hides them — a "Sent USDX" row under
|
|
1340
|
+
* a BSV figure would read as BSV leaving. A wallet with no token filters
|
|
1341
|
+
* nothing, and lists exactly what it listed before any of this existed.
|
|
1342
|
+
* Token rows are recognised by LABEL, not by holdings, like `renderItem`.
|
|
1343
|
+
*/
|
|
1344
|
+
const visibleActions = useMemo(() => {
|
|
1345
|
+
if (!hasTokens) return actions
|
|
1346
|
+
if (heldAsset) {
|
|
1347
|
+
return actions.filter(
|
|
1348
|
+
a => !!a.txid && tokenByTxid.get(a.txid.toLowerCase())?.asset.assetId === heldAsset.asset.assetId
|
|
1349
|
+
)
|
|
1350
|
+
}
|
|
1351
|
+
return actions.filter(a => !a.labels?.includes('mandala'))
|
|
1352
|
+
}, [actions, hasTokens, heldAsset, tokenByTxid])
|
|
1071
1353
|
|
|
1072
1354
|
/** Cancel a parked payment: abort the action so the inputs come back, and
|
|
1073
1355
|
* retire its queue row. Refuses once the counterparty has broadcast. */
|
|
@@ -1077,16 +1359,25 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1077
1359
|
if (!storage || !pm || busyRow) return
|
|
1078
1360
|
setBusyRow(txid)
|
|
1079
1361
|
setBusyLabel(t('cancelling_payment'))
|
|
1362
|
+
// FIX J: a token payment's cancel is overlay-authoritative — pass the
|
|
1363
|
+
// settlement deps so `cancelParkedPayment` checks admission before
|
|
1364
|
+
// aborting, refusing with 'already-sent' if the recipient's own submit
|
|
1365
|
+
// already beat the cancel (rule 3: the RECIPIENT settles the hop).
|
|
1366
|
+
// `mandalaSettlement` is `undefined` whenever Mandala is unavailable,
|
|
1367
|
+
// which leaves a plain BSV cancel exactly as it behaves today.
|
|
1368
|
+
const isTokenRow = tokenByTxid.has(txid)
|
|
1080
1369
|
try {
|
|
1081
1370
|
const outcome = await cancelParkedPayment({
|
|
1082
1371
|
storage,
|
|
1083
1372
|
wallet: pm as unknown as CancelParkedWallet,
|
|
1084
1373
|
originator: adminOriginator,
|
|
1085
|
-
txid
|
|
1374
|
+
txid,
|
|
1375
|
+
settlement: mandalaSettlement
|
|
1086
1376
|
})
|
|
1087
1377
|
if (outcome === 'cancelled') showToast(t('tx_abort_success'), { type: 'success' })
|
|
1088
|
-
else if (outcome === 'already-sent')
|
|
1089
|
-
|
|
1378
|
+
else if (outcome === 'already-sent') {
|
|
1379
|
+
showToast(t(isTokenRow ? 'token_cancel_already_sent' : 'pay_parked_already_sent'), { type: 'info' })
|
|
1380
|
+
} else showToast(t('tx_abort_failed'), { type: 'error' })
|
|
1090
1381
|
await onRefresh()
|
|
1091
1382
|
} catch (e: unknown) {
|
|
1092
1383
|
showToast(e instanceof Error ? e.message : t('unknown_error'), { type: 'error' })
|
|
@@ -1095,9 +1386,158 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1095
1386
|
setBusyLabel(undefined)
|
|
1096
1387
|
}
|
|
1097
1388
|
},
|
|
1098
|
-
[storage, managers.permissionsManager, adminOriginator, busyRow, onRefresh, t]
|
|
1389
|
+
[storage, managers.permissionsManager, adminOriginator, busyRow, onRefresh, t, mandalaSettlement, tokenByTxid]
|
|
1099
1390
|
)
|
|
1100
1391
|
|
|
1392
|
+
/**
|
|
1393
|
+
* The token half of each row, precomputed and keyed by txid.
|
|
1394
|
+
*
|
|
1395
|
+
* Built once per activity change rather than inline per render: `ActivityRow`
|
|
1396
|
+
* is memoised on prop identity, and a fresh object per render would defeat that
|
|
1397
|
+
* for exactly the rows a token holder scrolls past most.
|
|
1398
|
+
*/
|
|
1399
|
+
const tokenProps = useMemo(() => {
|
|
1400
|
+
const actionByTxid = new Map(actions.filter(a => a.txid).map(a => [a.txid as string, a]))
|
|
1401
|
+
const map = new Map<string, NonNullable<React.ComponentProps<typeof ActivityRow>['token']>>()
|
|
1402
|
+
for (const [txid, row] of tokenByTxid) {
|
|
1403
|
+
const signedBaseUnits = row.role === 'sent' ? -row.baseUnits : row.baseUnits
|
|
1404
|
+
const figure = formatTokenAmount(signedBaseUnits, row.asset.decimals, {
|
|
1405
|
+
showPlus: row.role === 'received'
|
|
1406
|
+
})
|
|
1407
|
+
const action = actionByTxid.get(txid)
|
|
1408
|
+
map.set(txid, {
|
|
1409
|
+
title: tokenRowTitle({
|
|
1410
|
+
role: row.role,
|
|
1411
|
+
ticker: row.asset.ticker,
|
|
1412
|
+
labels: action?.labels,
|
|
1413
|
+
description: action?.description,
|
|
1414
|
+
assetId: row.asset.assetId,
|
|
1415
|
+
baseUnits: row.baseUnits,
|
|
1416
|
+
t
|
|
1417
|
+
}),
|
|
1418
|
+
amount: figure ? { value: figure, unit: row.asset.ticker } : undefined,
|
|
1419
|
+
incoming: row.role === 'received',
|
|
1420
|
+
// The same generative face a BSV row draws, keyed on the token row's
|
|
1421
|
+
// OWN counterparty key rather than the wallet action's labels/sender
|
|
1422
|
+
// (meaningless for a token transfer) — see TokenActivityRow.counterpartyKey.
|
|
1423
|
+
// A received row is keyed on the sender's blinded per-payment key A′
|
|
1424
|
+
// by design (spec D2): the image differs on every payment from the
|
|
1425
|
+
// same payer, which is the point of the blinding, not a bug in it.
|
|
1426
|
+
counterpartyKey: row.counterpartyKey,
|
|
1427
|
+
status: tokenRowStatusView(row.status, row.role === 'received'),
|
|
1428
|
+
statusText: t(tokenRowStatusView(row.status, row.role === 'received').key)
|
|
1429
|
+
})
|
|
1430
|
+
}
|
|
1431
|
+
return map
|
|
1432
|
+
}, [tokenByTxid, actions, t])
|
|
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
|
+
|
|
1101
1541
|
const renderItem: ListRenderItem<Row> = useCallback(
|
|
1102
1542
|
({ item, index }) => {
|
|
1103
1543
|
if (item.kind === 'day') {
|
|
@@ -1106,17 +1546,24 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1106
1546
|
const key = item.txid || item.reference || `row-${index}`
|
|
1107
1547
|
const offline = item.txid ? offlineByTxid.get(item.txid) : undefined
|
|
1108
1548
|
const busy = busyRow === item.txid || (!!item.reference && busyRow === item.reference)
|
|
1549
|
+
// Identification is by LABEL, not by holdings: a user who sends their
|
|
1550
|
+
// last token keeps denomination across their whole history.
|
|
1551
|
+
const token = item.labels?.includes('mandala') ? tokenProps.get(key) : undefined
|
|
1109
1552
|
|
|
1110
1553
|
return (
|
|
1111
1554
|
<ActivityRow
|
|
1112
1555
|
currency={currency}
|
|
1556
|
+
walletUserId={walletUserId}
|
|
1557
|
+
contactsStore={contactsStore}
|
|
1113
1558
|
action={item}
|
|
1114
1559
|
rowKey={key}
|
|
1560
|
+
token={token}
|
|
1115
1561
|
offlineStatus={offline?.status}
|
|
1116
1562
|
expanded={expandedRow === key}
|
|
1117
1563
|
busy={busy}
|
|
1118
1564
|
busyLabel={busyLabel}
|
|
1119
1565
|
onToggle={toggleRow}
|
|
1566
|
+
onOpen={setOpenTx}
|
|
1120
1567
|
onExplorer={onExplorer}
|
|
1121
1568
|
onRefreshTx={onRefreshTx}
|
|
1122
1569
|
onAbort={onAbort}
|
|
@@ -1129,7 +1576,10 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1129
1576
|
[
|
|
1130
1577
|
colors,
|
|
1131
1578
|
currency,
|
|
1579
|
+
walletUserId,
|
|
1580
|
+
contactsStore,
|
|
1132
1581
|
offlineByTxid,
|
|
1582
|
+
tokenProps,
|
|
1133
1583
|
busyRow,
|
|
1134
1584
|
busyLabel,
|
|
1135
1585
|
expandedRow,
|
|
@@ -1145,22 +1595,13 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1145
1595
|
|
|
1146
1596
|
// ── header (balance + the three destinations + activity heading) ─────
|
|
1147
1597
|
const balanceParts = useMemo(
|
|
1148
|
-
() =>
|
|
1149
|
-
|
|
1598
|
+
() =>
|
|
1599
|
+
balance === null
|
|
1600
|
+
? null
|
|
1601
|
+
: formatAmountParts(balance, displayCurrency, satoshisPerUSD, { abbreviate: true, usdToFiat }),
|
|
1602
|
+
[balance, displayCurrency, satoshisPerUSD, usdToFiat]
|
|
1150
1603
|
)
|
|
1151
1604
|
|
|
1152
|
-
/** The line under the figure: the same money in the denominations the figure
|
|
1153
|
-
* is not using, so the user never has to convert in their head. */
|
|
1154
|
-
const balanceContext = useMemo(() => {
|
|
1155
|
-
if (balance === null) return ''
|
|
1156
|
-
const bsv = `${formatSatoshisAsBsvDecimal(balance)} BSV`
|
|
1157
|
-
const other = formatAmount(balance, currency === 'BSV' ? 'USD' : 'BSV', satoshisPerUSD, {
|
|
1158
|
-
abbreviate: true,
|
|
1159
|
-
usdToFiat
|
|
1160
|
-
})
|
|
1161
|
-
return `${bsv} · ${other}`
|
|
1162
|
-
}, [balance, currency, satoshisPerUSD, usdToFiat])
|
|
1163
|
-
|
|
1164
1605
|
/**
|
|
1165
1606
|
* Pinned above the list, not part of it.
|
|
1166
1607
|
*
|
|
@@ -1169,27 +1610,67 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1169
1610
|
* answer to "how much do I have" and the way to pay were both a scroll back
|
|
1170
1611
|
* up. Everything below them still scrolls with the activity it describes.
|
|
1171
1612
|
*/
|
|
1613
|
+
/** The hero figure: the token on screen, or the BSV balance. `null` is UNKNOWN. */
|
|
1614
|
+
const heroParts = heldAsset ? tokenAmountParts(heldAsset.baseUnits, heldAsset.asset) : balanceParts
|
|
1615
|
+
const heroText = heroParts ? `${heroParts.value} ${heroParts.unit}`.trim() : undefined
|
|
1616
|
+
|
|
1172
1617
|
const pinnedHeader = useMemo(
|
|
1173
1618
|
() => (
|
|
1174
1619
|
<View>
|
|
1175
1620
|
<TouchableOpacity
|
|
1176
|
-
|
|
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)}
|
|
1177
1632
|
activeOpacity={0.7}
|
|
1178
1633
|
style={styles.balanceBlock}
|
|
1179
|
-
accessibilityLabel={
|
|
1634
|
+
accessibilityLabel={
|
|
1635
|
+
heldAsset
|
|
1636
|
+
? undefined
|
|
1637
|
+
: t('wallet_balance_show_in', {
|
|
1638
|
+
unit: displayCurrency === 'BSV' ? (isFiatCurrency(currency) ? currency : 'USD') : 'BSV'
|
|
1639
|
+
})
|
|
1640
|
+
}
|
|
1641
|
+
accessibilityValue={heroText ? { text: heroText } : undefined}
|
|
1180
1642
|
>
|
|
1181
|
-
|
|
1182
|
-
|
|
1643
|
+
{/* With a token held, the coin switcher pill in the top bar IS the
|
|
1644
|
+
label (design 4a) — this block needs none of its own. Without a
|
|
1645
|
+
token it is the plain "You have" of today's screen — a holder
|
|
1646
|
+
with 1,240.00 USDX and no BSV must not read "You have / 0 sats"
|
|
1647
|
+
at display size with their real money elsewhere. */}
|
|
1648
|
+
{!hasTokens && (
|
|
1649
|
+
<Text style={[styles.balanceLabel, { color: colors.textTertiary }]}>{t('wallet_balance_you_have')}</Text>
|
|
1650
|
+
)}
|
|
1651
|
+
{heroParts === null ? (
|
|
1183
1652
|
<ActivityIndicator color={colors.textSecondary} style={styles.balanceSpinner} />
|
|
1184
1653
|
) : (
|
|
1185
1654
|
<>
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
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}
|
|
1193
1674
|
</>
|
|
1194
1675
|
)}
|
|
1195
1676
|
</TouchableOpacity>
|
|
@@ -1199,7 +1680,7 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1199
1680
|
<View style={styles.destinations}>
|
|
1200
1681
|
<PressableScale
|
|
1201
1682
|
haptic="confirm"
|
|
1202
|
-
onPress={() => destinationPress('
|
|
1683
|
+
onPress={() => destinationPress(payDestination('pay'))}
|
|
1203
1684
|
style={[styles.dest, styles.destPrimary, { backgroundColor: colors.accent }]}
|
|
1204
1685
|
>
|
|
1205
1686
|
<MaterialCommunityIcons name="arrow-top-right" size={19} color={colors.textOnAccent} />
|
|
@@ -1210,33 +1691,55 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1210
1691
|
|
|
1211
1692
|
<PressableScale
|
|
1212
1693
|
haptic="confirm"
|
|
1213
|
-
onPress={() => destinationPress('
|
|
1694
|
+
onPress={() => destinationPress(payDestination('get'))}
|
|
1214
1695
|
style={[styles.dest, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
|
|
1215
1696
|
>
|
|
1216
1697
|
<MaterialCommunityIcons name="arrow-bottom-left" size={19} color={colors.textPrimary} />
|
|
1217
1698
|
<Text style={[styles.destLabel, { color: colors.textPrimary }]}>{t('pay_direction_receive')}</Text>
|
|
1218
1699
|
</PressableScale>
|
|
1219
1700
|
|
|
1220
|
-
{/*
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
<
|
|
1229
|
-
|
|
1230
|
-
{
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1701
|
+
{/* Release- and network-gated (spec §5.5, task 11): no Vault
|
|
1702
|
+
destination until the host turns vaultEnabled on, and never off
|
|
1703
|
+
mainnet. `selectedNetwork` is a dependency of this memo, so the
|
|
1704
|
+
destination appears and disappears with a network switch. Plain
|
|
1705
|
+
push, not destinationPress — enrolment needs no wallet, and the
|
|
1706
|
+
Vault screen's own Deposit button runs the lazy wallet-creation
|
|
1707
|
+
path when it comes to that. */}
|
|
1708
|
+
{isVaultAvailable(selectedNetwork) && (
|
|
1709
|
+
<PressableScale
|
|
1710
|
+
haptic="confirm"
|
|
1711
|
+
onPress={() => router.push('/vault')}
|
|
1712
|
+
style={[styles.dest, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
|
|
1713
|
+
>
|
|
1714
|
+
<MaterialCommunityIcons name="safe" size={19} color={colors.textPrimary} />
|
|
1715
|
+
<Text style={[styles.destLabel, { color: colors.textPrimary }]}>{t('wallet_vault')}</Text>
|
|
1716
|
+
</PressableScale>
|
|
1717
|
+
)}
|
|
1234
1718
|
</View>
|
|
1235
1719
|
</View>
|
|
1236
1720
|
),
|
|
1237
|
-
[
|
|
1721
|
+
[
|
|
1722
|
+
heroParts,
|
|
1723
|
+
heroText,
|
|
1724
|
+
colors,
|
|
1725
|
+
t,
|
|
1726
|
+
router,
|
|
1727
|
+
selectedNetwork,
|
|
1728
|
+
hasTokens,
|
|
1729
|
+
heldAsset,
|
|
1730
|
+
payDestination,
|
|
1731
|
+
destinationPress,
|
|
1732
|
+
MaterialCommunityIcons
|
|
1733
|
+
]
|
|
1238
1734
|
)
|
|
1239
1735
|
|
|
1736
|
+
/** The issuer a single stuck row is waiting on, when it can be named. */
|
|
1737
|
+
const stuckIssuerName = useMemo(() => {
|
|
1738
|
+
const first = mandala.stuck[0]
|
|
1739
|
+
const held = first ? (mandala.balances ?? []).find(b => b.asset.assetId === first.assetId) : undefined
|
|
1740
|
+
return held?.asset.issuerName || t('token_issuer_fallback')
|
|
1741
|
+
}, [mandala.stuck, mandala.balances, t])
|
|
1742
|
+
|
|
1240
1743
|
const listHeader = useMemo(
|
|
1241
1744
|
() => (
|
|
1242
1745
|
<View>
|
|
@@ -1272,14 +1775,40 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1272
1775
|
label={
|
|
1273
1776
|
badge.kind === 'attention'
|
|
1274
1777
|
? t('home_payments_need_attention', { count: badge.count })
|
|
1275
|
-
:
|
|
1778
|
+
: badge.kind === 'token_attention'
|
|
1779
|
+
? // One stuck payment can name the issuer it is waiting
|
|
1780
|
+
// on; several cannot, so the plural says the true
|
|
1781
|
+
// thing instead of naming one of them.
|
|
1782
|
+
badge.count === 1
|
|
1783
|
+
? t('token_attention_one', { issuer: stuckIssuerName })
|
|
1784
|
+
: t('token_attention_many', { count: badge.count })
|
|
1785
|
+
: t('home_payments_unsent', { count: badge.count })
|
|
1786
|
+
}
|
|
1787
|
+
icon={
|
|
1788
|
+
badge.kind === 'attention'
|
|
1789
|
+
? 'alert-circle-outline'
|
|
1790
|
+
: badge.kind === 'token_attention'
|
|
1791
|
+
? 'time-outline'
|
|
1792
|
+
: 'send-outline'
|
|
1276
1793
|
}
|
|
1277
|
-
icon={badge.kind === 'attention' ? 'alert-circle-outline' : 'send-outline'}
|
|
1278
1794
|
iconColor={colors.warning}
|
|
1279
1795
|
isLast={i === stuckBadges.length - 1}
|
|
1280
|
-
onPress={() =>
|
|
1796
|
+
onPress={() => {
|
|
1797
|
+
if (badge.kind === 'token_attention') {
|
|
1798
|
+
// No per-asset sheet in v1 (2026-09-15 maintainer
|
|
1799
|
+
// decision): route to Pay with that asset selected, so
|
|
1800
|
+
// the holder lands on the form that can actually move
|
|
1801
|
+
// — or retry — the stuck payment.
|
|
1802
|
+
const assetId = mandala.stuck[0]?.assetId
|
|
1803
|
+
router.push(
|
|
1804
|
+
(assetId ? `/pay?asset=${encodeURIComponent(assetId)}` : '/pay') as Parameters<
|
|
1805
|
+
typeof router.push
|
|
1806
|
+
>[0]
|
|
1807
|
+
)
|
|
1808
|
+
return
|
|
1809
|
+
}
|
|
1281
1810
|
router.push(badge.kind === 'attention' ? '/pay?cell=get-handle' : '/pay?cell=pay-handle')
|
|
1282
|
-
}
|
|
1811
|
+
}}
|
|
1283
1812
|
/>
|
|
1284
1813
|
))}
|
|
1285
1814
|
</GroupedSection>
|
|
@@ -1308,30 +1837,133 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1308
1837
|
|
|
1309
1838
|
<View style={styles.activityHead}>
|
|
1310
1839
|
<Text style={[styles.activityTitle, { color: colors.textPrimary }]}>{t('wallet_activity')}</Text>
|
|
1311
|
-
<
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
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
|
+
>
|
|
1322
1859
|
<Ionicons
|
|
1323
|
-
name="
|
|
1324
|
-
size={
|
|
1325
|
-
color={
|
|
1860
|
+
name="filter-outline"
|
|
1861
|
+
size={14}
|
|
1862
|
+
color={
|
|
1863
|
+
filterOpen ? colors.textOnAccent : actions.length === 0 ? colors.textTertiary : colors.textSecondary
|
|
1864
|
+
}
|
|
1326
1865
|
/>
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
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')}
|
|
1330
1876
|
>
|
|
1331
|
-
{
|
|
1332
|
-
|
|
1333
|
-
|
|
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>
|
|
1334
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}
|
|
1335
1967
|
</View>
|
|
1336
1968
|
),
|
|
1337
1969
|
[
|
|
@@ -1340,6 +1972,10 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1340
1972
|
onExport,
|
|
1341
1973
|
exporting,
|
|
1342
1974
|
actions.length,
|
|
1975
|
+
filterOpen,
|
|
1976
|
+
filterQuery,
|
|
1977
|
+
filterKind,
|
|
1978
|
+
toggleFilter,
|
|
1343
1979
|
pendingResends.length,
|
|
1344
1980
|
stuckBadges,
|
|
1345
1981
|
resending,
|
|
@@ -1356,7 +1992,9 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1356
1992
|
onRequestAgain,
|
|
1357
1993
|
onCopyDetails,
|
|
1358
1994
|
onDismiss,
|
|
1359
|
-
onSendAgain
|
|
1995
|
+
onSendAgain,
|
|
1996
|
+
mandala.stuck,
|
|
1997
|
+
stuckIssuerName
|
|
1360
1998
|
]
|
|
1361
1999
|
)
|
|
1362
2000
|
|
|
@@ -1364,20 +2002,46 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1364
2002
|
<View style={[styles.container, { paddingTop: insets.top }]}>
|
|
1365
2003
|
<ScreenGradient from={colors.canvasTop} to={colors.canvasBase} height={360} />
|
|
1366
2004
|
|
|
1367
|
-
{/* Settings is the only
|
|
1368
|
-
money action, so it should not compete with Pay and
|
|
1369
|
-
Connections moved into Settings as "Connect to
|
|
1370
|
-
app is a once-in-a-while errand, not a
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
2005
|
+
{/* Settings is the only permanent fixture up here: it is navigation
|
|
2006
|
+
chrome, not a money action, so it should not compete with Pay and
|
|
2007
|
+
Vault for the eye. Connections moved into Settings as "Connect to
|
|
2008
|
+
App" — pairing a desktop app is a once-in-a-while errand, not a
|
|
2009
|
+
home-screen affordance.
|
|
2010
|
+
Once a token is held, the coin switcher (design 4a, 2026-09-16)
|
|
2011
|
+
takes the centre column as a filled pill — the screen's title IS
|
|
2012
|
+
the control that changes what the screen is showing, rather than a
|
|
2013
|
+
plain label buried in the balance block below. Both side columns
|
|
2014
|
+
share `iconBtn`'s width so the pill centres over an empty slot too,
|
|
2015
|
+
not just when a host supplies `topLeft`. */}
|
|
2016
|
+
<View style={styles.header} onLayout={e => setHeaderHeight(e.nativeEvent.layout.height)}>
|
|
2017
|
+
<View style={styles.headerSide}>{topLeft}</View>
|
|
2018
|
+
<View style={styles.headerCenter}>
|
|
2019
|
+
{hasTokens && (
|
|
2020
|
+
<TouchableOpacity
|
|
2021
|
+
onPress={() => setSwitcherOpen(true)}
|
|
2022
|
+
activeOpacity={0.7}
|
|
2023
|
+
hitSlop={8}
|
|
2024
|
+
style={[styles.switcherPill, { backgroundColor: colors.accent }]}
|
|
2025
|
+
accessibilityRole="button"
|
|
2026
|
+
accessibilityLabel={t('wallet_coin_switcher')}
|
|
2027
|
+
>
|
|
2028
|
+
<Text style={[styles.switcherPillLabel, { color: colors.textOnAccent }]} numberOfLines={1}>
|
|
2029
|
+
{heldAsset ? heldAsset.asset.ticker : BSV_LABEL}
|
|
2030
|
+
</Text>
|
|
2031
|
+
<Ionicons name="chevron-down" size={12} color={colors.textOnAccent} />
|
|
2032
|
+
</TouchableOpacity>
|
|
2033
|
+
)}
|
|
2034
|
+
</View>
|
|
2035
|
+
<View style={[styles.headerSide, styles.headerSideEnd]}>
|
|
2036
|
+
<TouchableOpacity
|
|
2037
|
+
onPress={() => router.push('/wallet-config')}
|
|
2038
|
+
style={[styles.iconBtn, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
|
|
2039
|
+
accessibilityRole="button"
|
|
2040
|
+
accessibilityLabel={t('wallet_settings')}
|
|
2041
|
+
>
|
|
2042
|
+
<Ionicons name="settings-outline" size={17} color={colors.textSecondary} />
|
|
2043
|
+
</TouchableOpacity>
|
|
2044
|
+
</View>
|
|
1381
2045
|
</View>
|
|
1382
2046
|
|
|
1383
2047
|
{/* Renders only when the keys could not be released — a destroyed key, a
|
|
@@ -1417,10 +2081,26 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1417
2081
|
<Text style={[styles.emptyRetryLabel, { color: colors.accent }]}>{t('activity_load_retry')}</Text>
|
|
1418
2082
|
</PressableScale>
|
|
1419
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
|
+
)
|
|
1420
2092
|
) : (
|
|
1421
|
-
<Text style={[styles.empty, { color: colors.textSecondary }]}>
|
|
2093
|
+
<Text style={[styles.empty, { color: colors.textSecondary }]}>
|
|
2094
|
+
{heldAsset
|
|
2095
|
+
? t('wallet_activity_empty_asset', { ticker: heldAsset.asset.ticker })
|
|
2096
|
+
: t('no_transactions')}
|
|
2097
|
+
</Text>
|
|
1422
2098
|
)
|
|
1423
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"
|
|
1424
2104
|
onEndReached={loadMore}
|
|
1425
2105
|
onEndReachedThreshold={0.3}
|
|
1426
2106
|
refreshing={refreshing}
|
|
@@ -1480,10 +2160,37 @@ export function WalletHomeScreen({ topLeft }: WalletHomeScreenProps = {}) {
|
|
|
1480
2160
|
}}
|
|
1481
2161
|
/>
|
|
1482
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
|
+
|
|
1483
2177
|
<ImportFromBackupPrompt
|
|
1484
2178
|
visible={!hasWallet && secretsReady && !walletBuilding && knownNoStoredIdentity}
|
|
1485
2179
|
onImport={() => router.push('/auth/mnemonic?flow=import')}
|
|
1486
2180
|
/>
|
|
2181
|
+
|
|
2182
|
+
{/* Mounted only once a token is held: a wallet without one keeps today's tree. */}
|
|
2183
|
+
{hasTokens && (
|
|
2184
|
+
<AssetSwitcherDropdown
|
|
2185
|
+
visible={switcherOpen}
|
|
2186
|
+
onClose={() => setSwitcherOpen(false)}
|
|
2187
|
+
top={insets.top + headerHeight}
|
|
2188
|
+
balances={mandala.balances ?? []}
|
|
2189
|
+
selected={heldAsset ? heldAsset.asset.assetId : null}
|
|
2190
|
+
onSelect={setSelectedAssetId}
|
|
2191
|
+
bsv={balanceParts}
|
|
2192
|
+
/>
|
|
2193
|
+
)}
|
|
1487
2194
|
</View>
|
|
1488
2195
|
)
|
|
1489
2196
|
}
|
|
@@ -1499,8 +2206,12 @@ const styles = StyleSheet.create({
|
|
|
1499
2206
|
paddingTop: spacing.sm,
|
|
1500
2207
|
paddingBottom: spacing.xs
|
|
1501
2208
|
},
|
|
1502
|
-
|
|
1503
|
-
|
|
2209
|
+
// Both sides share the settings icon's width, so the centre column (the
|
|
2210
|
+
// switcher pill, when it's there) stays centred whether or not a host
|
|
2211
|
+
// supplies `topLeft` — an empty slot is still a slot the same size.
|
|
2212
|
+
headerSide: { minWidth: 34, alignItems: 'flex-start', justifyContent: 'center' },
|
|
2213
|
+
headerSideEnd: { alignItems: 'flex-end' },
|
|
2214
|
+
headerCenter: { flex: 1, alignItems: 'center' },
|
|
1504
2215
|
iconBtn: {
|
|
1505
2216
|
width: 34,
|
|
1506
2217
|
height: 34,
|
|
@@ -1509,6 +2220,21 @@ const styles = StyleSheet.create({
|
|
|
1509
2220
|
alignItems: 'center',
|
|
1510
2221
|
justifyContent: 'center'
|
|
1511
2222
|
},
|
|
2223
|
+
// The switcher pill (design 4a): filled with the accent colour so it reads
|
|
2224
|
+
// as the screen's title AND its primary control, not a secondary label.
|
|
2225
|
+
switcherPill: {
|
|
2226
|
+
flexDirection: 'row',
|
|
2227
|
+
alignItems: 'center',
|
|
2228
|
+
gap: 6,
|
|
2229
|
+
paddingVertical: 8,
|
|
2230
|
+
paddingLeft: 14,
|
|
2231
|
+
paddingRight: 10,
|
|
2232
|
+
borderRadius: radii.pill
|
|
2233
|
+
},
|
|
2234
|
+
switcherPillLabel: {
|
|
2235
|
+
...typography.headline,
|
|
2236
|
+
fontWeight: '700'
|
|
2237
|
+
},
|
|
1512
2238
|
balanceBlock: {
|
|
1513
2239
|
alignItems: 'center',
|
|
1514
2240
|
paddingTop: spacing.xxl,
|
|
@@ -1534,6 +2260,19 @@ const styles = StyleSheet.create({
|
|
|
1534
2260
|
marginTop: 10,
|
|
1535
2261
|
fontVariant: ['tabular-nums']
|
|
1536
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
|
+
},
|
|
1537
2276
|
balanceUnit: { fontSize: 19, fontWeight: '600', letterSpacing: 0 },
|
|
1538
2277
|
balanceContext: { fontSize: 13, lineHeight: 18, marginTop: 10, fontVariant: ['tabular-nums'] },
|
|
1539
2278
|
|
|
@@ -1548,10 +2287,13 @@ const styles = StyleSheet.create({
|
|
|
1548
2287
|
listWrap: { flex: 1 },
|
|
1549
2288
|
dest: {
|
|
1550
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',
|
|
1551
2293
|
alignItems: 'center',
|
|
1552
2294
|
justifyContent: 'center',
|
|
1553
2295
|
gap: spacing.sm,
|
|
1554
|
-
borderRadius:
|
|
2296
|
+
borderRadius: radii.pill,
|
|
1555
2297
|
paddingTop: 15,
|
|
1556
2298
|
paddingBottom: 13,
|
|
1557
2299
|
borderWidth: StyleSheet.hairlineWidth,
|
|
@@ -1563,8 +2305,8 @@ const styles = StyleSheet.create({
|
|
|
1563
2305
|
borderColor: 'transparent',
|
|
1564
2306
|
shadowColor: '#000',
|
|
1565
2307
|
shadowOpacity: 0.28,
|
|
1566
|
-
shadowRadius:
|
|
1567
|
-
shadowOffset: { width: 0, height:
|
|
2308
|
+
shadowRadius: 6,
|
|
2309
|
+
shadowOffset: { width: 0, height: 2 },
|
|
1568
2310
|
elevation: 4
|
|
1569
2311
|
},
|
|
1570
2312
|
destLabel: { fontSize: 13, fontWeight: '600' },
|
|
@@ -1582,17 +2324,51 @@ const styles = StyleSheet.create({
|
|
|
1582
2324
|
paddingBottom: 10
|
|
1583
2325
|
},
|
|
1584
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
|
+
},
|
|
1585
2337
|
exportBtn: {
|
|
1586
2338
|
flexDirection: 'row',
|
|
1587
2339
|
alignItems: 'center',
|
|
1588
2340
|
gap: 6,
|
|
2341
|
+
height: 28,
|
|
1589
2342
|
paddingHorizontal: 11,
|
|
1590
|
-
paddingVertical: 6,
|
|
1591
2343
|
borderRadius: radii.pill,
|
|
1592
2344
|
borderWidth: StyleSheet.hairlineWidth
|
|
1593
2345
|
},
|
|
1594
2346
|
exportLabel: { fontSize: 12, fontWeight: '600' },
|
|
1595
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
|
+
|
|
1596
2372
|
dayHeader: {
|
|
1597
2373
|
fontSize: 10.5,
|
|
1598
2374
|
fontWeight: '700',
|