@bsv/expo-wallet-toolbox 0.1.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/LICENSE.txt +28 -0
- package/README.md +512 -0
- package/assets/sounds/payment-receive.wav +0 -0
- package/assets/sounds/payment-send.wav +0 -0
- package/assets/sounds/vault-close.wav +0 -0
- package/assets/sounds/vault-open.wav +0 -0
- package/core/amountFormatHelpers.ts +330 -0
- package/core/backup/RemoteSyncReader.ts +94 -0
- package/core/backup/client.ts +111 -0
- package/core/backup/codec.ts +218 -0
- package/core/backup/constants.ts +88 -0
- package/core/backup/cursor.ts +138 -0
- package/core/backup/derive.ts +46 -0
- package/core/backup/deviceId.ts +33 -0
- package/core/backup/erase.ts +67 -0
- package/core/backup/preference.ts +33 -0
- package/core/backup/push.ts +295 -0
- package/core/backup/restore.ts +152 -0
- package/core/backup/restoreOnImport.ts +119 -0
- package/core/backup/status.ts +46 -0
- package/core/config.tsx +47 -0
- package/core/constants.ts +35 -0
- package/core/context/ExchangeRateContext.tsx +69 -0
- package/core/context/LocalStorageProvider.tsx +225 -0
- package/core/context/UserContext.tsx +129 -0
- package/core/context/VaultContext.tsx +79 -0
- package/core/context/WalletConnectionContext.tsx +454 -0
- package/core/context/WalletContext.tsx +2938 -0
- package/core/context/buildGeneration.ts +37 -0
- package/core/deviceTier.ts +89 -0
- package/core/diskSpace.ts +62 -0
- package/core/displayCurrencies.ts +56 -0
- package/core/headers/OfflineFirstChaintracks.ts +176 -0
- package/core/headers/checkpoints.ts +39 -0
- package/core/headers/fs.ts +119 -0
- package/core/headers/headerStore.ts +333 -0
- package/core/headers/prewarm.ts +36 -0
- package/core/headers/syncHeaders.ts +73 -0
- package/core/hooks/useConfirmationSound.ts +135 -0
- package/core/hooks/useHaptics.ts +51 -0
- package/core/hooks/usePermissionQueue.ts +69 -0
- package/core/i18n/translations.tsx +6692 -0
- package/core/index.ts +295 -0
- package/core/localpay/blePermissions.ts +32 -0
- package/core/localpay/build.ts +392 -0
- package/core/localpay/codec.ts +338 -0
- package/core/localpay/deviceCaps.ts +175 -0
- package/core/localpay/nearbyAdvisory.ts +32 -0
- package/core/localpay/nearbyPermissions.ts +34 -0
- package/core/localpay/pending.ts +385 -0
- package/core/localpay/pendingAborts.ts +67 -0
- package/core/localpay/qr.ts +16 -0
- package/core/localpay/session.ts +277 -0
- package/core/localpay/sessionPolicy.ts +5 -0
- package/core/localpay/transport/awdl.ts +11 -0
- package/core/localpay/transport/ble.ts +159 -0
- package/core/localpay/transport/nearby.ts +12 -0
- package/core/localpay/transport/race.ts +110 -0
- package/core/localpay/transport/select.ts +128 -0
- package/core/localpay/transport/socket.ts +244 -0
- package/core/localpay/types.ts +82 -0
- package/core/localpay/verify.ts +204 -0
- package/core/logging.config.ts +10 -0
- package/core/logging.ts +77 -0
- package/core/mnemonicWallet.ts +180 -0
- package/core/monitor/TaskBackupPush.ts +168 -0
- package/core/monitor/TaskCreditInbox.ts +116 -0
- package/core/monitor/TaskDrainOutbox.ts +122 -0
- package/core/monitor/TaskSendOffline.ts +123 -0
- package/core/monitor/unfailRetry.ts +116 -0
- package/core/net/chainMatch.ts +34 -0
- package/core/net/online.ts +34 -0
- package/core/offline/cancelParked.ts +56 -0
- package/core/offline/hold.ts +127 -0
- package/core/offline/order.ts +109 -0
- package/core/offline/payerHold.ts +144 -0
- package/core/offline/plan.ts +264 -0
- package/core/offline/queueGrace.ts +52 -0
- package/core/parsePeerPayURI.ts +119 -0
- package/core/pay/beefRepair.ts +106 -0
- package/core/pay/creditErrors.ts +46 -0
- package/core/pay/creditInbox.ts +202 -0
- package/core/pay/damagedInbox.ts +64 -0
- package/core/pay/proofNudge.ts +23 -0
- package/core/pay/provenTxFromBump.ts +31 -0
- package/core/pay/rails/address.ts +329 -0
- package/core/pay/rails/handle.ts +617 -0
- package/core/pay/rails/index.ts +197 -0
- package/core/pay/rails/nearby.ts +79 -0
- package/core/pay/receiveFocus.ts +13 -0
- package/core/pay/recordProof.ts +91 -0
- package/core/pay/refreshProofGuard.ts +34 -0
- package/core/pay/sweeper.ts +75 -0
- package/core/pay/tokenAmount.ts +18 -0
- package/core/pay/userError.ts +18 -0
- package/core/pay/watchlist.ts +126 -0
- package/core/peerpay/control.ts +122 -0
- package/core/peerpay/handleResendRequests.ts +475 -0
- package/core/peerpay/inboxAttempts.ts +33 -0
- package/core/peerpay/metadataDecryptor.ts +42 -0
- package/core/peerpay/offlineNacks.ts +96 -0
- package/core/peerpay/outbox.ts +209 -0
- package/core/peerpay/rebuildToken.ts +76 -0
- package/core/peerpay/resendBeef.ts +115 -0
- package/core/services/arcadeBroadcastProvider.ts +214 -0
- package/core/services/capWalletArgs.ts +99 -0
- package/core/services/exchangeRate.ts +63 -0
- package/core/services/secrets/envelope.ts +102 -0
- package/core/services/secrets/hkdf.ts +37 -0
- package/core/services/secrets/index.ts +63 -0
- package/core/services/secrets/kek.ts +274 -0
- package/core/services/secrets/migration.ts +188 -0
- package/core/services/secrets/policy.ts +120 -0
- package/core/services/secrets/storage.ts +54 -0
- package/core/services/secrets/store.ts +125 -0
- package/core/services/secrets/types.ts +85 -0
- package/core/services/usdFxRates.ts +101 -0
- package/core/services/vault/VaultKeyService.ts +312 -0
- package/core/services/vault/backupAttestation.ts +136 -0
- package/core/services/vault/ceremony.ts +972 -0
- package/core/services/vault/ceremonyHost.ts +46 -0
- package/core/services/vault/devMock.ts +22 -0
- package/core/services/vault/driver.ts +197 -0
- package/core/services/vault/guard.ts +90 -0
- package/core/services/vault/k1.ts +75 -0
- package/core/services/vault/mockYubiKey.ts +217 -0
- package/core/services/vault/random.ts +20 -0
- package/core/services/vault/sealing.ts +84 -0
- package/core/services/vault/session.ts +59 -0
- package/core/services/vault/transfers.ts +1151 -0
- package/core/services/vault/types.ts +109 -0
- package/core/services/vault/vaultDerivation.ts +152 -0
- package/core/services/vault/vaultPassphrase.ts +287 -0
- package/core/services/vault/vaultStore.ts +104 -0
- package/core/services/walletArgLimits.ts +234 -0
- package/core/services/walletServiceConfig.ts +170 -0
- package/core/storage/LocalStorageAdapter.ts +58 -0
- package/core/storage/README.md +391 -0
- package/core/storage/StorageExpoSQLite.ts +2008 -0
- package/core/storage/errors.ts +73 -0
- package/core/storage/index.ts +3 -0
- package/core/storage/methods/findSql.ts +286 -0
- package/core/storage/methods/historyNotes.ts +61 -0
- package/core/storage/methods/listActionsSql.ts +212 -0
- package/core/storage/methods/listOutputsSql.ts +211 -0
- package/core/storage/methods/offlineActions.ts +156 -0
- package/core/storage/methods/processOfflineActions.ts +503 -0
- package/core/storage/methods/reclaim.ts +135 -0
- package/core/storage/methods/reviewStatusSql.ts +167 -0
- package/core/storage/methods/unprovenWithoutReqSql.ts +26 -0
- package/core/storage/methods/walletBalanceSql.ts +55 -0
- package/core/storage/schema/createTables.ts +385 -0
- package/core/storage/skipQueuedAncestors.ts +29 -0
- package/core/storage/sqlUpdateValue.ts +12 -0
- package/core/stores/ConnectionStore.ts +71 -0
- package/core/theme/ThemeContext.tsx +182 -0
- package/core/theme/assertThemeContrast.ts +109 -0
- package/core/theme/motion.ts +50 -0
- package/core/theme/tokens.ts +232 -0
- package/core/theme/useThemeStyles.tsx +156 -0
- package/core/walletDbRegistry.ts +110 -0
- package/core/walletMonitor.ts +149 -0
- package/core/walletRepair/runWalletCheck.ts +195 -0
- package/core/walletRepair/shouldReleaseUtxo.ts +18 -0
- package/package.json +86 -0
- package/ui/backupShares.ts +367 -0
- package/ui/components/QRScanner.tsx +353 -0
- package/ui/components/pay/AddressReceive.tsx +507 -0
- package/ui/components/pay/AvailableBalance.tsx +61 -0
- package/ui/components/pay/HandleReceive.tsx +896 -0
- package/ui/components/pay/MessageBoxConfig.tsx +256 -0
- package/ui/components/pay/NearbyAdvisoryModal.tsx +111 -0
- package/ui/components/pay/NearbyFlow.tsx +2542 -0
- package/ui/components/pay/OfflineNotice.tsx +337 -0
- package/ui/components/pay/PayCellRow.tsx +101 -0
- package/ui/components/pay/PayForm.tsx +223 -0
- package/ui/components/pay/PaymentQrDisplay.tsx +105 -0
- package/ui/components/pay/PaymentSuccessOverlay.tsx +266 -0
- package/ui/components/pay/RecipientField.tsx +308 -0
- package/ui/components/pay/RequestHub.tsx +75 -0
- package/ui/components/pay/ResultBanner.tsx +69 -0
- package/ui/components/pay/UniversalSend.tsx +687 -0
- package/ui/components/pay/useRecipientInput.ts +270 -0
- package/ui/components/security/WalletLockNotice.tsx +138 -0
- package/ui/components/ui/AlertCard.tsx +223 -0
- package/ui/components/ui/AppLogo.tsx +166 -0
- package/ui/components/ui/BlurChrome.tsx +72 -0
- package/ui/components/ui/Celebration.tsx +84 -0
- package/ui/components/ui/ChoiceSheet.ts +69 -0
- package/ui/components/ui/CustomSafeArea.tsx +74 -0
- package/ui/components/ui/ErrorBoundary.tsx +154 -0
- package/ui/components/ui/GroupedList.tsx +125 -0
- package/ui/components/ui/IconButton.tsx +105 -0
- package/ui/components/ui/ListRow.tsx +197 -0
- package/ui/components/ui/PermissionSheet.tsx +920 -0
- package/ui/components/ui/PresenceRow.tsx +215 -0
- package/ui/components/ui/PressableScale.tsx +105 -0
- package/ui/components/ui/ScreenGradient.tsx +47 -0
- package/ui/components/ui/ScrollFade.tsx +76 -0
- package/ui/components/ui/Sheet.tsx +342 -0
- package/ui/components/ui/Toast.tsx +142 -0
- package/ui/components/ui/index.ts +8 -0
- package/ui/components/vault/EnrollWizard.tsx +627 -0
- package/ui/components/vault/PassphraseField.tsx +306 -0
- package/ui/components/vault/PhraseBackupSheet.tsx +227 -0
- package/ui/components/vault/VaultBackdrop.tsx +354 -0
- package/ui/components/vault/VaultCeremonySheet.tsx +327 -0
- package/ui/components/wallet/ActivityRow.tsx +408 -0
- package/ui/components/wallet/AmountDisplay.tsx +48 -0
- package/ui/components/wallet/AmountInput.tsx +256 -0
- package/ui/components/wallet/BackupReminderSheet.tsx +168 -0
- package/ui/components/wallet/Balance.tsx +144 -0
- package/ui/components/wallet/BiometricAdvisoryModal.tsx +133 -0
- package/ui/components/wallet/ImportFromBackupPrompt.tsx +93 -0
- package/ui/exportDatabases.ts +122 -0
- package/ui/exportTransactions.ts +129 -0
- package/ui/hooks/useOfflineNoticeActions.ts +136 -0
- package/ui/hooks/useOnline.ts +70 -0
- package/ui/hooks/useSpendableBalance.ts +58 -0
- package/ui/hooks/useVaultBalance.ts +50 -0
- package/ui/importDatabases.ts +170 -0
- package/ui/index.ts +136 -0
- package/ui/isImageUrl.ts +10 -0
- package/ui/printRecoveryShares.ts +93 -0
- package/ui/resolveIdentity.ts +125 -0
- package/ui/screens/ConnectionsScreen.tsx +438 -0
- package/ui/screens/LogsScreen.tsx +432 -0
- package/ui/screens/PairScreen.tsx +288 -0
- package/ui/screens/PayScreen.tsx +479 -0
- package/ui/screens/SettingsScreen.tsx +180 -0
- package/ui/screens/TrustScreen.tsx +831 -0
- package/ui/screens/VaultRecoverScreen.tsx +226 -0
- package/ui/screens/VaultScreen.tsx +423 -0
- package/ui/screens/VaultTransferScreen.tsx +293 -0
- package/ui/screens/WalletCheckScreen.tsx +539 -0
- package/ui/screens/WalletConfigScreen.tsx +1095 -0
- package/ui/screens/WalletHomeScreen.tsx +1597 -0
- package/ui/screens/homeBadges.ts +18 -0
- package/ui/txStatus.ts +79 -0
- package/ui/validateTrust.ts +44 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react'
|
|
2
|
+
import { View, StyleSheet, Animated, Easing } from 'react-native'
|
|
3
|
+
import { useTheme } from '@bsv/expo-wallet-toolbox'
|
|
4
|
+
|
|
5
|
+
interface AppLogoProps {
|
|
6
|
+
size?: number
|
|
7
|
+
color?: string
|
|
8
|
+
rotate?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const AppLogo: React.FC<AppLogoProps> = ({ size = 150, color = '#2196F3', rotate = true }) => {
|
|
12
|
+
// Get theme colors if no specific color is provided
|
|
13
|
+
const { colors } = useTheme()
|
|
14
|
+
const logoColor = color || colors.primary
|
|
15
|
+
|
|
16
|
+
// Animation for rotation
|
|
17
|
+
const rotateAnim = useRef(new Animated.Value(0)).current
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (rotate) {
|
|
21
|
+
Animated.loop(
|
|
22
|
+
Animated.timing(rotateAnim, {
|
|
23
|
+
toValue: 1,
|
|
24
|
+
duration: 10000,
|
|
25
|
+
easing: Easing.linear,
|
|
26
|
+
useNativeDriver: true
|
|
27
|
+
})
|
|
28
|
+
).start()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
rotateAnim.stopAnimation()
|
|
33
|
+
}
|
|
34
|
+
}, [rotate, rotateAnim])
|
|
35
|
+
|
|
36
|
+
// Calculate positions for 8 vertices on a circle
|
|
37
|
+
const centerX = size / 2
|
|
38
|
+
const centerY = size / 2
|
|
39
|
+
const radius = size * 0.4
|
|
40
|
+
const dot = size * (8 / 150)
|
|
41
|
+
const vertices = []
|
|
42
|
+
|
|
43
|
+
// Create 8 vertices positioned in a circle
|
|
44
|
+
for (let i = 0; i < 8; i++) {
|
|
45
|
+
const angle = (i / 8) * 2 * Math.PI
|
|
46
|
+
vertices.push({
|
|
47
|
+
x: centerX + radius * Math.cos(angle),
|
|
48
|
+
y: centerY + radius * Math.sin(angle)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Create connections between vertices with a specific pattern
|
|
53
|
+
const connections = []
|
|
54
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
55
|
+
// Determine how many connections this vertex should have
|
|
56
|
+
// Every second vertex will connect to 6 others instead of 7
|
|
57
|
+
const skipVertexIndex = i % 2 === 0 ? (i + 4) % 8 : -1 // Skip the opposite vertex for even-indexed vertices
|
|
58
|
+
|
|
59
|
+
for (let j = 0; j < vertices.length; j++) {
|
|
60
|
+
// Don't connect vertex to itself and apply the skipping pattern
|
|
61
|
+
if (i !== j && j !== skipVertexIndex) {
|
|
62
|
+
// Avoid duplicate connections (only add if i < j)
|
|
63
|
+
if (i < j) {
|
|
64
|
+
connections.push({
|
|
65
|
+
startX: vertices[i].x,
|
|
66
|
+
startY: vertices[i].y,
|
|
67
|
+
endX: vertices[j].x,
|
|
68
|
+
endY: vertices[j].y
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const spin = rotateAnim.interpolate({
|
|
76
|
+
inputRange: [0, 1],
|
|
77
|
+
outputRange: ['0deg', '360deg']
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Animated.View
|
|
82
|
+
style={[
|
|
83
|
+
styles.container,
|
|
84
|
+
{
|
|
85
|
+
width: size,
|
|
86
|
+
height: size,
|
|
87
|
+
transform: rotate ? [{ rotate: spin }] : []
|
|
88
|
+
}
|
|
89
|
+
]}
|
|
90
|
+
>
|
|
91
|
+
{/* No background circle */}
|
|
92
|
+
|
|
93
|
+
{/* Connections between vertices */}
|
|
94
|
+
{connections.map((connection, index) => {
|
|
95
|
+
// Calculate line properties
|
|
96
|
+
const dx = connection.endX - connection.startX
|
|
97
|
+
const dy = connection.endY - connection.startY
|
|
98
|
+
const length = Math.sqrt(dx * dx + dy * dy)
|
|
99
|
+
const angle = Math.atan2(dy, dx) * (180 / Math.PI)
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<View
|
|
103
|
+
key={`line-${index}`}
|
|
104
|
+
style={[
|
|
105
|
+
styles.line,
|
|
106
|
+
{
|
|
107
|
+
width: length,
|
|
108
|
+
left: connection.startX,
|
|
109
|
+
top: connection.startY,
|
|
110
|
+
transform: [{ rotate: `${angle}deg` }],
|
|
111
|
+
backgroundColor: logoColor,
|
|
112
|
+
opacity: 0.6
|
|
113
|
+
}
|
|
114
|
+
]}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
})}
|
|
118
|
+
|
|
119
|
+
{/* Vertices (circles) */}
|
|
120
|
+
{vertices.map((vertex, index) => (
|
|
121
|
+
<View
|
|
122
|
+
key={`vertex-${index}`}
|
|
123
|
+
style={[
|
|
124
|
+
styles.vertex,
|
|
125
|
+
{
|
|
126
|
+
width: dot,
|
|
127
|
+
height: dot,
|
|
128
|
+
borderRadius: dot / 2,
|
|
129
|
+
left: vertex.x - dot / 2,
|
|
130
|
+
top: vertex.y - dot / 2,
|
|
131
|
+
backgroundColor: logoColor
|
|
132
|
+
}
|
|
133
|
+
]}
|
|
134
|
+
/>
|
|
135
|
+
))}
|
|
136
|
+
|
|
137
|
+
{/* No center dot */}
|
|
138
|
+
</Animated.View>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const styles = StyleSheet.create({
|
|
143
|
+
container: {
|
|
144
|
+
position: 'relative'
|
|
145
|
+
},
|
|
146
|
+
backgroundCircle: {
|
|
147
|
+
position: 'absolute',
|
|
148
|
+
backgroundColor: 'transparent'
|
|
149
|
+
},
|
|
150
|
+
line: {
|
|
151
|
+
position: 'absolute',
|
|
152
|
+
height: 1,
|
|
153
|
+
transformOrigin: 'left'
|
|
154
|
+
},
|
|
155
|
+
vertex: {
|
|
156
|
+
position: 'absolute'
|
|
157
|
+
},
|
|
158
|
+
centerDot: {
|
|
159
|
+
position: 'absolute',
|
|
160
|
+
width: 16,
|
|
161
|
+
height: 16,
|
|
162
|
+
borderRadius: 8
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
export default AppLogo
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StyleSheet, View, Platform } from 'react-native'
|
|
3
|
+
import { useTheme } from '@bsv/expo-wallet-toolbox'
|
|
4
|
+
|
|
5
|
+
interface BlurChromeProps {
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
intensity?: number
|
|
8
|
+
borderRadius?: number
|
|
9
|
+
style?: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* expo-blur ships an untransformed ESM barrel
|
|
14
|
+
* (`export { default as BlurView } from './BlurView'`), which Jest cannot
|
|
15
|
+
* parse for any consumer of the `ui` package barrel — even on Android/test
|
|
16
|
+
* environments that never render it. Required lazily (only when actually
|
|
17
|
+
* rendering on iOS), same pattern as core/context/WalletContext.tsx's lazy
|
|
18
|
+
* expo-router load.
|
|
19
|
+
*/
|
|
20
|
+
type BlurViewComponent = typeof import('expo-blur').BlurView
|
|
21
|
+
let blurViewComponent: BlurViewComponent | undefined
|
|
22
|
+
function loadBlurView(): BlurViewComponent {
|
|
23
|
+
if (!blurViewComponent) {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
25
|
+
blurViewComponent = require('expo-blur').BlurView as BlurViewComponent
|
|
26
|
+
}
|
|
27
|
+
return blurViewComponent
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Translucent wrapper using expo-blur on iOS, solid fallback on Android.
|
|
32
|
+
* Used for toolbar chrome and floating glass pill fallbacks.
|
|
33
|
+
*/
|
|
34
|
+
export const BlurChrome: React.FC<BlurChromeProps> = ({
|
|
35
|
+
children,
|
|
36
|
+
intensity = 80,
|
|
37
|
+
borderRadius = 0,
|
|
38
|
+
style
|
|
39
|
+
}) => {
|
|
40
|
+
const { isDark, colors } = useTheme()
|
|
41
|
+
|
|
42
|
+
if (Platform.OS === 'ios') {
|
|
43
|
+
const BlurView = loadBlurView()
|
|
44
|
+
return (
|
|
45
|
+
<BlurView
|
|
46
|
+
intensity={intensity}
|
|
47
|
+
tint={isDark ? 'dark' : 'light'}
|
|
48
|
+
style={[styles.container, { borderRadius }, style]}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</BlurView>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<View
|
|
57
|
+
style={[
|
|
58
|
+
styles.container,
|
|
59
|
+
{ borderRadius, backgroundColor: colors.chromeBackground },
|
|
60
|
+
style
|
|
61
|
+
]}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</View>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const styles = StyleSheet.create({
|
|
69
|
+
container: {
|
|
70
|
+
overflow: 'hidden',
|
|
71
|
+
},
|
|
72
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Celebration checkmark (spec Part 5) — used in EXACTLY three places:
|
|
3
|
+
* first payment sent, wallet created, backup verified. Everything else uses
|
|
4
|
+
* quiet feedback. Drawn check + success haptic; reduced motion = static check.
|
|
5
|
+
*/
|
|
6
|
+
import React, { useEffect } from 'react'
|
|
7
|
+
import { StyleSheet, View } from 'react-native'
|
|
8
|
+
import Svg, { Circle, Path } from 'react-native-svg'
|
|
9
|
+
import Animated, {
|
|
10
|
+
useSharedValue,
|
|
11
|
+
useAnimatedProps,
|
|
12
|
+
useAnimatedStyle,
|
|
13
|
+
withSpring,
|
|
14
|
+
withTiming,
|
|
15
|
+
withDelay,
|
|
16
|
+
useReducedMotion,
|
|
17
|
+
} from 'react-native-reanimated'
|
|
18
|
+
import { useTheme, springs, durations, haptics } from '@bsv/expo-wallet-toolbox'
|
|
19
|
+
|
|
20
|
+
const AnimatedPath = Animated.createAnimatedComponent(Path)
|
|
21
|
+
// Path M26 45 L39 58 L62 32:
|
|
22
|
+
// segment1 = sqrt(13²+13²) ≈ 18.4
|
|
23
|
+
// segment2 = sqrt(23²+26²) ≈ 34.7
|
|
24
|
+
// total ≈ 53.1
|
|
25
|
+
// Using 54 (slightly over actual) so dasharray covers the full stroke;
|
|
26
|
+
// slightly-under (48) would leave a visible gap at the tip.
|
|
27
|
+
const CHECK_LENGTH = 54
|
|
28
|
+
|
|
29
|
+
interface CelebrationProps {
|
|
30
|
+
size?: number
|
|
31
|
+
/** Called ~700ms after mount, when the moment has landed. */
|
|
32
|
+
onDone?: () => void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default function Celebration({ size = 88, onDone }: CelebrationProps) {
|
|
36
|
+
const { colors } = useTheme()
|
|
37
|
+
const reducedMotion = useReducedMotion()
|
|
38
|
+
const scale = useSharedValue(reducedMotion ? 1 : 0.6)
|
|
39
|
+
const opacity = useSharedValue(reducedMotion ? 1 : 0)
|
|
40
|
+
const draw = useSharedValue(reducedMotion ? 0 : CHECK_LENGTH)
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
haptics.success()
|
|
44
|
+
if (!reducedMotion) {
|
|
45
|
+
scale.value = withSpring(1, springs.snappy)
|
|
46
|
+
opacity.value = withTiming(1, { duration: durations.instant })
|
|
47
|
+
draw.value = withDelay(120, withTiming(0, { duration: 320 }))
|
|
48
|
+
}
|
|
49
|
+
if (onDone) {
|
|
50
|
+
const t = setTimeout(onDone, 700)
|
|
51
|
+
return () => clearTimeout(t)
|
|
52
|
+
}
|
|
53
|
+
}, []) // eslint-disable-line react-hooks/exhaustive-deps
|
|
54
|
+
|
|
55
|
+
const circleStyle = useAnimatedStyle(() => ({
|
|
56
|
+
opacity: opacity.value,
|
|
57
|
+
transform: [{ scale: scale.value }],
|
|
58
|
+
}))
|
|
59
|
+
const pathProps = useAnimatedProps(() => ({ strokeDashoffset: draw.value }))
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<View style={styles.center}>
|
|
63
|
+
<Animated.View style={circleStyle}>
|
|
64
|
+
<Svg width={size} height={size} viewBox="0 0 88 88">
|
|
65
|
+
<Circle cx="44" cy="44" r="42" fill={colors.success} />
|
|
66
|
+
<AnimatedPath
|
|
67
|
+
d="M26 45 L39 58 L62 32"
|
|
68
|
+
stroke="#FFFFFF"
|
|
69
|
+
strokeWidth={6}
|
|
70
|
+
strokeLinecap="round"
|
|
71
|
+
strokeLinejoin="round"
|
|
72
|
+
fill="none"
|
|
73
|
+
strokeDasharray={CHECK_LENGTH}
|
|
74
|
+
animatedProps={pathProps}
|
|
75
|
+
/>
|
|
76
|
+
</Svg>
|
|
77
|
+
</Animated.View>
|
|
78
|
+
</View>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const styles = StyleSheet.create({
|
|
83
|
+
center: { alignItems: 'center', justifyContent: 'center' },
|
|
84
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HIG action sheet for 3+ choices the person just initiated.
|
|
3
|
+
*
|
|
4
|
+
* iOS uses ActionSheetIOS (destructive first, cancel last). Android stacks the
|
|
5
|
+
* same options via showAlert — AlertCard already stacks 3+.
|
|
6
|
+
*/
|
|
7
|
+
import { ActionSheetIOS, Platform } from 'react-native'
|
|
8
|
+
import { showAlert } from './AlertCard'
|
|
9
|
+
|
|
10
|
+
export function choiceSheetOrder<T extends { key: string; destructive?: boolean }>(
|
|
11
|
+
options: T[],
|
|
12
|
+
cancelKey = 'cancel'
|
|
13
|
+
): Array<T | { key: string }> {
|
|
14
|
+
const destructive = options.filter(o => o.destructive)
|
|
15
|
+
const rest = options.filter(o => !o.destructive)
|
|
16
|
+
return [...destructive, ...rest, { key: cancelKey }]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function showChoiceSheet(args: {
|
|
20
|
+
title: string
|
|
21
|
+
message?: string
|
|
22
|
+
options: { key: string; label: string; destructive?: boolean }[]
|
|
23
|
+
cancelKey?: string
|
|
24
|
+
cancelLabel?: string
|
|
25
|
+
}): Promise<string> {
|
|
26
|
+
const cancelKey = args.cancelKey ?? 'cancel'
|
|
27
|
+
const cancelLabel = args.cancelLabel ?? 'Cancel'
|
|
28
|
+
const ordered = choiceSheetOrder(args.options, cancelKey)
|
|
29
|
+
const labelFor = (key: string) =>
|
|
30
|
+
key === cancelKey ? cancelLabel : (args.options.find(o => o.key === key)?.label ?? key)
|
|
31
|
+
const destructiveIndexes = ordered.flatMap((o, i) =>
|
|
32
|
+
'destructive' in o && o.destructive ? [i] : []
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
if (Platform.OS === 'ios') {
|
|
36
|
+
return new Promise(resolve => {
|
|
37
|
+
ActionSheetIOS.showActionSheetWithOptions(
|
|
38
|
+
{
|
|
39
|
+
title: args.title,
|
|
40
|
+
message: args.message,
|
|
41
|
+
options: ordered.map(o => labelFor(o.key)),
|
|
42
|
+
cancelButtonIndex: ordered.length - 1,
|
|
43
|
+
destructiveButtonIndex:
|
|
44
|
+
destructiveIndexes.length === 1
|
|
45
|
+
? destructiveIndexes[0]
|
|
46
|
+
: destructiveIndexes.length > 1
|
|
47
|
+
? destructiveIndexes
|
|
48
|
+
: undefined
|
|
49
|
+
},
|
|
50
|
+
buttonIndex => {
|
|
51
|
+
resolve(ordered[buttonIndex]?.key ?? cancelKey)
|
|
52
|
+
}
|
|
53
|
+
)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return showAlert({
|
|
58
|
+
title: args.title,
|
|
59
|
+
message: args.message,
|
|
60
|
+
buttons: ordered.map(o => {
|
|
61
|
+
const destructive = 'destructive' in o && o.destructive
|
|
62
|
+
return {
|
|
63
|
+
text: labelFor(o.key),
|
|
64
|
+
key: o.key,
|
|
65
|
+
style: o.key === cancelKey ? 'cancel' : destructive ? 'destructive' : 'default'
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View, Platform, StyleSheet, StyleProp, ViewStyle } from 'react-native'
|
|
3
|
+
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
4
|
+
import { useTheme } from '@bsv/expo-wallet-toolbox'
|
|
5
|
+
|
|
6
|
+
// Default minimum bottom inset for Android (keeps content above OS
|
|
7
|
+
// navigation). Was `ANDROID_MIN_BOTTOM_INSET` from the host app's
|
|
8
|
+
// `shared/constants` — that file is deliberately app-root-only config, not
|
|
9
|
+
// part of this package, so the value is now a plain default here instead of
|
|
10
|
+
// a cross-boundary import. Callers that need the app's own value can pass it
|
|
11
|
+
// explicitly via `minBottomInset`.
|
|
12
|
+
const DEFAULT_MIN_BOTTOM_INSET = 24
|
|
13
|
+
|
|
14
|
+
interface CustomSafeAreaProps {
|
|
15
|
+
children: React.ReactNode
|
|
16
|
+
style?: StyleProp<ViewStyle>
|
|
17
|
+
minTopInset?: number // Customizable minimum top inset
|
|
18
|
+
minBottomInset?: number // Customizable minimum bottom inset
|
|
19
|
+
edges?: ('top' | 'right' | 'bottom' | 'left')[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Custom SafeAreaView that respects a minimum top inset for Android devices
|
|
24
|
+
* to properly handle camera notches and provides consistent behavior across platforms.
|
|
25
|
+
* Also enforces a minimum bottom inset on Android to keep content above OS navigation.
|
|
26
|
+
*/
|
|
27
|
+
export default function CustomSafeArea({
|
|
28
|
+
children,
|
|
29
|
+
style,
|
|
30
|
+
minTopInset = 30, // Default minimum top inset for Android
|
|
31
|
+
minBottomInset = DEFAULT_MIN_BOTTOM_INSET, // Default minimum bottom inset for Android
|
|
32
|
+
edges
|
|
33
|
+
}: CustomSafeAreaProps) {
|
|
34
|
+
const insets = useSafeAreaInsets()
|
|
35
|
+
const { colors } = useTheme()
|
|
36
|
+
|
|
37
|
+
// Apply minimum insets only on Android
|
|
38
|
+
const appliedTopInset = Platform.OS === 'android' ? Math.max(insets.top, minTopInset) : insets.top
|
|
39
|
+
const appliedBottomInset = Platform.OS === 'android' ? Math.max(insets.bottom, minBottomInset) : insets.bottom
|
|
40
|
+
|
|
41
|
+
// If edges are specified, use SafeAreaView with edges
|
|
42
|
+
if (edges) {
|
|
43
|
+
return (
|
|
44
|
+
<SafeAreaView style={[{ backgroundColor: colors.background }, style]} edges={edges}>
|
|
45
|
+
{children}
|
|
46
|
+
</SafeAreaView>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Otherwise use View with manual padding
|
|
51
|
+
return (
|
|
52
|
+
<View
|
|
53
|
+
style={[
|
|
54
|
+
styles.container,
|
|
55
|
+
{
|
|
56
|
+
backgroundColor: colors.background,
|
|
57
|
+
paddingTop: appliedTopInset,
|
|
58
|
+
paddingBottom: appliedBottomInset,
|
|
59
|
+
paddingLeft: insets.left,
|
|
60
|
+
paddingRight: insets.right
|
|
61
|
+
},
|
|
62
|
+
style
|
|
63
|
+
]}
|
|
64
|
+
>
|
|
65
|
+
{children}
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
flex: 1
|
|
73
|
+
}
|
|
74
|
+
})
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react'
|
|
2
|
+
import { View, Text, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: ReactNode
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface State {
|
|
9
|
+
hasError: boolean
|
|
10
|
+
error: Error | null
|
|
11
|
+
errorInfo: ErrorInfo | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Error Boundary to catch JavaScript errors and prevent app crashes
|
|
16
|
+
* This is especially important for production builds where crashes are more severe
|
|
17
|
+
*/
|
|
18
|
+
export class ErrorBoundary extends Component<Props, State> {
|
|
19
|
+
constructor(props: Props) {
|
|
20
|
+
super(props)
|
|
21
|
+
this.state = {
|
|
22
|
+
hasError: false,
|
|
23
|
+
error: null,
|
|
24
|
+
errorInfo: null
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static getDerivedStateFromError(error: Error): State {
|
|
29
|
+
// Update state so the next render will show the fallback UI
|
|
30
|
+
return {
|
|
31
|
+
hasError: true,
|
|
32
|
+
error,
|
|
33
|
+
errorInfo: null
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
38
|
+
// Log the error to console
|
|
39
|
+
console.error('ErrorBoundary caught an error:', error, errorInfo)
|
|
40
|
+
|
|
41
|
+
// Update state with error details
|
|
42
|
+
this.setState({
|
|
43
|
+
error,
|
|
44
|
+
errorInfo
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// You can also log the error to an error reporting service here
|
|
48
|
+
// Example: Sentry.captureException(error, { extra: errorInfo })
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
resetError = () => {
|
|
52
|
+
this.setState({
|
|
53
|
+
hasError: false,
|
|
54
|
+
error: null,
|
|
55
|
+
errorInfo: null
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
render() {
|
|
60
|
+
if (this.state.hasError) {
|
|
61
|
+
return (
|
|
62
|
+
<View style={styles.container}>
|
|
63
|
+
<ScrollView style={styles.scrollView} contentContainerStyle={styles.contentContainer}>
|
|
64
|
+
<Text style={styles.title}>⚠️ Something went wrong</Text>
|
|
65
|
+
|
|
66
|
+
<Text style={styles.message}>
|
|
67
|
+
The app encountered an unexpected error. Please try restarting.
|
|
68
|
+
</Text>
|
|
69
|
+
|
|
70
|
+
{this.state.error && (
|
|
71
|
+
<View style={styles.errorBox}>
|
|
72
|
+
<Text style={styles.errorTitle}>Error:</Text>
|
|
73
|
+
<Text style={styles.errorText}>{this.state.error.toString()}</Text>
|
|
74
|
+
</View>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{this.state.errorInfo && (
|
|
78
|
+
<View style={styles.errorBox}>
|
|
79
|
+
<Text style={styles.errorTitle}>Stack Trace:</Text>
|
|
80
|
+
<Text style={styles.errorText}>
|
|
81
|
+
{this.state.errorInfo.componentStack}
|
|
82
|
+
</Text>
|
|
83
|
+
</View>
|
|
84
|
+
)}
|
|
85
|
+
|
|
86
|
+
<TouchableOpacity style={styles.button} onPress={this.resetError}>
|
|
87
|
+
<Text style={styles.buttonText}>Try Again</Text>
|
|
88
|
+
</TouchableOpacity>
|
|
89
|
+
</ScrollView>
|
|
90
|
+
</View>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return this.props.children
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const styles = StyleSheet.create({
|
|
99
|
+
container: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
backgroundColor: '#1a1a1a'
|
|
102
|
+
},
|
|
103
|
+
scrollView: {
|
|
104
|
+
flex: 1
|
|
105
|
+
},
|
|
106
|
+
contentContainer: {
|
|
107
|
+
padding: 20,
|
|
108
|
+
paddingTop: 60
|
|
109
|
+
},
|
|
110
|
+
title: {
|
|
111
|
+
fontSize: 24,
|
|
112
|
+
fontWeight: 'bold',
|
|
113
|
+
color: '#ff6b6b',
|
|
114
|
+
marginBottom: 16
|
|
115
|
+
},
|
|
116
|
+
message: {
|
|
117
|
+
fontSize: 16,
|
|
118
|
+
color: '#ffffff',
|
|
119
|
+
marginBottom: 24,
|
|
120
|
+
lineHeight: 24
|
|
121
|
+
},
|
|
122
|
+
errorBox: {
|
|
123
|
+
backgroundColor: '#2d2d2d',
|
|
124
|
+
padding: 16,
|
|
125
|
+
borderRadius: 8,
|
|
126
|
+
marginBottom: 16,
|
|
127
|
+
borderLeftWidth: 4,
|
|
128
|
+
borderLeftColor: '#ff6b6b'
|
|
129
|
+
},
|
|
130
|
+
errorTitle: {
|
|
131
|
+
fontSize: 14,
|
|
132
|
+
fontWeight: 'bold',
|
|
133
|
+
color: '#ff6b6b',
|
|
134
|
+
marginBottom: 8
|
|
135
|
+
},
|
|
136
|
+
errorText: {
|
|
137
|
+
fontSize: 12,
|
|
138
|
+
color: '#cccccc',
|
|
139
|
+
fontFamily: 'monospace',
|
|
140
|
+
lineHeight: 18
|
|
141
|
+
},
|
|
142
|
+
button: {
|
|
143
|
+
backgroundColor: '#4CAF50',
|
|
144
|
+
padding: 16,
|
|
145
|
+
borderRadius: 8,
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
marginTop: 16
|
|
148
|
+
},
|
|
149
|
+
buttonText: {
|
|
150
|
+
color: '#ffffff',
|
|
151
|
+
fontSize: 16,
|
|
152
|
+
fontWeight: 'bold'
|
|
153
|
+
}
|
|
154
|
+
})
|