Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions app/components/ResizableDivider.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
import { View, PanResponder, type ViewStyle } from "react-native"
import { themed } from "../theme/theme"
import { useRef, useState } from "react"
import { useMemo, useState } from "react"

type ResizableDividerProps = {
onResize: (width: number) => void
minWidth?: number
maxWidth?: number
currentWidth?: number
}

export function ResizableDivider({
onResize,
minWidth = 300,
maxWidth = 800,
currentWidth = 300,
}: ResizableDividerProps) {
const [isDragging, setIsDragging] = useState(false)

const panResponder = useRef(
PanResponder.create({
onMoveShouldSetPanResponder: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onPanResponderGrant: () => {
setIsDragging(true)
},
onPanResponderMove: (evt, gestureState) => {
// Calculate new width based on gesture
const newWidth = Math.max(minWidth, Math.min(maxWidth, gestureState.moveX))
onResize(newWidth)
},
onPanResponderRelease: () => {
setIsDragging(false)
},
onPanResponderTerminate: () => {
setIsDragging(false)
},
}),
).current
const panResponder = useMemo(
() =>
PanResponder.create({
onMoveShouldSetPanResponder: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onPanResponderGrant: () => {
setIsDragging(true)
},
onPanResponderMove: (evt, gestureState) => {
// Calculate new width based on gesture relative to the current width
let newWidth = currentWidth + gestureState.dx
if (newWidth < minWidth) {
newWidth = minWidth
}
if (newWidth > maxWidth) {
newWidth = maxWidth
}
onResize(newWidth)
},
onPanResponderRelease: () => {
setIsDragging(false)
},
onPanResponderTerminate: () => {
setIsDragging(false)
},
}),
[currentWidth, minWidth, maxWidth, onResize],
)

return <View {...panResponder.panHandlers} style={$divider(isDragging)} />
}
Expand Down
7 changes: 6 additions & 1 deletion app/screens/TimelineScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ export function TimelineScreen() {
ItemSeparatorComponent={Separator}
/>
</View>
<ResizableDivider onResize={setTimelineWidth} minWidth={300} maxWidth={800} />
<ResizableDivider
currentWidth={timelineWidth}
onResize={setTimelineWidth}
minWidth={300}
maxWidth={800}
/>
<View style={$flex}>
<DetailPanel selectedItem={selectedItem} onClose={() => setSelectedItemId(null)} />
</View>
Expand Down
2 changes: 1 addition & 1 deletion macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ SPEC CHECKSUMS:
glog: b7594b792ee4e02ed1f44b01d046ca25fa713e3d
hermes-engine: b5c9cfbe6415f1b0b24759f2942c8f33e9af6347
IRNativeModules: 2fa316ab0ca91ec3e7bd4ba7ab2fc1f642fb5542
RCT-Folly: abec2d7f4af402b4957c44e86ceff8725b23c1b4
RCT-Folly: e8b53d8c0d2d9df4a6a8b0a368a1a91fc62a88cb
RCTDeprecation: 9da6c2d8a3b1802142718283260fb06d702ddb07
RCTRequired: 574f9d55bda1d50676530b6c36bab4605612dfb6
RCTTypeSafety: 7de929c405e619c023116e7747118a2c5d5b2320
Expand Down