Fix tabbar swipe conflicting with drawer (#7501)
This commit is contained in:
@@ -13,6 +13,7 @@ import Animated, {
|
|||||||
} from 'react-native-reanimated'
|
} from 'react-native-reanimated'
|
||||||
|
|
||||||
import {PressableWithHover} from '#/view/com/util/PressableWithHover'
|
import {PressableWithHover} from '#/view/com/util/PressableWithHover'
|
||||||
|
import {BlockDrawerGesture} from '#/view/shell/BlockDrawerGesture'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
@@ -297,57 +298,59 @@ export function TabBar({
|
|||||||
testID={testID}
|
testID={testID}
|
||||||
style={[t.atoms.bg, a.flex_row]}
|
style={[t.atoms.bg, a.flex_row]}
|
||||||
accessibilityRole="tablist">
|
accessibilityRole="tablist">
|
||||||
<ScrollView
|
<BlockDrawerGesture>
|
||||||
testID={`${testID}-selector`}
|
<ScrollView
|
||||||
horizontal={true}
|
testID={`${testID}-selector`}
|
||||||
showsHorizontalScrollIndicator={false}
|
horizontal={true}
|
||||||
ref={scrollElRef}
|
showsHorizontalScrollIndicator={false}
|
||||||
contentContainerStyle={styles.contentContainer}
|
ref={scrollElRef}
|
||||||
onLayout={e => {
|
contentContainerStyle={styles.contentContainer}
|
||||||
containerSize.set(e.nativeEvent.layout.width)
|
|
||||||
}}
|
|
||||||
onScrollBeginDrag={() => {
|
|
||||||
// Remember that you've manually messed with the tabbar scroll.
|
|
||||||
// This will disable auto-adjustment until after next pager swipe or item tap.
|
|
||||||
syncScrollState.set('unsynced')
|
|
||||||
}}
|
|
||||||
onScroll={e => {
|
|
||||||
scrollX.value = Math.round(e.nativeEvent.contentOffset.x)
|
|
||||||
}}>
|
|
||||||
<Animated.View
|
|
||||||
onLayout={e => {
|
onLayout={e => {
|
||||||
contentSize.set(e.nativeEvent.layout.width)
|
containerSize.set(e.nativeEvent.layout.width)
|
||||||
}}
|
}}
|
||||||
style={{flexDirection: 'row', flexGrow: 1}}>
|
onScrollBeginDrag={() => {
|
||||||
{items.map((item, i) => {
|
// Remember that you've manually messed with the tabbar scroll.
|
||||||
return (
|
// This will disable auto-adjustment until after next pager swipe or item tap.
|
||||||
<TabBarItem
|
syncScrollState.set('unsynced')
|
||||||
key={i}
|
}}
|
||||||
index={i}
|
onScroll={e => {
|
||||||
testID={testID}
|
scrollX.value = Math.round(e.nativeEvent.contentOffset.x)
|
||||||
dragProgress={dragProgress}
|
}}>
|
||||||
item={item}
|
|
||||||
onPressItem={onPressItem}
|
|
||||||
onItemLayout={onItemLayout}
|
|
||||||
onTextLayout={onTextLayout}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
<Animated.View
|
<Animated.View
|
||||||
style={[
|
onLayout={e => {
|
||||||
indicatorStyle,
|
contentSize.set(e.nativeEvent.layout.width)
|
||||||
{
|
}}
|
||||||
position: 'absolute',
|
style={{flexDirection: 'row', flexGrow: 1}}>
|
||||||
left: 0,
|
{items.map((item, i) => {
|
||||||
bottom: 0,
|
return (
|
||||||
right: 0,
|
<TabBarItem
|
||||||
borderBottomWidth: 2,
|
key={i}
|
||||||
borderColor: t.palette.primary_500,
|
index={i}
|
||||||
},
|
testID={testID}
|
||||||
]}
|
dragProgress={dragProgress}
|
||||||
/>
|
item={item}
|
||||||
</Animated.View>
|
onPressItem={onPressItem}
|
||||||
</ScrollView>
|
onItemLayout={onItemLayout}
|
||||||
|
onTextLayout={onTextLayout}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
<Animated.View
|
||||||
|
style={[
|
||||||
|
indicatorStyle,
|
||||||
|
{
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
bottom: 0,
|
||||||
|
right: 0,
|
||||||
|
borderBottomWidth: 2,
|
||||||
|
borderColor: t.palette.primary_500,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Animated.View>
|
||||||
|
</ScrollView>
|
||||||
|
</BlockDrawerGesture>
|
||||||
<View style={[t.atoms.border_contrast_low, styles.outerBottomBorder]} />
|
<View style={[t.atoms.border_contrast_low, styles.outerBottomBorder]} />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user