From cf0c374b75bb95adcc2569492d1f0b1ed1f94b4c Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Tue, 22 Apr 2025 22:58:47 +0200 Subject: [PATCH] Optimize sending locked ecash, small UI fixes --- android/gradle.properties | 1 - ios/minibits_wallet.xcodeproj/project.pbxproj | 4 +- .../xcschemes/minibits_wallet.xcscheme | 2 +- package.json | 2 +- src/screens/ContactDetailScreen.tsx | 12 +++-- src/screens/Contacts/OwnName.tsx | 43 +++++----------- src/screens/Contacts/PrivateContacts.tsx | 8 +-- src/screens/MintsScreen.tsx | 11 +++-- src/screens/ProfileScreen.tsx | 18 +++++-- src/screens/RecoveryOptionsScreen.tsx | 11 ++++- src/screens/SendScreen.tsx | 49 ++++++++++--------- 11 files changed, 83 insertions(+), 78 deletions(-) diff --git a/android/gradle.properties b/android/gradle.properties index 48ca2bd0..5e24e3aa 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -37,4 +37,3 @@ newArchEnabled=true # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. hermesEnabled=true - diff --git a/ios/minibits_wallet.xcodeproj/project.pbxproj b/ios/minibits_wallet.xcodeproj/project.pbxproj index 284622ac..858d7895 100644 --- a/ios/minibits_wallet.xcodeproj/project.pbxproj +++ b/ios/minibits_wallet.xcodeproj/project.pbxproj @@ -301,7 +301,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = minibits_wallet/minibits_wallet.entitlements; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEVELOPMENT_TEAM = GR2ZKMCLAM; ENABLE_BITCODE = NO; INFOPLIST_FILE = minibits_wallet/Info.plist; @@ -336,7 +336,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = minibits_wallet/minibits_wallet.entitlements; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEVELOPMENT_TEAM = GR2ZKMCLAM; INFOPLIST_FILE = minibits_wallet/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = Minibits; diff --git a/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme b/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme index 9a1b755f..72677cb8 100644 --- a/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme +++ b/ios/minibits_wallet.xcodeproj/xcshareddata/xcschemes/minibits_wallet.xcscheme @@ -31,7 +31,7 @@ shouldAutocreateTestPlan = "YES"> { + handleError(e) + }, 500) + } else { + handleError(e) + } } } diff --git a/src/screens/Contacts/OwnName.tsx b/src/screens/Contacts/OwnName.tsx index 51002d6a..cbe087bb 100644 --- a/src/screens/Contacts/OwnName.tsx +++ b/src/screens/Contacts/OwnName.tsx @@ -351,7 +351,7 @@ export const OwnName = observer(function (props: {pubkey: string}) { text='Minibits' style={{fontFamily: 'Gluten-Regular', fontSize: 18}} />{' '} - kindly asks you for a small donation for your {ownName+MINIBITS_NIP05_DOMAIN} wallet address. + kindly asks you for a small donation for your new wallet address. - - - - + )} @@ -448,12 +449,14 @@ export const OwnName = observer(function (props: {pubkey: string}) { const $screen: ViewStyle = { // flex: 1 + } const $contentContainer: TextStyle = { // flex:1, padding: spacing.extraSmall, + //marginBottom: spacing.medium } const $iconContainer: ViewStyle = { @@ -463,12 +466,12 @@ const $iconContainer: ViewStyle = { const $supportText: TextStyle = { padding: spacing.small, - // textAlign: 'center', + textAlign: 'center', fontSize: 16, } const $card: ViewStyle = { - marginBottom: 0, + //marginBottom: 0, } const $payButtonContainer: ViewStyle = { @@ -513,33 +516,9 @@ const $buttonContainer: ViewStyle = { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', - marginVertical: spacing.small, + marginVertical: spacing.extraSmall, } const $ownNameButton: ViewStyle = { maxHeight: 50, } - - -const $invoiceContainer: ViewStyle = { - borderRadius: spacing.small, - alignSelf: 'stretch', - padding: spacing.small, - maxHeight: 150, - marginTop: spacing.small, - marginBottom: spacing.large, - } - - const $qrCodeContainer: ViewStyle = { - alignItems: 'center', - backgroundColor: 'white', - paddingHorizontal: spacing.small, - marginHorizontal: spacing.small, - marginBottom: spacing.small, - borderRadius: spacing.small -} - -const $bottomModal: ViewStyle = { - alignItems: 'center', - paddingVertical: spacing.large, -} \ No newline at end of file diff --git a/src/screens/Contacts/PrivateContacts.tsx b/src/screens/Contacts/PrivateContacts.tsx index 200f9791..55e820d6 100644 --- a/src/screens/Contacts/PrivateContacts.tsx +++ b/src/screens/Contacts/PrivateContacts.tsx @@ -219,18 +219,19 @@ export const PrivateContacts = observer(function (props: { encoded: contact.lud16 }, navigation, userSettingsStore.preferredUnit) - //reset + //@ts-ignore navigation.setParams({ paymentOption: undefined, }) return } - + //@ts-ignore navigation.navigate('ContactDetail', {contact: toJS(contact)}) } catch (e: any) { // reset so that invalid contact can be deleted + //@ts-ignore navigation.setParams({ paymentOption: undefined, }) @@ -239,7 +240,8 @@ export const PrivateContacts = observer(function (props: { } } - const gotoProfile = function () { + const gotoProfile = function () { + //@ts-ignore navigation.navigate('Profile') } diff --git a/src/screens/MintsScreen.tsx b/src/screens/MintsScreen.tsx index 3fac086a..f14b858f 100644 --- a/src/screens/MintsScreen.tsx +++ b/src/screens/MintsScreen.tsx @@ -1,6 +1,6 @@ import {observer} from 'mobx-react-lite' import React, {FC, useRef, useState} from 'react' -import {Alert, ScrollView, TextInput, TextStyle, View, ViewStyle} from 'react-native' +import {Alert, Platform, ScrollView, TextInput, TextStyle, View, ViewStyle} from 'react-native' import Clipboard from '@react-native-clipboard/clipboard' import { MINIBITS_MINT_URL @@ -272,10 +272,13 @@ export const MintsScreen = observer(function MintsScreen({ route }: Props) { const onShare = function () { if (!selectedMint) return toggleMintMenuModal() - setTimeout(() => { + if(Platform.OS === 'ios') { + setTimeout(() => { + toggleShareModal() + }, 500) + } else { toggleShareModal() - }, 500) - + } } const handleError = function (e: AppError) { diff --git a/src/screens/ProfileScreen.tsx b/src/screens/ProfileScreen.tsx index 0b33acd7..801e5ef1 100644 --- a/src/screens/ProfileScreen.tsx +++ b/src/screens/ProfileScreen.tsx @@ -1,6 +1,6 @@ import {observer} from 'mobx-react-lite' import React, {FC, useEffect, useState} from 'react' -import {ScrollView, Share, Switch, TextStyle, View, ViewStyle} from 'react-native' +import {Platform, ScrollView, Share, Switch, TextStyle, View, ViewStyle} from 'react-native' import {colors, spacing, useThemeColor} from '../theme' import {Icon, ListItem, Screen, Text, Card, BottomModal, Button, InfoModal, ErrorModal, Loading, Header} from '../components' import {useStores} from '../models' @@ -83,9 +83,13 @@ export const ProfileScreen = observer(function ProfileScreen({ route }: Props) { data: npub, }) - setTimeout(() => { + if(Platform.OS === 'ios') { + setTimeout(() => { + toggleQrCodeModal() + }, 500) // ios fix + } else { toggleQrCodeModal() - }, 500) // ios fix + } } @@ -96,9 +100,13 @@ export const ProfileScreen = observer(function ProfileScreen({ route }: Props) { data: pubkey, }) - setTimeout(() => { + if(Platform.OS === 'ios') { + setTimeout(() => { + toggleQrCodeModal() + }, 500) // ios fix + } else { toggleQrCodeModal() - }, 500) // ios fix + } } const onCopyNip05 = function () { diff --git a/src/screens/RecoveryOptionsScreen.tsx b/src/screens/RecoveryOptionsScreen.tsx index 8332700e..49e79723 100644 --- a/src/screens/RecoveryOptionsScreen.tsx +++ b/src/screens/RecoveryOptionsScreen.tsx @@ -160,7 +160,13 @@ export const RecoveryOptionsScreen = observer(function RecoveryOptionsScreen({ r toggleMintSelectorModal() if(mintBalanceToMintFrom) { - toggleMintQuoteModal() + if(Platform.OS === 'ios') { + setTimeout(() => { + toggleMintQuoteModal() + }, 500) + } else { + toggleMintQuoteModal() + } } } @@ -467,13 +473,14 @@ const $contentContainer: TextStyle = { const $mintsContainer: TextStyle = { // flex: 1, alignSelf: 'stretch', - minHeight: spacing.screenHeight * 0.15, + minHeight: spacing.screenHeight * 0.4, } const $quoteContainer: TextStyle = { // flex: 1, padding: spacing.small, alignSelf: 'stretch', + minHeight: spacing.screenHeight * 0.3, } const $pasteButton: ViewStyle = { diff --git a/src/screens/SendScreen.tsx b/src/screens/SendScreen.tsx index ab3f2619..4a9818c9 100644 --- a/src/screens/SendScreen.tsx +++ b/src/screens/SendScreen.tsx @@ -619,6 +619,28 @@ const togglePubkeySelectorModal = () => setIsPubkeySelectorModalVisible(previous throw new AppError(Err.VALIDATION_ERROR, 'Invalid key. Please provide public key in NPUB or HEX format.') } + const contact = contactsStore.findByNpub(lockedPubkey) || contactsStore.findByPubkey(lockedPubkey) + + if(contact) { + log.trace('[onLockPubkeySelect] Provided pubkey belongs to a contact', {contactName: contact.name}) + let relays: string[] = [] + + if(contact?.type === ContactType.PUBLIC) { + relays = relaysStore.allPublicUrls + } else { + relays = relaysStore.allUrls + } + + if (relays.length === 0) { + throw new AppError(Err.VALIDATION_ERROR, 'Missing NOSTR relays') + } + + setPaymentOption(SendOption.SEND_TOKEN) + setContactToSendFrom(getContactFrom()) + setContactToSendTo(contact) + setRelaysToShareTo(relays) + } + setIsLockedToPubkey(true) togglePubkeySelectorModal() } @@ -626,6 +648,7 @@ const togglePubkeySelectorModal = () => setIsPubkeySelectorModalVisible(previous const onLockPubkeyCancel = function () { togglePubkeySelectorModal() setLockedPubkey(undefined) + setContactToSendTo(undefined) } @@ -840,32 +863,10 @@ const togglePubkeySelectorModal = () => setIsPubkeySelectorModalVisible(previous } const gotoContacts = function () { - if(encodedTokenToSend && - lockedPubkey && - contactsStore.contacts.some(c => c.pubkey === lockedPubkey - )) { - const contact = contactsStore.findByPubkey(lockedPubkey) - let relays: string[] = [] + if(encodedTokenToSend && contactToSendTo) { - if(contact?.type === ContactType.PUBLIC) { - relays = relaysStore.allPublicUrls - } else { - relays = relaysStore.allUrls - } - - if (relays.length === 0) { - throw new AppError(Err.VALIDATION_ERROR, 'Missing NOSTR relays') - } - - setPaymentOption(SendOption.SEND_TOKEN) - setContactToSendFrom(getContactFrom()) - setContactToSendTo(contact) - setRelaysToShareTo(relays) - - if(encodedTokenToSend) { - toggleNostrDMModal() // open if we already have a token - } + toggleNostrDMModal() // open if we already have a token } else { //@ts-ignore