@@ -13,9 +13,8 @@ import { type EnvironmentId, sessionGrantsScope } from "@t3tools/contracts";
1313import { AUTH_SCOPE_OPTIONS } from "@t3tools/shared/authScopeOptions" ;
1414import { AsyncResult } from "effect/reactivity" ;
1515import * as Option from "effect/Option" ;
16- import { useEffect , useMemo , useRef , useState } from "react" ;
16+ import { useState } from "react" ;
1717import { Alert , Platform , Pressable , View } from "react-native" ;
18- import { Gesture , GestureDetector } from "react-native-gesture-handler" ;
1918import Reanimated , { ReduceMotion , useAnimatedStyle , withTiming } from "react-native-reanimated" ;
2019
2120import { type AppSymbolName , SymbolView } from "../../components/AppSymbol" ;
@@ -27,6 +26,7 @@ import { environmentSession } from "../../state/session";
2726import { useAtomCommand } from "../../state/use-atom-command" ;
2827import { connectionTone } from "../connection/connectionTone" ;
2928import { SettingsActionRow } from "./components/SettingsActionRow" ;
29+ import { SettingsDragHandle } from "./components/SettingsDragHandle" ;
3030import { SettingsSection } from "./components/SettingsSection" ;
3131
3232const ICON_SIZE = Platform . OS === "android" ? 24 : 22 ;
@@ -324,7 +324,7 @@ function RouteRow(props: {
324324 </ View >
325325 </ View >
326326 { props . editing ? (
327- < DragHandle
327+ < SettingsDragHandle
328328 title = { label }
329329 canMoveUp = { props . position > 1 }
330330 canMoveDown = { props . position < props . count }
@@ -337,62 +337,3 @@ function RouteRow(props: {
337337 </ Reanimated . View >
338338 ) ;
339339}
340-
341- /** Pan recognition wins over the settings scroll view only inside the handle. */
342- function DragHandle ( props : {
343- readonly title : string ;
344- readonly canMoveUp : boolean ;
345- readonly canMoveDown : boolean ;
346- readonly onStart : ( ) => void ;
347- readonly onMove : ( translation : number ) => void ;
348- readonly onEnd : ( translation : number , cancelled : boolean ) => void ;
349- readonly onStep : ( direction : "up" | "down" ) => void ;
350- } ) {
351- const latest = useRef ( props ) ;
352- useEffect ( ( ) => {
353- latest . current = props ;
354- } ) ;
355- const translation = useRef ( 0 ) ;
356- const gesture = useMemo (
357- ( ) =>
358- Gesture . Pan ( )
359- . minDistance ( 0 )
360- . shouldCancelWhenOutside ( false )
361- . runOnJS ( true )
362- . onStart ( ( ) => {
363- translation . current = 0 ;
364- latest . current . onStart ( ) ;
365- } )
366- . onUpdate ( ( event ) => {
367- translation . current = event . translationY ;
368- latest . current . onMove ( event . translationY ) ;
369- } )
370- . onFinalize ( ( _ , success ) => latest . current . onEnd ( translation . current , ! success ) ) ,
371- [ ] ,
372- ) ;
373- return (
374- < GestureDetector gesture = { gesture } >
375- < View
376- collapsable = { false }
377- accessible
378- accessibilityRole = "adjustable"
379- accessibilityLabel = { `Reorder ${ props . title } ` }
380- accessibilityActions = { [
381- ...( props . canMoveUp ? [ { name : "decrement" , label : "Move up" } ] : [ ] ) ,
382- ...( props . canMoveDown ? [ { name : "increment" , label : "Move down" } ] : [ ] ) ,
383- ] }
384- onAccessibilityAction = { ( { nativeEvent } ) => {
385- if ( nativeEvent . actionName === "decrement" && props . canMoveUp ) props . onStep ( "up" ) ;
386- if ( nativeEvent . actionName === "increment" && props . canMoveDown ) props . onStep ( "down" ) ;
387- } }
388- style = { { width : 48 , alignSelf : "stretch" , alignItems : "center" , justifyContent : "center" } }
389- >
390- < SymbolView
391- name = "line.3.horizontal"
392- size = { 20 }
393- tintColorClassName = "accent-foreground-muted"
394- />
395- </ View >
396- </ GestureDetector >
397- ) ;
398- }
0 commit comments