1.1.3 • Published 3 years ago

react-native-eazy-background v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Getting started

Base utility for mobile phone applicaion for android and ios

npm.io

Installation

yarn add react-native-eazy-background

Usage

Wrap your application inside the background

import Background from "react-native-eazy-background";
function App() {
  return <Background>{props.children}</Background>;
}

Use hook to show toase message

import { useToast } from 'react-native-eazy-background';

function App () {
    const toast = useToast();
    return <Button title='toast me' onPress={() => toast('toast message') />
}
import { useLoad, useToast } from 'react-native-eazy-background';

function App () {
    const loading = useLoad();
    const toast = useToast();
    useEffect = (() => {
        loading(true);
        toast('fetching data...', 'INFO');
        const data = await ...;
        ...
        toast('fetch success','SUCCESS');
        loading(false);
    })
}

Use StyleSheet shortcut

import { css } from "react-native-eazy-background";

function App() {
  return (
    <View style={[css.bg("red"), css.p(20), css.container]}>
      <Text style={[css.my(20), css.text_color("white"), css.text_center]}>Style</Text>
    </View>
  );
}

Use Context inside the class

import { ToastContext } from "react-native-eazy-background";

class HomeScreen extends React.Component {
  static contextType = ToastContext;
  render() {
    return (
      <View>
        <Button
          title="toast me"
          onPress={() => {
            this.context.toastMessage("message", "INFO");
          }}
        />
      </View>
    );
  }
}

Hooks

NameFormat
useToastuseToast(String: message, String: Type)
Toast TypeSUCCESS, ERROR, INFO, WARNING
useLoaduseLoad(Boolean value)

Props

NameTypeValue
safeAreaboolfalse
barStylestring'default' / 'light-content' / 'dark-content'
barHiddenbooltrue
topColorstring'#ffffff'
bottomColorstring'#000000'

StyleSheet(css)

most common value return

NameDescription
containerflex 1, justifyContent & alignItems: 'center'
centerjustifyContent: 'center', alignItems: 'center'
relativeposition: 'relative'
absoluteposition: 'absolute'
absolute_fluidposition: 'absolute', top, bottom, left, right = 0
flex_rowdirection: 'row'
flex_columndirection: 'column'
flex_wrapflexWrap : 'wrap'
overflow_visibleoverflow: 'visible'
overflow_hiddenoverflow: 'hidden'

most common value set

FunctionParameter / DefaultValue
topint: 0number
bottomint: 0number
leftint: 0number
rightint: 0number
flexint: 0number
flex_basisint: 0number
flex_growint: 0number
flex_shrinkint: 0number
directionstring: 'row''column', 'row', 'column-reverse', 'row-reverse'
justify_contentstring: 'center''flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly'
align_itemsstring: 'center''stretch', 'flex-start', 'flex-end', 'center', 'baseline'
align_selfstring: 'center''stretch', 'flex-start', 'flex-end', 'center', 'baseline'
align_contentstring: 'center''flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'stretch'
wint/string: 'auto'number, 'auto', percentage
min_wint/string: 'auto'number, 'auto', percentage
max_wint/string: 'auto'number, 'auto', percentage
hint/string: 'auto'number, 'auto', percentage
min_hint/string: 'auto'number, 'auto', percentage
max_hint/string: 'auto'number, 'auto', percentage
bgstirng: 'white'string, color code
opacityint: 1number
zindexint: 0number

** w = width, h = height, min_w = minWidth, max_w = maxWidth, min_h = minHeight, max_h = maxHeight, bg = background

spacing

FunctionDescription
p(value)padding = value
p(value1, value2)paddingTop, paddingBottom = value1 / paddingLeft, paddingRight = value2
p(v1, v2, v3)paddingTop = v1 / paddingLeft, paddingRight = v2 / paddingBottom = v3
p(v1, v2, v3, v4)paddingTop = v1 / paddingRight = v2 / paddingBottom = v3 / paddingLeft = v4
px(value)paddingLeft, paddingRight = value
py(value)paddingTop, paddingBottom = value
m(value)margin = value
m(value1, value2)marginTop, marginBottom = value1 / marginLeft, marginRight = value2
m(v1, v2, v3)marginTop = v1 / marginLeft, marginRight = v2 / marginBottom = v3
m(v1, v2, v3, v4)marginTop = v1 / marginRight = v2 / marginBottom = v3 / marginLeft = v4
mx(value)marginLeft, marginRight = value
my(value)marginTop, marginBottom = value

** spacing default value is 0

text

FunctionDescriptionValue
text_color(string: 'black')colorcolor code
text_fs(int: 14)fontSizenumber
text_align(string: 'left')alignment'auto', 'left', 'right', 'center', 'justify'
text_centeralignmentreturn 'center'
text_leftalignmentreturn 'left'
text_rightalignmentreturn 'right'
text_justifyalignmentreturn 'justify'
text_deco(string: 'none')textDecorationLine'none', 'underline', 'line-through', 'underline line-through'
text_undertextDecorationLinereturn 'underline'
text_throughttextDecorationLinereturn 'line-through'
text_lh(int: 0)lineHeightnumber
text_fw(int: 0)fontWeightnumber
text_ls(int: 0)letterSpacingnumber
text_italicfontStylereturn 'italic'
text_boldfontWeightreturn 'bold'
text_transform(string: 'none')textTransform'none', 'uppercase', 'lowercase', 'capitalize'
text_uppercasetextTransformreturn 'uppercase'
text_lowercasetextTransformreturn 'lowercase'
text_capitalizetextTransformreturn 'capitalize'

border

FunctionDescription
border(int: 1, string: 'solid', string: 'gainsboro')borderWidth, borderStyle, borderColor
border_left(int: 1, string: 'solid', string: 'gainsboro')borderWidth, borderStyle, borderLeftColor
border_right(int: 1, string: 'solid', string: 'gainsboro')borderWidth, borderStyle, borderRightColor
border_top(int: 1, string: 'solid', string: 'gainsboro')borderWidth, borderStyle, borderTopColor
border_bottom(int: 1, string: 'solid', string: 'gainsboro')borderWidth, borderStyle, borderBottomColor
shaodw(string: 'black', int: 3, int: 3)shadowColor, width, height
border(string: 'black')borderColor

License

MIT

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago