Skip to content

Commit

Permalink
refactor(mobile): fix biome issues
Browse files Browse the repository at this point in the history
  • Loading branch information
duongdev committed Jul 8, 2024
1 parent bad2b04 commit 1f4e071
Show file tree
Hide file tree
Showing 42 changed files with 583 additions and 467 deletions.
9 changes: 7 additions & 2 deletions apps/mobile/app/(app)/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { theme } from '@/lib/theme'
import { t } from '@lingui/macro'
import { useLingui } from '@lingui/react'
import { Tabs } from 'expo-router'
import { CogIcon, LandPlotIcon, ScanTextIcon, WalletIcon } from 'lucide-react-native'
import {
CogIcon,
LandPlotIcon,
ScanTextIcon,
WalletIcon,
} from 'lucide-react-native'

export default function TabLayout() {
const { colorScheme } = useColorScheme()
Expand All @@ -25,7 +30,7 @@ export default function TabLayout() {
},
headerStyle: {
backgroundColor: theme[colorScheme ?? 'light'].background,
}
},
}}
>
<Tabs.Screen
Expand Down
41 changes: 24 additions & 17 deletions apps/mobile/app/(app)/wallet/[walletId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,31 @@ export default function EditAccountScreen() {
navigation.setOptions({
headerRight: () => (
<Button
size='icon'
variant='ghost'
size="icon"
variant="ghost"
onPress={() =>
Alert.alert(t(i18n)`Delete wallet account will also delete all related transactions!`, '', [
{
text: t(i18n)`Cancel`,
style: 'cancel',
},
{
text: t(i18n)`Delete`,
style: 'destructive',
onPress: () => mutateDelete(walletId as string),
},
])
Alert.alert(
t(
i18n,
)`Delete wallet account will also delete all related transactions!`,
'',
[
{
text: t(i18n)`Cancel`,
style: 'cancel',
},
{
text: t(i18n)`Delete`,
style: 'destructive',
onPress: () => mutateDelete(walletId as string),
},
],
)
}
>
<Trash2Icon className='size-6 text-primary' />
<Trash2Icon className="size-6 text-primary" />
</Button>
)
),
})
}, [])

