Skip to content

Commit 1db8d92

Browse files
committed
fix(mobile): restore compact iPad trackpad scrolling
1 parent 7a12aff commit 1db8d92

1 file changed

Lines changed: 42 additions & 35 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useAtomValue } from "@effect/atom-react";
1919
import { useFocusEffect } from "@react-navigation/native";
2020
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2121
import { ActivityIndicator, Platform, View } from "react-native";
22+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
2223
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
2324
import { useSafeAreaInsets } from "react-native-safe-area-context";
2425

@@ -214,6 +215,8 @@ function HomeTopContentSpacer() {
214215
export function HomeScreen(props: HomeScreenProps) {
215216
const queuedThreadKeys = useQueuedThreadKeys();
216217
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
218+
// Let trackpad scrolling coexist with each row's horizontal swipe gesture.
219+
const homeScrollGesture = useMemo(() => Gesture.Native(), []);
217220
const insets = useSafeAreaInsets();
218221
const { fabClearance } = useAndroidControlSizing();
219222
const iosBottomToolbarClearance =
@@ -764,6 +767,7 @@ export function HomeScreen(props: HomeScreenProps) {
764767
onMoveThread={handleMoveThread}
765768
onSwipeableClose={handleSwipeableClose}
766769
onSwipeableWillOpen={handleSwipeableWillOpen}
770+
simultaneousSwipeGesture={homeScrollGesture}
767771
/>
768772
);
769773
},
@@ -782,6 +786,7 @@ export function HomeScreen(props: HomeScreenProps) {
782786
handleSwipeableWillOpen,
783787
handleUnsettleThread,
784788
handleSetThreadAutoSettle,
789+
homeScrollGesture,
785790
autoSettleOptOutEnvironmentIds,
786791
pinningEnvironmentIds,
787792
machineByEnvironmentId,
@@ -953,41 +958,43 @@ export function HomeScreen(props: HomeScreenProps) {
953958
rebuilds and `itemsAreEqual` keeps a minute tick (or an unrelated
954959
shell update) from re-rendering untouched rows. */}
955960
<SwipeableScrollGateProvider enabled={swipeEnabled}>
956-
<LegendList
957-
data={threadListV2Items}
958-
renderItem={renderV2Item}
959-
keyExtractor={v2KeyExtractor}
960-
getItemType={(item) => item.type}
961-
itemsAreEqual={threadListV2ListItemsAreEqual}
962-
estimatedItemSize={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
963-
drawDistance={500}
964-
recycleItems
965-
extraData={v2ExtraData}
966-
ListHeaderComponent={v2ListHeader}
967-
ListFooterComponent={
968-
settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
969-
<ThreadListV2ShowMoreRow
970-
hiddenCount={threadListV2Layout.hiddenSettledCount}
971-
onPress={showMoreSettled}
972-
/>
973-
) : null
974-
}
975-
ListEmptyComponent={v2ListEmpty}
976-
style={{ flex: 1 }}
977-
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
978-
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
979-
showsVerticalScrollIndicator={false}
980-
keyboardDismissMode="on-drag"
981-
keyboardShouldPersistTaps="handled"
982-
{...scrollGateHandlers}
983-
scrollEventThrottle={16}
984-
contentContainerStyle={{
985-
paddingBottom:
986-
Platform.OS === "ios"
987-
? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
988-
: Math.max(insets.bottom, 16) + (Platform.OS === "android" ? fabClearance : 88),
989-
}}
990-
/>
961+
<GestureDetector gesture={homeScrollGesture}>
962+
<LegendList
963+
data={threadListV2Items}
964+
renderItem={renderV2Item}
965+
keyExtractor={v2KeyExtractor}
966+
getItemType={(item) => item.type}
967+
itemsAreEqual={threadListV2ListItemsAreEqual}
968+
estimatedItemSize={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
969+
drawDistance={500}
970+
recycleItems
971+
extraData={v2ExtraData}
972+
ListHeaderComponent={v2ListHeader}
973+
ListFooterComponent={
974+
settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
975+
<ThreadListV2ShowMoreRow
976+
hiddenCount={threadListV2Layout.hiddenSettledCount}
977+
onPress={showMoreSettled}
978+
/>
979+
) : null
980+
}
981+
ListEmptyComponent={v2ListEmpty}
982+
style={{ flex: 1 }}
983+
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
984+
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
985+
showsVerticalScrollIndicator={false}
986+
keyboardDismissMode="on-drag"
987+
keyboardShouldPersistTaps="handled"
988+
{...scrollGateHandlers}
989+
scrollEventThrottle={16}
990+
contentContainerStyle={{
991+
paddingBottom:
992+
Platform.OS === "ios"
993+
? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
994+
: Math.max(insets.bottom, 16) + (Platform.OS === "android" ? fabClearance : 88),
995+
}}
996+
/>
997+
</GestureDetector>
991998
</SwipeableScrollGateProvider>
992999
</View>
9931000
</View>

0 commit comments

Comments
 (0)