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

Disable send route when sending is locked #1115

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
77 changes: 48 additions & 29 deletions packages/app/components/sidebar/HomeSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ScrollView,
Separator,
SideBar,
Spinner,
useMedia,
XStack,
YStack,
Expand All @@ -28,6 +29,7 @@ import { NavSheet } from '../NavSheet'
import { useUser } from 'app/utils/useUser'
import { ReferralLink } from '../ReferralLink'
import { useHoverStyles } from 'app/utils/useHoverStyles'
import { useIsSendingUnlocked } from 'app/utils/useIsSendingUnlocked'

const links = [
{
Expand Down Expand Up @@ -60,16 +62,23 @@ const links = [
].filter(Boolean) as { icon: ReactElement; text: string; href: string }[]

const HomeSideBar = ({ ...props }: YStackProps) => {
const { isSendingUnlocked, isLoading } = useIsSendingUnlocked()

return (
<SideBar {...props} ai={'flex-start'} pl="$7">
<Link href={'/'}>
<IconSendLogo color={'$color12'} size={'$2.5'} />
</Link>

<YStack gap={'$7'} pt={'$10'} jc={'space-between'}>
{links.map((link) => (
<SideBarNavLink key={link.href} {...link} />
))}
{!isLoading &&
links.map((link) => (
<SideBarNavLink
key={link.href}
disabled={link.href === '/send' && !isSendingUnlocked}
{...link}
/>
))}
</YStack>
</SideBar>
)
Expand All @@ -79,6 +88,7 @@ const HomeBottomSheet = () => {
const { profile } = useUser()
const hoverStyles = useHoverStyles()
const avatarUrl = profile?.avatar_url
const { isSendingUnlocked, isLoading } = useIsSendingUnlocked()

return (
<NavSheet navId="home">
Expand All @@ -96,34 +106,43 @@ const HomeBottomSheet = () => {
</YStack>
</XStack>
<Nav display="flex" flex={2} height="100%">
<ScrollView gap={'$4'} alignItems="stretch" height="100%">
{links.map((link, idx) => {
const first = idx === 0
const last = idx === links.length - 1
{isLoading ? (
<Spinner size="large" color="$color12" />
) : (
<ScrollView gap={'$4'} alignItems="stretch" height="100%">
{links.map((link, idx) => {
const first = idx === 0
const last = idx === links.length - 1

return (
<YStack
key={link.href}
gap={'$4'}
alignItems="stretch"
justifyContent="center"
p={'$2'}
w={'100%'}
bg={'$color1'}
borderTopLeftRadius={first ? '$6' : 0}
borderTopRightRadius={first ? '$6' : 0}
borderBottomLeftRadius={last ? '$6' : 0}
borderBottomRightRadius={last ? '$6' : 0}
paddingTop={first ? '$2' : 0}
paddingBottom={last ? '$2' : 0}
>
<YStack w={'100%'} p={'$4'} borderRadius={'$4'} hoverStyle={hoverStyles}>
<SideBarNavLink key={link.href} hoverStyle={{}} {...link} />
return (
<YStack
key={link.href}
gap={'$4'}
alignItems="stretch"
justifyContent="center"
p={'$2'}
w={'100%'}
bg={'$color1'}
borderTopLeftRadius={first ? '$6' : 0}
borderTopRightRadius={first ? '$6' : 0}
borderBottomLeftRadius={last ? '$6' : 0}
borderBottomRightRadius={last ? '$6' : 0}
paddingTop={first ? '$2' : 0}
paddingBottom={last ? '$2' : 0}
>
<YStack w={'100%'} p={'$4'} borderRadius={'$4'} hoverStyle={hoverStyles}>
<SideBarNavLink
key={link.href}
hoverStyle={{}}
disabled={link.href === '/send' && !isSendingUnlocked}
{...link}
/>
</YStack>
</YStack>
</YStack>
)
})}
</ScrollView>
)
})}
</ScrollView>
)}
</Nav>
</NavSheet>
)
Expand Down
9 changes: 8 additions & 1 deletion packages/app/components/sidebar/SideBarNavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ export function SideBarNavLink({
scale: '105%',
color: '$color12',
}}
disabledStyle={{
opacity: 0.5,
cursor: 'not-allowed',
left: '0%',
scale: '100%',
color: '$color10',
}}
fontSize={'$7'}
f={1}
fontWeight={isActiveRoute ? '400' : '300'}
gap="$3"
display="flex"
alignItems="center"
{...props}
href={props.disabled ? '' : props.href}
href={props.disabled ? '#' : props.href}
>
{icon}
{text}
Expand Down
174 changes: 89 additions & 85 deletions packages/app/features/home/__snapshots__/TokenDetails.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -953,122 +953,126 @@ exports[`TokenDetails renders correctly 1`] = `
}
>
<View
style={
{
"alignItems": "center",
"borderBottomLeftRadius": 9,
"borderBottomRightRadius": 9,
"borderTopLeftRadius": 9,
"borderTopRightRadius": 9,
"flexDirection": "column",
"gap": 7,
"height": 48,
"justifyContent": "center",
"maxHeight": 48,
"maxWidth": 48,
"minHeight": 48,
"minWidth": 48,
"overflow": "hidden",
"position": "relative",
"width": 48,
}
}
testID="MockSolitoLink"
>
<View
style={
{
"bottom": 0,
"alignItems": "center",
"borderBottomLeftRadius": 9,
"borderBottomRightRadius": 9,
"borderTopLeftRadius": 9,
"borderTopRightRadius": 9,
"flexDirection": "column",
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": 1,
"gap": 7,
"height": 48,
"justifyContent": "center",
"maxHeight": 48,
"maxWidth": 48,
"minHeight": 48,
"minWidth": 48,
"overflow": "hidden",
"position": "relative",
"width": 48,
}
}
>
<Image
fullscreen={true}
onError={[Function]}
onLoad={[Function]}
source={
{
"uri": "https://i.pravatar.cc/500?u=alice",
}
}
<View
style={
{
"height": 48,
"width": 48,
"bottom": 0,
"flexDirection": "column",
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": 1,
}
}
/>
</View>
<View
style={
{
"backgroundColor": "#86AE80",
"bottom": 0,
"flexDirection": "column",
"justifyContent": "center",
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": 0,
}
}
>
>
<Image
fullscreen={true}
onError={[Function]}
onLoad={[Function]}
source={
{
"uri": "https://i.pravatar.cc/500?u=alice",
}
}
style={
{
"height": 48,
"width": 48,
}
}
/>
</View>
<View
style={
{
"alignItems": "center",
"borderBottomLeftRadius": 9,
"borderBottomRightRadius": 9,
"borderTopLeftRadius": 9,
"borderTopRightRadius": 9,
"backgroundColor": "#86AE80",
"bottom": 0,
"flexDirection": "column",
"height": 48,
"justifyContent": "center",
"maxHeight": 48,
"maxWidth": 48,
"minHeight": 48,
"minWidth": 48,
"overflow": "hidden",
"position": "relative",
"width": 48,
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": 0,
}
}
>
<View
style={
{
"bottom": 0,
"alignItems": "center",
"borderBottomLeftRadius": 9,
"borderBottomRightRadius": 9,
"borderTopLeftRadius": 9,
"borderTopRightRadius": 9,
"flexDirection": "column",
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": 1,
"height": 48,
"justifyContent": "center",
"maxHeight": 48,
"maxWidth": 48,
"minHeight": 48,
"minWidth": 48,
"overflow": "hidden",
"position": "relative",
"width": 48,
}
}
>
<Image
fullscreen={true}
onError={[Function]}
onLoad={[Function]}
source={
{
"uri": "https://ui-avatars.com/api/?name=Alice&size=256&format=png&background=86ad7f",
}
}
<View
style={
{
"height": 48,
"width": 48,
"bottom": 0,
"flexDirection": "column",
"left": 0,
"position": "absolute",
"right": 0,
"top": 0,
"zIndex": 1,
}
}
/>
>
<Image
fullscreen={true}
onError={[Function]}
onLoad={[Function]}
source={
{
"uri": "https://ui-avatars.com/api/?name=Alice&size=256&format=png&background=86ad7f",
}
}
style={
{
"height": 48,
"width": 48,
}
}
/>
</View>
</View>
</View>
</View>
Expand Down
Loading
Loading