Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into chore/bump-expo-ver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
rolznz committed Dec 6, 2024
2 parents cdda0d9 + fce4ebc commit 7505837
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 64 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "Alby Go",
"slug": "alby-mobile",
"version": "1.7.1",
"version": "1.7.2",
"scheme": ["lightning", "bitcoin", "alby"],
"orientation": "portrait",
"icon": "./assets/icon.png",
Expand Down
6 changes: 6 additions & 0 deletions components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ import {
RefreshCw,
Settings2,
Share2,
Trash2,
TriangleAlert,
UserCircle2,
Wallet2,
WalletIcon,
X,
Expand Down Expand Up @@ -95,6 +97,8 @@ interopIcon(CircleCheck);
interopIcon(TriangleAlert);
interopIcon(LogOut);
interopIcon(ArchiveRestore);
interopIcon(UserCircle2);
interopIcon(Trash2);

export {
AlertCircle,
Expand Down Expand Up @@ -131,7 +135,9 @@ export {
RefreshCw,
Settings2,
Share2,
Trash2,
TriangleAlert,
UserCircle2,
Wallet2,
WalletIcon,
X,
Expand Down
2 changes: 1 addition & 1 deletion components/QRCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function QRCode({ value }: { value: string }) {
style={{ borderRadius: 28, elevation: 2 }}
>
<View className="flex items-center justify-center p-3 rounded-3xl bg-white w-96 h-96">
<QRCodeLibrary value={value} size={300} />
<QRCodeLibrary value={value} size={300} ecl="H" />
</View>
</LinearGradient>
);
Expand Down
6 changes: 5 additions & 1 deletion components/QRCodeScanner.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useIsFocused } from "@react-navigation/native";
import { Camera } from "expo-camera";
import { PermissionStatus } from "expo-modules-core/src/PermissionsInterface";
import React, { useEffect } from "react";
Expand All @@ -16,6 +17,7 @@ function QRCodeScanner({
onScanned,
startScanning = true,
}: QRCodeScannerProps) {
const isFocused = useIsFocused();
const [isScanning, setScanning] = React.useState(startScanning);
const [isLoading, setLoading] = React.useState(false);
const [permissionStatus, setPermissionStatus] = React.useState(
Expand Down Expand Up @@ -72,7 +74,9 @@ function QRCodeScanner({
</Text>
</View>
)}
{isScanning && <FocusableCamera onScanned={handleScanned} />}
{isScanning && isFocused && (
<FocusableCamera onScanned={handleScanned} />
)}
</>
)}
</View>
Expand Down
8 changes: 1 addition & 7 deletions components/ToastConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Link } from "expo-router";
import { View } from "react-native";
import { ToastConfig } from "react-native-toast-message";
import { useAppStore } from "~/lib/state/appStore";
import { CircleCheck, XCircle } from "./Icons";
import { Button } from "./ui/button";
import { Text } from "./ui/text";
Expand Down Expand Up @@ -35,18 +34,13 @@ export const toastConfig: ToastConfig = {
</View>
),
connectionError: ({ text1, text2, hide }) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const selectedWalletId = useAppStore((store) => store.selectedWalletId);
return (
<View className="bg-foreground rounded-xl px-6 py-3 mx-6 flex flex-col gap-2">
<View className="flex flex-row gap-2 justify-center items-center">
<XCircle className="text-background" width={16} height={16} />
<Text className="text-background font-semibold2">{text1}</Text>
</View>
<Link
href={`/settings/wallets/${selectedWalletId}/wallet-connection`}
asChild
>
<Link href={`/settings/wallets`} asChild>
<Button variant="secondary" size="sm">
<Text>Update Wallet Connection</Text>
</Button>
Expand Down
12 changes: 7 additions & 5 deletions components/ui/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Card = React.forwardRef<
<View
ref={ref}
className={cn(
"rounded-lg border border-border bg-card shadow-sm shadow-foreground/10",
"rounded-2xl border border-border bg-card shadow-sm shadow-foreground/10",
className,
)}
{...props}
Expand All @@ -25,7 +25,7 @@ const CardHeader = React.forwardRef<
>(({ className, ...props }, ref) => (
<View
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
className={cn("flex flex-col space-y-1.5 p-5", className)}
{...props}
/>
));
Expand All @@ -39,6 +39,8 @@ const CardTitle = React.forwardRef<
role="heading"
aria-level={3}
ref={ref}
numberOfLines={1}
ellipsizeMode="tail"
className={cn(
"text-xl text-card-foreground font-semibold2 leading-none tracking-tight",
className,
Expand All @@ -54,7 +56,7 @@ const CardDescription = React.forwardRef<
>(({ className, ...props }, ref) => (
<Text
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
className={cn("mt-1 text-sm text-muted-foreground", className)}
{...props}
/>
));
Expand All @@ -65,7 +67,7 @@ const CardContent = React.forwardRef<
React.ComponentPropsWithoutRef<typeof View>
>(({ className, ...props }, ref) => (
<TextClassContext.Provider value="text-card-foreground">
<View ref={ref} className={cn("p-6 pt-0", className)} {...props} />
<View ref={ref} className={cn("p-5", className)} {...props} />
</TextClassContext.Provider>
));
CardContent.displayName = "CardContent";
Expand All @@ -76,7 +78,7 @@ const CardFooter = React.forwardRef<
>(({ className, ...props }, ref) => (
<View
ref={ref}
className={cn("flex flex-row items-center p-6 pt-0", className)}
className={cn("flex flex-row items-center p-5", className)}
{...props}
/>
));
Expand Down
22 changes: 22 additions & 0 deletions lib/state/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface AppState {
setSecurityEnabled(securityEnabled: boolean): void;
addWallet(wallet: Wallet): void;
addAddressBookEntry(entry: AddressBookEntry): void;
removeAddressBookEntry: (index: number) => void;
reset(): void;
getLastAlbyPayment(): Date | null;
updateLastAlbyPayment(): void;
Expand Down Expand Up @@ -140,6 +141,26 @@ export const useAppStore = create<AppState>()((set, get) => {
});
};

const removeAddressBookEntry = (index: number) => {
const addressBookEntries = [...get().addressBookEntries];
if (index < 0 || index >= addressBookEntries.length) {
return;
}

addressBookEntries.splice(index, 1);

for (let i = index; i < addressBookEntries.length; i++) {
secureStorage.setItem(
getAddressBookEntryKey(i),
JSON.stringify(addressBookEntries[i]),
);
}

secureStorage.removeItem(getAddressBookEntryKey(addressBookEntries.length));

set({ addressBookEntries });
};

const initialSelectedWalletId = +(
secureStorage.getItem(selectedWalletIdKey) || "0"
);
Expand All @@ -162,6 +183,7 @@ export const useAppStore = create<AppState>()((set, get) => {
selectedWalletId: initialSelectedWalletId,
updateCurrentWallet,
removeCurrentWallet,
removeAddressBookEntry,
setUnlocked: (unlocked) => {
set({ unlocked });
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alby-go",
"version": "1.7.1",
"version": "1.7.2",
"main": "./index.js",
"scripts": {
"start": "expo start",
Expand Down
43 changes: 32 additions & 11 deletions pages/send/AddressBook.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Link, router } from "expo-router";
import { Pressable, ScrollView, View } from "react-native";
import { Pressable, ScrollView, TouchableOpacity, View } from "react-native";
import { Trash2 } from "~/components/Icons";
import Screen from "~/components/Screen";
import { Button } from "~/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "~/components/ui/card";
import { Text } from "~/components/ui/text";
import { useAppStore } from "~/lib/state/appStore";

export function AddressBook() {
const addressBookEntries = useAppStore((store) => store.addressBookEntries);

return (
<View className="flex-1 flex flex-col p-6 gap-3">
<Screen title="Address Book" />
Expand All @@ -30,16 +32,35 @@ export function AddressBook() {
},
});
}}
className="mb-4"
>
<Card className="w-full mb-4">
<CardHeader className="w-full">
<CardTitle>
{addressBookEntry.name || addressBookEntry.lightningAddress}
</CardTitle>
<CardDescription>
{addressBookEntry.lightningAddress}
</CardDescription>
</CardHeader>
<Card>
<CardContent className="flex flex-row items-center gap-4">
<View className="h-10 w-10 flex items-center justify-center rounded-full bg-accent">
<Text className="text-foreground text-base font-bold">
{addressBookEntry.name?.[0]?.toUpperCase() ||
addressBookEntry.lightningAddress?.[0]?.toUpperCase() ||
"SN"}
</Text>
</View>
<View className="flex flex-1 flex-col">
<CardTitle>
{addressBookEntry.name ||
addressBookEntry.lightningAddress}
</CardTitle>
<CardDescription>
{addressBookEntry.lightningAddress}
</CardDescription>
</View>
<TouchableOpacity
onPress={(e) => {
e.stopPropagation();
useAppStore.getState().removeAddressBookEntry(index);
}}
>
<Trash2 className="text-destructive" />
</TouchableOpacity>
</CardContent>
</Card>
</Pressable>
))
Expand Down
3 changes: 2 additions & 1 deletion pages/settings/address-book/NewAddressBookEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function NewAddressBookEntry() {
<DismissableKeyboardView>
<View className="flex-1 flex flex-col">
<View className="flex-1 flex flex-col p-3 gap-3">
<Screen title="New Address Book Entry" />
<Screen title="New Contact" />
<Label nativeID="name" className="self-start justify-self-start">
Name
</Label>
Expand Down Expand Up @@ -51,6 +51,7 @@ export function NewAddressBookEntry() {
</View>
<View className="p-6">
<Button
disabled={!name || !lightningAddress}
onPress={() => {
useAppStore
.getState()
Expand Down
Loading

0 comments on commit 7505837

Please sign in to comment.