0.0.3 • Published 7 years ago

react-native-default-style v0.0.3

Weekly downloads
2
License
GNU GPLv3
Repository
github
Last release
7 years ago

react-native-default-style-version react-native-default-style-version

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',
  }
});