react-native-ui-lib
Version:
[](https://travis-ci.org/wix/react-native-ui-lib) [](https://www.npmjs.com/package/react-native-ui-lib) [![NPM Down
51 lines (50 loc) • 1.68 kB
JavaScript
import React from "react";
import { View as RNView, StyleSheet, SafeAreaView } from "react-native";
import { BaseComponent } from "../../commons";
import * as Constants from "../../helpers/Constants";
/**
* @description: Wrapper component for React Native View component
* @extends: View
* @extendslink: https://facebook.github.io/react-native/docs/view.html
* @modifiers: margins, paddings, alignments, background, borderRadius
*/
export default class View extends BaseComponent {
generateStyles() {
this.styles = createStyles(this.props);
}
setNativeProps(nativeProps) {
this._root.setNativeProps(nativeProps); // eslint-disable-line
}
renderView() {
const { backgroundColor, borderRadius, paddings, margins, alignments, flexStyle } = this.state;
const { useSafeArea, style, left, top, right, bottom, flex: propsFlex, ...others } = this.props;
const Element = useSafeArea && Constants.isIOS ? SafeAreaView : RNView;
return (<Element {...others} style={[
this.styles.container,
backgroundColor && { backgroundColor },
borderRadius && { borderRadius },
flexStyle,
paddings,
margins,
alignments,
style
]} ref={r => (this.view = r)}>
{this.props.children}
</Element>);
}
render() {
return this.renderView();
}
measure(...args) {
this.view.measure(...args);
}
measureInWindow(...args) {
this.view.measureInWindow(...args);
}
}
View.displayName = "View";
function createStyles() {
return StyleSheet.create({
container: {}
});
}