Skip to content

Commit

Permalink
chore: show nfc button when nfc is available
Browse files Browse the repository at this point in the history
  • Loading branch information
sandipndev committed Nov 27, 2023
1 parent 295af7a commit c9f794a
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions app/screens/receive-bitcoin-screen/receive-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SetLightningAddressModal } from "@app/components/set-lightning-address-
import { GaloyCurrencyBubble } from "@app/components/atomic/galoy-currency-bubble"
import { ModalNfc } from "@app/components/modal-nfc"
import { CustomIcon } from "@app/components/custom-icon"
import nfcManager from "react-native-nfc-manager"

const ReceiveScreen = () => {
const {
Expand All @@ -37,21 +38,27 @@ const ReceiveScreen = () => {
const [displayReceiveNfc, setDisplayReceiveNfc] = useState(false)

useEffect(() => {
if (request?.type === "Lightning" && request?.state === "Created")
navigation.setOptions({
headerRight: () => (
<TouchableOpacity
style={styles.nfcIcon}
onPress={() => setDisplayReceiveNfc(true)}
>
<Text type="p2">{LL.ReceiveScreen.nfc()}</Text>
<CustomIcon name="nfc" color={colors.black} />
</TouchableOpacity>
),
})
else {
navigation.setOptions({ headerRight: () => <></> })
}
;(async () => {
if (
request?.type === "Lightning" &&
request?.state === "Created" &&
(await nfcManager.isSupported())
)
navigation.setOptions({
headerRight: () => (
<TouchableOpacity
style={styles.nfcIcon}
onPress={() => setDisplayReceiveNfc(true)}
>
<Text type="p2">{LL.ReceiveScreen.nfc()}</Text>
<CustomIcon name="nfc" color={colors.black} />
</TouchableOpacity>
),
})
else {
navigation.setOptions({ headerRight: () => <></> })
}
})()
}, [
LL.ReceiveScreen,
colors.black,
Expand Down

0 comments on commit c9f794a

Please sign in to comment.