@bsv/expo-wallet-toolbox 0.5.0 → 0.9.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 +2000 -0
- package/README.md +66 -1
- package/core/amountFormatHelpers.ts +258 -36
- package/core/backup/RemoteSyncReader.ts +133 -24
- package/core/backup/appData.ts +157 -0
- package/core/backup/client.ts +15 -1
- package/core/backup/codec.ts +149 -11
- package/core/backup/constants.ts +30 -1
- package/core/backup/cursor.ts +31 -2
- package/core/backup/push.ts +71 -5
- package/core/backup/restore.ts +104 -16
- package/core/backup/restoreOnImport.ts +94 -30
- package/core/backup/status.ts +13 -8
- package/core/config.tsx +12 -5
- package/core/constants.ts +14 -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/ExchangeRateContext.tsx +34 -27
- package/core/context/LocalStorageProvider.tsx +43 -40
- package/core/context/UserContext.tsx +18 -7
- package/core/context/VaultContext.tsx +49 -2
- package/core/context/WalletConnectionContext.tsx +203 -11
- package/core/context/WalletContext.tsx +685 -171
- 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 +99 -17
- package/core/headers/headerStore.ts +33 -14
- package/core/headers/syncHeaders.ts +12 -1
- package/core/i18n/translations.tsx +2186 -98
- package/core/identity/contactLink.ts +36 -0
- package/core/identity/handleRegistry/client.ts +314 -0
- package/core/identity/handleRegistry/keyPinStore.ts +70 -0
- package/core/identity/handleRegistry/profileCert.ts +254 -0
- package/core/identity/handleRegistry/registration.ts +559 -0
- package/core/identity/handleRegistry/resolver.ts +315 -0
- package/core/identity/handleRegistry/rules.ts +104 -0
- package/core/index.ts +53 -5
- package/core/localpay/build.ts +225 -24
- package/core/localpay/pending.ts +110 -7
- package/core/localpay/pendingAbortAuthority.ts +95 -0
- package/core/localpay/pendingAborts.ts +266 -26
- package/core/localpay/session.ts +42 -17
- package/core/localpay/settlementAck.ts +10 -1
- package/core/localpay/transport/socket.ts +52 -3
- package/core/localpay/verify.ts +100 -10
- package/core/mandala/abortGuard.ts +96 -20
- package/core/mandala/createRuntime.ts +206 -33
- package/core/mandala/drain.ts +89 -11
- package/core/mandala/inboxPrehold.ts +186 -0
- package/core/mandala/permissionModule.ts +202 -20
- package/core/mandala/settlementStore.ts +24 -2
- package/core/mandala/types.ts +40 -5
- package/core/monitor/MonitorSupervisor.ts +121 -0
- package/core/monitor/TaskBackupPush.ts +15 -1
- package/core/monitor/TaskCreditInbox.ts +1 -1
- package/core/monitor/TaskDrainOutbox.ts +15 -1
- package/core/monitor/TaskSendOffline.ts +15 -1
- package/core/net/online.ts +49 -0
- package/core/net/publicDestination.ts +91 -0
- package/core/net/validateArcUrl.ts +22 -0
- package/core/numberFormat.ts +19 -0
- package/core/offline/cancelParked.ts +134 -13
- package/core/offline/payerHold.ts +100 -24
- package/core/offline/plan.ts +37 -8
- package/core/pay/beefRepair.ts +6 -2
- package/core/pay/damagedInbox.ts +24 -0
- package/core/pay/rails/address.ts +107 -12
- package/core/pay/rails/handle.ts +117 -22
- package/core/pay/rails/index.ts +45 -7
- package/core/pay/rails/nativeIntent.ts +61 -0
- package/core/pay/receiveHistory.ts +93 -0
- package/core/pay/recordProof.ts +21 -7
- package/core/pay/refreshProofGuard.ts +42 -1
- package/core/pay/watchlist.ts +5 -2
- package/core/peerpay/control.ts +17 -18
- package/core/peerpay/handleResendRequests.ts +58 -4
- package/core/peerpay/outbox.ts +3 -1
- package/core/recovery/backupMaterial.ts +61 -0
- package/core/recovery/createWallet.ts +95 -0
- package/core/recovery/recoverWallet.ts +120 -0
- package/core/recovery/restoreWallet.ts +170 -0
- package/core/recovery/secret.ts +92 -0
- package/core/recovery/shareCollector.ts +71 -0
- package/core/recovery/shareParsing.ts +87 -0
- package/core/recovery/shares.ts +116 -0
- package/core/recovery/useRecoveryDeps.ts +70 -0
- package/core/services/arcTokenStorage.ts +52 -0
- package/core/services/arcadeBroadcastProvider.ts +233 -52
- package/core/services/autoApprovePolicy.ts +105 -0
- package/core/services/callbackToken.ts +19 -0
- package/core/services/capWalletArgs.ts +14 -2
- package/core/services/connectionAuthority.ts +98 -0
- package/core/services/exchangeRate.ts +36 -13
- package/core/services/externalOrigin.ts +16 -2
- package/core/services/secrets/kek.ts +126 -29
- package/core/services/secrets/migration.ts +16 -4
- package/core/services/secrets/store.ts +42 -14
- package/core/services/vault/VaultKeyService.ts +228 -45
- package/core/services/vault/chainRecovery.ts +483 -0
- package/core/services/vault/driver.ts +9 -1
- package/core/services/vault/enrolledSerialRegistry.ts +150 -0
- package/core/services/vault/guard.ts +218 -32
- package/core/services/vault/hardwareLease.ts +19 -0
- package/core/services/vault/metaAuthority.ts +210 -0
- package/core/services/vault/pivReset.ts +64 -23
- package/core/services/vault/r1comb.ts +139 -3
- package/core/services/vault/session.ts +25 -4
- package/core/services/vault/transfers.ts +868 -172
- package/core/services/vault/types.ts +19 -4
- package/core/services/vault/vaultStore.ts +256 -29
- package/core/services/walletArgLimits.ts +45 -2
- package/core/services/walletConnectionValidation.ts +76 -6
- package/core/services/walletServiceConfig.ts +40 -27
- package/core/storage/StorageExpoSQLite.ts +88 -47
- package/core/storage/methods/findSql.ts +24 -2
- package/core/storage/methods/listActionsSql.ts +8 -5
- package/core/storage/methods/listOutputsSql.ts +2 -2
- package/core/storage/methods/offlineActions.ts +10 -1
- package/core/storage/methods/processOfflineActions.ts +117 -25
- package/core/storage/methods/reviewStatusSql.ts +7 -2
- package/core/storage/schema/createTables.ts +155 -2
- package/core/stores/ConnectionStore.ts +34 -0
- package/core/toolboxConfig.ts +104 -0
- package/core/toolboxTypes.ts +40 -0
- package/core/userAvatar.ts +79 -0
- package/core/walletDbRegistry.ts +63 -0
- package/core/walletMonitor.ts +25 -4
- package/core/walletRepair/releaseStuckReservations.ts +72 -0
- package/core/walletRepair/shouldMarkUnspendable.ts +20 -0
- package/core/walletRepair/spenderConsumesOutpoint.ts +29 -0
- package/package.json +7 -7
- package/ui/activityFilter.ts +115 -0
- package/ui/backupShares.ts +26 -169
- package/ui/components/pay/AddressReceive.tsx +13 -6
- package/ui/components/pay/AssetPicker.tsx +30 -9
- package/ui/components/pay/MessageBoxConfig.tsx +16 -0
- package/ui/components/pay/NearbyFlow.tsx +480 -243
- package/ui/components/pay/PaymentSuccessOverlay.tsx +85 -10
- package/ui/components/pay/RecipientField.tsx +84 -70
- package/ui/components/pay/StepBar.tsx +32 -0
- package/ui/components/pay/UniversalSend.tsx +827 -205
- package/ui/components/ui/AlertCard.tsx +38 -5
- package/ui/components/ui/PencilEditField.tsx +109 -0
- package/ui/components/ui/PermissionSheet.tsx +197 -66
- package/ui/components/ui/SlideOverFromRight.tsx +86 -0
- package/ui/components/vault/EnrollWizard.tsx +61 -13
- package/ui/components/vault/vaultErrorCopy.ts +3 -1
- package/ui/components/wallet/ActivityRow.tsx +227 -123
- package/ui/components/wallet/AmountInput.tsx +26 -8
- package/ui/components/wallet/AssetSwitcherDropdown.tsx +22 -2
- package/ui/components/wallet/Balance.tsx +42 -23
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +16 -3
- 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/exportTransactions.ts +36 -4
- package/ui/hooks/useContactsStore.ts +10 -0
- package/ui/hooks/useExportWalletData.ts +25 -2
- package/ui/hooks/useMandala.ts +18 -1
- package/ui/hooks/useOnline.ts +65 -20
- package/ui/importDatabases.ts +339 -24
- package/ui/index.ts +33 -2
- package/ui/isImageUrl.ts +6 -0
- package/ui/printRecoveryShares.ts +9 -10
- package/ui/recoveryPrompts.ts +91 -0
- package/ui/resolveIdentity.ts +31 -9
- package/ui/screens/ConnectionsScreen.tsx +86 -19
- package/ui/screens/ContactScreen.tsx +289 -0
- package/ui/screens/ContactsScreen.tsx +373 -0
- package/ui/screens/IdentifierScreen.tsx +256 -0
- package/ui/screens/NewContactScreen.tsx +362 -0
- package/ui/screens/PairScreen.tsx +74 -2
- package/ui/screens/PayScreen.tsx +20 -7
- package/ui/screens/ProfileScreen.tsx +783 -0
- package/ui/screens/SettingsScreen.tsx +10 -4
- package/ui/screens/TransactionDetailScreen.tsx +419 -0
- package/ui/screens/TrustScreen.tsx +100 -5
- package/ui/screens/VaultScreen.tsx +410 -61
- package/ui/screens/VaultTransferScreen.tsx +59 -7
- package/ui/screens/WalletCheckScreen.tsx +17 -6
- package/ui/screens/WalletConfigScreen.tsx +124 -28
- package/ui/screens/WalletHomeScreen.tsx +640 -104
- package/ui/screens/detailActionKeys.ts +55 -0
- package/ui/tokenFormat.ts +44 -4
- package/ui/tokenStatus.ts +21 -0
- package/ui/txStatus.ts +48 -5
- package/core/storage/LocalStorageAdapter.ts +0 -58
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
type LayoutChangeEvent,
|
|
7
|
+
type NativeSyntheticEvent,
|
|
8
|
+
type StyleProp,
|
|
9
|
+
type TextLayoutEventData,
|
|
10
|
+
type TextStyle
|
|
11
|
+
} from 'react-native'
|
|
12
|
+
import { splitAmountFraction } from '../../../core/amountFormatHelpers'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Never let a figure be smaller than this, so a pathological value stays
|
|
16
|
+
* legible rather than collapsing (iOS Fabric's own fit-to-width bottoms out at
|
|
17
|
+
* 4pt and ignores `minimumFontScale`, which is why this measures instead).
|
|
18
|
+
*/
|
|
19
|
+
const MIN_FONT_SIZE = 12
|
|
20
|
+
|
|
21
|
+
/** Headroom for rounding and the trailing space a wrapped line drops. */
|
|
22
|
+
const FIT_MARGIN = 0.98
|
|
23
|
+
|
|
24
|
+
/** Ignore width changes smaller than this, so rounding never re-triggers a fit. */
|
|
25
|
+
const WIDTH_EPSILON = 1
|
|
26
|
+
|
|
27
|
+
export interface FitAmountProps {
|
|
28
|
+
value: string
|
|
29
|
+
unit?: string
|
|
30
|
+
/** Style of the figure. Its fontSize, lineHeight and letterSpacing are scaled together. */
|
|
31
|
+
style: StyleProp<TextStyle>
|
|
32
|
+
unitStyle?: StyleProp<TextStyle>
|
|
33
|
+
/**
|
|
34
|
+
* When set, the minor units are drawn in this style and hung from the top,
|
|
35
|
+
* the way a price tag writes cents. Its fontSize, lineHeight and
|
|
36
|
+
* letterSpacing scale with the figure; marginTop stays, matching `style`'s.
|
|
37
|
+
*/
|
|
38
|
+
fractionStyle?: StyleProp<TextStyle>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A figure that always sits on one line: however long `value` is, the type
|
|
43
|
+
* shrinks until it fits the width it is given, and grows back to full size
|
|
44
|
+
* when a shorter value arrives.
|
|
45
|
+
*
|
|
46
|
+
* Two facts drive it: the width of the slot (the wrapper's layout) and the
|
|
47
|
+
* width the figure takes on one line at full size (from `onTextLayout`). Width
|
|
48
|
+
* scales linearly with font size, so the scale is simply their ratio. Each is
|
|
49
|
+
* stored as it arrives and the scale is derived from both, so it does not
|
|
50
|
+
* matter which the platform reports first. Nothing is ellipsized or wrapped, so
|
|
51
|
+
* no digit is ever hidden.
|
|
52
|
+
*/
|
|
53
|
+
export function FitAmount({ value, unit, style, unitStyle, fractionStyle }: FitAmountProps) {
|
|
54
|
+
const [available, setAvailable] = useState(0)
|
|
55
|
+
const [fullWidth, setFullWidth] = useState(0)
|
|
56
|
+
|
|
57
|
+
const base = StyleSheet.flatten(style) ?? {}
|
|
58
|
+
const baseSize = base.fontSize ?? 17
|
|
59
|
+
const unitBase = StyleSheet.flatten(unitStyle) ?? {}
|
|
60
|
+
const floor = Math.min(1, MIN_FONT_SIZE / baseSize)
|
|
61
|
+
|
|
62
|
+
const scale = available > 0 && fullWidth > 0 ? Math.min(1, Math.max(floor, (available / fullWidth) * FIT_MARGIN)) : 1
|
|
63
|
+
|
|
64
|
+
const onLayout = useCallback((e: LayoutChangeEvent) => {
|
|
65
|
+
const width = e.nativeEvent.layout.width
|
|
66
|
+
setAvailable(prev => (Math.abs(prev - width) > WIDTH_EPSILON ? width : prev))
|
|
67
|
+
}, [])
|
|
68
|
+
|
|
69
|
+
// `scale` is the size this layout was produced at, which turns the width it
|
|
70
|
+
// reports back into the full-size width.
|
|
71
|
+
const onTextLayout = useCallback(
|
|
72
|
+
(e: NativeSyntheticEvent<TextLayoutEventData>) => {
|
|
73
|
+
// A figure that overflowed wraps, so the widths of all its lines add up to
|
|
74
|
+
// the width it would take on one.
|
|
75
|
+
const natural = e.nativeEvent.lines.reduce((sum, line) => sum + line.width, 0)
|
|
76
|
+
if (natural <= 0) return
|
|
77
|
+
const full = natural / scale
|
|
78
|
+
setFullWidth(prev => (Math.abs(prev - full) > WIDTH_EPSILON ? full : prev))
|
|
79
|
+
},
|
|
80
|
+
[scale]
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
const scaled: TextStyle = {
|
|
84
|
+
fontSize: baseSize * scale,
|
|
85
|
+
...(base.lineHeight != null ? { lineHeight: base.lineHeight * scale } : null),
|
|
86
|
+
...(base.letterSpacing != null ? { letterSpacing: base.letterSpacing * scale } : null)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const unitScaled = unitBase.fontSize != null ? { fontSize: unitBase.fontSize * scale } : null
|
|
90
|
+
const unitRun = unit ? <Text style={[unitStyle, unitScaled]}> {unit}</Text> : null
|
|
91
|
+
|
|
92
|
+
const parts = fractionStyle ? splitAmountFraction(value) : null
|
|
93
|
+
if (!parts?.frac) {
|
|
94
|
+
return (
|
|
95
|
+
<View onLayout={onLayout} style={styles.fill}>
|
|
96
|
+
<Text style={[style, scaled]} onTextLayout={onTextLayout}>
|
|
97
|
+
{value}
|
|
98
|
+
{unitRun}
|
|
99
|
+
</Text>
|
|
100
|
+
</View>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const frac = StyleSheet.flatten(fractionStyle) ?? {}
|
|
105
|
+
const fracScaled: TextStyle = {
|
|
106
|
+
...(frac.fontSize != null ? { fontSize: frac.fontSize * scale } : null),
|
|
107
|
+
...(frac.lineHeight != null ? { lineHeight: frac.lineHeight * scale } : null),
|
|
108
|
+
...(frac.letterSpacing != null ? { letterSpacing: frac.letterSpacing * scale } : null)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Raised cents need separate <Text>s in a row (nested text baseline-aligns
|
|
112
|
+
// and cannot be lifted), but only one <Text> can report a width. So a hidden
|
|
113
|
+
// copy holds the same runs nested, at the same sizes, and does the measuring;
|
|
114
|
+
// its width is the row's width.
|
|
115
|
+
return (
|
|
116
|
+
<View onLayout={onLayout} style={styles.fill}>
|
|
117
|
+
<Text
|
|
118
|
+
style={[style, scaled, styles.measure]}
|
|
119
|
+
onTextLayout={onTextLayout}
|
|
120
|
+
accessibilityElementsHidden
|
|
121
|
+
importantForAccessibility="no-hide-descendants"
|
|
122
|
+
>
|
|
123
|
+
{parts.head}
|
|
124
|
+
<Text style={[fractionStyle, fracScaled, styles.noMargin]}>{parts.frac}</Text>
|
|
125
|
+
{parts.tail}
|
|
126
|
+
{unitRun}
|
|
127
|
+
</Text>
|
|
128
|
+
<View style={styles.row}>
|
|
129
|
+
<Text style={[style, scaled]}>{parts.head}</Text>
|
|
130
|
+
<Text style={[fractionStyle, fracScaled]}>{parts.frac}</Text>
|
|
131
|
+
{parts.tail || unit ? (
|
|
132
|
+
<Text style={[style, scaled]}>
|
|
133
|
+
{parts.tail}
|
|
134
|
+
{unitRun}
|
|
135
|
+
</Text>
|
|
136
|
+
) : null}
|
|
137
|
+
</View>
|
|
138
|
+
</View>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const styles = StyleSheet.create({
|
|
143
|
+
fill: { alignSelf: 'stretch', alignItems: 'center' },
|
|
144
|
+
// `flex-start` hangs the minor units from the top of the figure's line box.
|
|
145
|
+
row: { flexDirection: 'row', alignItems: 'flex-start' },
|
|
146
|
+
measure: { position: 'absolute', opacity: 0 },
|
|
147
|
+
noMargin: { marginTop: 0 }
|
|
148
|
+
})
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pick an avatar icon — a bottom sheet with a scrollable, grouped grid.
|
|
3
|
+
*
|
|
4
|
+
* Grouped with a heading per section rather than one long grid: 67 glyphs in
|
|
5
|
+
* an undifferentiated wall is a search problem, and the headings turn it into
|
|
6
|
+
* "go to Animals". Same shape as the workspace-icon picker this was modelled
|
|
7
|
+
* on.
|
|
8
|
+
*
|
|
9
|
+
* Six columns, sized from the viewport rather than fixed, so the tiles stay
|
|
10
|
+
* square and tappable from the narrowest phone up.
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react'
|
|
13
|
+
import { Modal, Pressable, ScrollView, StyleSheet, Text, useWindowDimensions, View } from 'react-native'
|
|
14
|
+
import { useTranslation } from 'react-i18next'
|
|
15
|
+
import Animated, { useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated'
|
|
16
|
+
import {
|
|
17
|
+
durations,
|
|
18
|
+
easings,
|
|
19
|
+
radii,
|
|
20
|
+
spacing,
|
|
21
|
+
typography,
|
|
22
|
+
useTheme,
|
|
23
|
+
useUserAvatarIcon,
|
|
24
|
+
setUserAvatarIcon,
|
|
25
|
+
type AvatarIcon
|
|
26
|
+
} from '@bsv/expo-wallet-toolbox'
|
|
27
|
+
import PressableScale from '../ui/PressableScale'
|
|
28
|
+
import { AvatarGlyph } from './UserAvatar'
|
|
29
|
+
import { AVATAR_ICON_GROUPS } from './avatarIcons'
|
|
30
|
+
|
|
31
|
+
const COLUMNS = 6
|
|
32
|
+
|
|
33
|
+
export default function IconPickerSheet({ visible, onClose }: { visible: boolean; onClose: () => void }) {
|
|
34
|
+
const { colors } = useTheme()
|
|
35
|
+
const { t } = useTranslation()
|
|
36
|
+
const { width, height } = useWindowDimensions()
|
|
37
|
+
const reduced = useReducedMotion()
|
|
38
|
+
const chosen = useUserAvatarIcon()
|
|
39
|
+
const progress = useSharedValue(0)
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
progress.value = withTiming(visible ? 1 : 0, {
|
|
43
|
+
duration: visible ? durations.moderate : durations.quick,
|
|
44
|
+
easing: easings.out
|
|
45
|
+
})
|
|
46
|
+
}, [visible, progress])
|
|
47
|
+
|
|
48
|
+
// Rises from the bottom edge; reduced motion crossfades in place instead.
|
|
49
|
+
const sheetStyle = useAnimatedStyle(() =>
|
|
50
|
+
reduced
|
|
51
|
+
? { opacity: progress.value, transform: [{ translateY: 0 }] }
|
|
52
|
+
: { opacity: 1, transform: [{ translateY: (1 - progress.value) * height }] }
|
|
53
|
+
)
|
|
54
|
+
const scrimStyle = useAnimatedStyle(() => ({ opacity: progress.value }))
|
|
55
|
+
|
|
56
|
+
const tile = Math.floor((width - spacing.lg * 2 - spacing.sm * (COLUMNS - 1)) / COLUMNS)
|
|
57
|
+
|
|
58
|
+
const pick = (icon: AvatarIcon) => {
|
|
59
|
+
setUserAvatarIcon(icon)
|
|
60
|
+
onClose()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
|
|
65
|
+
<View style={StyleSheet.absoluteFill}>
|
|
66
|
+
<Animated.View style={[StyleSheet.absoluteFill, scrimStyle]}>
|
|
67
|
+
<Pressable style={[StyleSheet.absoluteFill, { backgroundColor: colors.scrim }]} onPress={onClose} />
|
|
68
|
+
</Animated.View>
|
|
69
|
+
<Animated.View
|
|
70
|
+
style={[
|
|
71
|
+
styles.sheet,
|
|
72
|
+
{ backgroundColor: colors.sheetBackground, maxHeight: height * 0.75 },
|
|
73
|
+
sheetStyle
|
|
74
|
+
]}
|
|
75
|
+
>
|
|
76
|
+
<View style={[styles.grabber, { backgroundColor: colors.separator }]} />
|
|
77
|
+
<Text style={[styles.title, { color: colors.textPrimary }]}>
|
|
78
|
+
{t('avatar_pick_icon', { defaultValue: 'Pick icon' })}
|
|
79
|
+
</Text>
|
|
80
|
+
<ScrollView contentContainerStyle={styles.scroll} showsVerticalScrollIndicator={false}>
|
|
81
|
+
{AVATAR_ICON_GROUPS.map(group => (
|
|
82
|
+
<View key={group.labelKey} style={styles.group}>
|
|
83
|
+
<Text style={[styles.groupLabel, { color: colors.textTertiary }]}>
|
|
84
|
+
{t(group.labelKey, { defaultValue: group.labelFallback })}
|
|
85
|
+
</Text>
|
|
86
|
+
<View style={styles.grid}>
|
|
87
|
+
{group.icons.map(opt => {
|
|
88
|
+
const selected = chosen?.family === opt.family && chosen?.name === opt.name
|
|
89
|
+
return (
|
|
90
|
+
<PressableScale
|
|
91
|
+
key={`${opt.family}/${opt.name}`}
|
|
92
|
+
haptic="tap"
|
|
93
|
+
onPress={() => pick(opt)}
|
|
94
|
+
accessibilityRole="button"
|
|
95
|
+
accessibilityState={{ selected }}
|
|
96
|
+
accessibilityLabel={opt.name}
|
|
97
|
+
style={[
|
|
98
|
+
styles.tile,
|
|
99
|
+
{
|
|
100
|
+
width: tile,
|
|
101
|
+
height: tile,
|
|
102
|
+
borderRadius: radii.md,
|
|
103
|
+
backgroundColor: selected ? colors.accent : colors.fillTertiary,
|
|
104
|
+
borderColor: selected ? colors.accent : colors.separator
|
|
105
|
+
}
|
|
106
|
+
]}
|
|
107
|
+
>
|
|
108
|
+
<AvatarGlyph
|
|
109
|
+
family={opt.family}
|
|
110
|
+
name={opt.name}
|
|
111
|
+
size={Math.round(tile * 0.55)}
|
|
112
|
+
color={selected ? colors.textOnAccent : colors.textPrimary}
|
|
113
|
+
/>
|
|
114
|
+
</PressableScale>
|
|
115
|
+
)
|
|
116
|
+
})}
|
|
117
|
+
</View>
|
|
118
|
+
</View>
|
|
119
|
+
))}
|
|
120
|
+
{/* Back to the plain disc — an avatar has to be removable, or the
|
|
121
|
+
first pick is permanent. */}
|
|
122
|
+
{chosen ? (
|
|
123
|
+
<PressableScale
|
|
124
|
+
haptic="tap"
|
|
125
|
+
onPress={() => {
|
|
126
|
+
setUserAvatarIcon(null)
|
|
127
|
+
onClose()
|
|
128
|
+
}}
|
|
129
|
+
style={[styles.clear, { borderColor: colors.separator }]}
|
|
130
|
+
>
|
|
131
|
+
<Text style={[styles.clearLabel, { color: colors.error }]}>
|
|
132
|
+
{t('avatar_remove', { defaultValue: 'Remove picture' })}
|
|
133
|
+
</Text>
|
|
134
|
+
</PressableScale>
|
|
135
|
+
) : null}
|
|
136
|
+
</ScrollView>
|
|
137
|
+
</Animated.View>
|
|
138
|
+
</View>
|
|
139
|
+
</Modal>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const styles = StyleSheet.create({
|
|
144
|
+
sheet: {
|
|
145
|
+
position: 'absolute',
|
|
146
|
+
left: 0,
|
|
147
|
+
right: 0,
|
|
148
|
+
bottom: 0,
|
|
149
|
+
borderTopLeftRadius: radii.xl,
|
|
150
|
+
borderTopRightRadius: radii.xl,
|
|
151
|
+
paddingBottom: spacing.xxxl
|
|
152
|
+
},
|
|
153
|
+
grabber: { width: 36, height: 4, borderRadius: 2, alignSelf: 'center', marginTop: spacing.sm },
|
|
154
|
+
title: { ...typography.headline, textAlign: 'center', marginTop: spacing.md, marginBottom: spacing.sm },
|
|
155
|
+
scroll: { paddingHorizontal: spacing.lg, paddingBottom: spacing.lg },
|
|
156
|
+
group: { marginTop: spacing.lg },
|
|
157
|
+
groupLabel: { ...typography.caption1, textTransform: 'uppercase', letterSpacing: 0.6, marginBottom: spacing.sm },
|
|
158
|
+
grid: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
|
|
159
|
+
tile: { alignItems: 'center', justifyContent: 'center', borderWidth: StyleSheet.hairlineWidth },
|
|
160
|
+
clear: {
|
|
161
|
+
marginTop: spacing.xl,
|
|
162
|
+
paddingVertical: spacing.md,
|
|
163
|
+
borderRadius: radii.lg,
|
|
164
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
165
|
+
alignItems: 'center'
|
|
166
|
+
},
|
|
167
|
+
clearLabel: { ...typography.body, fontWeight: '600' }
|
|
168
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "IDENTIFIER" row of a grouped card: the key abbreviated in monospace
|
|
3
|
+
* with a copy button on the right. Shared by Contact, New Contact and
|
|
4
|
+
* Profile so the same key reads the same way on all three.
|
|
5
|
+
*/
|
|
6
|
+
import React, { useCallback } from 'react'
|
|
7
|
+
import { StyleSheet, Text, View } from 'react-native'
|
|
8
|
+
import { useTranslation } from 'react-i18next'
|
|
9
|
+
import { useTheme, spacing, typography } from '@bsv/expo-wallet-toolbox'
|
|
10
|
+
import PressableScale from '../ui/PressableScale'
|
|
11
|
+
import { showToast } from '../ui/Toast'
|
|
12
|
+
import { abbreviateKey } from '../../../core/pay/counterparty'
|
|
13
|
+
|
|
14
|
+
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
15
|
+
let ioniconsComponent: IoniconsComponent | undefined
|
|
16
|
+
function loadIonicons(): IoniconsComponent {
|
|
17
|
+
if (!ioniconsComponent) {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
19
|
+
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
20
|
+
}
|
|
21
|
+
return ioniconsComponent
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Loaded lazily for the same reason every native module in this package is:
|
|
26
|
+
* the `ui` barrel must stay parseable under Jest, which cannot load the
|
|
27
|
+
* clipboard module's native binding.
|
|
28
|
+
*/
|
|
29
|
+
type ClipboardModule = typeof import('@react-native-clipboard/clipboard').default
|
|
30
|
+
let clipboardModule: ClipboardModule | undefined
|
|
31
|
+
function loadClipboard(): ClipboardModule {
|
|
32
|
+
if (!clipboardModule) {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
34
|
+
clipboardModule = require('@react-native-clipboard/clipboard').default as ClipboardModule
|
|
35
|
+
}
|
|
36
|
+
return clipboardModule
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default function IdentifierRow({ identityKey }: { identityKey: string }) {
|
|
40
|
+
const { t } = useTranslation()
|
|
41
|
+
const { colors } = useTheme()
|
|
42
|
+
const Ionicons = loadIonicons()
|
|
43
|
+
const onCopy = useCallback(() => {
|
|
44
|
+
loadClipboard().setString(identityKey)
|
|
45
|
+
showToast(t('copied'), { type: 'success' })
|
|
46
|
+
}, [identityKey, t])
|
|
47
|
+
return (
|
|
48
|
+
<View style={styles.row}>
|
|
49
|
+
<Text style={[styles.key, { color: colors.textPrimary }]} numberOfLines={1} ellipsizeMode="middle">
|
|
50
|
+
{abbreviateKey(identityKey)}
|
|
51
|
+
</Text>
|
|
52
|
+
<PressableScale
|
|
53
|
+
onPress={onCopy}
|
|
54
|
+
haptic="tap"
|
|
55
|
+
style={styles.copyBtn}
|
|
56
|
+
accessibilityRole="button"
|
|
57
|
+
accessibilityLabel={t('contact_copy_identifier')}
|
|
58
|
+
>
|
|
59
|
+
<Ionicons name="copy-outline" size={18} color={colors.textSecondary} />
|
|
60
|
+
</PressableScale>
|
|
61
|
+
</View>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const styles = StyleSheet.create({
|
|
66
|
+
row: { flexDirection: 'row', alignItems: 'center', minHeight: 48, paddingLeft: spacing.lg, paddingRight: spacing.xs },
|
|
67
|
+
key: { ...typography.subhead, fontFamily: 'monospace', flex: 1 },
|
|
68
|
+
copyBtn: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }
|
|
69
|
+
})
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import React from 'react'
|
|
14
14
|
import { StyleSheet, Text, View } from 'react-native'
|
|
15
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
16
15
|
import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
|
|
17
16
|
import PressableScale from '../ui/PressableScale'
|
|
18
17
|
|
|
@@ -34,14 +33,15 @@ export const ImportFromBackupPrompt: React.FC<{
|
|
|
34
33
|
}> = ({ visible, onImport }) => {
|
|
35
34
|
const { colors } = useTheme()
|
|
36
35
|
const Ionicons = loadIonicons()
|
|
37
|
-
const insets = useSafeAreaInsets()
|
|
38
36
|
|
|
39
37
|
if (!visible) return null
|
|
40
38
|
|
|
41
39
|
return (
|
|
42
|
-
<View style={[styles.wrapper, { paddingBottom:
|
|
40
|
+
<View style={[styles.wrapper, { paddingBottom: CARD_INSET }]} pointerEvents="box-none">
|
|
43
41
|
<View style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.separator }]}>
|
|
44
|
-
<
|
|
42
|
+
<View style={[styles.iconCircle, { backgroundColor: colors.fill }]}>
|
|
43
|
+
<Ionicons name="download-outline" size={22} color={colors.accent} />
|
|
44
|
+
</View>
|
|
45
45
|
<View style={styles.textGroup}>
|
|
46
46
|
<Text style={[styles.title, { color: colors.textPrimary }]}>{t('import_prompt_title')}</Text>
|
|
47
47
|
<Text style={[styles.body, { color: colors.textSecondary }]}>{t('import_prompt_body')}</Text>
|
|
@@ -54,6 +54,19 @@ export const ImportFromBackupPrompt: React.FC<{
|
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The card hugs the bottom of the screen, so its corners have to agree with the
|
|
59
|
+
* screen's own. Concentric rounding means the inner radius is the outer one
|
|
60
|
+
* less the gap between them — anything else and the two curves visibly fight.
|
|
61
|
+
*
|
|
62
|
+
* The display corner is a constant because no RN API reports it. 55pt is the
|
|
63
|
+
* modern iPhone notch-era radius; on a device that differs (an iPad, most
|
|
64
|
+
* Android hardware) the card is merely a little rounder or flatter than its
|
|
65
|
+
* housing, which is a far smaller error than not following it at all.
|
|
66
|
+
*/
|
|
67
|
+
const SCREEN_CORNER = 55
|
|
68
|
+
const CARD_INSET = spacing.lg
|
|
69
|
+
|
|
57
70
|
const styles = StyleSheet.create({
|
|
58
71
|
wrapper: {
|
|
59
72
|
position: 'absolute',
|
|
@@ -62,30 +75,39 @@ const styles = StyleSheet.create({
|
|
|
62
75
|
bottom: 0,
|
|
63
76
|
zIndex: 30,
|
|
64
77
|
alignItems: 'center',
|
|
65
|
-
paddingHorizontal:
|
|
78
|
+
paddingHorizontal: CARD_INSET
|
|
66
79
|
},
|
|
67
80
|
card: {
|
|
68
81
|
width: '100%',
|
|
69
82
|
maxWidth: 380,
|
|
70
|
-
borderRadius:
|
|
83
|
+
borderRadius: SCREEN_CORNER - CARD_INSET,
|
|
71
84
|
borderWidth: StyleSheet.hairlineWidth,
|
|
72
|
-
padding: spacing.
|
|
85
|
+
padding: spacing.xxl,
|
|
73
86
|
alignItems: 'center',
|
|
74
|
-
gap: spacing.
|
|
87
|
+
gap: spacing.md,
|
|
75
88
|
shadowColor: '#000',
|
|
76
89
|
shadowOffset: { width: 0, height: 4 },
|
|
77
90
|
shadowOpacity: 0.15,
|
|
78
91
|
shadowRadius: 12,
|
|
79
92
|
elevation: 6
|
|
80
93
|
},
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
iconCircle: {
|
|
95
|
+
width: 44,
|
|
96
|
+
height: 44,
|
|
97
|
+
borderRadius: 22,
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
justifyContent: 'center',
|
|
100
|
+
marginBottom: spacing.xs
|
|
101
|
+
},
|
|
102
|
+
textGroup: { alignItems: 'center', gap: spacing.xs },
|
|
83
103
|
title: { ...typography.subhead, fontWeight: '600', textAlign: 'center' },
|
|
84
104
|
body: { ...typography.footnote, textAlign: 'center' },
|
|
85
105
|
button: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
// Set apart from the copy it acts on, and given enough height that a pill
|
|
107
|
+
// border reads as a control rather than as a caption in a box.
|
|
108
|
+
marginTop: spacing.sm,
|
|
109
|
+
paddingVertical: spacing.md,
|
|
110
|
+
paddingHorizontal: spacing.xl,
|
|
89
111
|
borderRadius: radii.pill,
|
|
90
112
|
borderWidth: StyleSheet.hairlineWidth
|
|
91
113
|
},
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 34pt chrome-disc profile button, top-left of Home. Wears whatever avatar
|
|
3
|
+
* icon the user picked in Profile — the same `core/userAvatar.ts` choice the
|
|
4
|
+
* profile hero draws, so the two can never disagree.
|
|
5
|
+
*
|
|
6
|
+
* Original note: 34pt chrome-disc profile button, top-left of Home — passed through
|
|
7
|
+
* `WalletHomeScreen`'s existing (previously unused) `topLeft` prop from the
|
|
8
|
+
* host app's `app/index.tsx`, so this needed no package API change. Same disc
|
|
9
|
+
* as the settings button on the right (surfaceRaised + hairline), so the two
|
|
10
|
+
* bookend the header as a matched pair.
|
|
11
|
+
*/
|
|
12
|
+
import React from 'react'
|
|
13
|
+
import { StyleSheet } from 'react-native'
|
|
14
|
+
import { useTheme, useUserAvatarIcon } from '@bsv/expo-wallet-toolbox'
|
|
15
|
+
import { useTranslation } from 'react-i18next'
|
|
16
|
+
import PressableScale from '../ui/PressableScale'
|
|
17
|
+
import { AvatarGlyph } from './UserAvatar'
|
|
18
|
+
|
|
19
|
+
type ExpoRouterModule = typeof import('expo-router')
|
|
20
|
+
let expoRouterMod: ExpoRouterModule | undefined
|
|
21
|
+
function loadExpoRouter(): ExpoRouterModule {
|
|
22
|
+
if (!expoRouterMod) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
24
|
+
expoRouterMod = require('expo-router') as ExpoRouterModule
|
|
25
|
+
}
|
|
26
|
+
return expoRouterMod
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function ProfileButton() {
|
|
30
|
+
const { colors } = useTheme()
|
|
31
|
+
const { t } = useTranslation()
|
|
32
|
+
const { router } = loadExpoRouter()
|
|
33
|
+
const avatar = useUserAvatarIcon()
|
|
34
|
+
return (
|
|
35
|
+
<PressableScale
|
|
36
|
+
onPress={() => router.push('/profile' as never)}
|
|
37
|
+
haptic="tap"
|
|
38
|
+
hitSlop={5}
|
|
39
|
+
style={[styles.disc, { backgroundColor: colors.surfaceRaised, borderColor: colors.surfaceRaisedBorder }]}
|
|
40
|
+
accessibilityRole="button"
|
|
41
|
+
accessibilityLabel={t('profile')}
|
|
42
|
+
>
|
|
43
|
+
<AvatarGlyph
|
|
44
|
+
family={avatar?.family ?? 'ionicons'}
|
|
45
|
+
name={avatar?.name ?? 'person-outline'}
|
|
46
|
+
size={17}
|
|
47
|
+
color={colors.textSecondary}
|
|
48
|
+
/>
|
|
49
|
+
</PressableScale>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const styles = StyleSheet.create({
|
|
54
|
+
disc: {
|
|
55
|
+
width: 34,
|
|
56
|
+
height: 34,
|
|
57
|
+
borderRadius: 17,
|
|
58
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center'
|
|
61
|
+
}
|
|
62
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user's own face, wherever "you" is drawn.
|
|
3
|
+
*
|
|
4
|
+
* One component so the home button and the profile hero can never disagree
|
|
5
|
+
* about what the user picked. With no choice stored it falls back to the
|
|
6
|
+
* plain person glyph those surfaces have always shown, so an install that
|
|
7
|
+
* never opens the picker looks exactly as it did.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react'
|
|
10
|
+
import { StyleSheet, View } from 'react-native'
|
|
11
|
+
import { useTheme, useUserAvatarIcon, type AvatarIconFamily } from '@bsv/expo-wallet-toolbox'
|
|
12
|
+
|
|
13
|
+
type VectorIcons = typeof import('@expo/vector-icons')
|
|
14
|
+
let vectorIcons: VectorIcons | undefined
|
|
15
|
+
function loadIcons(): VectorIcons {
|
|
16
|
+
if (!vectorIcons) {
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
|
+
vectorIcons = require('@expo/vector-icons') as VectorIcons
|
|
19
|
+
}
|
|
20
|
+
return vectorIcons
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Draw one catalogue entry, whichever family it came from. */
|
|
24
|
+
export function AvatarGlyph({
|
|
25
|
+
family,
|
|
26
|
+
name,
|
|
27
|
+
size,
|
|
28
|
+
color
|
|
29
|
+
}: {
|
|
30
|
+
family: AvatarIconFamily
|
|
31
|
+
name: string
|
|
32
|
+
size: number
|
|
33
|
+
color: string
|
|
34
|
+
}) {
|
|
35
|
+
const { Ionicons, MaterialCommunityIcons } = loadIcons()
|
|
36
|
+
const Icon = family === 'ionicons' ? Ionicons : MaterialCommunityIcons
|
|
37
|
+
return <Icon name={name as never} size={size} color={color} />
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default function UserAvatar({
|
|
41
|
+
size = 34,
|
|
42
|
+
/** Glyph size; defaults to roughly half the disc, as the 34pt button does. */
|
|
43
|
+
glyphSize,
|
|
44
|
+
color,
|
|
45
|
+
background,
|
|
46
|
+
borderColor,
|
|
47
|
+
style
|
|
48
|
+
}: {
|
|
49
|
+
size?: number
|
|
50
|
+
glyphSize?: number
|
|
51
|
+
color?: string
|
|
52
|
+
background?: string
|
|
53
|
+
borderColor?: string
|
|
54
|
+
style?: object
|
|
55
|
+
}) {
|
|
56
|
+
const { colors } = useTheme()
|
|
57
|
+
const chosen = useUserAvatarIcon()
|
|
58
|
+
const glyph = glyphSize ?? Math.round(size * 0.5)
|
|
59
|
+
return (
|
|
60
|
+
<View
|
|
61
|
+
style={[
|
|
62
|
+
styles.disc,
|
|
63
|
+
{
|
|
64
|
+
width: size,
|
|
65
|
+
height: size,
|
|
66
|
+
borderRadius: size / 2,
|
|
67
|
+
backgroundColor: background ?? colors.surfaceRaised,
|
|
68
|
+
borderColor: borderColor ?? colors.surfaceRaisedBorder
|
|
69
|
+
},
|
|
70
|
+
style
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
<AvatarGlyph
|
|
74
|
+
family={chosen?.family ?? 'ionicons'}
|
|
75
|
+
name={chosen?.name ?? 'person-outline'}
|
|
76
|
+
size={glyph}
|
|
77
|
+
color={color ?? colors.textSecondary}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const styles = StyleSheet.create({
|
|
84
|
+
disc: { alignItems: 'center', justifyContent: 'center', borderWidth: StyleSheet.hairlineWidth, overflow: 'hidden' }
|
|
85
|
+
})
|