267 lines
12 KiB
TypeScript
267 lines
12 KiB
TypeScript
// Metro module 15020 (f15021).
|
|
import * as Module19 from "react";
|
|
import { useMemo, useEffect } from "react";
|
|
import { GuildsNodeType } from "../../../stores/SortedGuildStore";
|
|
import GuildsBarDnDStore from "./GuildsBarDnDStore";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import { MobileHomeDrawerExperiment } from "../../home_drawer/native/HomeDrawerExperiment";
|
|
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import { useDerivedValue, useAnimatedStyle, useSharedValue } from "../../reanimated/ReanimatedRexport";
|
|
import * as _spring from "../../../design/animation/reanimated/spring/spring";
|
|
import ReanimatedNativeView from "../../core/native/ReanimatedNativeView";
|
|
import * as _TransitionGroup from "../../../design/components/TransitionGroup/TransitionGroup";
|
|
import { TransitionGroup } from "../../../design/components/TransitionGroup/TransitionGroup";
|
|
import GuildsBarGuildFolder from "./GuildsBarGuildFolder";
|
|
import GuildsBarGuild from "./GuildsBarGuild";
|
|
import { shallow } from "../../../_bundle/Module3802";
|
|
let useStyles, DRAG_SPRING_PHYSICS, __initData, __initData2, __initData3, __initData4, getItemPreviewKey, renderAnimatedItemPreview, __initData5, __initData6, AnimatedItemPreview;
|
|
const PreviewItem = function PreviewItem(props) {
|
|
let derivedValue, derivedValue2;
|
|
const { DragRegion, draggedHeight } = props;
|
|
let draggedNode = props.draggedNode;
|
|
const { dropComplete, gestureState, listInsets, overNode, overState, scrollPosition, windowSize, dropPosition } = props;
|
|
derivedValue = void 0;
|
|
derivedValue2 = void 0;
|
|
const styles = useStyles();
|
|
const enableHome = MobileHomeDrawerExperiment.useConfig({
|
|
location: "drag-preview"
|
|
}).enableHome;
|
|
const x = () => Math.max(scrollPosition.get() < DragRegion.get().min ? DragRegion.get().min - scrollPosition.get() : 0, listInsets.get().start);
|
|
x.__closure = {
|
|
scrollPosition,
|
|
DragRegion,
|
|
listInsets
|
|
};
|
|
x.__workletHash = 17436881889698;
|
|
x.__initData = __initData;
|
|
derivedValue = useDerivedValue(x);
|
|
const y = () => Math.min(scrollPosition.get() + (windowSize - listInsets.get().end) > DragRegion.get().max ? DragRegion.get().max - draggedHeight - scrollPosition.get() : windowSize - listInsets.get().end - draggedHeight, windowSize - listInsets.get().end - draggedHeight);
|
|
y.__closure = {
|
|
scrollPosition,
|
|
windowSize,
|
|
listInsets,
|
|
DragRegion,
|
|
draggedHeight
|
|
};
|
|
y.__workletHash = 4371355784;
|
|
y.__initData = __initData2;
|
|
derivedValue2 = useDerivedValue(y);
|
|
const G = function G() {
|
|
const r7 = dropPosition != null ? dropPosition - scrollPosition.get() : gestureState.get().absoluteY - draggedHeight / 2;
|
|
const r35 = gestureState.get().mode != null && dropPosition == null ? Math.min(Math.max(r7, derivedValue.get()), derivedValue2.get()) : Math.max(-draggedHeight, Math.min(r7, windowSize));
|
|
const r52 = function t(a0) {
|
|
if (a0 ? dropPosition != null : a0) {
|
|
_ReanimatedRexport.runOnJS(dropComplete)();
|
|
}
|
|
};
|
|
r52.__closure = {
|
|
dropPosition,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
dropComplete
|
|
};
|
|
r52.__workletHash = 12640145939434;
|
|
r52.__initData = __initData4;
|
|
return {
|
|
top: _spring.withSpring(r35, DRAG_SPRING_PHYSICS, "animate-always", r52)
|
|
};
|
|
};
|
|
G.__closure = {
|
|
dropPosition,
|
|
scrollPosition,
|
|
gestureState,
|
|
draggedHeight,
|
|
minY: derivedValue,
|
|
maxY: derivedValue2,
|
|
windowSize,
|
|
withSpring: _spring.withSpring,
|
|
DRAG_SPRING_PHYSICS,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
dropComplete
|
|
};
|
|
G.__workletHash = 5676492640532;
|
|
G.__initData = __initData3;
|
|
const animatedStyle = useAnimatedStyle(G);
|
|
const memo = useMemo(() => {
|
|
if (!(overState !== "convert-after" && overState !== "convert-before") && overNode != null) {
|
|
return {
|
|
type: GuildsNodeType.FOLDER,
|
|
id: -1,
|
|
parentId: void 0,
|
|
name: void 0,
|
|
color: void 0,
|
|
expanded: false,
|
|
children: [overNode]
|
|
};
|
|
}
|
|
}, [overState, overNode]);
|
|
const style = [styles.dragPreview, enableHome ? styles.dragPreviewHome : null, animatedStyle];
|
|
if (memo != null) {
|
|
draggedNode = memo;
|
|
}
|
|
return <ReanimatedNativeView style={style} nativeID="guilds-bar-drag-preview">
|
|
<TransitionGroup renderItem={renderAnimatedItemPreview} items={[draggedNode]} getItemKey={getItemPreviewKey} />
|
|
</ReanimatedNativeView>;
|
|
};
|
|
getItemPreviewKey = function getItemPreviewKey(a0) {
|
|
return `${a0.id}`;
|
|
};
|
|
renderAnimatedItemPreview = function renderAnimatedItemPreview(a0, a1, a2, a3) {
|
|
return <AnimatedItemPreview key={a0} node={a1} transitionState={a2} cleanUp={a3} />;
|
|
};
|
|
AnimatedItemPreview = function AnimatedItemPreview(props) {
|
|
const { node, transitionState, cleanUp } = props;
|
|
const styles = useStyles();
|
|
let enableHome = MobileHomeDrawerExperiment.useConfig({
|
|
location: "drag-preview"
|
|
}).enableHome;
|
|
const sharedValue = useSharedValue(transitionState === _TransitionGroup.TransitionStates.ENTERED ? 0 : 1);
|
|
const isFolder = node.type === GuildsNodeType.FOLDER;
|
|
if (enableHome) {
|
|
enableHome = !isFolder;
|
|
}
|
|
if (enableHome) {
|
|
enableHome = transitionState !== _TransitionGroup.TransitionStates.YEETED;
|
|
}
|
|
const w = function w() {
|
|
const r26 = sharedValue.get();
|
|
let r10 = 1;
|
|
const r0 = isFolder ? r26 === 1 ? 1 : 0.3 : r26 === 1 ? 1 : 0.33;
|
|
const r30 = !isFolder && sharedValue.get() !== 1 ? {
|
|
translateX: 10,
|
|
translateY: -10
|
|
} : {
|
|
translateX: 0,
|
|
translateY: 0
|
|
};
|
|
const { translateX, translateY } = r30;
|
|
const zIndex = isFolder ? 0 : 1;
|
|
const transform = [{
|
|
translateY: _spring.withSpring(translateY, DRAG_SPRING_PHYSICS, "animate-always")
|
|
}, {
|
|
translateX: _spring.withSpring(translateX, DRAG_SPRING_PHYSICS, "animate-always")
|
|
}, ,];
|
|
const r45 = function t(a0) {
|
|
if ((a0 ? transitionState === _TransitionGroup.TransitionStates.YEETED : a0) && isFolder) {
|
|
_ReanimatedRexport.runOnJS(cleanUp)();
|
|
}
|
|
};
|
|
r45.__closure = {
|
|
transitionState,
|
|
TransitionStates: _TransitionGroup.TransitionStates,
|
|
isFolder,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
cleanUp
|
|
};
|
|
r45.__workletHash = 9409925192880;
|
|
r45.__initData = __initData6;
|
|
transform[2] = {
|
|
scale: _spring.withSpring(r0, DRAG_SPRING_PHYSICS, "animate-always", r45)
|
|
};
|
|
if (isFolder) {
|
|
r10 = sharedValue.get();
|
|
}
|
|
return {
|
|
zIndex,
|
|
transform,
|
|
opacity: _spring.withSpring(r10, DRAG_SPRING_PHYSICS, "animate-always")
|
|
};
|
|
};
|
|
w.__closure = {
|
|
isFolder,
|
|
visible: sharedValue,
|
|
withSpring: _spring.withSpring,
|
|
DRAG_SPRING_PHYSICS,
|
|
transitionState,
|
|
TransitionStates: _TransitionGroup.TransitionStates,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
cleanUp
|
|
};
|
|
w.__workletHash = 13465198693221;
|
|
w.__initData = __initData5;
|
|
const animatedStyle = useAnimatedStyle(w);
|
|
useEffect(() => {
|
|
sharedValue.set(transitionState === _TransitionGroup.TransitionStates.YEETED ? 0 : 1);
|
|
});
|
|
return <ReanimatedNativeView style={[styles.animatedPreviewStyle, enableHome ? styles.animatedPreviewStyleHome : null, animatedStyle]}>
|
|
{node.type === GuildsNodeType.FOLDER ? <GuildsBarGuildFolder id={node.id} expanded={node.expanded} color={node.color} name={node.name} childNodes={node.children} isDragPreview hideExpandedChildren={!enableHome} /> : <GuildsBarGuild guildId={node.id} isDragPreview hideExpandedChildren={!enableHome} />}
|
|
</ReanimatedNativeView>;
|
|
};
|
|
useStyles = createStyles({
|
|
dragPreview: {
|
|
position: "absolute",
|
|
left: 0
|
|
},
|
|
animatedPreviewStyle: {
|
|
position: "absolute"
|
|
},
|
|
dragPreviewHome: {
|
|
right: 0
|
|
},
|
|
animatedPreviewStyleHome: {
|
|
left: 0,
|
|
right: 0
|
|
}
|
|
});
|
|
DRAG_SPRING_PHYSICS = {
|
|
mass: 0.5,
|
|
damping: 80,
|
|
stiffness: 320
|
|
};
|
|
__initData = {
|
|
code: "function GuildsBarDragPreviewTsx1(){const{scrollPosition,DragRegion,listInsets}=this.__closure;return Math.max(scrollPosition.get()<DragRegion.get().min?DragRegion.get().min-scrollPosition.get():0,listInsets.get().start);}"
|
|
};
|
|
__initData2 = {
|
|
code: "function GuildsBarDragPreviewTsx2(){const{scrollPosition,windowSize,listInsets,DragRegion,draggedHeight}=this.__closure;return Math.min(scrollPosition.get()+(windowSize-listInsets.get().end)>DragRegion.get().max?DragRegion.get().max-draggedHeight-scrollPosition.get():windowSize-listInsets.get().end-draggedHeight,windowSize-listInsets.get().end-draggedHeight);}"
|
|
};
|
|
__initData3 = {
|
|
code: "function GuildsBarDragPreviewTsx3(){const{dropPosition,scrollPosition,gestureState,draggedHeight,minY,maxY,windowSize,withSpring,DRAG_SPRING_PHYSICS,runOnJS,dropComplete}=this.__closure;let translateY=function(){if(dropPosition!=null){return dropPosition-scrollPosition.get();}return gestureState.get().absoluteY-draggedHeight/2;}();if(gestureState.get().mode!=null&&dropPosition==null){translateY=Math.min(Math.max(translateY,minY.get()),maxY.get());}else{translateY=Math.max(-draggedHeight,Math.min(translateY,windowSize));}return{top:withSpring(translateY,DRAG_SPRING_PHYSICS,'animate-always',function(finished){if(finished&&dropPosition!=null){runOnJS(dropComplete)();}})};}"
|
|
};
|
|
__initData4 = {
|
|
code: "function GuildsBarDragPreviewTsx4(finished){const{dropPosition,runOnJS,dropComplete}=this.__closure;if(finished&&dropPosition!=null){runOnJS(dropComplete)();}}"
|
|
};
|
|
__initData5 = {
|
|
code: "function GuildsBarDragPreviewTsx5(){const{isFolder,visible,withSpring,DRAG_SPRING_PHYSICS,transitionState,TransitionStates,runOnJS,cleanUp}=this.__closure;const targetScale=function(){if(isFolder){return visible.get()===1?1:0.3;}return visible.get()===1?1:0.33;}();const{translateX:translateX,translateY:translateY}=function(){if(isFolder){return{translateX:0,translateY:0};}if(visible.get()===1){return{translateX:0,translateY:0};}return{translateX:10,translateY:-10};}();return{zIndex:isFolder?0:1,transform:[{translateY:withSpring(translateY,DRAG_SPRING_PHYSICS,'animate-always')},{translateX:withSpring(translateX,DRAG_SPRING_PHYSICS,'animate-always')},{scale:withSpring(targetScale,DRAG_SPRING_PHYSICS,'animate-always',function(finished){if(finished&&transitionState===TransitionStates.YEETED&&isFolder){runOnJS(cleanUp)();}})}],opacity:withSpring(isFolder?visible.get():1,DRAG_SPRING_PHYSICS,'animate-always')};}"
|
|
};
|
|
__initData6 = {
|
|
code: "function GuildsBarDragPreviewTsx6(finished){const{transitionState,TransitionStates,isFolder,runOnJS,cleanUp}=this.__closure;if(finished&&transitionState===TransitionStates.YEETED&&isFolder){runOnJS(cleanUp)();}}"
|
|
};
|
|
const r45 = Module19.memo(function GuildsBarDragPreview() {
|
|
const props = GuildsBarDnDStore(({ dragSpecs, overSpecs, gestureState: gestureState2, scrollPosition: scrollPosition2, DragRegion: dragRegion2, windowSize: windowSize2, dropComplete: dropComplete2, listInsets: listInsets2, dropSpecs }) => {
|
|
if (dropSpecs != null) {
|
|
const overState2 = dropSpecs.overState;
|
|
return {
|
|
draggedNode: dropSpecs.dragNode,
|
|
draggedHeight: dropSpecs.itemSize,
|
|
overState: overState2,
|
|
overNode: overState2.startsWith("convert") ? dropSpecs.overNode : void 0,
|
|
dropPosition: dropSpecs.dropPosition,
|
|
gestureState: gestureState2,
|
|
scrollPosition: scrollPosition2,
|
|
DragRegion: dragRegion2,
|
|
windowSize: windowSize2,
|
|
dropComplete: dropComplete2,
|
|
listInsets: listInsets2
|
|
};
|
|
}
|
|
if (dragSpecs != null && overSpecs != null) {
|
|
const state = overSpecs.state;
|
|
return {
|
|
draggedNode: dragSpecs.node,
|
|
draggedHeight: dragSpecs.itemSize,
|
|
overState: state,
|
|
overNode: state.startsWith("convert") ? overSpecs.node : void 0,
|
|
dropPosition: void 0,
|
|
gestureState: gestureState2,
|
|
scrollPosition: scrollPosition2,
|
|
DragRegion: dragRegion2,
|
|
windowSize: windowSize2,
|
|
dropComplete: dropComplete2,
|
|
listInsets: listInsets2
|
|
};
|
|
}
|
|
return null;
|
|
}, shallow);
|
|
return props != null ? <PreviewItem {...props} /> : null;
|
|
});
|
|
export default r45;
|