Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Help Icon to "Setup Wallet Connection" #106

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions components/Icons.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
import {
AlertCircle,
ArrowDown,
ArrowLeftRight,
Bitcoin,
BookUser,
Camera,
CameraOff,
CheckCircle,
ChevronDown,
ChevronUp,
CircleHelp,
ClipboardPaste,
Cog,
Copy,
Currency,
Egg,
Hotel,
Keyboard,
LucideIcon,
XCircle,
MoveUpRight,
MoveDownRight,
Menu,
MoveDown,
MoveDownLeft,
MoveDownRight,
MoveUp,
MoveDown,
Camera,
Menu,
ZapIcon,
WalletIcon,
Copy,
Currency,
Settings2,
ArrowLeftRight,
MoveUpRight,
Palette,
PlusCircle,
Cog,
ClipboardPaste,
Keyboard,
BookUser,
Wallet2,
ArrowDown,
ChevronDown,
Bitcoin,
Share2,
Power,
RefreshCw,
ChevronUp,
Settings2,
Share2,
Wallet2,
WalletIcon,
X,
Hotel,
Power,
CameraOff,
Palette,
Egg,
XCircle,
ZapIcon,
} from "lucide-react-native";
import { cssInterop } from "nativewind";

Expand Down Expand Up @@ -83,6 +84,7 @@ interopIcon(Power);
interopIcon(CameraOff);
interopIcon(Palette);
interopIcon(Egg);
interopIcon(CircleHelp);

export {
AlertCircle,
Expand Down Expand Up @@ -119,4 +121,5 @@ export {
Power,
Palette,
Egg,
CircleHelp,
};
21 changes: 17 additions & 4 deletions components/ToastConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { ToastConfig } from "react-native-toast-message";
import { Text } from "./ui/text";
import { Link } from "expo-router";
import { View } from "react-native";
import {
BaseToast,
BaseToastProps,
ToastConfig,
} from "react-native-toast-message";
import { useAppStore } from "~/lib/state/appStore";

import { CheckCircle, XCircle } from "./Icons";
import { Link } from "expo-router";
import { Button } from "./ui/button";
import { useAppStore } from "~/lib/state/appStore";
import { Text } from "./ui/text";

export const toastConfig: ToastConfig = {
info: (props: BaseToastProps) => (
<BaseToast
{...props}
text2NumberOfLines={2}
text1Style={{ fontSize: 16 }}
text2Style={{ fontSize: 14 }}
/>
),
Comment on lines +15 to +22
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the default text size for the info toast was unreadable, so I made it a little bit bigger.

success: ({ text1, text2 }) => (
<View className="bg-foreground rounded-full px-6 py-3 mx-6">
<View className="flex flex-row gap-2 justify-center items-center">
Expand Down
49 changes: 32 additions & 17 deletions pages/settings/wallets/WalletConnection.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import { Pressable, Text, View } from "react-native";
import React from "react";
import * as Clipboard from "expo-clipboard";
import { nwc } from "@getalby/sdk";
import { ClipboardPaste, X } from "~/components/Icons";
import { useAppStore } from "lib/state/appStore";
import { Camera } from "expo-camera/legacy"; // TODO: check if Android camera detach bug is fixed and update camera
import * as Clipboard from "expo-clipboard";
import { router } from "expo-router";
import { Button } from "~/components/ui/button";
import { useInfo } from "~/hooks/useInfo";
import { useBalance } from "~/hooks/useBalance";
import { useAppStore } from "lib/state/appStore";
import React from "react";
import { Pressable, Text, View } from "react-native";
import Toast from "react-native-toast-message";
import { errorToast } from "~/lib/errorToast";
import { Nip47Capability } from "@getalby/sdk/dist/NWCClient";
import { CircleHelp, ClipboardPaste, X } from "~/components/Icons";
import Loading from "~/components/Loading";
import QRCodeScanner from "~/components/QRCodeScanner";
import Screen from "~/components/Screen";
import { Button } from "~/components/ui/button";
import { useBalance } from "~/hooks/useBalance";
import { useInfo } from "~/hooks/useInfo";
import { errorToast } from "~/lib/errorToast";

import { nwc } from "@getalby/sdk";
import { Nip47Capability } from "@getalby/sdk/dist/NWCClient";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about these import order changes - I have prettier enabled by default.

Maybe we should add a .prettierrc in a separate PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already is one, but it's pretty empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't matter if it's pretty empty - it should use prettier sane defaults. It was added recently though, and we didn't run a full format. We should do that. I will create a separate issue.


export function WalletConnection() {
const hasConnection = useAppStore((store) => !!store.nwcClient);
const walletIdWithConnection = useAppStore((store) =>
store.wallets.findIndex((wallet) => wallet.nostrWalletConnectUrl),
);
const [isScanning, setScanning] = React.useState(false);
const [isConnecting, setConnecting] = React.useState(false);
const [isScanning, setIsScanning] = React.useState(false);
const [isConnecting, setIsConnecting] = React.useState(false);
Comment on lines +25 to +26
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes react warning useState call is not destructured into value + setter pair

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this warning, weird. Do you know what plugin this is coming from?

const { data: walletInfo } = useInfo();
const { data: balance } = useBalance();

async function scan() {
const { status } = await Camera.requestCameraPermissionsAsync();
setScanning(status === "granted");
setIsScanning(status === "granted");
}

const handleScanned = (data: string) => {
Expand All @@ -53,7 +54,7 @@ export function WalletConnection() {

async function connect(nostrWalletConnectUrl: string) {
try {
setConnecting(true);
setIsConnecting(true);
// make sure connection is valid
const nwcClient = new nwc.NWCClient({
nostrWalletConnectUrl,
Expand Down Expand Up @@ -83,7 +84,7 @@ export function WalletConnection() {
console.error(error);
errorToast(error);
}
setConnecting(false);
setIsConnecting(false);
}

return (
Expand All @@ -102,7 +103,21 @@ export function WalletConnection() {
>
<X className="text-foreground" />
</Pressable>
) : null
) : (
<Pressable
onPress={() => {
Toast.show({
type: "info",
visibilityTime: 8000,
text1: "Connect a Wallet",
text2:
"Go to your 'Alby Hub' -> 'Connections' -> 'Add Connection' -> Scan QR Code",
});
}}
>
<CircleHelp className="text-foreground" />
</Pressable>
)
}
/>
{hasConnection && (
Expand Down