Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Perronef5 committed Oct 11, 2024
1 parent c54991b commit a212ad9
Show file tree
Hide file tree
Showing 45 changed files with 1,354 additions and 917 deletions.
12 changes: 12 additions & 0 deletions src/assets/images/visibilityOff.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions src/components/AddressBookSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import ContactsList from '@features/addressBook/ContactsList'
import { CSAccount } from '@storage/cloudStorage'
import { Portal } from '@gorhom/portal'
import { useTranslation } from 'react-i18next'
import { WalletNavigationProp } from '@services/WalletService/pages/WalletPage/WalletPageNavigator'
import HeliumBottomSheet from './HeliumBottomSheet'
import { SafeAreaBox, Text } from '.'
import { SendNavigationProp } from '@services/WalletService/pages/SendPage/SentPageNavigator'

Check failure on line 24 in src/components/AddressBookSelector.tsx

View workflow job for this annotation

GitHub Actions / build

`@services/WalletService/pages/SendPage/SentPageNavigator` import should occur before import of `./HeliumBottomSheet`
import { AddressBookNavigationProp } from '@features/addressBook/addressBookTypes'

Check failure on line 25 in src/components/AddressBookSelector.tsx

View workflow job for this annotation

GitHub Actions / build

`@features/addressBook/addressBookTypes` import should occur before import of `./HeliumBottomSheet`

export type AddressBookRef = {
showAddressBook: (opts: { address?: string; index?: number }) => void
Expand All @@ -43,7 +44,9 @@ const AddressBookSelector = forwardRef(

const bottomSheetModalRef = useRef<BottomSheet>(null)
const { t } = useTranslation()
const homeNav = useNavigation<WalletNavigationProp>()
const navigation = useNavigation<
SendNavigationProp & AddressBookNavigationProp
>()
const [address, setAddress] = useState<string>()
const [index, setIndex] = useState<number>()

Expand Down Expand Up @@ -89,8 +92,14 @@ const AddressBookSelector = forwardRef(
)

const handleAddNewContact = useCallback(() => {
homeNav.navigate('AddNewContact')
}, [homeNav])
// eslint-disable-next-line @typescript-eslint/no-explicit-any
;(navigation as any).navigate('AddressBook', {
screen: 'AddNewContact',
initial: false,
params: undefined,
})
bottomSheetModalRef.current?.close()
}, [navigation, address])

Check failure on line 102 in src/components/AddressBookSelector.tsx

View workflow job for this annotation

GitHub Actions / build

React Hook useCallback has an unnecessary dependency: 'address'. Either exclude it or remove the dependency array

