Skip to content

Commit

Permalink
Merge branch 'master' into task-setup-wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Dec 20, 2024
2 parents e2dfe0b + c8a4576 commit 4113e53
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 146 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Alby Go",
"slug": "alby-mobile",
"version": "1.7.2",
"scheme": ["lightning", "bitcoin", "alby"],
"scheme": ["lightning", "bitcoin", "alby", "nostr+walletconnect"],
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "automatic",
Expand Down
20 changes: 19 additions & 1 deletion lib/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { router } from "expo-router";
import { BOLT11_REGEX } from "./constants";
import { lnurl as lnurlLib } from "./lnurl";

const SUPPORTED_SCHEMES = ["lightning:", "bitcoin:", "alby:"];
const SUPPORTED_SCHEMES = [
"lightning:",
"bitcoin:",
"alby:",
"nostr+walletconnect:",
];

// Register exp scheme for testing during development
// https://docs.expo.dev/guides/linking/#creating-urls
Expand All @@ -22,6 +27,19 @@ export const handleLink = async (url: string) => {

if (SUPPORTED_SCHEMES.indexOf(parsedUrl.protocol) > -1) {
let { username, hostname, protocol, pathname, search } = parsedUrl;
if (parsedUrl.protocol === "nostr+walletconnect:") {
if (router.canDismiss()) {
router.dismissAll();
}
console.info("Navigating to wallet setup");
router.push({
pathname: "/settings/wallets/setup",
params: {
nwcUrl: protocol + hostname + search,
},
});
return;
}

if (parsedUrl.protocol === "exp:") {
if (!parsedUrl.pathname) {
Expand Down
60 changes: 25 additions & 35 deletions pages/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ type Boostagram = {
name: string;
podcast: string;
url: string;
episode?: string;
itemID?: string;
ts?: string;
episode?: string | number;
itemID?: string | number;
ts?: string | number;
message?: string;
sender_id: string;
sender_id: string | number;
sender_name: string;
time: string;
action: string;
Expand Down Expand Up @@ -204,40 +204,30 @@ function TransactionDetailRow(props: {
}

function PodcastingInfo({ boost }: { boost: Boostagram }) {
const renderDetail = (title: string, content: any) => {
if (content === 0 || !!content) {
return <TransactionDetailRow title={title} content={String(content)} />;
}
return null;
};
return (
<>
{boost.message && (
<TransactionDetailRow title="Message" content={boost.message} />
)}
{boost.podcast && (
<TransactionDetailRow title="Podcast" content={boost.podcast} />
)}
{boost.episode && (
<TransactionDetailRow title="Episode" content={boost.episode} />
)}
{boost.action && (
<TransactionDetailRow title="Action" content={boost.action} />
)}
{boost.ts && (
<TransactionDetailRow title="Timestamp" content={boost.ts} />
)}
{boost.value_msat_total && (
<TransactionDetailRow
title="Total amount"
content={
Math.floor(boost.value_msat_total / 1000) +
(Math.floor(boost.value_msat_total / 1000) === 1 ? " sat" : " sats")
}
/>
)}
{boost.sender_name && (
<TransactionDetailRow title="Sender" content={boost.sender_name} />
)}
{boost.app_name && (
<TransactionDetailRow title="App" content={boost.app_name} />
{renderDetail("Message", boost.message)}
{renderDetail("Podcast", boost.podcast)}
{renderDetail("Episode", boost.episode)}
{renderDetail("Action", boost.action)}
{renderDetail("Timestamp", boost.ts)}
{renderDetail(
"Total amount",
boost.value_msat_total
? Math.floor(boost.value_msat_total / 1000) +
(Math.floor(boost.value_msat_total / 1000) === 1
? " sat"
: " sats")
: null,
)}
{renderDetail("Sender", boost.sender_name)}
{renderDetail("App", boost.app_name)}
</>
);
}

export default PodcastingInfo;
133 changes: 64 additions & 69 deletions pages/settings/Wallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,71 @@ export function Wallets() {
const selectedWalletId = useAppStore((store) => store.selectedWalletId);
const wallets = useAppStore((store) => store.wallets);
return (
<>
<View className="flex-1 flex flex-col">
<Screen title="Manage Wallets" />
<View className="flex-1 px-6 py-3">
<FlatList
className="flex flex-col"
data={wallets}
renderItem={(item) => {
const active = item.index === selectedWalletId;
<View className="flex-1 flex flex-col">
<Screen title="Manage Wallets" />
<View className="flex-1 px-6 py-3">
<FlatList
className="flex flex-col"
data={wallets}
renderItem={(item) => {
const active = item.index === selectedWalletId;

return (
<TouchableOpacity
onPress={() => {
if (item.index !== selectedWalletId) {
useAppStore.getState().setSelectedWalletId(item.index);
router.dismissAll();
router.navigate("/");
Toast.show({
type: "success",
text1: `Switched wallet to ${item.item.name || DEFAULT_WALLET_NAME}`,
position: "top",
});
}
}}
className={cn(
"flex flex-row items-center justify-between p-6 rounded-2xl border-2",
active ? "border-primary" : "border-transparent",
)}
>
<View className="flex flex-row gap-4 items-center flex-shrink">
<Wallet2 className="text-foreground" />
<Text
className={cn(
"text-xl pr-16",
active && "font-semibold2",
)}
numberOfLines={1}
ellipsizeMode="tail"
>
{item.item.name || DEFAULT_WALLET_NAME}
</Text>
</View>
{active && (
<Link
href={`/settings/wallets/${selectedWalletId}`}
className="absolute right-4"
asChild
>
<TouchableOpacity>
<Settings2 className="text-foreground w-32 h-32" />
</TouchableOpacity>
</Link>
)}
</TouchableOpacity>
);
}}
/>
</View>
<View className="p-6">
<Button
size="lg"
onPress={() => {
router.dismissAll();
router.push("/settings/wallets/setup");
}}
>
<Text>Connect a Wallet</Text>
</Button>
</View>
return (
<TouchableOpacity
onPress={() => {
if (item.index !== selectedWalletId) {
useAppStore.getState().setSelectedWalletId(item.index);
router.dismissAll();
router.navigate("/");
Toast.show({
type: "success",
text1: `Switched wallet to ${item.item.name || DEFAULT_WALLET_NAME}`,
position: "top",
});
}
}}
className={cn(
"flex flex-row items-center justify-between p-6 rounded-2xl border-2",
active ? "border-primary" : "border-transparent",
)}
>
<View className="flex flex-row gap-4 items-center flex-shrink">
<Wallet2 className="text-foreground" />
<Text
className={cn("text-xl pr-16", active && "font-semibold2")}
numberOfLines={1}
ellipsizeMode="tail"
>
{item.item.name || DEFAULT_WALLET_NAME}
</Text>
</View>
{active && (
<Link
href={`/settings/wallets/${selectedWalletId}`}
className="absolute right-4"
asChild
>
<TouchableOpacity>
<Settings2 className="text-foreground w-32 h-32" />
</TouchableOpacity>
</Link>
)}
</TouchableOpacity>
);
}}
/>
</View>
</>
<View className="p-6">
<Button
size="lg"
onPress={() => {
router.dismissAll();
router.push("/settings/wallets/setup");
}}
>
<Text>Connect a Wallet</Text>
</Button>
</View>
</View>
);
}
Loading

0 comments on commit 4113e53

Please sign in to comment.