Expand All @@ -90,12 +96,13 @@ export default function EditAccountScreen() {
>
<AccountForm
onSubmit={({ balance, ...data }) => {
const adjustedBalance = (balance ?? 0) - ((walletAccount.balance as number) ?? 0)
const adjustedBalance =
(balance ?? 0) - ((walletAccount.balance as number) ?? 0)
mutateUpdate({
id: walletId as string,
data: {
...data,
balance: adjustedBalance
balance: adjustedBalance,
},
})
}}
Expand Down
6 changes: 3 additions & 3 deletions apps/mobile/app/(app)/wallet/accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export default function WalletAccountsScreen() {
ListEmptyComponent={
isLoading ? (
<>
<Skeleton className='mx-6 mb-5 mt-3 h-4 rounded-full' />
<Skeleton className='mx-6 mb-5 mt-3 h-4 rounded-full' />
<Skeleton className='mx-6 mb-5 mt-3 h-4 rounded-full' />
<Skeleton className="mx-6 mb-5 mt-3 h-4 rounded-full" />
<Skeleton className="mx-6 mb-5 mt-3 h-4 rounded-full" />
<Skeleton className="mx-6 mb-5 mt-3 h-4 rounded-full" />
</>
) : (
<Text className="font-sans text-muted-foreground text-center mt-6 mb-9">
Expand Down
7 changes: 2 additions & 5 deletions apps/mobile/app/(auth)/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function LoginScreen() {
keyboardShouldPersistTaps="handled"
>
<Trans>
<View className='gap-4'>
<View className="gap-4">
<Text className="text-3xl text-primary font-semibold font-sans">
Manage your expense seamlessly
</Text>
Expand All @@ -38,10 +38,7 @@ export default function LoginScreen() {
<View className="flex flex-col gap-3">
<AppleAuthButton />
<GoogleAuthButton />
<Button
variant="outline"
onPress={() => setWithEmail(true)}
>
<Button variant="outline" onPress={() => setWithEmail(true)}>
<MailIcon className="w-5 h-5 text-primary" />
<Text>{t(i18n)`Continue with Email`}</Text>
</Button>
Expand Down
8 changes: 7 additions & 1 deletion apps/mobile/app/(aux)/privacy-policy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { Text } from 'react-native'
export default function PrivacyScreen() {
return (
<Text className="font-sans m-4">
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.
</Text>
)
}
8 changes: 7 additions & 1 deletion apps/mobile/app/(aux)/terms-of-service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { Text } from 'react-native'
export default function TermsScreen() {
return (
<Text className="font-sans m-4">
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.
</Text>
)
}
15 changes: 9 additions & 6 deletions apps/mobile/components/auth/emailSchema.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import * as z from 'zod';
import * as z from 'zod'

export const emailFormSchema = z.object({
emailAddress: z.string().email().min(1, { message: 'Input your email address' }),
});
emailAddress: z
.string()
.email()
.min(1, { message: 'Input your email address' }),
})

export type EmailFormValues = z.infer<typeof emailFormSchema>;
export type EmailFormValues = z.infer<typeof emailFormSchema>

export const verifyEmailFormSchema = z.object({
code: z.string().min(1, { message: 'Input the verification code' }),
});
})

export type VerifyEmailFormValues = z.infer<typeof verifyEmailFormSchema>;
export type VerifyEmailFormValues = z.infer<typeof verifyEmailFormSchema>
32 changes: 16 additions & 16 deletions apps/mobile/components/common/add-new-button.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { cn } from "@/lib/utils"
import { PlusCircleIcon } from "lucide-react-native"
import { Button } from "../ui/button"
import { Text } from "../ui/text"
import { cn } from '@/lib/utils'
import { PlusCircleIcon } from 'lucide-react-native'
import { Button } from '../ui/button'
import { Text } from '../ui/text'

type AddNewButtonProps = {
label: string
className?: string
onPress?: () => void
}

export function AddNewButton(
{ label, className, onPress }: AddNewButtonProps,
) {
export function AddNewButton({ label, className, onPress }: AddNewButtonProps) {
return (
<Button variant='outline' onPress={onPress} className={cn(
'border-dashed items-center gap-4 mx-6 my-1.5 !h-11 !py-2',
className
)}>
<PlusCircleIcon className='w-5 h-5 text-muted-foreground' />
<Text className="font-normal font-sans">
{label}
</Text>
<Button
variant="outline"
onPress={onPress}
className={cn(
'border-dashed items-center gap-4 mx-6 my-1.5 !h-11 !py-2',
className,
)}
>
<PlusCircleIcon className="w-5 h-5 text-muted-foreground" />
<Text className="font-normal font-sans">{label}</Text>
</Button>
)
}
}
12 changes: 6 additions & 6 deletions apps/mobile/components/common/back-button.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useRouter } from "expo-router";
import { ArrowLeftIcon } from "lucide-react-native";
import { Button } from "../ui/button";
import { useRouter } from 'expo-router'
import { ArrowLeftIcon } from 'lucide-react-native'
import { Button } from '../ui/button'

export function BackButton() {
const router = useRouter()
if (!router.canGoBack) {
return null
}
return (
<Button size='icon' variant='ghost' onPress={router.back}>
<ArrowLeftIcon className='w-6 h-6 text-primary' />
<Button size="icon" variant="ghost" onPress={router.back}>
<ArrowLeftIcon className="w-6 h-6 text-primary" />
</Button>
)
}
}
35 changes: 17 additions & 18 deletions apps/mobile/components/common/currency-sheet.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { currencies } from "@6pm/currency";
import { BottomSheetFlatList, BottomSheetTextInput } from "@gorhom/bottom-sheet";
import { t } from "@lingui/macro";
import { useLingui } from "@lingui/react";
import { SearchIcon } from "lucide-react-native";
import { useState } from "react";
import { View } from "react-native";
import { Text } from "../ui/text";
import { MenuItem } from "./menu-item";
import { currencies } from '@6pm/currency'
import { BottomSheetFlatList, BottomSheetTextInput } from '@gorhom/bottom-sheet'
import { t } from '@lingui/macro'
import { useLingui } from '@lingui/react'
import { SearchIcon } from 'lucide-react-native'
import { useState } from 'react'
import { View } from 'react-native'
import { Text } from '../ui/text'
import { MenuItem } from './menu-item'

type CurrencySheetListProps = {
onSelect: (currency: typeof currencies[number]) => void;
value: string;
onSelect: (currency: (typeof currencies)[number]) => void
value: string
}

