Files
discord-decomp/_bundle/GenericTouchable.jsx
T
2026-11-01 12:12:55 +02:00

254 lines
8.0 KiB
React

// Metro module 5340 (f5341).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import _possibleConstructorReturn from "./_possibleConstructorReturn";
import _getPrototypeOf from "./_getPrototypeOf";
import _inherits from "./_inherits";
import { Component } from "react";
import { Platform, Animated } from "react-native";
import { State } from "./Module5278";
import { BaseButton } from "./InnerBaseButton";
let c3252_8;
let GenericTouchable;
let env3252 = {};
env3252[7] = function _isNativeReflectConstruct() {
let c14811_0;
try {
c14811_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c14811_0;
};
env3252[7] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
Platform;
c3252_8 = {
UNDETERMINED: 0,
BEGAN: 1,
MOVED_OUTSIDE: 2
};
GenericTouchable = function GenericTouchable(...args) {
_classCallCheck(this, GenericTouchable);
const r11 = [...args];
const r10 = _getPrototypeOf(GenericTouchable);
const r27 = _possibleConstructorReturn(this, (0, env3252[7])() ? Reflect.construct(r10, r11, _getPrototypeOf(this).constructor) : r10.apply(this, r11));
r27.longPressDetected = false;
r27.pointerInside = true;
r27.STATE = c3252_8.UNDETERMINED;
r27.onGestureEvent = (a0) => {
const pointerInside = a0.nativeEvent.pointerInside;
if (this.pointerInside !== pointerInside) {
if (pointerInside) {
this.onMoveIn();
} else {
this.onMoveOut();
}
}
this.pointerInside = pointerInside;
};
r27.onHandlerStateChange = (a0) => {
L14: {
const state = a0.nativeEvent.state;
if (state !== State.CANCELLED && state !== State.FAILED) {
if (state === State.BEGAN) {
if (this.STATE === c3252_8.UNDETERMINED) {
this.handlePressIn();
break L14;
}
}
if (state !== State.END) {
break L14;
}
const longPressDetected = this.longPressDetected;
const r0 = (longPressDetected ? !longPressDetected : this.STATE !== c3252_8.MOVED_OUTSIDE) && this.pressOutTimeout === void 0;
this.handleGoToUndetermined();
if (!r0) {
break L14;
}
const props = this.props;
const onPress = props.onPress;
if (onPress == null) {
break L14;
}
onPress.call(props);
} else {
this.moveToState(c3252_8.UNDETERMINED);
}
}
};
r27.onLongPressDetected = () => {
this.longPressDetected = true;
const props = this.props;
const onLongPress = props.onLongPress;
if (onLongPress != null) {
onLongPress.call(props);
}
};
return r27;
};
_inherits(GenericTouchable, Component);
const r61 = _createClass(GenericTouchable, [{
key: "handlePressIn",
value: function handlePressIn() {
if (this.props.delayPressIn) {
this.pressInTimeout = setTimeout(() => {
this.moveToState(c3252_8.BEGAN);
this.pressInTimeout = void 0;
}, this.props.delayPressIn);
} else {
this.moveToState(c3252_8.BEGAN);
}
if (this.props.onLongPress) {
this.longPressTimeout = setTimeout(this.onLongPressDetected, (this.props.delayPressIn || 0) + (this.props.delayLongPress || 0));
}
}
}, {
key: "handleMoveOutside",
value: function handleMoveOutside() {
if (this.props.delayPressOut) {
this.pressOutTimeout = this.pressOutTimeout || setTimeout(() => {
this.moveToState(c3252_8.MOVED_OUTSIDE);
this.pressOutTimeout = void 0;
}, this.props.delayPressOut);
} else {
this.moveToState(c3252_8.MOVED_OUTSIDE);
}
}
}, {
key: "handleGoToUndetermined",
value: function handleGoToUndetermined() {
clearTimeout(this.pressOutTimeout);
if (this.props.delayPressOut) {
this.pressOutTimeout = setTimeout(() => {
const STATE = this.STATE;
if (STATE === c3252_8.UNDETERMINED) {
this.moveToState(c3252_8.BEGAN);
}
this.moveToState(c3252_8.UNDETERMINED);
this.pressOutTimeout = void 0;
}, this.props.delayPressOut);
} else {
const STATE = this.STATE;
if (STATE === c3252_8.UNDETERMINED) {
this.moveToState(c3252_8.BEGAN);
}
this.moveToState(c3252_8.UNDETERMINED);
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
this.reset();
}
}, {
key: "reset",
value: function reset() {
this.longPressDetected = false;
this.pointerInside = true;
clearTimeout(this.pressInTimeout);
clearTimeout(this.pressOutTimeout);
clearTimeout(this.longPressTimeout);
this.pressOutTimeout = void 0;
this.longPressTimeout = void 0;
this.pressInTimeout = void 0;
}
}, {
key: "moveToState",
value: function moveToState(a0) {
if (a0 !== this.STATE) {
if (a0 === c3252_8.BEGAN) {
const props4 = this.props;
const onPressIn = props4.onPressIn;
if (onPressIn != null) {
onPressIn.call(props4);
}
} else if (a0 === c3252_8.MOVED_OUTSIDE) {
const props3 = this.props;
const onPressOut2 = props3.onPressOut;
if (onPressOut2 != null) {
onPressOut2.call(props3);
}
} else if (a0 === c3252_8.UNDETERMINED) {
this.reset();
if (this.STATE === c3252_8.BEGAN) {
const props2 = this.props;
const onPressOut = props2.onPressOut;
if (onPressOut != null) {
onPressOut.call(props2);
}
}
}
const props = this.props;
const onStateChange = props.onStateChange;
if (onStateChange != null) {
onStateChange.call(props, this.STATE, a0);
}
this.STATE = a0;
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.reset();
}
}, {
key: "onMoveIn",
value: function onMoveIn() {
const STATE = this.STATE;
if (STATE === c3252_8.MOVED_OUTSIDE) {
this.moveToState(c3252_8.BEGAN);
}
}
}, {
key: "onMoveOut",
value: function onMoveOut() {
clearTimeout(this.longPressTimeout);
this.longPressTimeout = void 0;
if (this.STATE === c3252_8.BEGAN) {
this.handleMoveOutside();
}
}
}, {
key: "render",
value: function render() {
let hitSlop = typeof this.props.hitSlop === "number" ? {
top: this.props.hitSlop,
left: this.props.hitSlop,
bottom: this.props.hitSlop,
right: this.props.hitSlop
} : this.props.hitSlop;
if (hitSlop == null) {
hitSlop = void 0;
}
const props = {
accessible: this.props.accessible !== false,
accessibilityLabel: this.props.accessibilityLabel,
accessibilityHint: this.props.accessibilityHint,
accessibilityRole: this.props.accessibilityRole,
accessibilityState: this.props.accessibilityState,
accessibilityActions: this.props.accessibilityActions,
onAccessibilityAction: this.props.onAccessibilityAction,
nativeID: this.props.nativeID,
onLayout: this.props.onLayout
};
const onHandlerStateChange = this.props.disabled ? void 0 : this.onHandlerStateChange;
let touchSoundDisabled = this.props.touchSoundDisabled;
if (touchSoundDisabled == null) {
touchSoundDisabled = false;
}
return <BaseButton style={this.props.containerStyle} onHandlerStateChange={onHandlerStateChange} onGestureEvent={this.onGestureEvent} hitSlop={hitSlop} userSelect={this.props.userSelect} shouldActivateOnStart={this.props.shouldActivateOnStart} disallowInterruption={this.props.disallowInterruption} testID={this.props.testID} touchSoundDisabled={touchSoundDisabled} enabled={!this.props.disabled} {...this.props.extraButtonProps}>
<Animated.View {...props} style={this.props.style}>{this.props.children}</Animated.View>
</BaseButton>;
}
}]);
r61.defaultProps = {
delayLongPress: 600,
extraButtonProps: {
rippleColor: "transparent",
exclusive: true
}
};
export default r61;
export { c3252_8 as TOUCHABLE_STATE };