Skip to content

Commit

Permalink
Fix voter screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Perronef5 committed Oct 15, 2024
1 parent fa45693 commit 6596735
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 150 deletions.
82 changes: 36 additions & 46 deletions src/components/BlurActionSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { memo, useCallback, useMemo, useRef, useState } from 'react'
import {
BottomSheetModal,
BottomSheetModalProvider,
import React, { memo, useCallback, useMemo, useRef } from 'react'
import BottomSheet, {
BottomSheetBackdrop,
BottomSheetScrollView,
} from '@gorhom/bottom-sheet'
import { LayoutChangeEvent } from 'react-native'
import { Edge } from 'react-native-safe-area-context'
import { useAsync } from 'react-async-hook'
import { Portal } from '@gorhom/portal'
import { useColors, useOpacity } from '@theme/themeHooks'
import CustomBlurBackdrop from './CustomBlurBackdrop'
import { ThemeProvider } from '@shopify/restyle'
import { lightTheme } from '@theme/theme'
import { useTranslation } from 'react-i18next'
import SafeAreaBox from './SafeAreaBox'
import { wh } from '../utils/layout'
import HeliumBottomSheet from './HeliumBottomSheet'
import Text from './Text'

type Props = {
title: string
Expand All @@ -21,10 +21,8 @@ type Props = {
}

const BlurActionSheet = ({ title, open, children, onClose }: Props) => {
const bottomSheetModalRef = useRef<BottomSheetModal>(null)
const [contentHeight, setContentHeight] = useState(0)
const { backgroundStyle } = useOpacity('gray.700', 0.4)
const colors = useColors()
const bottomSheetModalRef = useRef<BottomSheet>(null)
const { t } = useTranslation()

const handleOnClose = useCallback(() => {
if (onClose) {
Expand All @@ -34,62 +32,54 @@ const BlurActionSheet = ({ title, open, children, onClose }: Props) => {

useAsync(async () => {
if (open) {
await bottomSheetModalRef.current?.present()
await bottomSheetModalRef.current?.expand()
} else {
await bottomSheetModalRef.current?.dismiss()
await bottomSheetModalRef.current?.close()
}
}, [open])

const snapPoints = useMemo(() => {
let maxHeight: number | string = '75%'
if (contentHeight > 0) {
maxHeight = Math.min(wh * 0.75, contentHeight)
}

return [maxHeight]
}, [contentHeight])

const renderBackdrop = useCallback(
(props) => (
<CustomBlurBackdrop
<BottomSheetBackdrop
onPress={handleOnClose}
title={title}
disappearsOnIndex={-1}
appearsOnIndex={0}
opacity={0.6}
opacity={1}
{...props}
/>
>
<SafeAreaBox flex={1}>
<Text
variant="textLgSemibold"
color="primaryText"
marginTop="xl"
textAlign="center"
>
{t('blurActionSheet.selectAnOption')}
</Text>
</SafeAreaBox>
</BottomSheetBackdrop>
),
[handleOnClose, title],
[handleOnClose, title, t],
)

const safeEdges = useMemo(() => ['bottom'] as Edge[], [])

const handleContentLayout = useCallback((e: LayoutChangeEvent) => {
setContentHeight(e.nativeEvent.layout.height + 40)
}, [])

return (
<Portal>
<BottomSheetModalProvider>
<BottomSheetModal
ref={bottomSheetModalRef}
index={0}
snapPoints={snapPoints}
backdropComponent={renderBackdrop}
backgroundStyle={backgroundStyle}
onDismiss={handleOnClose}
handleIndicatorStyle={{
backgroundColor: colors.primaryText,
}}
>
<HeliumBottomSheet
ref={bottomSheetModalRef}
index={-1}
backdropComponent={renderBackdrop}
>
<ThemeProvider theme={lightTheme}>
<BottomSheetScrollView>
<SafeAreaBox edges={safeEdges} onLayout={handleContentLayout}>
<SafeAreaBox edges={safeEdges} padding="xl" marginTop="xl">
{children}
</SafeAreaBox>
</BottomSheetScrollView>
</BottomSheetModal>
</BottomSheetModalProvider>
</ThemeProvider>
</HeliumBottomSheet>
</Portal>
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'
import CheckMarkFill from '@assets/images/checkmarkFill.svg'
import { useColors } from '@theme/themeHooks'
import { Color } from '@theme/theme'
import { Color, Theme } from '@theme/theme'
import { Insets } from 'react-native'
import { BoxProps } from '@shopify/restyle'
import Box from './Box'
import Text from './Text'
import { TouchableOpacityBoxProps } from './TouchableOpacityBox'
import TouchableContainer from './TouchableContainer'

export const LIST_ITEM_HEIGHT = 70
Expand All @@ -21,7 +21,7 @@ export type ListItemProps = {
hasDivider?: boolean
hasPressedState?: boolean
hitSlop?: Insets
} & TouchableOpacityBoxProps
} & BoxProps<Theme>

const ListItem = ({
Icon,
Expand Down
22 changes: 14 additions & 8 deletions src/components/Pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Color =
| 'iotGreen'
| 'mobileBlue'
| 'hntBlue'
| 'quinary'
export const Pill = memo(
({
text,
Expand Down Expand Up @@ -50,24 +51,29 @@ export const Pill = memo(
text: 'orange.500',
},
black: {
background: 'black',
background: 'base.black',
text: 'base.white',
border: 'black',
border: 'base.black',
},
hntBlue: {
background: 'hntBlue',
background: 'purple.500',
text: 'base.white',
border: 'black',
border: 'purple.500',
},
iotGreen: {
background: 'iotGreen',
text: 'base.white',
border: 'black',
border: 'iotGreen',
},
mobileBlue: {
background: 'mobileBlue',
background: 'blue.600',
text: 'base.white',
border: 'black',
border: 'blue.600',
},
quinary: {
background: 'fg.quinary-400',
text: 'primaryBackground',
border: 'fg.quinary-400',
},
}
return (
Expand All @@ -93,11 +99,11 @@ export const Pill = memo(

{text ? (
<Text
variant="textSmRegular"
ml="2"
mr="2"
color={colorDefs[color].text as any}

Check warning on line 104 in src/components/Pill.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
{...textProps}
variant="textSmSemibold"
>
{text}
</Text>
Expand Down
13 changes: 4 additions & 9 deletions src/components/SegmentedControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ const SegmentedItem = ({
>
{option.Icon && (
<option.Icon
color={selected ? primaryBackground : colors['fg.quinary-400']}
color={selected ? primaryBackground : colors['text.disabled']}
{...option.iconProps}
/>
)}
<Text
variant="textLgSemibold"
fontSize={17}
color={selected ? 'primaryBackground' : 'fg.quinary-400'}
color={selected ? 'primaryBackground' : 'text.disabled'}
textAlign="center"
>
{option.label}
Expand Down Expand Up @@ -162,13 +162,8 @@ const SegmentedControl = forwardRef(
}, [leftPosition, itemWidth, hasTouched])

return (
<Box borderRadius="4xl" alignItems="center">
<Box
borderRadius="4xl"
{...boxProps}
flexDirection="row"
position="relative"
>
<Box borderRadius="4xl" alignItems="center" {...boxProps}>
<Box borderRadius="4xl" flexDirection="row" position="relative">
<ReAnimatedBox
position="absolute"
width={itemWidth}
Expand Down
40 changes: 26 additions & 14 deletions src/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,32 @@ export const Select: React.FC<SelectProps> = ({
open={filtersOpen}
onClose={() => setFiltersOpen(false)}
>
<>
{options.map((option) => (
<ListItem
key={option.value}
title={option.label}
onPress={() => {
onValueChange(option.value)
setFiltersOpen(false)
}}
selected={value === option.value}
hasPressedState={false}
/>
))}
</>
<Box marginTop="6xl">
{options.map((option, index) => {
const borderTopStartRadius = index === 0 ? 'xl' : 'none'
const borderTopEndRadius = index === 0 ? 'xl' : 'none'
const borderBottomStartRadius =
index === options.length - 1 ? 'xl' : 'none'
const borderBottomEndRadius =
index === options.length - 1 ? 'xl' : 'none'

return (
<ListItem
key={option.value}
title={option.label}
onPress={() => {
onValueChange(option.value)
setFiltersOpen(false)
}}
selected={value === option.value}
borderTopStartRadius={borderTopStartRadius}
borderTopEndRadius={borderTopEndRadius}
borderBottomStartRadius={borderBottomStartRadius}
borderBottomEndRadius={borderBottomEndRadius}
/>
)
})}
</Box>
</BlurActionSheet>
</>
)
Expand Down
8 changes: 4 additions & 4 deletions src/features/account/AccountActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ const AccountActionBar = ({
>
<FabButton
icon="swaps"
backgroundColor="orange.300"
backgroundColor="primaryText"
backgroundColorOpacityPressed={0.4}
iconColor="orange.700"
iconColor="primaryBackground"
title={compact || maxCompact ? undefined : t('accountView.swaps')}
onPress={handleAction('swaps')}
width={maxCompact ? 47.5 : undefined}
Expand Down Expand Up @@ -173,9 +173,9 @@ const AccountActionBar = ({
>
<FabButton
icon="airdrop"
backgroundColor="violet.300"
backgroundColor="primaryText"
backgroundColorOpacityPressed={0.4}
iconColor="violet.700"
iconColor="primaryBackground"
title={
compact || maxCompact ? undefined : t('airdropScreen.airdrop')
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/governance/GovernanceWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const GovernanceWrapper: React.FC<
<ReAnimatedBox entering={FadeIn} paddingHorizontal="5">
<Box flex={1}>
<Box flexDirection="column" height="100%">
<Box mt="6" mb="6">
<Box mt="6xl">
<NetworkTabs />
</Box>
{loading ? (
Expand Down
Loading

0 comments on commit 6596735

Please sign in to comment.