Skip to content

Commit

Permalink
Merge pull request #1 from m4ttheweric/m4ttheweric/cover-screen
Browse files Browse the repository at this point in the history
Added support for "coverScreen" option.
  • Loading branch information
m4ttheweric authored Apr 13, 2021
2 parents eca008f + 02dd352 commit eafdbd3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 49 deletions.
60 changes: 38 additions & 22 deletions packages/modal-enhanced-react-native-web/.babelrc
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["last 1 versions", "ie >= 10"]
},
"modules": false,
"loose": true,
"useBuiltIns": true
}],
[
"env",
{
"targets": {
"browsers": ["last 1 versions", "ie >= 10"]
},
"modules": false,
"loose": true,
"useBuiltIns": true
}
],
"stage-0",
"react",
"react-native"
],
"plugins": [
["babel-plugin-transform-class-properties", {
"loose": true
}],
["transform-object-rest-spread", {
"useBuiltIns": true
}],
["transform-react-remove-prop-types", {
"mode": "wrap"
}],
["module-resolver", {
"alias": {
"react-native": ["react-native-web"]
[
"babel-plugin-transform-class-properties",
{
"loose": true
}
],
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
],
[
"transform-react-remove-prop-types",
{
"mode": "remove"
// had to change this to remove to avoid build errors
}
],
[
"module-resolver",
{
"alias": {
"react-native": ["react-native-web"]
}
}
}]
]
],
"env": {
"commonjs": {
"plugins": ["add-module-exports"]
}
}
}
}
6 changes: 3 additions & 3 deletions packages/modal-enhanced-react-native-web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ class ReactNativeModal extends Component {

// User can define custom react-native-animatable animations, see PR #72
buildAnimations = (props) => {
let animationIn = props.animationIn;
let animationOut = props.animationOut;
let { animationIn } = props;
let { animationOut } = props;

if (isObject(animationIn)) {
const animationName = JSON.stringify(animationIn);
Expand Down Expand Up @@ -373,7 +373,7 @@ class ReactNativeModal extends Component {
);
}

let animationOut = this.animationOut;
let { animationOut } = this;

if (this.inSwipeClosingState) {
this.inSwipeClosingState = false;
Expand Down
60 changes: 38 additions & 22 deletions packages/modal-react-native-web/.babelrc
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
{
"presets": [
["env", {
"targets": {
"browsers": ["last 1 versions", "ie >= 10"]
},
"modules": false,
"loose": true,
"useBuiltIns": true
}],
[
"env",
{
"targets": {
"browsers": ["last 1 versions", "ie >= 10"]
},
"modules": false,
"loose": true,
"useBuiltIns": true
}
],
"stage-0",
"react",
"react-native"
],
"plugins": [
["transform-class-properties", {
"loose": true
}],
["transform-object-rest-spread", {
"useBuiltIns": true
}],
["transform-react-remove-prop-types", {
"mode": "wrap"
}],
["module-resolver", {
"alias": {
"react-native": ["react-native-web"]
[
"transform-class-properties",
{
"loose": true
}
],
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
],
[
"transform-react-remove-prop-types",
{
"mode": "remove"
// had to change this to remove to avoid build errors
}
],
[
"module-resolver",
{
"alias": {
"react-native": ["react-native-web"]
}
}
}]
]
],
"env": {
"commonjs": {
"plugins": ["add-module-exports"]
}
}
}
}
15 changes: 13 additions & 2 deletions packages/modal-react-native-web/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Animated, Dimensions, Easing, Platform } from 'react-native';
import { View, Animated, Dimensions, Easing, Platform } from 'react-native';

import ModalPortal from './Portal';
import * as ariaAppHider from './ariaAppHider';
Expand All @@ -27,6 +27,7 @@ export default class Modal extends Component {
children: PropTypes.node.isRequired,
ariaHideApp: PropTypes.bool,
appElement: PropTypes.instanceOf(SafeHTMLElement),
coverScreen: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -38,6 +39,7 @@ export default class Modal extends Component {
onDismiss: () => {},
ariaHideApp: true,
appElement: null,
coverScreen: true,
};

constructor(props) {
Expand Down Expand Up @@ -245,7 +247,7 @@ export default class Modal extends Component {
: styles.bgNotTransparent;
const animationStyle = this.getAnimationStyle();

return (
return this.props.coverScreen ? (
<ModalPortal>
<Animated.View
aria-modal="true"
Expand All @@ -254,6 +256,15 @@ export default class Modal extends Component {
{children}
</Animated.View>
</ModalPortal>
) : (
<View>
<Animated.View
aria-modal="true"
style={[styles.baseStyle, transparentStyle, animationStyle]}
>
{children}
</Animated.View>
</View>
);
}
}

0 comments on commit eafdbd3

Please sign in to comment.