UNPKG

react-native-navigation-drilldown

Version:
96 lines 4.99 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var react_native_1 = require("react-native"); var react_native_platform_touchable_1 = require("react-native-platform-touchable"); var Icon_1 = require("./Icon"); var styles = react_native_1.StyleSheet.create({ wideText: { flex: 1, }, container: { flexDirection: 'row', height: 48, alignItems: 'center', }, disabled: { opacity: 0.5, }, }); var Handle = (function (_super) { __extends(Handle, _super); function Handle() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.renderContent = function () { var _a = _this.props, contentStyle = _a.contentStyle, contentProps = _a.contentProps, renderContent = _a.renderContent; if (renderContent) { var contentElement = renderContent(); return contentElement && React.cloneElement(contentElement, __assign({}, contentProps, { style: [contentProps && contentProps.style, contentStyle] }), _this.renderLeftIcon(), _this.renderTitle(), _this.renderRightIcon()); } return (<react_native_1.View {...contentProps} style={[styles.container, contentStyle]}> {_this.renderLeftIcon()} {_this.renderTitle()} {_this.renderRightIcon()} </react_native_1.View>); }; _this.renderLeftIcon = function () { var _a = _this.props, leftIcon = _a.leftIcon, leftIconStyle = _a.leftIconStyle, leftIconProps = _a.leftIconProps, renderLeftIcon = _a.renderLeftIcon, disabled = _a.disabled; if (renderLeftIcon) { var leftIconElement = renderLeftIcon(leftIcon); return leftIconElement && React.cloneElement(leftIconElement, __assign({}, leftIconProps, { style: [leftIconProps && leftIconProps.style, leftIconStyle, disabled && styles.disabled] })); } else if (leftIcon) { var source = typeof leftIcon === 'string' ? { uri: leftIcon } : leftIcon; return (<Icon_1.default wrapperStyle={[leftIconStyle, disabled && styles.disabled]} {...leftIconProps} source={source}/>); } return null; }; _this.renderTitle = function () { var _a = _this.props, title = _a.title, titleStyle = _a.titleStyle, titleProps = _a.titleProps, renderTitle = _a.renderTitle, disabled = _a.disabled; if (renderTitle) { var titleElement = renderTitle(title); return titleElement && React.cloneElement(titleElement, __assign({}, titleProps, { style: [titleProps && titleProps.style, titleStyle, disabled && styles.disabled] })); } return (<react_native_1.Text {...titleProps} style={[styles.wideText, titleStyle, disabled && styles.disabled]}>{title}</react_native_1.Text>); }; _this.renderRightIcon = function () { var _a = _this.props, rightIcon = _a.rightIcon, rightIconStyle = _a.rightIconStyle, rightIconProps = _a.rightIconProps, renderRightIcon = _a.renderRightIcon, disabled = _a.disabled; if (renderRightIcon) { var rightIconElement = renderRightIcon(rightIcon); return rightIconElement && React.cloneElement(rightIconElement, __assign({}, rightIconProps, { style: [rightIconProps && rightIconProps.style, rightIconStyle, disabled && styles.disabled] })); } else if (rightIcon) { var source = typeof rightIcon === 'string' ? { uri: rightIcon } : rightIcon; return (<Icon_1.default wrapperStyle={[rightIconStyle, disabled && styles.disabled]} {...rightIconProps} source={source}/>); } return null; }; return _this; } Handle.prototype.render = function () { return (<react_native_platform_touchable_1.default disabled={this.props.disabled} onPress={this.props.onPress}> {this.renderContent()} </react_native_platform_touchable_1.default>); }; return Handle; }(React.PureComponent)); exports.Handle = Handle; //# sourceMappingURL=Handle.js.map