Skip to content

Commit

Permalink
non-sticky max addrs msg
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulnr7 committed Apr 16, 2024
1 parent 3746abc commit 9d1619a
Showing 1 changed file with 32 additions and 9 deletions.
@@ -1,7 +1,7 @@
import {useFocusEffect} from '@react-navigation/native'
import {useTheme} from '@yoroi/theme'
import * as React from 'react'
import {StyleSheet, View, ViewToken} from 'react-native'
import {NativeScrollEvent, NativeSyntheticEvent, ScrollView, StyleSheet, View, ViewToken} from 'react-native'
import Animated, {Layout} from 'react-native-reanimated'
import {SafeAreaView} from 'react-native-safe-area-context'

Expand Down Expand Up @@ -72,25 +72,48 @@ export const ListMultipleAddressesScreen = () => {
}, [track]),
)

const [showAddressLimitInfo, setShowAddressLimitInfo] = React.useState(true)
const scrollViewRef = React.useRef<ScrollView>(null)

const handleScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
if (event.nativeEvent.contentOffset.y <= 0) {
setShowAddressLimitInfo(true)
} else if (showAddressLimitInfo && event.nativeEvent.contentOffset.y > 0) {
setShowAddressLimitInfo(false)
}
}
React.useEffect(() => {
if (hasReachedGapLimit) {
setShowAddressLimitInfo(true)
}
}, [hasReachedGapLimit])

return (
<SafeAreaView style={styles.root} edges={['left', 'right', 'bottom']}>
<View style={styles.content}>
{hasReachedGapLimit && (
{showAddressLimitInfo && hasReachedGapLimit && (
<>
<ShowAddressLimitInfo />

<Spacer height={16} />
</>
)}

<Animated.FlatList
data={addressInfos}
keyExtractor={(addressInfo) => addressInfo.address}
renderItem={renderAddressInfo}
layout={Layout}
<ScrollView
ref={scrollViewRef}
onScroll={handleScroll}
scrollEventThrottle={16}
showsVerticalScrollIndicator={false}
onViewableItemsChanged={onViewableItemsChanged}
/>
>
<Animated.FlatList
data={addressInfos}
keyExtractor={(addressInfo) => addressInfo.address}
renderItem={renderAddressInfo}
layout={Layout}
showsVerticalScrollIndicator={false}
onViewableItemsChanged={onViewableItemsChanged}
/>
</ScrollView>
</View>

<Animated.View
Expand Down

0 comments on commit 9d1619a

Please sign in to comment.