Skip to content

Commit

Permalink
fix: create component, conditional display, lnurl amount param
Browse files Browse the repository at this point in the history
  • Loading branch information
reneaaron committed Sep 25, 2024
1 parent 04bebc5 commit 758787d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 29 deletions.
46 changes: 46 additions & 0 deletions components/AlbyBanner.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<View className="border bg-card border-muted rounded mt-5 flex flex-col gap-3 p-5">
<Text className="font-semibold2 text-center">✨ Enjoying Alby Go?</Text>
<Text className="text-muted-foreground text-center">Help us grow and improve by supporting our development.</Text>
<View className="flex flex-row gap-3 mt-3">
{amounts.map(({ value, emoji }) => (
<Button
key={value}
variant="secondary"
size="sm"
onPress={() => {
router.navigate({
pathname: "/send",
params: {
url: "[email protected]",
amount: value
},
});
}}
>
<Text>{emoji} {new Intl.NumberFormat().format(value)}</Text>
</Button>
))}
</View>
</View>
);
}

export default AlbyBanner;
27 changes: 2 additions & 25 deletions pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -123,31 +124,7 @@ export function Home() {
)}
</View>
</TouchableOpacity>
{/* <TouchableOpacity className="w-full" onPress={() => {
router.navigate({
pathname: "/send",
params: {
url: "[email protected]"
},
});
}}>
<Button variant="secondary" size="sm"><Text>✨Support Alby Go</Text></Button>
<Card className="w-full mt-5">
<CardHeader>
<CardTitle>✨ Like Alby Go?</CardTitle>
<CardDescription>Help us grow and improve by supporting our development</CardDescription>
</CardHeader>
</Card>
</TouchableOpacity> */}
<View className="border bg-card border-muted rounded mt-5 flex flex-col gap-3 p-3 ">
<Text className="font-semibold2 text-center">✨ Enjoying Alby Go?</Text>
<Text className="text-muted-foreground text-center">Help us grow and improve by supporting our development</Text>
<View className="flex flex-row gap-3 mt-3">
<Button variant="secondary" size="sm"><Text>🧡 1000</Text></Button>
<Button variant="secondary" size="sm"><Text>🚀 5000</Text></Button>
<Button variant="secondary" size="sm"><Text>🔥 10000</Text></Button>
</View>
</View>
<AlbyBanner />
</View>
<View className="flex items-center justify-center">
<Link href="/transactions" asChild>
Expand Down
7 changes: 4 additions & 3 deletions pages/send/LNURLPay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion pages/send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down Expand Up @@ -103,6 +103,7 @@ export function Send() {
params: {
lnurlDetailsJSON: JSON.stringify(lnurlDetails),
originalText,
amount,
},
});
}
Expand Down

0 comments on commit 758787d

Please sign in to comment.