react-native-default-style
v0.0.3
Published
Use ReactNative Components using default styles for each component.
Downloads
3
Maintainers
Readme
react-native-default-style
A React Native's module that allows you use all their components with predefined styles by default.
Installation
npm i -S react-native-default-style
Usage
Basic Usage
// src/configureDefaultStyles.js
import { setDefaultStyles, COMPONENT_TYPE } from 'react-native-default-style';
export const configureDefaultStyles = () => {
const allDefaultStyles = {
type: COMPONENT_TYPE.DEFAULT,
styles: {
backgroundColor: '#F00'
}
};
const textDefaultStyles = {
type: COMPONENT_TYPE.TEXT,
styles: {
color: '#FFF'
}
};
setDefaultStyles([ allDefaultStyles, textDefaultStyles ]);
};
// src/app.js
import React, { Component } from 'react';
import { StyleSheet } from 'react-native';
import { configureDefaultStyles } from './configureDefaultStyles';
import { View, Text } from 'react-native-default-style';
configureDefaultStyles(); // You must only execute once.
const MyView = (props) => {
return (<View><Text>This is my first test</Text></View>);
}
const MyOtherView = (props) => {
return (<View><Text style={myStyles.myOtherView}>This is my second test.</Text></View>);
}
const myStyles = StyleSheet.create({
myOtherView: {
color: '#09F',
}
});