| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- // @flow
-
- import React from 'react';
- import {
- TouchableHighlight,
- TouchableWithoutFeedback,
- View
- } from 'react-native';
-
- import AbstractContainer from '../AbstractContainer';
-
- /**
- * Represents a container of React Native/mobile {@link Component} children.
- *
- * @extends AbstractContainer
- */
- export default class Container extends AbstractContainer {
- /**
- * {@code Container} component's property types.
- *
- * @static
- */
- static propTypes = AbstractContainer.propTypes;
-
- /**
- * Implements React's {@link Component#render()}.
- *
- * @inheritdoc
- * @returns {ReactElement}
- */
- render() {
- const {
- accessibilityLabel,
- accessible,
- onClick,
- touchFeedback = onClick,
- visible = true,
- ...props
- } = this.props;
-
- // visible
- if (!visible) {
- return null;
- }
-
- const onClickOrTouchFeedback = onClick || touchFeedback;
- let element
- = super._render(
- View,
- {
- pointerEvents: onClickOrTouchFeedback ? 'auto' : 'box-none',
- ...props
- });
-
- // onClick & touchFeedback
- if (element && onClickOrTouchFeedback) {
- element
- = React.createElement(
- touchFeedback
- ? TouchableHighlight
- : TouchableWithoutFeedback,
- {
- accessibilityLabel,
- accessible,
- onPress: onClick
- },
- element);
- }
-
- return element;
- }
- }
|