@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.
Files changed (240) hide show
  1. package/LICENSE.txt +28 -0
  2. package/README.md +512 -0
  3. package/assets/sounds/payment-receive.wav +0 -0
  4. package/assets/sounds/payment-send.wav +0 -0
  5. package/assets/sounds/vault-close.wav +0 -0
  6. package/assets/sounds/vault-open.wav +0 -0
  7. package/core/amountFormatHelpers.ts +330 -0
  8. package/core/backup/RemoteSyncReader.ts +94 -0
  9. package/core/backup/client.ts +111 -0
  10. package/core/backup/codec.ts +218 -0
  11. package/core/backup/constants.ts +88 -0
  12. package/core/backup/cursor.ts +138 -0
  13. package/core/backup/derive.ts +46 -0
  14. package/core/backup/deviceId.ts +33 -0
  15. package/core/backup/erase.ts +67 -0
  16. package/core/backup/preference.ts +33 -0
  17. package/core/backup/push.ts +295 -0
  18. package/core/backup/restore.ts +152 -0
  19. package/core/backup/restoreOnImport.ts +119 -0
  20. package/core/backup/status.ts +46 -0
  21. package/core/config.tsx +47 -0
  22. package/core/constants.ts +35 -0
  23. package/core/context/ExchangeRateContext.tsx +69 -0
  24. package/core/context/LocalStorageProvider.tsx +225 -0
  25. package/core/context/UserContext.tsx +129 -0
  26. package/core/context/VaultContext.tsx +79 -0
  27. package/core/context/WalletConnectionContext.tsx +454 -0
  28. package/core/context/WalletContext.tsx +2938 -0
  29. package/core/context/buildGeneration.ts +37 -0
  30. package/core/deviceTier.ts +89 -0
  31. package/core/diskSpace.ts +62 -0
  32. package/core/displayCurrencies.ts +56 -0
  33. package/core/headers/OfflineFirstChaintracks.ts +176 -0
  34. package/core/headers/checkpoints.ts +39 -0
  35. package/core/headers/fs.ts +119 -0
  36. package/core/headers/headerStore.ts +333 -0
  37. package/core/headers/prewarm.ts +36 -0
  38. package/core/headers/syncHeaders.ts +73 -0
  39. package/core/hooks/useConfirmationSound.ts +135 -0
  40. package/core/hooks/useHaptics.ts +51 -0
  41. package/core/hooks/usePermissionQueue.ts +69 -0
  42. package/core/i18n/translations.tsx +6692 -0
  43. package/core/index.ts +295 -0
  44. package/core/localpay/blePermissions.ts +32 -0
  45. package/core/localpay/build.ts +392 -0
  46. package/core/localpay/codec.ts +338 -0
  47. package/core/localpay/deviceCaps.ts +175 -0
  48. package/core/localpay/nearbyAdvisory.ts +32 -0
  49. package/core/localpay/nearbyPermissions.ts +34 -0
  50. package/core/localpay/pending.ts +385 -0
  51. package/core/localpay/pendingAborts.ts +67 -0
  52. package/core/localpay/qr.ts +16 -0
  53. package/core/localpay/session.ts +277 -0
  54. package/core/localpay/sessionPolicy.ts +5 -0
  55. package/core/localpay/transport/awdl.ts +11 -0
  56. package/core/localpay/transport/ble.ts +159 -0
  57. package/core/localpay/transport/nearby.ts +12 -0
  58. package/core/localpay/transport/race.ts +110 -0
  59. package/core/localpay/transport/select.ts +128 -0
  60. package/core/localpay/transport/socket.ts +244 -0
  61. package/core/localpay/types.ts +82 -0
  62. package/core/localpay/verify.ts +204 -0
  63. package/core/logging.config.ts +10 -0
  64. package/core/logging.ts +77 -0
  65. package/core/mnemonicWallet.ts +180 -0
  66. package/core/monitor/TaskBackupPush.ts +168 -0
  67. package/core/monitor/TaskCreditInbox.ts +116 -0
  68. package/core/monitor/TaskDrainOutbox.ts +122 -0
  69. package/core/monitor/TaskSendOffline.ts +123 -0
  70. package/core/monitor/unfailRetry.ts +116 -0
  71. package/core/net/chainMatch.ts +34 -0
  72. package/core/net/online.ts +34 -0
  73. package/core/offline/cancelParked.ts +56 -0
  74. package/core/offline/hold.ts +127 -0
  75. package/core/offline/order.ts +109 -0
  76. package/core/offline/payerHold.ts +144 -0
  77. package/core/offline/plan.ts +264 -0
  78. package/core/offline/queueGrace.ts +52 -0
  79. package/core/parsePeerPayURI.ts +119 -0
  80. package/core/pay/beefRepair.ts +106 -0
  81. package/core/pay/creditErrors.ts +46 -0
  82. package/core/pay/creditInbox.ts +202 -0
  83. package/core/pay/damagedInbox.ts +64 -0
  84. package/core/pay/proofNudge.ts +23 -0
  85. package/core/pay/provenTxFromBump.ts +31 -0
  86. package/core/pay/rails/address.ts +329 -0
  87. package/core/pay/rails/handle.ts +617 -0
  88. package/core/pay/rails/index.ts +197 -0
  89. package/core/pay/rails/nearby.ts +79 -0
  90. package/core/pay/receiveFocus.ts +13 -0
  91. package/core/pay/recordProof.ts +91 -0
  92. package/core/pay/refreshProofGuard.ts +34 -0
  93. package/core/pay/sweeper.ts +75 -0
  94. package/core/pay/tokenAmount.ts +18 -0
  95. package/core/pay/userError.ts +18 -0
  96. package/core/pay/watchlist.ts +126 -0
  97. package/core/peerpay/control.ts +122 -0
  98. package/core/peerpay/handleResendRequests.ts +475 -0
  99. package/core/peerpay/inboxAttempts.ts +33 -0
  100. package/core/peerpay/metadataDecryptor.ts +42 -0
  101. package/core/peerpay/offlineNacks.ts +96 -0
  102. package/core/peerpay/outbox.ts +209 -0
  103. package/core/peerpay/rebuildToken.ts +76 -0
  104. package/core/peerpay/resendBeef.ts +115 -0
  105. package/core/services/arcadeBroadcastProvider.ts +214 -0
  106. package/core/services/capWalletArgs.ts +99 -0
  107. package/core/services/exchangeRate.ts +63 -0
  108. package/core/services/secrets/envelope.ts +102 -0
  109. package/core/services/secrets/hkdf.ts +37 -0
  110. package/core/services/secrets/index.ts +63 -0
  111. package/core/services/secrets/kek.ts +274 -0
  112. package/core/services/secrets/migration.ts +188 -0
  113. package/core/services/secrets/policy.ts +120 -0
  114. package/core/services/secrets/storage.ts +54 -0
  115. package/core/services/secrets/store.ts +125 -0
  116. package/core/services/secrets/types.ts +85 -0
  117. package/core/services/usdFxRates.ts +101 -0
  118. package/core/services/vault/VaultKeyService.ts +312 -0
  119. package/core/services/vault/backupAttestation.ts +136 -0
  120. package/core/services/vault/ceremony.ts +972 -0
  121. package/core/services/vault/ceremonyHost.ts +46 -0
  122. package/core/services/vault/devMock.ts +22 -0
  123. package/core/services/vault/driver.ts +197 -0
  124. package/core/services/vault/guard.ts +90 -0
  125. package/core/services/vault/k1.ts +75 -0
  126. package/core/services/vault/mockYubiKey.ts +217 -0
  127. package/core/services/vault/random.ts +20 -0
  128. package/core/services/vault/sealing.ts +84 -0
  129. package/core/services/vault/session.ts +59 -0
  130. package/core/services/vault/transfers.ts +1151 -0
  131. package/core/services/vault/types.ts +109 -0
  132. package/core/services/vault/vaultDerivation.ts +152 -0
  133. package/core/services/vault/vaultPassphrase.ts +287 -0
  134. package/core/services/vault/vaultStore.ts +104 -0
  135. package/core/services/walletArgLimits.ts +234 -0
  136. package/core/services/walletServiceConfig.ts +170 -0
  137. package/core/storage/LocalStorageAdapter.ts +58 -0
  138. package/core/storage/README.md +391 -0
  139. package/core/storage/StorageExpoSQLite.ts +2008 -0
  140. package/core/storage/errors.ts +73 -0
  141. package/core/storage/index.ts +3 -0
  142. package/core/storage/methods/findSql.ts +286 -0
  143. package/core/storage/methods/historyNotes.ts +61 -0
  144. package/core/storage/methods/listActionsSql.ts +212 -0
  145. package/core/storage/methods/listOutputsSql.ts +211 -0
  146. package/core/storage/methods/offlineActions.ts +156 -0
  147. package/core/storage/methods/processOfflineActions.ts +503 -0
  148. package/core/storage/methods/reclaim.ts +135 -0
  149. package/core/storage/methods/reviewStatusSql.ts +167 -0
  150. package/core/storage/methods/unprovenWithoutReqSql.ts +26 -0
  151. package/core/storage/methods/walletBalanceSql.ts +55 -0
  152. package/core/storage/schema/createTables.ts +385 -0
  153. package/core/storage/skipQueuedAncestors.ts +29 -0
  154. package/core/storage/sqlUpdateValue.ts +12 -0
  155. package/core/stores/ConnectionStore.ts +71 -0
  156. package/core/theme/ThemeContext.tsx +182 -0
  157. package/core/theme/assertThemeContrast.ts +109 -0
  158. package/core/theme/motion.ts +50 -0
  159. package/core/theme/tokens.ts +232 -0
  160. package/core/theme/useThemeStyles.tsx +156 -0
  161. package/core/walletDbRegistry.ts +110 -0
  162. package/core/walletMonitor.ts +149 -0
  163. package/core/walletRepair/runWalletCheck.ts +195 -0
  164. package/core/walletRepair/shouldReleaseUtxo.ts +18 -0
  165. package/package.json +86 -0
  166. package/ui/backupShares.ts +367 -0
  167. package/ui/components/QRScanner.tsx +353 -0
  168. package/ui/components/pay/AddressReceive.tsx +507 -0
  169. package/ui/components/pay/AvailableBalance.tsx +61 -0
  170. package/ui/components/pay/HandleReceive.tsx +896 -0
  171. package/ui/components/pay/MessageBoxConfig.tsx +256 -0
  172. package/ui/components/pay/NearbyAdvisoryModal.tsx +111 -0
  173. package/ui/components/pay/NearbyFlow.tsx +2542 -0
  174. package/ui/components/pay/OfflineNotice.tsx +337 -0
  175. package/ui/components/pay/PayCellRow.tsx +101 -0
  176. package/ui/components/pay/PayForm.tsx +223 -0
  177. package/ui/components/pay/PaymentQrDisplay.tsx +105 -0
  178. package/ui/components/pay/PaymentSuccessOverlay.tsx +266 -0
  179. package/ui/components/pay/RecipientField.tsx +308 -0
  180. package/ui/components/pay/RequestHub.tsx +75 -0
  181. package/ui/components/pay/ResultBanner.tsx +69 -0
  182. package/ui/components/pay/UniversalSend.tsx +687 -0
  183. package/ui/components/pay/useRecipientInput.ts +270 -0
  184. package/ui/components/security/WalletLockNotice.tsx +138 -0
  185. package/ui/components/ui/AlertCard.tsx +223 -0
  186. package/ui/components/ui/AppLogo.tsx +166 -0
  187. package/ui/components/ui/BlurChrome.tsx +72 -0
  188. package/ui/components/ui/Celebration.tsx +84 -0
  189. package/ui/components/ui/ChoiceSheet.ts +69 -0
  190. package/ui/components/ui/CustomSafeArea.tsx +74 -0
  191. package/ui/components/ui/ErrorBoundary.tsx +154 -0
  192. package/ui/components/ui/GroupedList.tsx +125 -0
  193. package/ui/components/ui/IconButton.tsx +105 -0
  194. package/ui/components/ui/ListRow.tsx +197 -0
  195. package/ui/components/ui/PermissionSheet.tsx +920 -0
  196. package/ui/components/ui/PresenceRow.tsx +215 -0
  197. package/ui/components/ui/PressableScale.tsx +105 -0
  198. package/ui/components/ui/ScreenGradient.tsx +47 -0
  199. package/ui/components/ui/ScrollFade.tsx +76 -0
  200. package/ui/components/ui/Sheet.tsx +342 -0
  201. package/ui/components/ui/Toast.tsx +142 -0
  202. package/ui/components/ui/index.ts +8 -0
  203. package/ui/components/vault/EnrollWizard.tsx +627 -0
  204. package/ui/components/vault/PassphraseField.tsx +306 -0
  205. package/ui/components/vault/PhraseBackupSheet.tsx +227 -0
  206. package/ui/components/vault/VaultBackdrop.tsx +354 -0
  207. package/ui/components/vault/VaultCeremonySheet.tsx +327 -0
  208. package/ui/components/wallet/ActivityRow.tsx +408 -0
  209. package/ui/components/wallet/AmountDisplay.tsx +48 -0
  210. package/ui/components/wallet/AmountInput.tsx +256 -0
  211. package/ui/components/wallet/BackupReminderSheet.tsx +168 -0
  212. package/ui/components/wallet/Balance.tsx +144 -0
  213. package/ui/components/wallet/BiometricAdvisoryModal.tsx +133 -0
  214. package/ui/components/wallet/ImportFromBackupPrompt.tsx +93 -0
  215. package/ui/exportDatabases.ts +122 -0
  216. package/ui/exportTransactions.ts +129 -0
  217. package/ui/hooks/useOfflineNoticeActions.ts +136 -0
  218. package/ui/hooks/useOnline.ts +70 -0
  219. package/ui/hooks/useSpendableBalance.ts +58 -0
  220. package/ui/hooks/useVaultBalance.ts +50 -0
  221. package/ui/importDatabases.ts +170 -0
  222. package/ui/index.ts +136 -0
  223. package/ui/isImageUrl.ts +10 -0
  224. package/ui/printRecoveryShares.ts +93 -0
  225. package/ui/resolveIdentity.ts +125 -0
  226. package/ui/screens/ConnectionsScreen.tsx +438 -0
  227. package/ui/screens/LogsScreen.tsx +432 -0
  228. package/ui/screens/PairScreen.tsx +288 -0
  229. package/ui/screens/PayScreen.tsx +479 -0
  230. package/ui/screens/SettingsScreen.tsx +180 -0
  231. package/ui/screens/TrustScreen.tsx +831 -0
  232. package/ui/screens/VaultRecoverScreen.tsx +226 -0
  233. package/ui/screens/VaultScreen.tsx +423 -0
  234. package/ui/screens/VaultTransferScreen.tsx +293 -0
  235. package/ui/screens/WalletCheckScreen.tsx +539 -0
  236. package/ui/screens/WalletConfigScreen.tsx +1095 -0
  237. package/ui/screens/WalletHomeScreen.tsx +1597 -0
  238. package/ui/screens/homeBadges.ts +18 -0
  239. package/ui/txStatus.ts +79 -0
  240. package/ui/validateTrust.ts +44 -0
