Skip to content

Commit

Permalink
fix: manual scroll on refresh press for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
thoreyjona committed Dec 23, 2024
1 parent 9ca7d16 commit 3d773a8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion apps/native/app/src/screens/wallet/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,21 @@ export const WalletScreen: NavigationFunctionComponent = ({ componentId }) => {
}
}, [])

// Using the onRefresh function when pressing the update button in ios is buggy,
// it scrolls the list half out of view when done - so we do it manually instead
const programaticScrollWhenRefreshing = () => {
flatListRef.current?.scrollToOffset({ offset: -300, animated: true })
res
.refetch()
.then(() => {
// Ofsetting to 0 scrolls the top of the list out of view, so we offset to -150
flatListRef.current?.scrollToOffset({ offset: -150, animated: true })
})
.catch(() => {
flatListRef.current?.scrollToOffset({ offset: -150, animated: true })
})
}

useNavigationComponentDidAppear(() => {
setHiddenContent(false)
}, componentId)
Expand Down Expand Up @@ -319,7 +334,9 @@ export const WalletScreen: NavigationFunctionComponent = ({ componentId }) => {
</Typography>
)}
<Button
onPress={() => onRefresh()}
onPress={() =>
isIos ? programaticScrollWhenRefreshing() : onRefresh()
}
title={intl.formatMessage({ id: 'wallet.update' })}
isTransparent={true}
icon={refreshIcon}
Expand Down

0 comments on commit 3d773a8

Please sign in to comment.