From 52441c1d63740e82a0699247115aad2bd173885c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:45:28 +0000 Subject: [PATCH 01/10] Update dependency react-native-svg to v15.11.1 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37c6db35c..af4b73db4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,7 +91,7 @@ "react-native-screens": "3.35.0", "react-native-secure-key-store": "github:BlueWallet/react-native-secure-key-store#2076b4849e88aa0a78e08bfbb4ce3923e0925cbc", "react-native-share": "11.1.0", - "react-native-svg": "15.10.1", + "react-native-svg": "15.11.1", "react-native-tcp-socket": "6.2.0", "react-native-vector-icons": "10.2.0", "react-native-watch-connectivity": "1.1.0", @@ -22299,9 +22299,9 @@ } }, "node_modules/react-native-svg": { - "version": "15.10.1", - "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-15.10.1.tgz", - "integrity": "sha512-Hqz/doQciVFK/Df2v+wsW96oY5jxlta7rZ31KQYo78dlgvAHEaGr6paEOAMvlIruw7EHNQ0Vc1ZmJPJF2kfIPQ==", + "version": "15.11.1", + "resolved": "https://registry.npmjs.org/react-native-svg/-/react-native-svg-15.11.1.tgz", + "integrity": "sha512-Qmwx/yJKt+AHUr4zjxx/Q69qwKtRfr1+uIfFMQoq3WFRhqU76aL9db1DyvPiY632DAsVGba1pHf92OZPkpjrdQ==", "license": "MIT", "dependencies": { "css-select": "^5.1.0", diff --git a/package.json b/package.json index e58d8aaba..30a0d6692 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,7 @@ "react-native-screens": "3.35.0", "react-native-secure-key-store": "github:BlueWallet/react-native-secure-key-store#2076b4849e88aa0a78e08bfbb4ce3923e0925cbc", "react-native-share": "11.1.0", - "react-native-svg": "15.10.1", + "react-native-svg": "15.11.1", "react-native-tcp-socket": "6.2.0", "react-native-vector-icons": "10.2.0", "react-native-watch-connectivity": "1.1.0", From 32e2fc6ca34b2fa36f7d555b5eb5b3d6ffafbe1a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:58:02 +0000 Subject: [PATCH 02/10] Update dependency react-native-gesture-handler to v2.22.0 --- package-lock.json | 11 +++++------ package.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9a44460e8..71ef050c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,7 +70,7 @@ "react-native-document-picker": "9.3.1", "react-native-draglist": "github:BlueWallet/react-native-draglist#a4af02f", "react-native-fs": "2.20.0", - "react-native-gesture-handler": "2.21.2", + "react-native-gesture-handler": "2.22.0", "react-native-handoff": "github:BlueWallet/react-native-handoff#v0.0.4", "react-native-haptic-feedback": "2.3.3", "react-native-image-picker": "7.2.2", @@ -22019,15 +22019,14 @@ } }, "node_modules/react-native-gesture-handler": { - "version": "2.21.2", - "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.21.2.tgz", - "integrity": "sha512-HcwB225K9aeZ8e/B8nFzEh+2T4EPWTeamO1l/y3PcQ9cyCDYO2zja/G31ITpYRIqkip7XzGs6wI/gnHOQn1LDQ==", + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/react-native-gesture-handler/-/react-native-gesture-handler-2.22.0.tgz", + "integrity": "sha512-m5Ps1cOSxSiMP4re+XsbeWcC9DNJuIEjMSmtUxBdyfYEJtdu5iAAiX7KlHHrf2mnK4I/56Ncy4PvPKWBwSpWpQ==", "license": "MIT", "dependencies": { "@egjs/hammerjs": "^2.0.17", "hoist-non-react-statics": "^3.3.0", - "invariant": "^2.2.4", - "prop-types": "^15.7.2" + "invariant": "^2.2.4" }, "peerDependencies": { "react": "*", diff --git a/package.json b/package.json index dc2cf5140..073fb218f 100644 --- a/package.json +++ b/package.json @@ -134,7 +134,7 @@ "react-native-document-picker": "9.3.1", "react-native-draglist": "github:BlueWallet/react-native-draglist#a4af02f", "react-native-fs": "2.20.0", - "react-native-gesture-handler": "2.21.2", + "react-native-gesture-handler": "2.22.0", "react-native-handoff": "github:BlueWallet/react-native-handoff#v0.0.4", "react-native-haptic-feedback": "2.3.3", "react-native-image-picker": "7.2.2", From 16a8e7ae6187ed0a77a7998546e887b2a82ae990 Mon Sep 17 00:00:00 2001 From: "transifex-integration[bot]" <43880903+transifex-integration[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 13:37:41 +0000 Subject: [PATCH 03/10] Translate loc/en.json in pl 100% reviewed source file: 'loc/en.json' on 'pl'. --- loc/pl.json | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/loc/pl.json b/loc/pl.json index 217493e5d..771451015 100644 --- a/loc/pl.json +++ b/loc/pl.json @@ -28,6 +28,8 @@ "enter_amount": "Wprowadź kwotę", "qr_custom_input_button": "Stuknij 10 razy, aby wprowadzić niestandardowe dane", "unlock": "Odblokuj", + "port": "Port", + "ssl_port": "Port SSL", "suggested": "Sugerowane" }, "azteco": { @@ -74,6 +76,7 @@ "please_pay": "Proszę zapłać", "preimage": "Obraz pierwotny", "sats": "satoshi.", + "date_time": "Data i czas", "wasnt_paid_and_expired": "Ta faktura nie została opłacona i przeterminowała się." }, "plausibledeniability": { @@ -190,7 +193,7 @@ "outdated_rate": "Ostatnia aktualizacja kursu: {date}", "psbt_tx_open": "Otwórz podpisaną transakcję", "psbt_tx_scan": "Skanuj Podpisane Transakcje", - "qr_error_no_qrcode": "Nie udało nam się znaleźć kodu QR na wybranym obrazie. Upewnij się, że obraz zawiera tylko kod QR bez dodatkowych treści, takich jak tekst czy przyciski.", + "qr_error_no_qrcode": "Nie udało nam się znaleźć prawidłowego kodu QR w wybranym obrazie. Upewnij się, że obraz zawiera tylko kod QR i nie ma dodatkowych elementów, takich jak tekst lub przyciski.", "reset_amount": "Resetuj ilość", "reset_amount_confirm": "Czy chcesz zresetować ilość?", "success_done": "Zrobione", @@ -250,15 +253,10 @@ "electrum_status": "Status", "electrum_preferred_server": "Preferowany serwer", "electrum_preferred_server_description": "Wprowadź serwer, którego ma używać twój portfel do wszystkich operacji związanych z Bitcoinem. Po zapisaniu ustawień, portfel będzie korzystał wyłącznie z tego serwera do sprawdzania sald, wysyłania transakcji oraz pobierania danych z sieci. Upewnij się, że masz zaufanie do tego serwera przed jego wyborem.", - "electrum_clear_alert_title": "Wyczyścić historię?", - "electrum_clear_alert_message": "Czy chcesz wyczyścić historię serwerów Electrum?", - "electrum_clear_alert_cancel": "Anuluj", - "electrum_clear_alert_ok": "Ok", - "electrum_reset": "Ustaw wartości domyślne", "electrum_unable_to_connect": "Nie można się połączyć z {server}.", "electrum_history": "Historia", - "electrum_reset_to_default": "Czy na pewno ustawić domyślne ustawienia Electrum?", - "electrum_clear": "Wyczyść historię", + "electrum_reset_to_default": "To pozwoli BlueWallet losowo wybrać serwer z sugerowanej listy i historii. Historia Twoich serwerów pozostanie niezmieniona.", + "electrum_reset": "Ustaw wartości domyślne", "encrypt_decrypt": "Odszyfruj Magazyn Danych", "encrypt_decrypt_q": "Czy jesteś pewien, że chcesz odszyfrować schowek? To pozwoli na dostęp do twoich portfeli bez hasła.", "encrypt_enc_and_pass": "Szyfrowany i chroniony hasłem", @@ -272,6 +270,8 @@ "encrypt_title": "Zabezpieczenia", "encrypt_tstorage": "Dane", "encrypt_use": "Użyj {type}", + "set_as_preferred": "Ustaw jako preferowany", + "set_as_preferred_electrum": "Ustawienie {host}:{port} jako preferowanego serwera wyłączy losowe łączenie się z sugerowanym serwerem.", "encrypted_feature_disabled": "Ta funkcja nie może być używana z włączonym szyfrowaniem pamięci.", "encrypt_use_expl": "{type} będzie użyty w celu potwierdzenia twojej tożsamości przed wykonaniem transakcji, odblokowaniem, eksportem lub usunięciem portfela. {type} nie będzie użyty do odblokowania danych zaszyfrowanych.", "biometrics_fail": "Jeśli {type} nie jest włączony lub nie udaje się odblokować, możesz alternatywnie użyć kodu dostępu swojego urządzenia.", @@ -291,6 +291,7 @@ "network": "Sieć", "network_broadcast": "Rozgłoś transakcję", "network_electrum": "Serwer Electrum", + "electrum_suggested_description": "Gdy preferowany serwer nie jest ustawiony, sugerowany serwer zostanie wybrany losowo do użycia.", "not_a_valid_uri": "Nieprawidłowy adres", "notifications": "Powiadomienia", "open_link_in_explorer": "Otwórz link w eksploratorze bloków", @@ -654,6 +655,8 @@ "bip47": { "payment_code": "Kod płatności", "contacts": "Kontakty", + "bip47_explain": "Kod wielokrotnego użytku i do udostępnienia.", + "bip47_explain_subtitle": "BIP47", "purpose": "Kod wielokrotnego użytku możliwy do udostępnienia (BIP47)", "pay_this_contact": "Zapłać temu kontaktowi", "rename_contact": "Zmień nazwę kontaktu", @@ -667,7 +670,7 @@ "notification_tx_unconfirmed": "Transakcja powiadomienia nie została jeszcze potwierdzona, proszę czekać", "failed_create_notif_tx": "Nie udało się utworzyć transakcji on-chain", "onchain_tx_needed": "Wymagana transakcja on-chain", - "notif_tx_sent": "Transakcja powiadomienia wysłana. Proszę czekać na jej potwierdzenie", + "notif_tx_sent" : "Transakcja powiadomienia wysłana. Proszę czekać na jej potwierdzenie", "notif_tx": "Transakcja powiadomienia", "not_found": "Kod płatności nie znaleziony" } From bba96e5308e3451c7a5d23bdcbb6308a10bd900d Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sun, 12 Jan 2025 15:55:26 -0400 Subject: [PATCH 04/10] wio --- .../org.eclipse.buildship.core.prefs | 13 ++- android/app/.classpath | 2 +- .../app/.settings/org.eclipse.jdt.core.prefs | 4 + class/wallets/types.ts | 14 +++ hooks/context/useStorage.ts | 19 +++- ios/Podfile.lock | 20 ++-- package-lock.json | 41 ++++++++ package.json | 1 + screen/send/ScanQRCode.js | 99 +++++++++---------- screen/wallets/WalletTransactions.tsx | 4 +- 10 files changed, 151 insertions(+), 66 deletions(-) create mode 100644 android/app/.settings/org.eclipse.jdt.core.prefs diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs index 9d2efc8e7..12ee26f01 100644 --- a/android/.settings/org.eclipse.buildship.core.prefs +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -1,2 +1,13 @@ +arguments=--init-script /var/folders/wp/mctylz615p727_90j3yv0vnc0000gn/T/db3b08fc4a9ef609cb16b96b200fa13e563f396e9bb1ed0905fdab7bc3bc513b.gradle --init-script /var/folders/wp/mctylz615p727_90j3yv0vnc0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle +auto.sync=false +build.scans.enabled=false +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.project.dir= -eclipse.preferences.version=1 \ No newline at end of file +eclipse.preferences.version=1 +gradle.user.home= +java.home=/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home +jvm.arguments= +offline.mode=false +override.workspace.settings=true +show.console.view=true +show.executions.view=true diff --git a/android/app/.classpath b/android/app/.classpath index eb19361b5..bbe97e501 100644 --- a/android/app/.classpath +++ b/android/app/.classpath @@ -1,6 +1,6 @@ - + diff --git a/android/app/.settings/org.eclipse.jdt.core.prefs b/android/app/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..626e0e1d5 --- /dev/null +++ b/android/app/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.source=17 diff --git a/class/wallets/types.ts b/class/wallets/types.ts index 932eddff6..a27f80f53 100644 --- a/class/wallets/types.ts +++ b/class/wallets/types.ts @@ -117,8 +117,16 @@ export type Transaction = { * if known, who is on the other end of the transaction (BIP47 payment code) */ counterparty?: string; + memo: string; }; +export interface Transaction { + hash: string; + memo: string; + value: number; + // ...other transaction fields... +} + /** * in some cases we add additional data to each tx object so the code that works with that transaction can find the * wallet that owns it etc @@ -146,4 +154,10 @@ export type TWallet = | SegwitP2SHWallet | WatchOnlyWallet; +export interface TWallet { + getID: () => string; + getTransactions: () => Transaction[]; + // ...other wallet methods... +} + export type THDWalletForWatchOnly = HDSegwitBech32Wallet | HDSegwitP2SHWallet | HDLegacyP2PKHWallet; diff --git a/hooks/context/useStorage.ts b/hooks/context/useStorage.ts index 4394e3d15..6d9701ba8 100644 --- a/hooks/context/useStorage.ts +++ b/hooks/context/useStorage.ts @@ -1,4 +1,21 @@ import { useContext } from 'react'; import { StorageContext } from '../../components/Context/StorageProvider'; -export const useStorage = () => useContext(StorageContext); +export const useStorage = () => { + const context = useContext(StorageContext); + + const fetchAndSaveWalletTransactions = async (walletID: string) => { + // ...existing implementation to fetch and save transactions... + }; + + const getTransactions = (walletID: string): Transaction[] => { + const wallet = wallets.find(w => w.getID() === walletID); + return wallet ? wallet.getTransactions() : []; + }; + + return { + ...context, + fetchAndSaveWalletTransactions, + getTransactions, + }; +}; diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 608db44a2..000801c0a 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -13,7 +13,7 @@ PODS: - hermes-engine/Pre-built (= 0.75.4) - hermes-engine/Pre-built (0.75.4) - lottie-ios (4.5.0) - - lottie-react-native (7.1.0): + - lottie-react-native (7.2.1): - DoubleConversion - glog - hermes-engine @@ -1613,7 +1613,7 @@ PODS: - React - RNCAsyncStorage (2.1.0): - React-Core - - RNCClipboard (1.15.0): + - RNCClipboard (1.16.0): - React-Core - RNCPushNotificationIOS (1.11.0): - React-Core @@ -1623,7 +1623,7 @@ PODS: - React-Core - RNFS (2.20.0): - React-Core - - RNGestureHandler (2.21.2): + - RNGestureHandler (2.22.0): - DoubleConversion - glog - hermes-engine @@ -1667,7 +1667,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNLocalize (3.3.0): + - RNLocalize (3.4.1): - React-Core - RNPermissions (5.2.2): - React-Core @@ -1829,7 +1829,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNSVG (15.10.1): + - RNSVG (15.11.1): - React-Core - RNVectorIcons (10.2.0): - DoubleConversion @@ -2209,7 +2209,7 @@ SPEC CHECKSUMS: glog: 69ef571f3de08433d766d614c73a9838a06bf7eb hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0 lottie-ios: a881093fab623c467d3bce374367755c272bdd59 - lottie-react-native: 015e84640c4b8dd47049a8c981996fd203001ddf + lottie-react-native: 816fb00189b309b3eee7c152ddfc8d37f56d1865 RCT-Folly: 34124ae2e667a0e5f0ea378db071d27548124321 RCTDeprecation: 726d24248aeab6d7180dac71a936bbca6a994ed1 RCTRequired: a94e7febda6db0345d207e854323c37e3a31d93b @@ -2280,15 +2280,15 @@ SPEC CHECKSUMS: ReactNativeCameraKit: e72b838dac4ea2da19b7eb5d00b23125072790fd RealmJS: 9fd51c849eb552ade9f7b11db42a319b4f6cab4c RNCAsyncStorage: c91d753ede6dc21862c4922cd13f98f7cfde578e - RNCClipboard: dbcf25b8f666b4685c02eeb65be981d30198e505 + RNCClipboard: d05e3f409b80d63c6507fd5753846e5992057799 RNCPushNotificationIOS: 6c4ca3388c7434e4a662b92e4dfeeee858e6f440 RNDefaultPreference: 8a089ee8ce829a66c5453e3c5434f0785499d1c3 RNDeviceInfo: ae26ae45db3f9937f038a284bcd0a1db8d70db96 RNFS: 89de7d7f4c0f6bafa05343c578f61118c8282ed8 - RNGestureHandler: 5b24d10761754ad271b714e536c457fd89b17c54 + RNGestureHandler: 43970f04f34f186b4a5b2057cbf99c3039753c36 RNHandoff: bc8af5a86853ff13b033e7ba1114c3c5b38e6385 RNKeychain: 4df48b5186ca2b6a99f5ead69ad587154e084a32 - RNLocalize: d024afa9204c13885e61dc88b8190651bcaabac9 + RNLocalize: 15463c4d79c7da45230064b4adcf5e9bb984667e RNPermissions: 6f08c623b0c8ca7d95faa71c3956b159b34f25c3 RNQrGenerator: 7c604c0eb608af64ff586ab0c040796a04eff247 RNQuickAction: c2c8f379e614428be0babe4d53a575739667744d @@ -2297,7 +2297,7 @@ SPEC CHECKSUMS: RNReanimated: 000b758cfbcd9c20c15b7ef305f98f036b288feb RNScreens: 35bb8e81aeccf111baa0ea01a54231390dbbcfd9 RNShare: 6204e6a1987ba3e7c47071ef703e5449a0e3548a - RNSVG: 3421710ac15f4f2dc47e5c122f2c2e4282116830 + RNSVG: 46769c92d1609e617dbf9326ad8a0cff912d0982 RNVectorIcons: 182892e7d1a2f27b52d3c627eca5d2665a22ee28 RNWatch: 28fe1f5e0c6410d45fd20925f4796fce05522e3f SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d diff --git a/package-lock.json b/package-lock.json index 71ef050c8..4499f03e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,6 +81,7 @@ "react-native-permissions": "5.2.2", "react-native-prompt-android": "github:BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376", "react-native-push-notification": "8.1.1", + "react-native-qrcode-scanner": "^1.5.5", "react-native-qrcode-svg": "6.3.2", "react-native-quick-actions": "0.3.13", "react-native-randombytes": "3.6.1", @@ -22148,6 +22149,46 @@ "react-native": ">=0.33" } }, + "node_modules/react-native-qrcode-scanner": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/react-native-qrcode-scanner/-/react-native-qrcode-scanner-1.5.5.tgz", + "integrity": "sha512-il79uStkFqUvofqXJQfOL30qgQyU17MUKxj7IGHv6oT2OxIY/vutTwuPPDbsivtv0yTMHP4dGx/79oys4eAuNw==", + "license": "MIT", + "dependencies": { + "@react-native-async-storage/async-storage": "^1.13.4", + "prop-types": "^15.5.10", + "react-native-permissions": "^2.0.2" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-native-qrcode-scanner" + }, + "peerDependencies": { + "react-native-camera": ">=1.0.2" + } + }, + "node_modules/react-native-qrcode-scanner/node_modules/@react-native-async-storage/async-storage": { + "version": "1.24.0", + "resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.24.0.tgz", + "integrity": "sha512-W4/vbwUOYOjco0x3toB8QCr7EjIP6nE9G7o8PMguvvjYT5Awg09lyV4enACRx4s++PPulBiBSjL0KTFx2u0Z/g==", + "license": "MIT", + "dependencies": { + "merge-options": "^3.0.4" + }, + "peerDependencies": { + "react-native": "^0.0.0-0 || >=0.60 <1.0" + } + }, + "node_modules/react-native-qrcode-scanner/node_modules/react-native-permissions": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-2.2.2.tgz", + "integrity": "sha512-ihf4shQDSX5Oo9ChQXb9kr13mmyyNem5MaEvOpr3dCjhBOBWyEMztXm9/uPK1Qg5PsNpaYLa1KpcPZDCw87LXg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.8.6", + "react-native": ">=0.60.0" + } + }, "node_modules/react-native-qrcode-svg": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/react-native-qrcode-svg/-/react-native-qrcode-svg-6.3.2.tgz", diff --git a/package.json b/package.json index 073fb218f..634168db4 100644 --- a/package.json +++ b/package.json @@ -145,6 +145,7 @@ "react-native-permissions": "5.2.2", "react-native-prompt-android": "github:BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376", "react-native-push-notification": "8.1.1", + "react-native-qrcode-scanner": "^1.5.5", "react-native-qrcode-svg": "6.3.2", "react-native-quick-actions": "0.3.13", "react-native-randombytes": "3.6.1", diff --git a/screen/send/ScanQRCode.js b/screen/send/ScanQRCode.js index ca773cb5a..f4fe59bb2 100644 --- a/screen/send/ScanQRCode.js +++ b/screen/send/ScanQRCode.js @@ -2,7 +2,7 @@ import { useFocusEffect, useIsFocused, useNavigation, useRoute } from '@react-na import * as bitcoin from 'bitcoinjs-lib'; import createHash from 'create-hash'; import React, { useCallback, useEffect, useState } from 'react'; -import { Alert, Platform, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native'; +import { Platform, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native'; import Base43 from '../../blue_modules/base43'; import * as fs from '../../blue_modules/fs'; import { BlueURDecoder, decodeUR, extractSingleWorkload } from '../../blue_modules/ur'; @@ -14,6 +14,8 @@ import { isCameraAuthorizationStatusGranted } from '../../helpers/scan-qr'; import loc from '../../loc'; import { useSettings } from '../../hooks/context/useSettings'; import CameraScreen from '../../components/CameraScreen'; +import SafeArea from '../../components/SafeArea'; +import presentAlert from '../../components/Alert'; let decoder = false; @@ -120,20 +122,13 @@ const ScanQRCode = () => { } catch (error) { console.warn(error); setIsLoading(true); - Alert.alert( - loc.send.scan_error, - loc._.invalid_animated_qr_code_fragment, - [ - { - text: loc._.ok, - onPress: () => { - setIsLoading(false); - }, - style: 'default', - }, - ], - { cancelabe: false }, - ); + presentAlert({ + title: loc.send.scan_error, + message: loc._.invalid_animated_qr_code_fragment, + onPress: () => { + setIsLoading(false); + }, + }); } }; @@ -170,20 +165,14 @@ const ScanQRCode = () => { } catch (error) { console.warn(error); setIsLoading(true); - Alert.alert( - loc.send.scan_error, - loc._.invalid_animated_qr_code_fragment, - [ - { - text: loc._.ok, - onPress: () => { - setIsLoading(false); - }, - style: 'default', - }, - ], - { cancelabe: false }, - ); + + presentAlert({ + title: loc.send.scan_error, + message: loc._.invalid_animated_qr_code_fragment, + onPress: () => { + setIsLoading(false); + }, + }); } }; @@ -272,22 +261,45 @@ const ScanQRCode = () => { navigation.goBack(); }; + const handleReadCode = event => { + onBarCodeRead({ data: event?.nativeEvent?.codeStringValue }); + }; + + const handleBackdoorOkPress = () => { + setBackdoorVisible(false); + setBackdoorText(''); + if (backdoorText) onBarCodeRead({ data: backdoorText }); + }; + + // this is an invisible backdoor button on bottom left screen corner + // tapping it 10 times fires prompt dialog asking for a string thats gona be passed to onBarCodeRead. + // this allows to mock and test QR scanning in e2e tests + const handleInvisibleBackdoorPress = async () => { + setBackdoorPressed(backdoorPressed + 1); + if (backdoorPressed < 5) return; + setBackdoorPressed(0); + setBackdoorVisible(true); + }; + const render = isLoading ? ( ) : ( - <> + {!cameraStatusGranted ? ( {loc.send.permission_camera_message}