@@ -0,0 +1,125 @@
1
+ import React from 'react'
2
+ import { StyleSheet, Text, View } from 'react-native'
3
+ import { useTheme, spacing, radii, typography } from '@bsv/expo-wallet-toolbox'
4
+
5
+ interface GroupedListSection {
6
+ header?: string
7
+ footer?: string
8
+ children: React.ReactNode
9
+ }
10
+
11
+ interface GroupedListProps {
12
+ sections: GroupedListSection[]
13
+ }
14
+
15
+ /**
16
+ * iOS-style grouped inset list with section headers and footers.
17
+ * Wraps children in rounded, elevated containers on the
18
+ * secondary background.
19
+ */
20
+ export const GroupedList: React.FC<GroupedListProps> = ({ sections }) => {
21
+ const { colors } = useTheme()
22
+
23
+ return (
24
+ <View style={styles.container}>
25
+ {sections.map((section, idx) => (
26
+ <View key={idx} style={styles.section}>
27
+ {section.header && (
28
+ <Text style={[styles.header, { color: colors.textTertiary }]}>
29
+ {section.header.toUpperCase()}
30
+ </Text>
31
+ )}
32
+ <View
33
+ style={[
34
+ styles.group,
35
+ {
36
+ backgroundColor: colors.backgroundElevated,
37
+ borderColor: colors.separator,
38
+ }
39
+ ]}
40
+ >
41
+ {section.children}
42
+ </View>
43
+ {section.footer && (
44
+ <Text style={[styles.footer, { color: colors.textTertiary }]}>
45
+ {section.footer}
46
+ </Text>
47
+ )}
48
+ </View>
49
+ ))}
50
+ </View>
51
+ )
52
+ }
53
+
54
+ /**
55
+ * Standalone section for inline use without the GroupedList wrapper.
56
+ */
57
+ export const GroupedSection: React.FC<GroupedListSection> = ({
58
+ header,
59
+ footer,
60
+ children
61
+ }) => {
62
+ const { colors } = useTheme()
63
+
64
+ return (
65
+ <View style={styles.section}>
66
+ {header && (
67
+ <Text style={[styles.header, { color: colors.textTertiary }]}>
68
+ {header.toUpperCase()}
69
+ </Text>
70
+ )}
71
+ <View
72
+ style={[
73
+ styles.group,
74
+ {
75
+ backgroundColor: colors.backgroundElevated,
76
+ borderColor: colors.separator,
77
+ }
78
+ ]}
79
+ >
80
+ {children}
81
+ </View>
82
+ {footer && (
83
+ <Text style={[styles.footer, { color: colors.textTertiary }]}>
84
+ {footer}
85
+ </Text>
86
+ )}
87
+ </View>
88
+ )
89
+ }
90
+
91
+ const styles = StyleSheet.create({
92
+ container: {
93
+ flex: 1,
94
+ },
95
+ section: {
96
+ marginBottom: spacing.xxl,
97
+ },
98
+ // Tracked small caps, matching the day headings in the activity list — a
99
+ // section header is a label for the block under it, not a line of prose.
100
+ header: {
101
+ fontSize: 10.5,
102
+ fontWeight: '700',
103
+ letterSpacing: 1.3,
104
+ paddingHorizontal: spacing.xl,
105
+ paddingBottom: spacing.sm,
106
+ },
107
+ // A card lifted off the canvas: the border does the work in dark, the shadow
108
+ // in light, and the radius says "object" in both.
109
+ group: {
110
+ borderRadius: radii.lg,
111
+ marginHorizontal: spacing.lg,
112
+ borderWidth: StyleSheet.hairlineWidth,
113
+ overflow: 'hidden',
114
+ shadowColor: '#000',
115
+ shadowOpacity: 0.05,
116
+ shadowRadius: 3,
117
+ shadowOffset: { width: 0, height: 1 },
118
+ elevation: 1,
119
+ },
120
+ footer: {
121
+ ...typography.footnote,
122
+ paddingHorizontal: spacing.xl,
123
+ paddingTop: spacing.sm,
124
+ },
125
+ })
@@ -0,0 +1,105 @@
1
+ import React from 'react'
2
+ import { StyleSheet, Text, View } from 'react-native'
3
+ import { useTheme, hitTargets } from '@bsv/expo-wallet-toolbox'
4
+ import PressableScale from './PressableScale'
5
+
6
+ /**
7
+ * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
8
+ * etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
9
+ * that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
10
+ * Ionicons is loaded lazily, only when actually rendering, same pattern as
11
+ * this package's other native-module-boundary fixes (expo-router, expo-blur).
12
+ */
13
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
14
+ let ioniconsComponent: IoniconsComponent | undefined
15
+ function loadIonicons(): IoniconsComponent {
16
+ if (!ioniconsComponent) {
17
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
18
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
19
+ }
20
+ return ioniconsComponent
21
+ }
22
+
23
+ interface IconButtonProps {
24
+ name: keyof IoniconsComponent['glyphMap']
25
+ onPress: () => void
26
+ onLongPress?: () => void
27
+ size?: number
28
+ color?: string
29
+ disabled?: boolean
30
+ badge?: number | string
31
+ accessibilityLabel?: string
32
+ }
33
+
34
+ /**
35
+ * Minimal icon button with proper 44pt hit target (iOS HIG).
36
+ * Supports an optional numeric badge overlay.
37
+ */
38
+ export const IconButton: React.FC<IconButtonProps> = ({
39
+ name,
40
+ onPress,
41
+ onLongPress,
42
+ size = 22,
43
+ color,
44
+ disabled = false,
45
+ badge,
46
+ accessibilityLabel
47
+ }) => {
48
+ const { colors } = useTheme()
49
+ const iconColor = color ?? colors.accent
50
+ const Ionicons = loadIonicons()
51
+
52
+ return (
53
+ <PressableScale
54
+ onPress={onPress}
55
+ onLongPress={onLongPress}
56
+ disabled={disabled}
57
+ scaleTo={0.92}
58
+ style={[
59
+ styles.container,
60
+ disabled && styles.disabled
61
+ ]}
62
+ accessibilityLabel={accessibilityLabel}
63
+ accessibilityRole="button"
64
+ hitSlop={4}
65
+ >
66
+ <Ionicons name={name} size={size} color={iconColor} />
67
+ {badge !== undefined && (
68
+ <View style={[styles.badge, { backgroundColor: colors.accent }]}>
69
+ {/* The accent inverts between themes, so the count has to ride on
70
+ textOnAccent — a fixed white here is white-on-white in dark. */}
71
+ <Text style={[styles.badgeText, { color: colors.textOnAccent }]}>
72
+ {typeof badge === 'number' && badge > 99 ? '99+' : badge}
73
+ </Text>
74
+ </View>
75
+ )}
76
+ </PressableScale>
77
+ )
78
+ }
79
+
80
+ const styles = StyleSheet.create({
81
+ container: {
82
+ width: hitTargets.minimum,
83
+ height: hitTargets.minimum,
84
+ alignItems: 'center',
85
+ justifyContent: 'center',
86
+ },
87
+ disabled: {
88
+ opacity: 0.3,
89
+ },
90
+ badge: {
91
+ position: 'absolute',
92
+ top: 4,
93
+ right: 4,
94
+ minWidth: 16,
95
+ height: 16,
96
+ borderRadius: 8,
97
+ alignItems: 'center',
98
+ justifyContent: 'center',
99
+ paddingHorizontal: 4,
100
+ },
101
+ badgeText: {
102
+ fontSize: 10,
103
+ fontWeight: '700',
104
+ },
105
+ })
@@ -0,0 +1,197 @@
1
+ import React from 'react'
2
+ import { StyleSheet, Text, View } from 'react-native'
3
+ import { useTheme, spacing, typography } from '@bsv/expo-wallet-toolbox'
4
+ import PressableScale from './PressableScale'
5
+
6
+ /**
7
+ * @expo/vector-icons' index barrel re-exports every icon set (AntDesign,
8
+ * etc.), one of which reaches expo-font -> expo-asset -- untransformed ESM
9
+ * that Jest cannot parse when eagerly pulled in via the `ui` package barrel.
10
+ * Both icon sets are loaded lazily, only when actually rendering, same
11
+ * pattern as this package's other native-module-boundary fixes (expo-router,
12
+ * expo-blur).
13
+ */
14
+ type IoniconsComponent = typeof import('@expo/vector-icons').Ionicons
15
+ type MaterialCommunityIconsComponent = typeof import('@expo/vector-icons').MaterialCommunityIcons
16
+ let ioniconsComponent: IoniconsComponent | undefined
17
+ let materialCommunityIconsComponent: MaterialCommunityIconsComponent | undefined
18
+ function loadIonicons(): IoniconsComponent {
19
+ if (!ioniconsComponent) {
20
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
21
+ ioniconsComponent = require('@expo/vector-icons').Ionicons as IoniconsComponent
22
+ }
23
+ return ioniconsComponent
24
+ }
25
+ function loadMaterialCommunityIcons(): MaterialCommunityIconsComponent {
26
+ if (!materialCommunityIconsComponent) {
27
+ materialCommunityIconsComponent = require('@expo/vector-icons')
28
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
29
+ .MaterialCommunityIcons as MaterialCommunityIconsComponent
30
+ }
31
+ return materialCommunityIconsComponent
32
+ }
33
+
34
+ interface ListRowProps {
35
+ label: string
36
+ /** Secondary line under the label. Settings rows use this for the explaining copy. */
37
+ subtitle?: string
38
+ value?: string
39
+ /** Ionicons name by default; a MaterialCommunityIcons name when
40
+ * `iconFamily="material-community"`. */
41
+ icon?: keyof IoniconsComponent['glyphMap'] | keyof MaterialCommunityIconsComponent['glyphMap']
42
+ /** Ionicons covers almost everything here, but a few concepts have no glyph
43
+ * in it (e.g. a bank vault — `lock-closed` reads as a generic padlock).
44
+ * Opt into MaterialCommunityIcons per row for those. */
45
+ iconFamily?: 'ionicons' | 'material-community'
46
+ iconColor?: string
47
+ onPress?: () => void
48
+ showChevron?: boolean
49
+ chevronDown?: boolean
50
+ destructive?: boolean
51
+ trailing?: React.ReactNode
52
+ isLast?: boolean
53
+ }
54
+
55
+ /**
56
+ * Standard row for iOS-style grouped lists.
57
+ * Shows icon (optional), label, value/trailing, and chevron.
58
+ */
59
+ export const ListRow: React.FC<ListRowProps> = ({
60
+ label,
61
+ subtitle,
62
+ value,
63
+ icon,
64
+ iconFamily = 'ionicons',
65
+ iconColor,
66
+ onPress,
67
+ showChevron = true,
68
+ chevronDown = false,
69
+ destructive = false,
70
+ trailing,
71
+ isLast = false
72
+ }) => {
73
+ const { colors } = useTheme()
74
+ const Ionicons = loadIonicons()
75
+ const MaterialCommunityIcons = loadMaterialCommunityIcons()
76
+
77
+ const content = (
78
+ <View style={[styles.container, !isLast && { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: colors.separator }]}>
79
+ {icon && (
80
+ <View
81
+ style={[
82
+ styles.iconContainer,
83
+ iconColor
84
+ ? { backgroundColor: iconColor + '1A', borderColor: iconColor + '2E' }
85
+ : { backgroundColor: colors.surfaceSunken, borderColor: colors.surfaceSunkenBorder }
86
+ ]}
87
+ >
88
+ {iconFamily === 'material-community' ? (
89
+ <MaterialCommunityIcons
90
+ name={icon as keyof typeof MaterialCommunityIcons.glyphMap}
91
+ size={17}
92
+ color={iconColor || colors.textSecondary}
93
+ />
94
+ ) : (
95
+ <Ionicons
96
+ name={icon as keyof typeof Ionicons.glyphMap}
97
+ size={17}
98
+ color={iconColor || colors.textSecondary}
99
+ />
100
+ )}
101
+ </View>
102
+ )}
103
+ <View style={styles.textColumn}>
104
+ <Text
105
+ style={[
106
+ styles.label,
107
+ { color: destructive ? colors.error : colors.textPrimary }
108
+ ]}
109
+ numberOfLines={1}
110
+ >
111
+ {label}
112
+ </Text>
113
+ {subtitle ? (
114
+ <Text style={[styles.subtitle, { color: colors.textSecondary }]} numberOfLines={2}>
115
+ {subtitle}
116
+ </Text>
117
+ ) : null}
118
+ </View>
119
+ <View style={styles.trailing}>
120
+ {trailing}
121
+ {value && !trailing && (
122
+ <Text style={[styles.value, { color: colors.textSecondary }]} numberOfLines={1}>
123
+ {value}
124
+ </Text>
125
+ )}
126
+ {showChevron && onPress && !destructive && (
127
+ <Ionicons
128
+ name={chevronDown ? 'chevron-down' : 'chevron-forward'}
129
+ size={18}
130
+ color={colors.textQuaternary}
131
+ style={styles.chevron}
132
+ />
133
+ )}
134
+ </View>
135
+ </View>
136
+ )
137
+
138
+ if (onPress) {
139
+ return (
140
+ <PressableScale
141
+ onPress={onPress}
142
+ scaleTo={0.98}
143
+ haptic="tap"
144
+ >
145
+ {content}
146
+ </PressableScale>
147
+ )
148
+ }
149
+
150
+ return content
151
+ }
152
+
153
+ const styles = StyleSheet.create({
154
+ container: {
155
+ flexDirection: 'row',
156
+ alignItems: 'center',
157
+ minHeight: 44,
158
+ paddingVertical: spacing.md,
159
+ paddingHorizontal: spacing.lg,
160
+ },
161
+ // A well the glyph sits in, tinted by the row's own colour rather than
162
+ // flooded with it. A grid of saturated tiles reads as decoration and makes
163
+ // every row shout equally; the tint keeps the category cue and drops the
164
+ // shouting.
165
+ iconContainer: {
166
+ width: 28,
167
+ height: 28,
168
+ borderRadius: 9,
169
+ borderWidth: StyleSheet.hairlineWidth,
170
+ alignItems: 'center',
171
+ justifyContent: 'center',
172
+ marginRight: spacing.md,
173
+ },
174
+ textColumn: {
175
+ flex: 1,
176
+ },
177
+ label: {
178
+ ...typography.body,
179
+ },
180
+ subtitle: {
181
+ ...typography.footnote,
182
+ marginTop: 1,
183
+ },
184
+ trailing: {
185
+ flexDirection: 'row',
186
+ alignItems: 'center',
187
+ flexShrink: 0,
188
+ marginLeft: spacing.sm,
189
+ },
190
+ value: {
191
+ ...typography.body,
192
+ maxWidth: 200,
193
+ },
194
+ chevron: {
195
+ marginLeft: spacing.xs,
196
+ },
197
+ })