Skip to content

Commit 4fb1bf7

Browse files
committed
Merge branch 'dev' of bargsend:0xsend/sendapp into temporal-changes
2 parents 15d8624 + 1ff344e commit 4fb1bf7

17 files changed

+1056
-1188
lines changed

apps/next/pages/[tag].tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import { CheckoutTagSchema } from 'app/features/account/sendtag/checkout/Checkou
1010
import { assert } from 'app/utils/assert'
1111
import { supabaseAdmin } from 'app/utils/supabase/admin'
1212
import { ButtonOption, TopNav } from 'app/components/TopNav'
13+
import { MobileButtonRowLayout } from 'app/components/MobileButtonRowLayout'
1314

14-
export const Page: NextPageWithLayout<{ sendid: string }> = ({ sendid }) => {
15+
export const Page: NextPageWithLayout<{ sendid: number | null }> = ({ sendid }) => {
1516
return (
1617
<>
1718
<Head>
@@ -82,9 +83,11 @@ export const getServerSideProps = (async (ctx: GetServerSidePropsContext) => {
8283
}) satisfies GetServerSideProps
8384

8485
Page.getLayout = (children) => (
85-
<HomeLayout TopNav={<TopNav header="Profile" noSubroute button={ButtonOption.PROFILE} />}>
86-
{children}
87-
</HomeLayout>
86+
<MobileButtonRowLayout.Profile>
87+
<HomeLayout TopNav={<TopNav header="Profile" noSubroute button={ButtonOption.PROFILE} />}>
88+
{children}
89+
</HomeLayout>
90+
</MobileButtonRowLayout.Profile>
8891
)
8992

9093
export default Page

apps/next/pages/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { useEffect, useState } from 'react'
1515
import { getRemoteAssets } from 'utils/getRemoteAssets'
1616
import type { GetPlaiceholderImage } from 'app/utils/getPlaiceholderImage'
1717

18+
import { MobileButtonRowLayout } from 'app/components/MobileButtonRowLayout'
19+
1820
const log = debug('app:pages:index')
1921

2022
export const Page: NextPageWithLayout<InferGetServerSidePropsType<typeof getServerSideProps>> = ({
@@ -34,9 +36,13 @@ export const Page: NextPageWithLayout<InferGetServerSidePropsType<typeof getServ
3436
<title>Send | Home</title>
3537
</Head>
3638
{session ? (
37-
<HomeLayout TopNav={<TopNav header="Home" button={ButtonOption.PROFILE} showLogo={true} />}>
38-
<HomeScreen />
39-
</HomeLayout>
39+
<MobileButtonRowLayout.Home>
40+
<HomeLayout
41+
TopNav={<TopNav header="Home" button={ButtonOption.PROFILE} showLogo={true} />}
42+
>
43+
<HomeScreen />
44+
</HomeLayout>
45+
</MobileButtonRowLayout.Home>
4046
) : (
4147
<AuthCarouselContext.Provider
4248
value={{

apps/next/pages/profile/[sendid].tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Database } from '@my/supabase/database.types'
88
import { userOnboarded } from 'utils/userOnboarded'
99
import { supabaseAdmin } from 'app/utils/supabase/admin'
1010
import { ButtonOption, TopNav } from 'app/components/TopNav'
11+
import { MobileButtonRowLayout } from 'app/components/MobileButtonRowLayout'
1112

1213
export const Page: NextPageWithLayout = () => {
1314
return (
@@ -67,9 +68,11 @@ export const getServerSideProps = (async (ctx: GetServerSidePropsContext) => {
6768
}) satisfies GetServerSideProps
6869

6970
Page.getLayout = (children) => (
70-
<HomeLayout TopNav={<TopNav header="Profile" noSubroute button={ButtonOption.PROFILE} />}>
71-
{children}
72-
</HomeLayout>
71+
<MobileButtonRowLayout.Profile>
72+
<HomeLayout TopNav={<TopNav header="Profile" noSubroute button={ButtonOption.PROFILE} />}>
73+
{children}
74+
</HomeLayout>
75+
</MobileButtonRowLayout.Profile>
7376
)
7477

7578
export default Page
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import {
2+
XStack,
3+
Stack,
4+
styled,
5+
type XStackProps,
6+
AnimatePresence,
7+
LinearGradient,
8+
usePwa,
9+
} from '@my/ui'
10+
import { useSendAccount } from 'app/utils/send-accounts'
11+
import { useSendAccountBalances } from 'app/utils/useSendAccountBalances'
12+
import { parseUnits } from 'viem'
13+
import { coinsDict } from 'app/data/coins'
14+
import { baseMainnet, usdcAddress } from '@my/wagmi'
15+
import { HomeButtons } from '../features/home/HomeButtons'
16+
import { useScrollDirection } from '../provider/scroll'
17+
import { ProfileButtons } from 'app/features/profile/ProfileButtons'
18+
import { useUser } from 'app/utils/useUser'
19+
import { useProfileLookup } from 'app/utils/useProfileLookup'
20+
import { useProfileScreenParams } from 'app/routers/params'
21+
22+
const Row = styled(XStack, {
23+
w: '100%',
24+
ai: 'center',
25+
mx: 'auto',
26+
jc: 'space-around',
27+
gap: '$4',
28+
maw: 768,
29+
$gtLg: {
30+
pt: '$4',
31+
},
32+
})
33+
34+
export const Home = ({ children, ...props }: XStackProps) => {
35+
const isPwa = usePwa()
36+
const { isLoading: isLoadingSendAccount } = useSendAccount()
37+
const { balances, isLoading: isLoadingBalances } = useSendAccountBalances()
38+
const usdcBalance = balances?.USDC
39+
const canSend =
40+
usdcBalance !== undefined &&
41+
usdcBalance >= parseUnits('.20', coinsDict[usdcAddress[baseMainnet.id]].decimals)
42+
43+
const { direction } = useScrollDirection()
44+
45+
const isLoading = isLoadingSendAccount || isLoadingBalances
46+
47+
return (
48+
<>
49+
{children}
50+
<AnimatePresence>
51+
{!isLoading && direction !== 'down' && (
52+
<Stack
53+
w={'100%'}
54+
pb={isPwa ? '$1' : '$5'}
55+
px="$4"
56+
$platform-web={{
57+
position: 'fixed',
58+
bottom: 0,
59+
}}
60+
$gtLg={{
61+
display: 'none',
62+
}}
63+
animation="200ms"
64+
opacity={1}
65+
animateOnly={['scale', 'transform', 'opacity']}
66+
enterStyle={{ opacity: 0, scale: 0.9 }}
67+
exitStyle={{ opacity: 0, scale: 0.95 }}
68+
>
69+
<LinearGradient
70+
h={'150%'}
71+
top={'-50%'}
72+
start={{ x: 0, y: 1 }}
73+
end={{ x: 0, y: 0 }}
74+
locations={[0, 0.33]}
75+
fullscreen
76+
colors={['transparent', '$background']}
77+
$gtLg={{ display: 'none' }}
78+
/>
79+
<Row {...props}>
80+
<Stack f={1} w="50%" flexDirection="row-reverse" maw={350}>
81+
<HomeButtons.DepositButton />
82+
</Stack>
83+
{canSend && (
84+
<Stack f={1} w="50%" jc={'center'} maw={350}>
85+
<HomeButtons.SendButton />
86+
</Stack>
87+
)}
88+
</Row>
89+
</Stack>
90+
)}
91+
</AnimatePresence>
92+
</>
93+
)
94+
}
95+
96+
export const Profile = (
97+
{ children, ...props }: XStackProps //@todo another use case for a generated type for our route names
98+
) => {
99+
const isPwa = usePwa()
100+
const [{ sendid, tag }] = useProfileScreenParams()
101+
const identifier = tag ?? sendid ?? ''
102+
const identifierType = tag ? 'tag' : 'sendid'
103+
const { profile, isLoading } = useUser()
104+
const { data: otherUserProfile } = useProfileLookup(identifierType, identifier?.toString() || '')
105+
106+
const { direction } = useScrollDirection()
107+
108+
const isVisible = Boolean(otherUserProfile) && profile?.send_id !== otherUserProfile?.sendid
109+
110+
return (
111+
<>
112+
{children}
113+
<AnimatePresence>
114+
{!isLoading && isVisible && direction !== 'down' && (
115+
<Stack
116+
w={'100%'}
117+
pb={isPwa ? '$1' : '$5'}
118+
px="$4"
119+
$platform-web={{
120+
position: 'fixed',
121+
bottom: 0,
122+
}}
123+
$gtLg={{
124+
display: 'none',
125+
}}
126+
animation="200ms"
127+
opacity={1}
128+
animateOnly={['scale', 'transform', 'opacity']}
129+
enterStyle={{ opacity: 0, scale: 0.9 }}
130+
exitStyle={{ opacity: 0, scale: 0.95 }}
131+
>
132+
<LinearGradient
133+
h={'150%'}
134+
top={'-50%'}
135+
start={{ x: 0, y: 1 }}
136+
end={{ x: 0, y: 0 }}
137+
locations={[0, 0.33]}
138+
fullscreen
139+
colors={['transparent', '$background']}
140+
$gtLg={{ display: 'none' }}
141+
/>
142+
<Row {...props}>
143+
<Stack w={200}>
144+
<ProfileButtons.SendButton
145+
identifier={otherUserProfile?.tag ?? otherUserProfile?.sendid ?? ''}
146+
idType="tag"
147+
/>
148+
</Stack>
149+
</Row>
150+
</Stack>
151+
)}
152+
</AnimatePresence>
153+
</>
154+
)
155+
}
156+
157+
export const MobileButtonRowLayout = {
158+
Home: Home,
159+
Profile: Profile,
160+
}
+15-91
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,18 @@
11
import { IconArrowRight, IconDeposit } from 'app/components/icons'
22
import { useRootScreenParams } from 'app/routers/params'
3-
import { parseUnits } from 'viem'
4-
import { useSendAccountBalances } from 'app/utils/useSendAccountBalances'
5-
import { coinsDict } from 'app/data/coins'
6-
import { baseMainnet, usdcAddress } from '@my/wagmi'
7-
import {
8-
XStack,
9-
LinkableButton,
10-
Stack,
11-
styled,
12-
type XStackProps,
13-
AnimatePresence,
14-
LinearGradient,
15-
usePwa,
16-
useMedia,
17-
type LinkableButtonProps,
18-
} from '@my/ui'
19-
import { useSendAccount } from 'app/utils/send-accounts'
20-
21-
const Row = styled(XStack, {
22-
w: '100%',
23-
ai: 'center',
24-
mx: 'auto',
25-
jc: 'space-around',
26-
gap: '$4',
27-
maw: 768,
28-
$gtLg: {
29-
pt: '$4',
30-
},
31-
})
32-
33-
export const HomeButtonRow = ({
34-
isVisible = true,
35-
...props
36-
}: XStackProps & { isVisible?: boolean }) => {
37-
const isPwa = usePwa()
38-
const media = useMedia()
39-
const { isLoading: isSendAccountLoading } = useSendAccount()
40-
const { balances, isLoading: balancesIsLoading } = useSendAccountBalances()
41-
const usdcBalance = balances?.USDC
42-
const canSend =
43-
usdcBalance !== undefined &&
44-
usdcBalance >= parseUnits('.20', coinsDict[usdcAddress[baseMainnet.id]].decimals)
45-
46-
return (
47-
<AnimatePresence>
48-
{!balancesIsLoading && !isSendAccountLoading && isVisible && (
49-
<Stack
50-
w={'100%'}
51-
pb={isPwa ? '$1' : '$5'}
52-
px="$4"
53-
$platform-web={{
54-
position: media.lg ? 'fixed' : 'relative',
55-
bottom: 0,
56-
}}
57-
$gtLg={{
58-
position: 'relative',
59-
pb: '$0',
60-
px: '$0',
61-
}}
62-
animation="200ms"
63-
opacity={1}
64-
animateOnly={['scale', 'transform', 'opacity']}
65-
enterStyle={{ opacity: 0, scale: 0.9 }}
66-
exitStyle={{ opacity: 0, scale: 0.95 }}
67-
>
68-
<LinearGradient
69-
h={'150%'}
70-
top={'-50%'}
71-
start={{ x: 0, y: 1 }}
72-
end={{ x: 0, y: 0 }}
73-
locations={[0, 0.33]}
74-
fullscreen
75-
colors={['transparent', '$background']}
76-
$gtLg={{ display: 'none' }}
77-
/>
78-
<Row {...props}>
79-
<Stack f={1} w="50%" flexDirection="row-reverse" maw={350}>
80-
<DepositButton />
81-
</Stack>
82-
{canSend && (
83-
<Stack f={1} w="50%" jc={'center'} maw={350}>
84-
<SendButton />
85-
</Stack>
86-
)}
87-
</Row>
88-
</Stack>
89-
)}
90-
</AnimatePresence>
91-
)
92-
}
3+
import { XStack, LinkableButton, type LinkableButtonProps } from '@my/ui'
934

945
export const DepositButton = () => {
956
return (
96-
<LinkableButton theme="green" href="/deposit" px={'$3.5'} h={'$4.5'} borderRadius={'$4'} f={1}>
7+
<LinkableButton
8+
theme="green"
9+
href="/deposit"
10+
px={'$3.5'}
11+
h={'$4.5'}
12+
borderRadius={'$4'}
13+
f={1}
14+
testID="homeDepositButton"
15+
>
9716
<XStack w={'100%'} jc={'space-between'} ai={'center'}>
9817
<LinkableButton.Text
9918
fontWeight={'500'}
@@ -139,3 +58,8 @@ export const SendButton = (props: Omit<LinkableButtonProps, 'href' | 'children'>
13958
</LinkableButton>
14059
)
14160
}
61+
62+
export const HomeButtons = {
63+
DepositButton: DepositButton,
64+
SendButton: SendButton,
65+
}

0 commit comments

Comments
 (0)