0.5.9 • Published 2 years ago

rn-structure v0.5.9

Weekly downloads
61
License
ISC
Repository
gitlab
Last release
2 years ago

rn-structure

Documentation

  1. Installation
  2. Usage
  3. Structure
  4. Components
  5. Stores
  6. Utils
  7. Libraries

Installation

Get started with rn-structure by installing the node module with yarn or npm:

Installing (React Native >= 0.60.0)

npm install -g rn-structure@latest

or

yarn global add rn-structure@latest

Installing (React Native == 0.59.x)

npm install -g rn-structure@0.3.1

or

yarn add global rn-structure@0.3.1

Usage

rn-init <project-name>

With custom Bundle Identifier (IOS only. For Android is coming soon or you can use react-native-rename)

rn-bundle <newBundleIdentifier> <project-path>

Note: If you don't enter a specific project-path, the project-path will take the path to the current directory

npm start

npm run android                         # <=> react-native run-android
npm run ios                             # <=> react-native run-ios
npm run SE                              # <=> react-native run-ios --simulator='iPhone SE'

npm run reload                          # <=> adb shell input text 'rr' working reload android build debugging
npm run toggle                          # <=> adb shell input keyevent 82 show toggle

npm run restart                         # <=> react-native start --reset-cache

npm run build:android                   # compile source code
npm run build:ios                       # compile source code

npm run build:release:android           # build file APK release
npm run sync:android                    # clean project android

npm test
npm run coverage

Note: If you have prepared configuration for the release application, you can use the following command to create file apk, ipa.

sh build.sh

Structure

  .
  ├──package.json
  ├──index.js
  ├──debugging:
  │   └──ReactotronConfig.js
  └──src:
      ├──assets:
      │   ├──package.json
      │   ├──index.js
      │   ├──data:
      │   │   ├── ...
      │   │   └──index.js
      │   ├──fonts:
      │   │   └── ...
      │   ├──icons:
      │   │   ├── ...
      │   │   └──index.js
      │   └──images:
      │       ├── ...
      │       └──index.js
      ├──common:
      │   ├── ...
      │   ├──elements:
      │   │   ├── ...
      │   │   └──index.js
      │   └──components:
      │       ├──package.json
      │       ├──index.js
      │       ├──Button
      │       │   └──index.js
      │       ├──Header:
      │       │   └──index.js
      │       ├──Label:
      │       │   └──index.js
      │       ├──Spinner:
      │       │   └──index.js
      │       ├──Switch:
      │       │   └──index.js
      │       └──List:
      │           └──index.js
      ├──configs:
      │   ├──Animations.js
      │   └──index.js
      ├──containers:
      │   ├──package.json
      │   ├──index.js
      │   └──HomePage:
      │       ├──styles.js
      │       └──index.js
      ├──routers:
      │   └───index.js
      ├──stores:
      │   ├──package.json
      │   ├──index.js
      │   ├──actions:
      │   │   ├── ...
      │   │   └──index.js
      │   └──reducers:
      │       ├── ...
      │       ├──init.js
      │       └──index.js
      ├──utils:
      │   ├──package.json
      │   ├──index.js
      │   ├──styles.js
      │   ├──hooks.js
      │   ├──colors.js
      │   ├──strings.js
      │   ├──constants.js
      │   ├──functions.js
      │   ├──fetches.js
      │   ├──asyncStorage.js
      │   └──types.js
      └──App.js

Components

  1. Button
  2. Header
  3. Label
  4. List
  5. Spinner
  6. Switch

Label

example

  <Label.H5 numberOfLines={1} style={styles.titleHeaderContainerStyle} color={'#FFFFFF'}>{`Home`}</Label.H5>

Header

example

  <Header style={styles.header}>
    <Button onPress={this.goBack} source={ICONS.ic_back_white} style={styles.buttonBack} buttonImageStyle={styles.iconButtonBack} />
    <Label.H5 numberOfLines={1} style={styles.titleHeaderContainerStyle} color={'#FFFFFF'}>{`Home`}</Label.H5>
    <Button onPress={this.onPressSetting} source={ICONS.ic_setting_white} style={styles.buttonSetting} buttonImageStyle={styles.iconButtonSetting} />
  </Header>

List

Spinner

example

  <Spinner visible={isSpinning} />

Stores

sagas

    .
    ├──stores:
        ├──package.json
        ├──index.js
        ├──actions:
        │   ├── ...
        │   └──index.js
        ├──reducers:
        │   ├── ...
        │   ├──init.js
        │   └──index.js
        └──sagas:
            ├── ...
            ├──init.js
            └──index.js

Utils

Sound

    .
    ├──utils:
    │   ├──...
    │   ├──audioPlayer.js
    │   └──...
    └──...

#Demo

react-native-vector-icons

    .
    ├──utils:
    │   ├──...
    │   ├──getIconType.js
    │   └──types.js
    └──...

example

type ButtonProps = {
  style: any,
  textStyle: any,
  source: any,
  onPress: Function,
  iconType: string,
  iconName: string,
  iconColor: string,
  iconSize: number,
  children: string,
}

const Button = (props: ButtonIconProps) => {
  const {
    style,
    textStyle,
    source,
    onPress,
    iconType,
    iconName,
    iconColor,
    iconSize,
    children,
  } = props;
  let Icon = getIconType(iconType || 'material');
  return (
    <TouchableOpacity activeOpacity={0.7} onPress={() => onPress()} style={[styles.container, style]}>
      {
        (source) && <Image {...source} style={[styles.icon, { width: iconSize, height: iconSize }]} />
      }
      {
        (iconName) && <Icon name={iconName} size={iconSize} color={iconColor} />
      }
      {
        (children) && <Text style={[styles.text, textStyle]}>{children}</Text>
      }
    </TouchableOpacity>
  );
};

import { IconTypes } from '../types';

<Button iconType={IconTypes.ionicon} iconName={'md-search'} iconColor={'#2D4EF5'} onPress={() => console.log('test')} />

Libraries

UI:

react-native-linear-gradient
react-native-gesture-handler

Stores:

redux
react-redux

Middleware

redux-persist
redux-actions
redux-saga
@redux-saga/is

or

redux-thunk

Navigation

react-navigation@latest

Fetch:

abortcontroller-polyfill

Logging: installing reactotron

reactotron-react-native
reactotron-redux
reactotron-redux-saga

Utils:

moment
lodash.memoize
lodash.isempty
lodash.merge
0.5.8

2 years ago

0.5.9

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.7

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5-beta

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago