@bsv/expo-wallet-toolbox 0.25.0 → 0.26.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 +43 -0
- package/core/context/WalletContext.tsx +11 -15
- package/core/i18n/translations.tsx +221 -36
- package/core/identity/handleRegistry/client.ts +110 -16
- package/core/identity/handleRegistry/registration.ts +115 -17
- package/core/index.ts +8 -0
- package/core/net/wocLimiter.ts +133 -0
- package/core/pay/beefRepair.ts +3 -1
- package/core/pay/rails/address.ts +2 -2
- package/core/profiles/profileStore.ts +4 -1
- package/core/services/arcadeBroadcastProvider.ts +6 -0
- package/core/services/exchangeRate.ts +8 -1
- package/core/services/groupSpendingLimit.ts +26 -0
- package/core/services/signingPermissionPolicy.ts +14 -8
- package/core/services/vault/ceremony.ts +13 -0
- package/core/services/vault/ceremonyHost.ts +58 -0
- package/core/services/vault/failedVaultSpend.ts +40 -0
- package/core/services/vault/outputAuthority.ts +13 -6
- package/core/services/vault/transfers.ts +56 -12
- package/core/services/vault/wocLookup.ts +5 -2
- package/core/storage/encryptedDbImage.ts +11 -2
- package/core/theme/tokens.ts +26 -12
- package/package.json +2 -1
- package/ui/components/QRScanner.tsx +24 -22
- package/ui/components/pay/MessageBoxConfig.tsx +10 -16
- package/ui/components/pay/NearbyAdvisoryModal.tsx +6 -13
- package/ui/components/pay/NearbyFlow.tsx +72 -35
- package/ui/components/pay/PayForm.tsx +27 -19
- package/ui/components/pay/PaymentSuccessOverlay.tsx +8 -6
- package/ui/components/pay/UniversalSend.tsx +4 -1
- package/ui/components/ui/AlertCard.tsx +3 -2
- package/ui/components/ui/BalancedText.tsx +117 -0
- package/ui/components/ui/ErrorBoundary.tsx +31 -14
- package/ui/components/ui/GroupedList.tsx +28 -22
- package/ui/components/ui/ListRow.tsx +126 -35
- package/ui/components/ui/PermissionSheet.tsx +31 -24
- package/ui/components/ui/PresenceRow.tsx +15 -23
- package/ui/components/ui/Sheet.tsx +11 -17
- package/ui/components/ui/Toast.tsx +13 -17
- package/ui/components/vault/EnrollWizard.tsx +446 -196
- package/ui/components/vault/KeyChooser.tsx +7 -20
- package/ui/components/vault/VaultCeremonySheet.tsx +44 -36
- package/ui/components/wallet/AmountInput.tsx +11 -17
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +13 -17
- package/ui/index.ts +1 -1
- package/ui/screens/TrustScreen.tsx +49 -61
- package/ui/screens/VaultScreen.tsx +99 -60
- package/ui/screens/VaultTransferScreen.tsx +34 -27
- package/ui/screens/WalletCheckScreen.tsx +25 -24
- package/ui/screens/WalletConfigScreen.tsx +66 -72
|
@@ -10,25 +10,17 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import React from 'react'
|
|
12
12
|
import { StyleSheet, Text, View } from 'react-native'
|
|
13
|
+
import { Circle, CircleDot } from 'lucide-react-native'
|
|
13
14
|
import PressableScale from '../ui/PressableScale'
|
|
14
15
|
import { useTheme, spacing, radii, typography, type VaultKeyRecord } from '@bsv/expo-wallet-toolbox'
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* package's
|
|
18
|
+
* lucide, the family this app draws every other glyph from (its settings rows,
|
|
19
|
+
* its headers, its sheets). Imported at module scope, unlike
|
|
20
|
+
* @expo/vector-icons: lucide-react-native ships a CJS entry for `require`, so
|
|
21
|
+
* it needs no transform and reaches no native module at import time, which is
|
|
22
|
+
* what this package's lazy icon loads exist to avoid.
|
|
22
23
|
*/
|
|
23
|
-
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
24
|
-
let ioniconsComponent: IoniconsComponent | undefined
|
|
25
|
-
function loadIonicons(): IoniconsComponent {
|
|
26
|
-
if (!ioniconsComponent) {
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
28
|
-
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
29
|
-
}
|
|
30
|
-
return ioniconsComponent
|
|
31
|
-
}
|
|
32
24
|
|
|
33
25
|
/** The one display form of a vault key: `nickname · …serialTail4`. */
|
|
34
26
|
export function vaultKeyLabel(k: { nickname: string; serial: string }): string {
|
|
@@ -49,7 +41,6 @@ export const KeyChooser: React.FC<{
|
|
|
49
41
|
onSelect: (serial: string) => void
|
|
50
42
|
}> = ({ keys, selected, onSelect }) => {
|
|
51
43
|
const { colors } = useTheme()
|
|
52
|
-
const Ionicons = loadIonicons()
|
|
53
44
|
return (
|
|
54
45
|
<View style={[styles.list, { backgroundColor: colors.backgroundElevated, borderColor: colors.separator }]}>
|
|
55
46
|
{keys.map((k, i) => {
|
|
@@ -70,11 +61,7 @@ export const KeyChooser: React.FC<{
|
|
|
70
61
|
}
|
|
71
62
|
]}
|
|
72
63
|
>
|
|
73
|
-
<
|
|
74
|
-
name={on ? 'radio-button-on' : 'radio-button-off'}
|
|
75
|
-
size={22}
|
|
76
|
-
color={on ? colors.accent : colors.textTertiary}
|
|
77
|
-
/>
|
|
64
|
+
{on ? <CircleDot size={20} color={colors.accent} /> : <Circle size={20} color={colors.textTertiary} />}
|
|
78
65
|
<Text style={[styles.label, { color: colors.textPrimary }]} numberOfLines={1}>
|
|
79
66
|
{vaultKeyLabel(k)}
|
|
80
67
|
</Text>
|
|
@@ -16,6 +16,18 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import React, { useEffect, useRef, useState } from 'react'
|
|
18
18
|
import { View, Text, StyleSheet, TextInput, ActivityIndicator, Platform } from 'react-native'
|
|
19
|
+
import type { HardwareKeyArtComponent } from './EnrollWizard'
|
|
20
|
+
import {
|
|
21
|
+
CircleAlert,
|
|
22
|
+
Cpu,
|
|
23
|
+
FingerprintPattern,
|
|
24
|
+
Grid3x3,
|
|
25
|
+
Lock,
|
|
26
|
+
LockOpen,
|
|
27
|
+
RefreshCw,
|
|
28
|
+
Send,
|
|
29
|
+
type LucideIcon
|
|
30
|
+
} from 'lucide-react-native'
|
|
19
31
|
import Animated, {
|
|
20
32
|
useSharedValue,
|
|
21
33
|
useAnimatedStyle,
|
|
@@ -43,49 +55,40 @@ import {
|
|
|
43
55
|
type CeremonyPhase,
|
|
44
56
|
type VaultErrorCode
|
|
45
57
|
} from '@bsv/expo-wallet-toolbox'
|
|
58
|
+
import { BalancedText } from '../ui/BalancedText'
|
|
46
59
|
|
|
47
60
|
const t = (k: string, opts?: Record<string, unknown>) => i18n.t(k, opts) as string
|
|
48
61
|
|
|
49
62
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* this package's
|
|
63
|
+
* lucide, the family this app draws every other glyph from (its settings rows,
|
|
64
|
+
* its headers, its sheets). Imported at module scope, unlike
|
|
65
|
+
* @expo/vector-icons: lucide-react-native ships a CJS entry for `require`, so
|
|
66
|
+
* it needs no transform and reaches no native module at import time, which is
|
|
67
|
+
* what this package's lazy icon loads exist to avoid.
|
|
55
68
|
*/
|
|
56
|
-
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
57
|
-
let ioniconsComponent: IoniconsComponent | undefined
|
|
58
|
-
function loadIonicons(): IoniconsComponent {
|
|
59
|
-
if (!ioniconsComponent) {
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
61
|
-
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
62
|
-
}
|
|
63
|
-
return ioniconsComponent
|
|
64
|
-
}
|
|
65
69
|
|
|
66
70
|
/** Swallows the sheet's dismiss while work is in flight — `Sheet` requires an
|
|
67
71
|
* onClose, and cancelling mid-operation is the thing we are preventing. */
|
|
68
72
|
const noop = (): void => {}
|
|
69
73
|
|
|
70
|
-
const PhaseIcon: Record<CeremonyPhase,
|
|
71
|
-
idle:
|
|
72
|
-
'waiting-for-key':
|
|
73
|
-
connecting:
|
|
74
|
-
'pin-entry':
|
|
75
|
-
'awaiting-touch':
|
|
76
|
-
preparing:
|
|
77
|
-
broadcasting:
|
|
78
|
-
armed:
|
|
79
|
-
error:
|
|
74
|
+
const PhaseIcon: Record<CeremonyPhase, LucideIcon> = {
|
|
75
|
+
idle: Lock,
|
|
76
|
+
'waiting-for-key': Cpu,
|
|
77
|
+
connecting: RefreshCw,
|
|
78
|
+
'pin-entry': Grid3x3,
|
|
79
|
+
'awaiting-touch': FingerprintPattern,
|
|
80
|
+
preparing: LockOpen,
|
|
81
|
+
broadcasting: Send,
|
|
82
|
+
armed: LockOpen,
|
|
83
|
+
error: CircleAlert
|
|
80
84
|
}
|
|
81
85
|
|
|
82
|
-
export const VaultCeremonySheet: React.FC = () => {
|
|
86
|
+
export const VaultCeremonySheet: React.FC<{ keyArt?: HardwareKeyArtComponent }> = ({ keyArt: KeyArt }) => {
|
|
83
87
|
const { colors } = useTheme()
|
|
84
88
|
const { state, submitPin, cancel, retry } = useVault()
|
|
85
89
|
const reducedMotion = useReducedMotion()
|
|
86
90
|
const [pin, setPin] = useState('')
|
|
87
91
|
const [keyNames, setKeyNames] = useState('')
|
|
88
|
-
const Ionicons = loadIonicons()
|
|
89
92
|
|
|
90
93
|
const phase = state.phase
|
|
91
94
|
// 'armed' stays hidden: it persists for the whole retention window, so
|
|
@@ -204,6 +207,9 @@ export const VaultCeremonySheet: React.FC = () => {
|
|
|
204
207
|
})()
|
|
205
208
|
|
|
206
209
|
const iconColor = phase === 'error' ? colors.error : colors.accent
|
|
210
|
+
const PhaseGlyph = PhaseIcon[phase]
|
|
211
|
+
// The two phases that ask for the key itself. `awaiting-touch` is the blink.
|
|
212
|
+
const showKey = KeyArt && (phase === 'waiting-for-key' || phase === 'awaiting-touch')
|
|
207
213
|
|
|
208
214
|
return (
|
|
209
215
|
<Sheet
|
|
@@ -220,13 +226,15 @@ export const VaultCeremonySheet: React.FC = () => {
|
|
|
220
226
|
}}
|
|
221
227
|
>
|
|
222
228
|
<View style={styles.body}>
|
|
223
|
-
{reason ? <
|
|
229
|
+
{reason ? <BalancedText style={[styles.reason, { color: colors.textSecondary }]}>{reason}</BalancedText> : null}
|
|
224
230
|
|
|
225
231
|
<Animated.View style={[styles.iconWrap, { backgroundColor: colors.backgroundSecondary }, pulseStyle]}>
|
|
226
232
|
{phase === 'connecting' || busy ? (
|
|
227
233
|
<ActivityIndicator color={iconColor} />
|
|
234
|
+
) : showKey && KeyArt ? (
|
|
235
|
+
<KeyArt waiting={phase === 'awaiting-touch'} size={104} />
|
|
228
236
|
) : (
|
|
229
|
-
<
|
|
237
|
+
<PhaseGlyph size={36} color={iconColor} />
|
|
230
238
|
)}
|
|
231
239
|
</Animated.View>
|
|
232
240
|
|
|
@@ -237,9 +245,9 @@ export const VaultCeremonySheet: React.FC = () => {
|
|
|
237
245
|
this is what the user sees as it dismisses and before the next tap. */}
|
|
238
246
|
{betweenBatches && progress && (
|
|
239
247
|
<>
|
|
240
|
-
<
|
|
248
|
+
<BalancedText style={[styles.subtitle, { color: colors.textSecondary }]}>
|
|
241
249
|
{t('vault_nfc_sign_batch', { b: batchIndex, n: batches })}
|
|
242
|
-
</
|
|
250
|
+
</BalancedText>
|
|
243
251
|
<Text style={[styles.hint, { color: colors.textSecondary }]}>
|
|
244
252
|
{t('vault_sign_progress', { signed: progress.signed, total: progress.total })}
|
|
245
253
|
</Text>
|
|
@@ -249,22 +257,22 @@ export const VaultCeremonySheet: React.FC = () => {
|
|
|
249
257
|
{/* The whole point of the busy phases: say the work is real and say
|
|
250
258
|
not to leave. While signatures are being gathered, say how many. */}
|
|
251
259
|
{busy && (
|
|
252
|
-
<
|
|
260
|
+
<BalancedText style={[styles.subtitle, { color: colors.textSecondary }]}>
|
|
253
261
|
{phase === 'broadcasting'
|
|
254
262
|
? t('vault_sending_sub')
|
|
255
263
|
: progress
|
|
256
264
|
? t('vault_sign_progress', { signed: progress.signed, total: progress.total })
|
|
257
265
|
: t('vault_unlocking_sub')}
|
|
258
|
-
</
|
|
266
|
+
</BalancedText>
|
|
259
267
|
)}
|
|
260
268
|
|
|
261
269
|
{phase === 'awaiting-touch' && <TouchCountdown color={colors.accent} trackColor={colors.backgroundSecondary} />}
|
|
262
270
|
|
|
263
271
|
{phase === 'pin-entry' && (
|
|
264
272
|
<>
|
|
265
|
-
<
|
|
273
|
+
<BalancedText style={[styles.subtitle, { color: colors.textSecondary }]}>
|
|
266
274
|
{nfc ? t('vault_pin_sub_nfc') : t('vault_pin_sub_usb')}
|
|
267
|
-
</
|
|
275
|
+
</BalancedText>
|
|
268
276
|
<TextInput
|
|
269
277
|
ref={pinInputRef}
|
|
270
278
|
style={[styles.pin, { color: colors.textPrimary, backgroundColor: colors.backgroundSecondary }]}
|
|
@@ -303,11 +311,11 @@ export const VaultCeremonySheet: React.FC = () => {
|
|
|
303
311
|
)}
|
|
304
312
|
|
|
305
313
|
{phase === 'error' && errCode === 'pin-invalid' && (
|
|
306
|
-
<
|
|
314
|
+
<BalancedText style={[styles.subtitle, { color: colors.textSecondary }]}>
|
|
307
315
|
{typeof state.error?.retriesLeft === 'number'
|
|
308
316
|
? t('vault_pin_invalid_retry', { count: state.error.retriesLeft })
|
|
309
317
|
: t('vault_pin_invalid_retry_generic')}
|
|
310
|
-
</
|
|
318
|
+
</BalancedText>
|
|
311
319
|
)}
|
|
312
320
|
|
|
313
321
|
{phase === 'error' && (
|
|
@@ -20,21 +20,16 @@ import {
|
|
|
20
20
|
import { parseTokenAmount, tokenAmountInputText, tokenAmountMask, tokenUnitsFromField } from '../../tokenFormat'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
* lucide, like every other glyph this app draws. Imported at module scope
|
|
24
|
+
* rather than behind a lazy loader: what had to be deferred is
|
|
25
|
+
* @expo/vector-icons' index barrel, which re-exports every icon set and so
|
|
26
|
+
* reaches expo-font -> expo-asset as untransformed ESM; nothing here pulls
|
|
27
|
+
* that barrel in any more. lucide publishes both module formats and Jest
|
|
28
|
+
* resolves the ESM one, so the app pins this name to lucide's CJS entry in
|
|
29
|
+
* jest.moduleNameMapper (package.json), as it already does for its other
|
|
30
|
+
* ESM-only dependencies.
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
let ioniconsComponent: IoniconsComponent | undefined
|
|
31
|
-
function loadIonicons(): IoniconsComponent {
|
|
32
|
-
if (!ioniconsComponent) {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
34
|
-
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
35
|
-
}
|
|
36
|
-
return ioniconsComponent
|
|
37
|
-
}
|
|
32
|
+
import { Wallet, X } from 'lucide-react-native'
|
|
38
33
|
|
|
39
34
|
export const SEND_MAX_VALUE = '2099999999999999'
|
|
40
35
|
|
|
@@ -102,7 +97,6 @@ export const AmountInput: React.FC<AmountInputProps> = ({
|
|
|
102
97
|
const { settings } = useWallet()
|
|
103
98
|
const { satoshisPerUSD, usdToFiat = {} } = useContext(ExchangeRateContext)
|
|
104
99
|
const reducedMotion = useReducedMotion()
|
|
105
|
-
const Ionicons = loadIonicons()
|
|
106
100
|
|
|
107
101
|
const currency = settings?.currency || 'BSV'
|
|
108
102
|
// ONE conjunction, and it is what keeps three denominations from colliding:
|
|
@@ -199,7 +193,7 @@ export const AmountInput: React.FC<AmountInputProps> = ({
|
|
|
199
193
|
return (
|
|
200
194
|
<View style={[styles.row, { backgroundColor: colors.backgroundSecondary, borderColor: colors.accent }]}>
|
|
201
195
|
<View style={styles.sendMaxDisplay}>
|
|
202
|
-
<
|
|
196
|
+
<Wallet size={18} color={colors.accent} />
|
|
203
197
|
<Text style={[styles.sendMaxLabel, { color: colors.accent }]}>{t(maxLabelKey)}</Text>
|
|
204
198
|
</View>
|
|
205
199
|
<TouchableOpacity
|
|
@@ -209,7 +203,7 @@ export const AmountInput: React.FC<AmountInputProps> = ({
|
|
|
209
203
|
}}
|
|
210
204
|
style={[styles.clearButton, { backgroundColor: colors.fill }]}
|
|
211
205
|
>
|
|
212
|
-
<
|
|
206
|
+
<X size={16} color={colors.accent} />
|
|
213
207
|
</TouchableOpacity>
|
|
214
208
|
</View>
|
|
215
209
|
)
|
|
@@ -16,24 +16,21 @@ import React from 'react'
|
|
|
16
16
|
import { ActivityIndicator, Modal, Platform, Pressable, StyleSheet, Text, View } from 'react-native'
|
|
17
17
|
import { useTheme, spacing, radii, typography, i18n } from '@bsv/expo-wallet-toolbox'
|
|
18
18
|
import PressableScale from '../ui/PressableScale'
|
|
19
|
+
import { BalancedText } from '../ui/BalancedText'
|
|
19
20
|
|
|
20
21
|
const t = (k: string, o?: Record<string, unknown>) => i18n.t(k, o) as string
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* lucide, like every other glyph this app draws. Imported at module scope
|
|
25
|
+
* rather than behind a lazy loader: what had to be deferred is
|
|
26
|
+
* @expo/vector-icons' index barrel, which re-exports every icon set and so
|
|
27
|
+
* reaches expo-font -> expo-asset as untransformed ESM; nothing here pulls
|
|
28
|
+
* that barrel in any more. lucide publishes both module formats and Jest
|
|
29
|
+
* resolves the ESM one, so the app pins this name to lucide's CJS entry in
|
|
30
|
+
* jest.moduleNameMapper (package.json), as it already does for its other
|
|
31
|
+
* ESM-only dependencies.
|
|
27
32
|
*/
|
|
28
|
-
|
|
29
|
-
let ioniconsComponent: IoniconsComponent | undefined
|
|
30
|
-
function loadIonicons(): IoniconsComponent {
|
|
31
|
-
if (!ioniconsComponent) {
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
33
|
-
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
34
|
-
}
|
|
35
|
-
return ioniconsComponent
|
|
36
|
-
}
|
|
33
|
+
import { Fingerprint } from 'lucide-react-native'
|
|
37
34
|
|
|
38
35
|
export const BiometricAdvisoryModal: React.FC<{
|
|
39
36
|
visible: boolean
|
|
@@ -53,7 +50,6 @@ export const BiometricAdvisoryModal: React.FC<{
|
|
|
53
50
|
onContinue: () => void
|
|
54
51
|
}> = ({ visible, loading = false, degraded = false, onCancel, onContinue }) => {
|
|
55
52
|
const { colors } = useTheme()
|
|
56
|
-
const Ionicons = loadIonicons()
|
|
57
53
|
|
|
58
54
|
if (!visible) return null
|
|
59
55
|
|
|
@@ -77,12 +73,12 @@ export const BiometricAdvisoryModal: React.FC<{
|
|
|
77
73
|
/>
|
|
78
74
|
<View style={[styles.card, { backgroundColor: colors.sheetBackground, borderColor: colors.separator }]}>
|
|
79
75
|
<View style={[styles.heroIcon, { backgroundColor: colors.fillTertiary }]}>
|
|
80
|
-
<
|
|
76
|
+
<Fingerprint size={28} color={colors.accent} />
|
|
81
77
|
</View>
|
|
82
78
|
<Text style={[styles.title, { color: colors.textPrimary }]}>{t('biometric_advisory_title')}</Text>
|
|
83
|
-
<
|
|
79
|
+
<BalancedText style={[styles.body, { color: colors.textSecondary }]}>
|
|
84
80
|
{t(degraded ? 'biometric_advisory_body_degraded' : 'biometric_advisory_body')}
|
|
85
|
-
</
|
|
81
|
+
</BalancedText>
|
|
86
82
|
|
|
87
83
|
<PressableScale
|
|
88
84
|
haptic="confirm"
|
package/ui/index.ts
CHANGED
|
@@ -124,7 +124,7 @@ export {
|
|
|
124
124
|
// app-shell level (app/_layout.tsx) alongside PermissionSheet/ToastHost above.
|
|
125
125
|
// The 1-of-N YubiKey vault has no phrase path: PassphraseField,
|
|
126
126
|
// PhraseBackupSheet and VaultRecoverScreen are gone (spec §3.5).
|
|
127
|
-
export { EnrollWizard } from './components/vault/EnrollWizard'
|
|
127
|
+
export { EnrollWizard, type HardwareKeyArtComponent } from './components/vault/EnrollWizard'
|
|
128
128
|
export { KeyChooser, vaultKeyLabel } from './components/vault/KeyChooser'
|
|
129
129
|
export { vaultErrorCopy, RETRYABLE_VAULT_ERRORS, type VaultErrorParams } from './components/vault/vaultErrorCopy'
|
|
130
130
|
export { BackupReminderSheet } from './components/wallet/BackupReminderSheet'
|
|
@@ -2,6 +2,21 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
|
2
2
|
import { View, Text, StyleSheet, ScrollView, TextInput, TouchableOpacity, Modal, ActivityIndicator } from 'react-native'
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native'
|
|
4
4
|
import { SvgUri } from 'react-native-svg'
|
|
5
|
+
import {
|
|
6
|
+
ArrowLeft,
|
|
7
|
+
ChevronDown,
|
|
8
|
+
ChevronUp,
|
|
9
|
+
FileText,
|
|
10
|
+
Globe,
|
|
11
|
+
Image as ImageGlyph,
|
|
12
|
+
KeyRound,
|
|
13
|
+
Plus,
|
|
14
|
+
Search,
|
|
15
|
+
ShieldCheck,
|
|
16
|
+
Tag,
|
|
17
|
+
UserRound,
|
|
18
|
+
X
|
|
19
|
+
} from 'lucide-react-native'
|
|
5
20
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
6
21
|
import { useTranslation } from 'react-i18next'
|
|
7
22
|
// Same deep path WalletContext uses: the package root does not re-export the
|
|
@@ -15,21 +30,12 @@ import { showAlert } from '../components/ui/AlertCard'
|
|
|
15
30
|
import { haptics, useTheme, spacing, radii, typography, useWallet } from '@bsv/expo-wallet-toolbox'
|
|
16
31
|
|
|
17
32
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* this package's
|
|
33
|
+
* lucide, the family this app draws every other glyph from (its settings rows,
|
|
34
|
+
* its headers, its sheets). Imported at module scope, unlike
|
|
35
|
+
* @expo/vector-icons: lucide-react-native ships a CJS entry for `require`, so
|
|
36
|
+
* it needs no transform and reaches no native module at import time, which is
|
|
37
|
+
* what this package's lazy icon loads exist to avoid.
|
|
23
38
|
*/
|
|
24
|
-
type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
|
|
25
|
-
let ioniconsComponent: IoniconsComponent | undefined
|
|
26
|
-
function loadIonicons(): IoniconsComponent {
|
|
27
|
-
if (!ioniconsComponent) {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
29
|
-
ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
|
|
30
|
-
}
|
|
31
|
-
return ioniconsComponent
|
|
32
|
-
}
|
|
33
39
|
|
|
34
40
|
/**
|
|
35
41
|
* expo-image's package entry is raw TypeScript (`main: src/index.ts`), which
|
|
@@ -246,7 +252,6 @@ export function TrustScreen() {
|
|
|
246
252
|
const { colors } = useTheme()
|
|
247
253
|
const insets = useSafeAreaInsets()
|
|
248
254
|
const { router } = loadExpoRouter()
|
|
249
|
-
const Ionicons = loadIonicons()
|
|
250
255
|
|
|
251
256
|
const { settings, updateSettings } = useWallet()
|
|
252
257
|
|
|
@@ -340,7 +345,9 @@ export function TrustScreen() {
|
|
|
340
345
|
{/* Header */}
|
|
341
346
|
<View style={[styles.header, { borderBottomColor: colors.separator }]}>
|
|
342
347
|
<TouchableOpacity onPress={() => router.back()} style={styles.backButton}>
|
|
343
|
-
<
|
|
348
|
+
<View style={[styles.headerBackWell, { backgroundColor: colors.surfaceSunken }]}>
|
|
349
|
+
<ArrowLeft size={16} color={colors.textPrimary} />
|
|
350
|
+
</View>
|
|
344
351
|
</TouchableOpacity>
|
|
345
352
|
<Text style={[styles.headerTitle, { color: colors.textPrimary }]}>{t('trust_network')}</Text>
|
|
346
353
|
<View style={styles.backButton} />
|
|
@@ -365,7 +372,7 @@ export function TrustScreen() {
|
|
|
365
372
|
{ borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: colors.separator }
|
|
366
373
|
]}
|
|
367
374
|
>
|
|
368
|
-
<
|
|
375
|
+
<Search size={16} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
|
|
369
376
|
<TextInput
|
|
370
377
|
style={[styles.searchInput, { color: colors.textPrimary }]}
|
|
371
378
|
placeholder={t('search')}
|
|
@@ -416,16 +423,16 @@ export function TrustScreen() {
|
|
|
416
423
|
<View style={styles.actions}>
|
|
417
424
|
{!isFirst && !isSearching && (
|
|
418
425
|
<TouchableOpacity onPress={() => onMoveUp(item.identityKey)} style={styles.actionBtn}>
|
|
419
|
-
<
|
|
426
|
+
<ChevronUp size={16} color={colors.textSecondary} />
|
|
420
427
|
</TouchableOpacity>
|
|
421
428
|
)}
|
|
422
429
|
{!isLast && !isSearching && (
|
|
423
430
|
<TouchableOpacity onPress={() => onMoveDown(item.identityKey)} style={styles.actionBtn}>
|
|
424
|
-
<
|
|
431
|
+
<ChevronDown size={16} color={colors.textSecondary} />
|
|
425
432
|
</TouchableOpacity>
|
|
426
433
|
)}
|
|
427
434
|
<TouchableOpacity onPress={() => onRemove(item.identityKey)} style={styles.actionBtn}>
|
|
428
|
-
<
|
|
435
|
+
<X size={16} color={colors.error} />
|
|
429
436
|
</TouchableOpacity>
|
|
430
437
|
</View>
|
|
431
438
|
</View>
|
|
@@ -442,7 +449,7 @@ export function TrustScreen() {
|
|
|
442
449
|
]}
|
|
443
450
|
onPress={() => setShowAdd(true)}
|
|
444
451
|
>
|
|
445
|
-
<
|
|
452
|
+
<Plus size={16} color={colors.accent} style={{ marginRight: spacing.sm }} />
|
|
446
453
|
<Text style={[styles.addProviderText, { color: colors.accent }]}>{t('add_provider')}</Text>
|
|
447
454
|
</TouchableOpacity>
|
|
448
455
|
</GroupedSection>
|
|
@@ -510,7 +517,6 @@ function AddProviderModal({
|
|
|
510
517
|
colors: any
|
|
511
518
|
}) {
|
|
512
519
|
const { t } = useTranslation()
|
|
513
|
-
const Ionicons = loadIonicons()
|
|
514
520
|
const [advanced, setAdvanced] = useState(false)
|
|
515
521
|
const [domain, setDomain] = useState('')
|
|
516
522
|
const [name, setName] = useState('')
|
|
@@ -620,7 +626,7 @@ function AddProviderModal({
|
|
|
620
626
|
<View style={[styles.modalHeader]}>
|
|
621
627
|
<Text style={[styles.modalTitle, { color: colors.textPrimary }]}>{t('add_provider')}</Text>
|
|
622
628
|
<TouchableOpacity onPress={onClose}>
|
|
623
|
-
<
|
|
629
|
+
<X size={16} color={colors.textSecondary} />
|
|
624
630
|
</TouchableOpacity>
|
|
625
631
|
</View>
|
|
626
632
|
|
|
@@ -630,12 +636,7 @@ function AddProviderModal({
|
|
|
630
636
|
Enter the domain name for the provider you'd like to add.
|
|
631
637
|
</Text>
|
|
632
638
|
<View style={[styles.inputRow, { borderColor: colors.separator, backgroundColor: colors.fillTertiary }]}>
|
|
633
|
-
<
|
|
634
|
-
name="globe-outline"
|
|
635
|
-
size={16}
|
|
636
|
-
color={colors.textSecondary}
|
|
637
|
-
style={{ marginRight: spacing.sm }}
|
|
638
|
-
/>
|
|
639
|
+
<Globe size={16} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
|
|
639
640
|
<TextInput
|
|
640
641
|
placeholder="trustedentity.com"
|
|
641
642
|
placeholderTextColor={colors.textSecondary}
|
|
@@ -658,7 +659,7 @@ function AddProviderModal({
|
|
|
658
659
|
onPress={handleDomainSubmit}
|
|
659
660
|
style={[styles.primaryBtn, { backgroundColor: colors.accent }]}
|
|
660
661
|
>
|
|
661
|
-
<
|
|
662
|
+
<FileText size={16} color={colors.background} />
|
|
662
663
|
<Text style={[styles.primaryBtnText, { color: colors.background }]}>{t('get_provider_details')}</Text>
|
|
663
664
|
</TouchableOpacity>
|
|
664
665
|
)}
|
|
@@ -671,12 +672,7 @@ function AddProviderModal({
|
|
|
671
672
|
|
|
672
673
|
{/* Name */}
|
|
673
674
|
<View style={[styles.inputRow, { borderColor: colors.separator, backgroundColor: colors.fillTertiary }]}>
|
|
674
|
-
<
|
|
675
|
-
name="person-outline"
|
|
676
|
-
size={16}
|
|
677
|
-
color={colors.textSecondary}
|
|
678
|
-
style={{ marginRight: spacing.sm }}
|
|
679
|
-
/>
|
|
675
|
+
<UserRound size={16} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
|
|
680
676
|
<TextInput
|
|
681
677
|
placeholder="Entity Name"
|
|
682
678
|
placeholderTextColor={colors.textSecondary}
|
|
@@ -693,12 +689,7 @@ function AddProviderModal({
|
|
|
693
689
|
|
|
694
690
|
{/* Icon */}
|
|
695
691
|
<View style={[styles.inputRow, { borderColor: colors.separator, backgroundColor: colors.fillTertiary }]}>
|
|
696
|
-
<
|
|
697
|
-
name="image-outline"
|
|
698
|
-
size={16}
|
|
699
|
-
color={colors.textSecondary}
|
|
700
|
-
style={{ marginRight: spacing.sm }}
|
|
701
|
-
/>
|
|
692
|
+
<ImageGlyph size={16} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
|
|
702
693
|
<TextInput
|
|
703
694
|
placeholder="https://trustedentity.com/icon.png"
|
|
704
695
|
placeholderTextColor={colors.textSecondary}
|
|
@@ -717,12 +708,7 @@ function AddProviderModal({
|
|
|
717
708
|
|
|
718
709
|
{/* Public key */}
|
|
719
710
|
<View style={[styles.inputRow, { borderColor: colors.separator, backgroundColor: colors.fillTertiary }]}>
|
|
720
|
-
<
|
|
721
|
-
name="key-outline"
|
|
722
|
-
size={16}
|
|
723
|
-
color={colors.textSecondary}
|
|
724
|
-
style={{ marginRight: spacing.sm }}
|
|
725
|
-
/>
|
|
711
|
+
<KeyRound size={16} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
|
|
726
712
|
<TextInput
|
|
727
713
|
placeholder="0295bf1c7842d14b..."
|
|
728
714
|
placeholderTextColor={colors.textSecondary}
|
|
@@ -746,7 +732,7 @@ function AddProviderModal({
|
|
|
746
732
|
onPress={handleDirectValidate}
|
|
747
733
|
style={[styles.primaryBtn, { backgroundColor: colors.accent }]}
|
|
748
734
|
>
|
|
749
|
-
<
|
|
735
|
+
<ShieldCheck size={16} color={colors.background} />
|
|
750
736
|
<Text style={[styles.primaryBtnText, { color: colors.background }]}>{t('validate_details')}</Text>
|
|
751
737
|
</TouchableOpacity>
|
|
752
738
|
)}
|
|
@@ -755,11 +741,11 @@ function AddProviderModal({
|
|
|
755
741
|
|
|
756
742
|
{/* Toggle advanced */}
|
|
757
743
|
<TouchableOpacity onPress={() => setAdvanced(v => !v)} style={styles.advancedBtn}>
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
color={colors.textPrimary}
|
|
762
|
-
|
|
744
|
+
{advanced ? (
|
|
745
|
+
<ChevronUp size={16} color={colors.textPrimary} />
|
|
746
|
+
) : (
|
|
747
|
+
<ChevronDown size={16} color={colors.textPrimary} />
|
|
748
|
+
)}
|
|
763
749
|
<Text style={{ marginLeft: spacing.xs, color: colors.textPrimary }}>
|
|
764
750
|
{advanced ? t('hide_advanced') : t('show_advanced')}
|
|
765
751
|
</Text>
|
|
@@ -788,12 +774,7 @@ function AddProviderModal({
|
|
|
788
774
|
{ marginTop: spacing.md, borderColor: colors.separator, backgroundColor: colors.fillTertiary }
|
|
789
775
|
]}
|
|
790
776
|
>
|
|
791
|
-
<
|
|
792
|
-
name="pricetag-outline"
|
|
793
|
-
size={16}
|
|
794
|
-
color={colors.textSecondary}
|
|
795
|
-
style={{ marginRight: spacing.sm }}
|
|
796
|
-
/>
|
|
777
|
+
<Tag size={16} color={colors.textSecondary} style={{ marginRight: spacing.sm }} />
|
|
797
778
|
<TextInput
|
|
798
779
|
placeholder="Description"
|
|
799
780
|
placeholderTextColor={colors.textSecondary}
|
|
@@ -818,7 +799,7 @@ function AddProviderModal({
|
|
|
818
799
|
onPress={() => onAdd({ name, description, iconUrl: icon, identityKey })}
|
|
819
800
|
style={[styles.saveBtn, { backgroundColor: colors.accent, opacity: ready ? 1 : 0.5, flex: 0 }]}
|
|
820
801
|
>
|
|
821
|
-
<
|
|
802
|
+
<ShieldCheck size={16} color={colors.background} />
|
|
822
803
|
<Text style={[styles.saveBtnText, { color: colors.background }]}>Add</Text>
|
|
823
804
|
</TouchableOpacity>
|
|
824
805
|
</View>
|
|
@@ -830,6 +811,13 @@ function AddProviderModal({
|
|
|
830
811
|
|
|
831
812
|
// -------------------- Styles --------------------
|
|
832
813
|
const styles = StyleSheet.create({
|
|
814
|
+
headerBackWell: {
|
|
815
|
+
width: 32,
|
|
816
|
+
height: 32,
|
|
817
|
+
borderRadius: 16,
|
|
818
|
+
alignItems: 'center',
|
|
819
|
+
justifyContent: 'center'
|
|
820
|
+
},
|
|
833
821
|
header: {
|
|
834
822
|
flexDirection: 'row',
|
|
835
823
|
alignItems: 'center',
|