react-native-modalfy
Version:
Modal citizen of React Native
39 lines (34 loc) • 2.69 kB
JavaScript
export default function (stackItem, stack) {
const stackItemOption = key => {
var _stackItem$component$, _stackItem$component$2, _stackItem$options;
return (_stackItem$component$ = stackItem === null || stackItem === void 0 ? void 0 : (_stackItem$component$2 = stackItem.component.modalOptions) === null || _stackItem$component$2 === void 0 ? void 0 : _stackItem$component$2[key]) !== null && _stackItem$component$ !== void 0 ? _stackItem$component$ : stackItem === null || stackItem === void 0 ? void 0 : (_stackItem$options = stackItem.options) === null || _stackItem$options === void 0 ? void 0 : _stackItem$options[key];
};
const extractOption = key => {
var _ref, _stackItem$component$3, _stackItem$component$4, _stackItem$options2;
return (_ref = (_stackItem$component$3 = stackItem === null || stackItem === void 0 ? void 0 : (_stackItem$component$4 = stackItem.component.modalOptions) === null || _stackItem$component$4 === void 0 ? void 0 : _stackItem$component$4[key]) !== null && _stackItem$component$3 !== void 0 ? _stackItem$component$3 : stackItem === null || stackItem === void 0 ? void 0 : (_stackItem$options2 = stackItem.options) === null || _stackItem$options2 === void 0 ? void 0 : _stackItem$options2[key]) !== null && _ref !== void 0 ? _ref : stack.defaultOptions[key];
};
return {
position: extractOption('position'),
backBehavior: extractOption('backBehavior'),
backdropColor: extractOption('backdropColor'),
containerStyle: extractOption('containerStyle'),
animateInConfig: extractOption('animateInConfig'),
backdropOpacity: extractOption('backdropOpacity'),
animateOutConfig: extractOption('animateOutConfig'),
transitionOptions: extractOption('transitionOptions'),
stackContainerStyle: extractOption('stackContainerStyle'),
disableFlingGesture: extractOption('disableFlingGesture'),
pointerEventsBehavior: extractOption('pointerEventsBehavior'),
backdropAnimationDuration: extractOption('backdropAnimationDuration'),
/**
* NOTE: In StackItem's updateAnimatedValue() we don't use the `animateIn/OutConfig` if
* `animationIn/Out` exists. However, those can be coming from the defaultOptions and
* in the stackItem option, only `animateIn/OutConfig` would be defined. Hence the need
* for this check so that the default `animationIn/Out` wouldn't override the stackItem
* specific `animateIn/OutConfig`.
*/
animationIn: stackItemOption('animateInConfig') ? undefined : extractOption('animationIn'),
animationOut: stackItemOption('animateOutConfig') ? undefined : extractOption('animationOut')
};
}
//# sourceMappingURL=getStackItemOptions.js.map