205 lines
7.5 KiB
React
205 lines
7.5 KiB
React
// Metro module 1195 (f1196).
|
|
import _classCallCheck from "./_classCallCheck";
|
|
import _createClass from "./_createClass";
|
|
import _possibleConstructorReturn from "./_possibleConstructorReturn";
|
|
import _getPrototypeOf from "./_getPrototypeOf";
|
|
import _inherits from "./_inherits";
|
|
import * as Module19 from "react";
|
|
import { Component } from "react";
|
|
import * as _Module17 from "react-native";
|
|
import { Platform, Animated, Dimensions, PanResponder, Easing, Appearance, View, ScrollView } from "react-native";
|
|
import { isNativeDriverSupportedForColorAnimations, isModalSupported } from "./Module1196";
|
|
import { notWeb } from "./Module1002";
|
|
import { PULL_DOWN_CLOSE_THRESHOLD, SLIDE_ANIMATION_DURATION, BACKGROUND_ANIMATION_DURATION, FeedbackWidgetManager, FeedbackButtonManager, ScreenshotButtonManager } from "./NOOP_SET_VISIBILITY";
|
|
import { debug } from "./Module817";
|
|
import { getTheme } from "./Module1199";
|
|
import { FeedbackButton } from "./FeedbackButton";
|
|
import { getFeedbackButtonOptions, getScreenshotButtonOptions, getFeedbackOptions } from "./Module1133";
|
|
import { ScreenshotButton } from "./takeScreenshot";
|
|
import { modalWrapper, topSpacer, modalSheetContainer } from "./_default_1202";
|
|
import * as _FeedbackWidget from "./FeedbackWidget";
|
|
let c1000_15;
|
|
let FeedbackWidgetProvider;
|
|
let env1000 = {};
|
|
env1000[14] = function _isNativeReflectConstruct() {
|
|
let c12905_0;
|
|
try {
|
|
c12905_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
} catch ($e) {}
|
|
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
|
|
return !!c12905_0;
|
|
};
|
|
env1000[14] = _isNativeReflectConstruct2;
|
|
return _isNativeReflectConstruct2();
|
|
};
|
|
Platform;
|
|
c1000_15 = isNativeDriverSupportedForColorAnimations();
|
|
FeedbackWidgetProvider = function FeedbackWidgetProvider(a0) {
|
|
_classCallCheck(this, FeedbackWidgetProvider);
|
|
const r10 = [a0];
|
|
const r9 = _getPrototypeOf(FeedbackWidgetProvider);
|
|
const r27 = _possibleConstructorReturn(this, (0, env1000[14])() ? Reflect.construct(r9, r10, _getPrototypeOf(this).constructor) : r9.apply(this, r10));
|
|
r27.state = {
|
|
isButtonVisible: false,
|
|
isScreenshotButtonVisible: false,
|
|
isVisible: false,
|
|
backgroundOpacity: new Animated.Value(0),
|
|
panY: new Animated.Value(Dimensions.get("screen").height),
|
|
isScrollAtTop: true
|
|
};
|
|
r27._panResponder = PanResponder.create({
|
|
onStartShouldSetPanResponder: (a0, a1) => notWeb() && this.state.isScrollAtTop && a1.dy > 0,
|
|
onMoveShouldSetPanResponder: (a0, a1) => notWeb() && this.state.isScrollAtTop && a1.dy > 0,
|
|
onPanResponderMove: (a0, a1) => {
|
|
if (a1.dy > 0) {
|
|
this.state.panY.setValue(a1.dy);
|
|
}
|
|
},
|
|
onPanResponderRelease: (a0, a1) => {
|
|
if (a1.dy > PULL_DOWN_CLOSE_THRESHOLD) {
|
|
Animated.timing(this.state.panY, {
|
|
toValue: Dimensions.get("screen").height,
|
|
duration: SLIDE_ANIMATION_DURATION,
|
|
useNativeDriver: true
|
|
}).start(() => {
|
|
this._handleClose();
|
|
});
|
|
} else {
|
|
Animated.spring(this.state.panY, {
|
|
toValue: 0,
|
|
useNativeDriver: true
|
|
}).start();
|
|
}
|
|
}
|
|
});
|
|
r27._handleScroll = (a0) => {
|
|
this.setState({
|
|
isScrollAtTop: a0.nativeEvent.contentOffset.y <= 0
|
|
});
|
|
};
|
|
r27._setVisibilityFunction = (a0) => {
|
|
const isVisible = a0;
|
|
if (a0) {
|
|
this.setState({
|
|
isVisible: a0
|
|
});
|
|
} else {
|
|
Animated.parallel([Animated.timing(this.state.panY, {
|
|
toValue: Dimensions.get("screen").height,
|
|
duration: SLIDE_ANIMATION_DURATION,
|
|
useNativeDriver: true,
|
|
easing: Easing.out(Easing.quad)
|
|
}), Animated.timing(this.state.backgroundOpacity, {
|
|
toValue: 0,
|
|
duration: BACKGROUND_ANIMATION_DURATION,
|
|
useNativeDriver: c1000_15,
|
|
easing: Easing.out(Easing.quad)
|
|
})]).start(() => {
|
|
this.setState({
|
|
isVisible
|
|
});
|
|
});
|
|
}
|
|
};
|
|
r27._setButtonVisibilityFunction = (a0) => {
|
|
this.setState({
|
|
isButtonVisible: a0
|
|
});
|
|
};
|
|
r27._setScreenshotButtonVisibilityFunction = (a0) => {
|
|
this.setState({
|
|
isScreenshotButtonVisible: a0
|
|
});
|
|
};
|
|
r27._handleClose = () => {
|
|
FeedbackWidgetManager.hide();
|
|
};
|
|
FeedbackButtonManager.initialize(r27._setButtonVisibilityFunction);
|
|
ScreenshotButtonManager.initialize(r27._setScreenshotButtonVisibilityFunction);
|
|
FeedbackWidgetManager.initialize(r27._setVisibilityFunction);
|
|
return r27;
|
|
};
|
|
_inherits(FeedbackWidgetProvider, Component);
|
|
exports.FeedbackWidgetProvider = _createClass(FeedbackWidgetProvider, [{
|
|
key: "componentDidMount",
|
|
value: function componentDidMount() {
|
|
this._themeListener = Appearance.addChangeListener(() => {
|
|
this.forceUpdate();
|
|
});
|
|
}
|
|
}, {
|
|
key: "componentWillUnmount",
|
|
value: function componentWillUnmount() {
|
|
if (this._themeListener) {
|
|
this._themeListener.remove();
|
|
}
|
|
}
|
|
}, {
|
|
key: "componentDidUpdate",
|
|
value: function componentDidUpdate(a0, a1) {
|
|
if (!a1.isVisible && this.state.isVisible) {
|
|
Animated.parallel([Animated.timing(this.state.backgroundOpacity, {
|
|
toValue: 1,
|
|
duration: BACKGROUND_ANIMATION_DURATION,
|
|
useNativeDriver: c1000_15,
|
|
easing: Easing.in(Easing.quad)
|
|
}), Animated.timing(this.state.panY, {
|
|
toValue: 0,
|
|
duration: SLIDE_ANIMATION_DURATION,
|
|
useNativeDriver: true,
|
|
easing: Easing.in(Easing.quad)
|
|
})]).start(() => {
|
|
debug.log("FeedbackWidgetProvider componentDidUpdate");
|
|
});
|
|
} else if (a1.isVisible && !this.state.isVisible) {
|
|
this.state.backgroundOpacity.setValue(0);
|
|
}
|
|
}
|
|
}, {
|
|
key: "render",
|
|
value: function render() {
|
|
if (isModalSupported()) {
|
|
const theme = getTheme();
|
|
const state = this.state;
|
|
let isButtonVisible = state.isButtonVisible;
|
|
let isScreenshotButtonVisible = state.isScreenshotButtonVisible;
|
|
const isVisible2 = state.isVisible;
|
|
const backgroundColor = state.backgroundOpacity.interpolate({
|
|
inputRange: [0, 1],
|
|
outputRange: ["rgba(0, 0, 0, 0)", "rgba(0, 0, 0, 0.9)"]
|
|
});
|
|
const Fragment = Module19.Fragment;
|
|
const children = this.props.children;
|
|
if (isButtonVisible) {
|
|
isButtonVisible = <FeedbackButton {...getFeedbackButtonOptions()} />;
|
|
}
|
|
if (isScreenshotButtonVisible) {
|
|
isScreenshotButtonVisible = <ScreenshotButton {...getScreenshotButtonOptions()} />;
|
|
}
|
|
return <Fragment>
|
|
{children}
|
|
{isButtonVisible}
|
|
{isScreenshotButtonVisible}
|
|
{isVisible2 && <Animated.View style={[modalWrapper, {
|
|
backgroundColor
|
|
}]}>
|
|
<_Module17.Modal visible={isVisible2} transparent animationType="none" onRequestClose={this._handleClose} testID="feedback-form-modal">
|
|
<View style={topSpacer} />
|
|
<Animated.View style={[modalSheetContainer(theme), {
|
|
transform: [{
|
|
translateY: this.state.panY
|
|
}]
|
|
}]} {...this._panResponder.panHandlers}>
|
|
<ScrollView bounces={false} keyboardShouldPersistTaps="handled" automaticallyAdjustKeyboardInsets={false} onScroll={this._handleScroll}>
|
|
<_FeedbackWidget.FeedbackWidget {...getFeedbackOptions()} onFormClose={this._handleClose} onFormSubmitted={this._handleClose} />
|
|
</ScrollView>
|
|
</Animated.View>
|
|
</_Module17.Modal>
|
|
</Animated.View>}
|
|
</Fragment>;
|
|
}
|
|
debug.error("FeedbackWidget Modal is not supported in React Native < 0.71 with Fabric renderer.");
|
|
return <>{this.props.children}</>;
|
|
}
|
|
}]);
|