diff options
author | Ivan Chen <ivan@tagg.id> | 2021-06-11 18:09:57 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-06-11 18:09:57 -0400 |
commit | 24f79b9cb3456b3901155ed2e4c8fc66710b97b2 (patch) | |
tree | 0d6f3de21599a567e4e7aa7abe93d12186e734f8 | |
parent | 22a58b2ad08297b6d5dd3dd241ae23a756ae7552 (diff) |
Fix keyboard avoiding for last item, Add comment for scroll to index fail
-rw-r--r-- | src/screens/profile/IndividualMoment.tsx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/screens/profile/IndividualMoment.tsx b/src/screens/profile/IndividualMoment.tsx index 80438bcd..f8113aba 100644 --- a/src/screens/profile/IndividualMoment.tsx +++ b/src/screens/profile/IndividualMoment.tsx @@ -9,7 +9,12 @@ import {AVATAR_DIM} from '../../constants'; import {MainStackParams} from '../../routes'; import {RootState} from '../../store/rootreducer'; import {MomentPostType} from '../../types'; -import {isIPhoneX, normalize, StatusBarHeight} from '../../utils'; +import { + isIPhoneX, + normalize, + SCREEN_HEIGHT, + StatusBarHeight, +} from '../../utils'; /** * Individual moment view opened when user clicks on a moment tile @@ -92,6 +97,7 @@ const IndividualMoment: React.FC<IndividualMomentProps> = ({ <FlatList ref={scrollRef} data={momentData} + contentContainerStyle={styles.listContentContainer} renderItem={({item, index}) => ( <MomentPost moment={item} @@ -103,6 +109,14 @@ const IndividualMoment: React.FC<IndividualMomentProps> = ({ keyExtractor={(item, _) => item.moment_id} showsVerticalScrollIndicator={false} initialScrollIndex={initialIndex} + onScrollToIndexFailed={() => { + // TODO: code below does not work, index resets to 0 + // const wait = new Promise((resolve) => setTimeout(resolve, 500)); + // wait.then(() => { + // console.log('scrolling to ', initialIndex); + // scrollRef.current?.scrollToIndex({index: initialIndex}); + // }); + }} /> </BlurView> </MomentContext.Provider> @@ -116,6 +130,9 @@ const styles = StyleSheet.create({ header: { height: normalize(70), }, + listContentContainer: { + paddingBottom: SCREEN_HEIGHT * 0.2, + }, }); export default IndividualMoment; |