export function CurrencySheetList({ onSelect, value }: CurrencySheetListProps) {
Expand All @@ -19,7 +19,10 @@ export function CurrencySheetList({ onSelect, value }: CurrencySheetListProps) {

const filteredCurrencies = currencies.filter((currency) => {
const search = searchValue.toLowerCase()
return currency.name.toLowerCase().includes(search) || currency.code.toLowerCase().includes(search)
return (
currency.name.toLowerCase().includes(search) ||
currency.code.toLowerCase().includes(search)
)
})

return (
Expand All @@ -36,7 +39,7 @@ export function CurrencySheetList({ onSelect, value }: CurrencySheetListProps) {
<BottomSheetTextInput
placeholder={t(i18n)`Search currency...`}
placeholderClassName="text-muted-foreground font-sans"
className='mb-3 pl-11 web:flex h-11 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-sm lg:text-sm native:text-base native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 font-sans web:focus-visible:ring-ring web:focus-visible:ring-offset-2'
className="mb-3 pl-11 web:flex h-11 web:w-full rounded-md border border-input bg-background px-3 web:py-2 text-sm lg:text-sm native:text-base native:leading-[1.25] text-foreground placeholder:text-muted-foreground web:ring-offset-background file:border-0 file:bg-transparent file:font-medium web:focus-visible:outline-none web:focus-visible:ring-2 font-sans web:focus-visible:ring-ring web:focus-visible:ring-offset-2"
value={searchValue}
onChangeText={setSearchValue}
/>
Expand All @@ -47,11 +50,7 @@ export function CurrencySheetList({ onSelect, value }: CurrencySheetListProps) {
label={item.name}
onPress={() => onSelect(item)}
className={item.code === value ? 'bg-muted' : ''}
rightSection={
<Text>
{item.code}
</Text>
}
rightSection={<Text>{item.code}</Text>}
/>
)}
/>
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/components/common/generic-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { type LucideProps, icons } from 'lucide-react-native'
import type { FC } from 'react'

/**
* TODO: Only export the icons that are used to reduce the bundle size
*/
* TODO: Only export the icons that are used to reduce the bundle size
*/

const GenericIcon: FC<
LucideProps & {
Expand Down
5 changes: 1 addition & 4 deletions apps/mobile/components/common/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import Svg, { type SvgProps, Path } from 'react-native-svg'

export const Logo = (props: SvgProps) => (
<Svg
viewBox="0 0 765 765"
fill="none"
{...props}>
<Svg viewBox="0 0 765 765" fill="none" {...props}>
<Path
fill="#E4E4E7"
fillRule="evenodd"
Expand Down
15 changes: 11 additions & 4 deletions apps/mobile/components/common/menu-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@ type MenuItemProps = {
disabled?: boolean
}

export const MenuItem = forwardRef(function(
{ label, icon: Icon, rightSection, onPress, className, disabled }: MenuItemProps,
export const MenuItem = forwardRef(function (
{
label,
icon: Icon,
rightSection,
onPress,
className,
disabled,
}: MenuItemProps,
ref: React.ForwardedRef<React.ElementRef<typeof Pressable>>,
) {
return (
Expand All @@ -23,8 +30,8 @@ export const MenuItem = forwardRef(function(
ref={ref}
disabled={disabled}
className={cn(
"flex flex-row items-center gap-4 px-6 justify-between h-14 active:bg-muted",
disabled && "opacity-50",
'flex flex-row items-center gap-4 px-6 justify-between h-14 active:bg-muted',
disabled && 'opacity-50',
className,
)}
>
Expand Down
8 changes: 4 additions & 4 deletions apps/mobile/components/common/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ export function Toolbar() {
const { i18n } = useLingui()
return (
<View className="gap-3 items-center absolute flex-row bottom-4 left-6 right-6">
<TouchableOpacity activeOpacity={0.8} className='flex-1'>
<TouchableOpacity activeOpacity={0.8} className="flex-1">
<Input
placeholder={t(i18n)`Ask AI anything...`}
className="flex-1 pl-10"
// editable={false}
pointerEvents='none'
pointerEvents="none"
/>
<View className="absolute left-3 top-1/2 transform -translate-y-1/2">
<Sparkles className="w-5 h-5 text-muted-foreground" />
</View>
</TouchableOpacity>
<Link href="/new-record" asChild>
<Button size='icon'>
<PlusIcon className='size-6 text-primary-foreground' />
<Button size="icon">
<PlusIcon className="size-6 text-primary-foreground" />
</Button>
</Link>
</View>
Expand Down
Loading

0 comments on commit 1f4e071

Please sign in to comment.