unlatching as platform specific

This commit is contained in:
balzack 2022-10-04 22:06:44 -07:00
parent fddcaa97be
commit a7c97de50e

View File

@ -1,4 +1,4 @@
import { TextInput, View, TouchableOpacity, Text, } from 'react-native'; import { Platform, TextInput, View, TouchableOpacity, Text, } from 'react-native';
import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp'; import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp';
import { useState, useRef, useEffect } from 'react'; import { useState, useRef, useEffect } from 'react';
import { useConversation } from './useConversation.hook'; import { useConversation } from './useConversation.hook';
@ -33,10 +33,6 @@ export function ConversationHeader({ closeConversation, openDetails }) {
); );
} }
function show(arg) {
console.log(arg);
}
export function ConversationBody() { export function ConversationBody() {
const { state, actions } = useConversation(); const { state, actions } = useConversation();
@ -45,16 +41,19 @@ export function ConversationBody() {
const latch = () => { const latch = () => {
if (!state.momentum) { if (!state.momentum) {
actions.latch(); actions.latch();
ref.current.scrollToIndex({ animated: false, index: 0 }); ref.current.scrollToIndex({ animated: true, index: 0 });
} }
} }
const noop = () => {};
return ( return (
<View style={styles.topics}> <View style={styles.topics}>
<FlatList <FlatList
ref={ref} ref={ref}
data={state.topics} data={state.topics}
onMomentumScrollEnd={actions.unlatch} onMomentumScrollEnd={ Platform.OS === 'ios' ? noop : actions.unlatch }
onScrollBeginDrag={ Platform.OS !== 'ios' ? noop : actions.unlatch }
maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } } maintainVisibleContentPosition={ state.latched ? null : { minIndexForVisibile: 2, } }
inverted={true} inverted={true}
renderItem={({item}) => (<TopicItem item={item} />)} renderItem={({item}) => (<TopicItem item={item} />)}