From 758787d084236c033a180ad7a0d953dda9851f2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Aaron?= Date: Wed, 25 Sep 2024 15:47:16 +0200 Subject: [PATCH] fix: create component, conditional display, lnurl amount param --- components/AlbyBanner.tsx | 46 +++++++++++++++++++++++++++++++++++++++ pages/Home.tsx | 27 ++--------------------- pages/send/LNURLPay.tsx | 7 +++--- pages/send/Send.tsx | 3 ++- 4 files changed, 54 insertions(+), 29 deletions(-) create mode 100644 components/AlbyBanner.tsx diff --git a/components/AlbyBanner.tsx b/components/AlbyBanner.tsx new file mode 100644 index 0000000..97e7e8c --- /dev/null +++ b/components/AlbyBanner.tsx @@ -0,0 +1,46 @@ +import { View } from "react-native"; +import { Text } from "~/components/ui/text"; +import { Button } from "./ui/button"; +import { router } from "expo-router"; + +function AlbyBanner() { + const showAlbyBanner = new Date().getDate() === 21; + const amounts = [ + { value: 1000, emoji: '🧡' }, + { value: 5000, emoji: '🔥' }, + { value: 10000, emoji: '🚀' } + ]; + + if (!showAlbyBanner) { + return null; + } + + return ( + + ✨ Enjoying Alby Go? + Help us grow and improve by supporting our development. + + {amounts.map(({ value, emoji }) => ( + + ))} + + + ); +} + +export default AlbyBanner; diff --git a/pages/Home.tsx b/pages/Home.tsx index 44671eb..317340b 100644 --- a/pages/Home.tsx +++ b/pages/Home.tsx @@ -22,6 +22,7 @@ import { SvgProps } from "react-native-svg"; import { Button } from "~/components/ui/button"; import Screen from "~/components/Screen"; import { useOnboarding } from "~/hooks/useOnboarding"; +import AlbyBanner from "~/components/AlbyBanner"; dayjs.extend(relativeTime); @@ -123,31 +124,7 @@ export function Home() { )} - {/* { - router.navigate({ - pathname: "/send", - params: { - url: "hello@getalby.com" - }, - }); - }}> - - - - ✨ Like Alby Go? - Help us grow and improve by supporting our development - - - */} - - ✨ Enjoying Alby Go? - Help us grow and improve by supporting our development - - - - - - + diff --git a/pages/send/LNURLPay.tsx b/pages/send/LNURLPay.tsx index bd410a3..7a65a4f 100644 --- a/pages/send/LNURLPay.tsx +++ b/pages/send/LNURLPay.tsx @@ -12,17 +12,18 @@ import { DualCurrencyInput } from "~/components/DualCurrencyInput"; import DismissableKeyboardView from "~/components/DismissableKeyboardView"; export function LNURLPay() { - const { lnurlDetailsJSON, originalText } = + const { lnurlDetailsJSON, originalText, amount: amountParam } = useLocalSearchParams() as unknown as { lnurlDetailsJSON: string; originalText: string; + amount: string; }; const lnurlDetails: LNURLPayServiceResponse = JSON.parse(lnurlDetailsJSON); const [isLoading, setLoading] = React.useState(false); - const [amount, setAmount] = React.useState(""); + const [amount, setAmount] = React.useState(amountParam); const [comment, setComment] = React.useState(""); const [isAmountReadOnly, setAmountReadOnly] = React.useState(false); - + console.log(amountParam, amount) useEffect(() => { // Handle fixed amount LNURLs if (lnurlDetails.minSendable === lnurlDetails.maxSendable) { diff --git a/pages/send/Send.tsx b/pages/send/Send.tsx index 923ad40..5f0e432 100644 --- a/pages/send/Send.tsx +++ b/pages/send/Send.tsx @@ -19,7 +19,7 @@ import Loading from "~/components/Loading"; import DismissableKeyboardView from "~/components/DismissableKeyboardView"; export function Send() { - const { url } = useLocalSearchParams<{ url: string }>(); + const { url, amount } = useLocalSearchParams<{ url: string, amount: string }>(); const [isLoading, setLoading] = React.useState(false); const [keyboardOpen, setKeyboardOpen] = React.useState(false); const [keyboardText, setKeyboardText] = React.useState(""); @@ -103,6 +103,7 @@ export function Send() { params: { lnurlDetailsJSON: JSON.stringify(lnurlDetails), originalText, + amount, }, }); }