Skip to content

Commit

Permalink
fix: copy preimage & payment hash (#117)
Browse files Browse the repository at this point in the history
* fix: copy preimage & payment hash

* fix: classes
  • Loading branch information
reneaaron authored Sep 12, 2024
1 parent dd69c43 commit ce5d6ba
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions pages/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Nip47Transaction } from "@getalby/sdk/dist/NWCClient";
import dayjs from "dayjs";
import { useLocalSearchParams } from "expo-router";
import React from "react";
import { View } from "react-native";
import { View, TouchableOpacity } from "react-native";
import Screen from "~/components/Screen";
import { MoveDownLeft, MoveUpRight } from "~/components/Icons";
import { Text } from "~/components/ui/text";
import { useGetFiatAmount } from "~/hooks/useGetFiatAmount";
import { cn } from "~/lib/utils";
import * as Clipboard from "expo-clipboard";
import Toast from "react-native-toast-message";

export function Transaction() {
const { transactionJSON } = useLocalSearchParams() as unknown as {
Expand Down Expand Up @@ -69,10 +71,12 @@ export function Transaction() {
<TransactionDetailRow
title="Payment Hash"
content={transaction.payment_hash}
copy
/>
<TransactionDetailRow
title="Preimage"
content={transaction.preimage}
copy
/>
<TransactionDetailRow
title="Fee"
Expand All @@ -86,11 +90,30 @@ export function Transaction() {
);
}

function TransactionDetailRow(props: { title: string; content: string }) {
function TransactionDetailRow(props: {
title: string;
content: string;
copy?: boolean;
}) {
return (
<View className="flex flex-row gap-3">
<Text className="w-32 text-muted-foreground">{props.title}</Text>
<Text className="flex-1 text-foreground font-medium2">{props.content}</Text>
{props.copy ? (
<TouchableOpacity
className="flex-1"
onPress={() => {
Clipboard.setStringAsync(props.content);
Toast.show({
type: "success",
text1: "Copied to clipboard",
});
}}
>
<Text className="text-foreground font-medium2">{props.content}</Text>
</TouchableOpacity>
) : (
<Text className="flex-1 text-foreground font-medium2">{props.content}</Text>
)}
</View>
);
}

0 comments on commit ce5d6ba

Please sign in to comment.