react-web-native-sketch
Version:
[TODO: We need an overview of how this can be used via npm vs as a local package]
80 lines • 3.9 kB
JavaScript
;
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 __1 = require("../../");
var View_1 = require("../../primitives/View/View");
var theme_1 = require("../../utils/theme");
var hoist_non_react_statics_1 = require("../../lib/hoist-non-react-statics");
// TODO set proper type for WrappedComponent (it must check for existence of navigationOptions)
function addTopbar(WrappedComponent) {
if (!WrappedComponent.navigationOptions) {
return WrappedComponent;
}
var Enhance = /** @class */ (function (_super) {
__extends(Enhance, _super);
function Enhance() {
return _super !== null && _super.apply(this, arguments) || this;
}
Enhance.prototype.render = function () {
var navigationOptions = (typeof WrappedComponent.navigationOptions === 'function'
? WrappedComponent.navigationOptions({ navigation: this.props.navigation })
: WrappedComponent.navigationOptions), topbarHeight = __1.isXs() ? theme_1.appTheme.topBarHeightMobile : theme_1.appTheme.topBarHeightDesktop;
return (React.createElement(View_1.View, { style: {
width: '100%',
height: '100%',
flexDirection: 'column',
backgroundColor: '#eee'
} },
React.createElement(View_1.View, { style: {
height: topbarHeight,
// backgroundColor: appTheme.topbarColor,
backgroundColor: '#000',
zIndex: 100,
width: '50%',
position: 'absolute',
left: '50%',
transform: 'translateX(-50%)',
boxShadow: '0px 2px 4px -1px rgba(0, 0, 0, 0.2), 0px 4px 5px 0px rgba(0, 0, 0, 0.14), 0px 1px 10px 0px rgba(0, 0, 0, 0.12)',
justifyContent: 'space-between',
alignItems: 'center',
color: '#fff'
} },
navigationOptions.headerLeft || React.createElement(View_1.View, null),
navigationOptions.title || React.createElement(View_1.View, null),
navigationOptions.headerRight || React.createElement(View_1.View, null)),
React.createElement(View_1.View, { style: [
{
width: '100%',
top: topbarHeight,
bottom: 0,
position: 'absolute',
},
] },
React.createElement(WrappedComponent, __assign({}, this.props)))));
};
return Enhance;
}(React.PureComponent));
// need this for statics like react-native-navigation navigatorStyle/ navigatorButtons
hoist_non_react_statics_1.hoistNonReactStatics(Enhance, WrappedComponent);
return Enhance;
}
exports.addTopbar = addTopbar;
//# sourceMappingURL=addTopbar.js.map