return (
<Portal>
Expand Down
123 changes: 123 additions & 0 deletions src/components/Balancer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { ReactNode, useLayoutEffect, useRef, useState } from 'react'
import { LayoutChangeEvent, StyleSheet, View } from 'react-native'

type Props = {
children?: ReactNode
ratio?: number
}

type BareBalancerProps = {
containerHeight?: number
children?: ReactNode
parentRef: React.RefObject<View>
ratio?: number
}

const measureComponent = (
component: React.RefObject<View>,
): Promise<{ width: number; height: number }> => {
return new Promise((resolve) => {
if (component.current === null) {
return { width: 0, height: 0 }
}

setTimeout(
() =>
component.current?.measure(
(x: number, y: number, width: number, height: number) =>
resolve({ width, height }),
),
0,
)
})
}

const styles = StyleSheet.create({
container: {
flexDirection: 'row',
display: 'flex',
justifyContent: 'center',
},
})

export const BareBalancerContainer: React.FC<Props> = ({ children, ratio }) => {
const [dimensions, setDimensions] = useState<
{ width: number; height: number } | undefined
>()

const parentRef = useRef<View>(null)

const onPageLayout = (event: LayoutChangeEvent) => {
const { width, height } = event.nativeEvent.layout
setDimensions({ width, height })
}

return (
<View ref={parentRef} onLayout={onPageLayout} style={styles.container}>
<BareBalancerWithoutPageLayout
parentRef={parentRef}
ratio={ratio}
containerHeight={dimensions?.height}
>
{children}
</BareBalancerWithoutPageLayout>
</View>
)
}

export const BareBalancerWithoutPageLayout: React.FC<BareBalancerProps> = ({
children,
containerHeight,
parentRef,
ratio = 1,
}) => {
const [ran, setRan] = useState<boolean>(false)
const childRef = useRef<View>(null)

// investigate performance
// useEffect(() => {
// setRan(false);
// }, [children]);

useLayoutEffect(() => {
const relayout = async () => {
const update = (width?: number) => {
childRef.current?.setNativeProps({ style: { maxWidth: width } })
}

update(undefined)
setRan(true)
const { height: initialHeight, width: initialWidth } =
await measureComponent(parentRef)

let left: number = initialWidth / 2
let right: number = initialWidth
let middle: number

while (left + 1 < right) {
middle = ~~((left + right) / 2)

Check failure on line 98 in src/components/Balancer.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected use of '~'

Check failure on line 98 in src/components/Balancer.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected use of '~'

update(middle)
const { height: currentHeight } = await measureComponent(parentRef)

if (currentHeight === initialHeight) {
right = middle
} else {
left = middle
}
}

// Update the wrapper width
update(right * ratio + initialWidth * (1 - ratio))
//update(initialWidth - (initialWidth - right) * ratio);

Check failure on line 112 in src/components/Balancer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
}
if (!ran) {
if (parentRef.current === null) {
return
}
void relayout()

Check failure on line 118 in src/components/Balancer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected 'undefined' and instead saw 'void'
}
}, [ran, containerHeight, parentRef, ratio])

return <View ref={childRef}>{children}</View>
}
4 changes: 2 additions & 2 deletions src/components/HNTKeyboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ const HNTKeyboardSelector = forwardRef(
marginRight="xs"
overflow="hidden"
>
<BackgroundFill backgroundColor="error.500" />
<Text variant="textLgMedium" color="error.500">
<BackgroundFill backgroundColor="fg.quinary-400" />
<Text variant="textLgMedium" color="primaryText">
{t('generic.cancel')}
</Text>
</TouchableOpacityBox>
Expand Down
8 changes: 7 additions & 1 deletion src/components/SegmentedControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Box, ReAnimatedBox, Text } from '.'
import TouchableOpacityBox from './TouchableOpacityBox'

type Option = {
value: string
value: string | number
label: string
Icon?: FC<SvgProps>
iconProps?: SvgProps
Expand All @@ -19,11 +19,13 @@ const SegmentedItem = ({
selected,
onSelected,
onSetWidth,
fullWidth,
}: {
option: Option
selected: boolean
onSelected: ((event: GestureResponderEvent) => void) | undefined
onSetWidth: (width: number) => void
fullWidth?: boolean
}) => {
const { primaryBackground, ...colors } = useColors()

Expand All @@ -36,6 +38,7 @@ const SegmentedItem = ({

return (
<TouchableOpacityBox
flex={fullWidth ? 1 : undefined}
paddingVertical="2"
paddingHorizontal="3"
justifyContent="center"
Expand Down Expand Up @@ -67,11 +70,13 @@ type Props = {
options: Option[]
selectedIndex: number
onItemSelected: (index: number) => void
fullWidth?: boolean
} & BoxProps<Theme>
const SegmentedControl = ({
options,
onItemSelected,
selectedIndex,
fullWidth,
...boxProps
}: Props) => {
const [optionWidths, setOptionWidths] = useState(
Expand Down Expand Up @@ -126,6 +131,7 @@ const SegmentedControl = ({
/>
{options.map((option, index) => (
<SegmentedItem
fullWidth={fullWidth}
key={option.value}
option={option}
selected={index === selectedIndex}
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const TI = forwardRef(
style={{
color: getTextColor,
fontSize: fontSize || inputVariants.regular.fontSize,
fontWeight: fontWeight || 'bold',
fontWeight: fontWeight || '500',
fontFamily: floatingLabel
? textVariants.textSmRegular.fontFamily
: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/components/TouchableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TouchableContainer = ({
onLayout,
hitSlop,
backgroundColor = 'cardBackground',
backgroundColorPressed = 'bg.primary-hover',
backgroundColorPressed = 'gray.200',
...boxProps
}: ButtonPressAnimationProps & {
backgroundColorPressed?: BoxProps<Theme>['backgroundColor']
Expand Down
20 changes: 8 additions & 12 deletions src/features/account/AccountActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ const AccountActionBar = ({
>
<FabButton
icon="fatArrowDown"
backgroundColor="green.light-500"
backgroundColorOpacity={0.2}
backgroundColor="green.300"
backgroundColorOpacityPressed={0.4}
iconColor="green.light-500"
iconColor="green.700"
title={compact || maxCompact ? undefined : t('accountView.deposit')}
onPress={handleAction('request')}
width={maxCompact ? 47.5 : undefined}
Expand Down Expand Up @@ -144,10 +143,9 @@ const AccountActionBar = ({
>
<FabButton
icon="swaps"
backgroundColor="orange.500"
backgroundColorOpacity={0.2}
backgroundColor="orange.300"
backgroundColorOpacityPressed={0.4}
iconColor="orange.500"
iconColor="orange.700"
title={compact || maxCompact ? undefined : t('accountView.swaps')}
onPress={handleAction('swaps')}
width={maxCompact ? 47.5 : undefined}
Expand Down Expand Up @@ -175,10 +173,9 @@ const AccountActionBar = ({
>
<FabButton
icon="airdrop"
backgroundColor="violet.200"
backgroundColorOpacity={0.2}
backgroundColor="violet.300"
backgroundColorOpacityPressed={0.4}
iconColor="violet.200"
iconColor="violet.700"
title={
compact || maxCompact ? undefined : t('airdropScreen.airdrop')
}
Expand Down Expand Up @@ -208,10 +205,9 @@ const AccountActionBar = ({
>
<FabButton
icon="fatArrowUp"
backgroundColor="blue.light-500"
backgroundColorOpacity={0.2}
backgroundColor="blue.300"
backgroundColorOpacityPressed={0.4}
iconColor="blue.light-500"
iconColor="blue.700"
title={compact || maxCompact ? undefined : t('accountView.send')}
onPress={handleAction('send')}
reverse
Expand Down
7 changes: 5 additions & 2 deletions src/features/account/AccountManageTokenListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useSolana } from '../../solana/SolanaProvider'
import { syncTokenAccounts } from '../../store/slices/balancesSlice'
import { useAppDispatch } from '../../store/store'
import AccountTokenCurrencyBalance from './AccountTokenCurrencyBalance'
import { NavBarHeight } from '@components/ServiceNavBar'

const CheckableTokenListItem = ({
bottomBorder,
Expand Down Expand Up @@ -56,8 +57,7 @@ const CheckableTokenListItem = ({
flexDirection="row"
minHeight={72}
alignItems="center"
paddingHorizontal="4"
paddingVertical="4"
padding="4"
borderBottomColor="primaryBackground"
borderBottomWidth={bottomBorder ? 2 : 0}
disabled
Expand Down Expand Up @@ -183,6 +183,9 @@ const AccountManageTokenListScreen: React.FC = () => {
data={mints}
renderItem={renderItem}
keyExtractor={keyExtractor}
contentContainerStyle={{
paddingBottom: NavBarHeight,
}}
/>
</BackScreen>
</ScrollBox>
Expand Down
Loading

0 comments on commit a212ad9

Please sign in to comment.