/cms-mobile

Primary LanguageTypeScript

100xDev CMS Mobile App!

Getting Started

To get a local copy up and running, please follow these simple steps.

Prerequisites

React Native environment setup on your machine.

Setup

  1. Fork this repo in your own GitHub account
  2. Clone the forked repo to your local machine
  3. Run pnpm install to install all dependencies in the project
  4. For Android:
    pnpm android
    
    For iOS:
    pnpm ios
    

Instructions

This is the boilerplate that Infinite Red uses as a way to test bleeding-edge changes to our React Native stack.

Currently includes:

  • React Native
  • React Navigation
  • MobX State Tree
  • TypeScript
  • And more!

Comes with Built-in generators

Component generator

This is the generator you will be using most often. They come pre-wrapped with mobx-react-lite's observer function, which you'll need to trigger re-renders if any MobX-State-Tree properties that are being used in this component change.

npx ignite-cli generate component MyAwesomeButton
  • Creates the component/function

Screen generator

Generates a "hooks enabled" screen that is also pre-wrapped with mobx-react-lite's observer function, making it automatically re-render anytime a relevant MST property changes.

npx ignite-cli generate screen Settings

Model generator

Creates a Mobx-State-Tree model.

npx ignite-cli generate model Pizza
  • Creates the model
  • Creates a unit test file
  • Appends export to models/index.ts unless you pass --skip-index-file

Folder Structure:

ignite-project
├── app
│   ├── components
│   ├── config
│   ├── i18n
│   ├── models
│   ├── navigators
│   ├── screens
│   ├── services
│   ├── theme
│   ├── utils
│   └── app.tsx
├── assets
│   ├── icons
│   └── images
├── test
│   ├── __snapshots__
│   ├── mockFile.ts
│   └── setup.ts
├── README.md
├── android
│   ├── app
│   ├── build.gradle
│   ├── gradle
│   ├── gradle.properties
│   ├── gradlew
│   ├── gradlew.bat
│   ├── keystores
│   └── settings.gradle
├── ignite
│   └── templates
|       |── app-icon
│       ├── component
│       ├── model
│       ├── navigator
│       └── screen
├── index.js
├── ios
│   ├── IgniteProject
│   ├── IgniteProject-tvOS
│   ├── IgniteProject-tvOSTests
│   ├── IgniteProject.xcodeproj
│   └── IgniteProjectTests
├── .env
└── package.json

./app directory

Included in an Ignite boilerplate project is the app directory. This is a directory you would normally have to create when using vanilla React Native.

The inside of the app directory looks similar to the following:

app
├── components
├── config
├── i18n
├── models
├── navigators
├── screens
├── services
├── theme
├── utils
└── app.tsx

components This is where your reusable components live which help you build your screens.

i18n This is where your translations will live if you are using react-native-i18n.

models This is where your app's models will live. Each model has a directory which will contain the mobx-state-tree model file, test file, and any other supporting files like actions, types, etc.

navigators This is where your react-navigation navigators will live.

screens This is where your screen components will live. A screen is a React component which will take up the entire screen and be part of the navigation hierarchy. Each screen will have a directory containing the .tsx file, along with any assets or other helper files.

services Any services that interface with the outside world will live here (think REST APIs, Push Notifications, etc.).

theme Here lives the theme for your application, including spacing, colors, and typography.

utils This is a great place to put miscellaneous helpers and utilities. Things like date helpers, formatters, etc. are often found here. However, it should only be used for things that are truly shared across your application. If a helper or utility is only used by a specific component or model, consider co-locating your helper with that component or model.

app.tsx This is the entry point to your app. This is where you will find the main App component which renders the rest of the application.

./assets directory

This directory is designed to organize and store various assets, making it easy for you to manage and use them in your application. The assets are further categorized into subdirectories, including icons and images:

assets
├── icons
└── images

icons This is where your icon assets will live. These icons can be used for buttons, navigation elements, or any other UI components. The recommended format for icons is PNG, but other formats can be used as well.

Ignite comes with a built-in Icon component. You can find detailed usage instructions in the docs.

images This is where your images will live, such as background images, logos, or any other graphics. You can use various formats such as PNG, JPEG, or GIF for your images.

Another valuable built-in component within Ignite is the AutoImage component. You can find detailed usage instructions in the docs.

How to use your icon or image assets:

import { Image } from 'react-native';

const MyComponent = () => {
  return (
    <Image source={require('../assets/images/my_image.png')} />
  );
};