GithubHelp home page GithubHelp logo

jjmoon / whatssub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kimjson/whatssub

0.0 1.0 0.0 1.22 MB

Open source react-native application built in expo.

License: Other

JavaScript 5.34% TypeScript 94.66%

whatssub's Introduction

whatssub

CircleCI codecov All Contributors PRs Welcome

whatssub

Contributing to whatssub

Specification

Gain points

1. Sample of context-api with `react-hook` (`useContext`).
2. Know how to structure react native app with typescript.
3. Know how to navigate between screens with `react-navigation`.
4. Know how to write test code with `@testing-library/react-native`.
5. Know how to `lint` your project with `tslint`.
6. Know how to localize your project.

INSTALL

npm install && npm start
// or
yarn && yarn start

Structures

app/
├─ .dooboo // necessary if using dooboo-cli
├─ assets
│  └─ icons // app icons
│  └─ images // app images like background images
├─ node_modules/
├─ src/
│  └─ apis
│  └─ components
│     └─ navigations
│     └─ screen
│     └─ shared
│  └─ contexts
│  └─ hooks
│  └─ utils
│  └─ App.tsx
├─ test/
├─ .buckconfig
├─ .gitattributes
├─ .gitignore
├─ .watchmanconfig
├─ app.sample.json
├─ babel.config.js
├─ index.js
├─ jest.config.js
├─ GoogleService-Info.plist
├─ google-services.json
├─ package.json
├─ README.md
├─ STRINGS.js
├─ tsconfig.json
└─ tslint.json

app.json

Run below to make your own app variables.

cp app.sample.json app.json

  • app variables

    Name Description required? default
    facebookAppId facebook app id true null
    facebookDisplayName facebook display name true whatssub
    ios.config.googleSignIn.reservedClientId REVERSED_CLIENT_ID in GoogleService-Info.plist firebase ios app project. true {our test ios}
    android.config.googleSignIn.certificateHash SHA1 or SHA256 hash keys from expo fetch:android:hashes true {our test ios}
    ...
      "ios": {
        "supportsTablet": false,
        "bundleIdentifier": "com.dooboolab.whatssub",
        "config": {
          "googleSignIn": {
            "reservedClientId": "<reservedClientId>"
          }
        }
      },
      "android": {
        "package": "com.dooboolab.whatssub",
        "googleServicesFile": "./google-services.json",
        "config": {
          "googleSignIn": {
            "certificateHash": "<certificateHash>"
          }
        }
      }
    ...

config.ts

Run below to make your own config variables.

cp config.sample.ts config.ts

  • config variables

    Name Description required? default
    iOSClientId CLIENT_ID in GoogleService-Info.plist firebase ios app project. true {our test ios clientId}
    export const iOSClientId = '';

Running the project

Running the project is as simple as running

npm run start

This runs the start script specified in our package.json, and will spawn off a server which reloads the page as we save our files. Typically the server runs at http://localhost:8080, but should be automatically opened for you.

Testing the project

Testing is also just a command away:

npm test

Result

> jest -u

 PASS  src/components/shared/__tests__/Button.test.tsx
 PASS  src/components/screen/__tests__/Intro.test.tsx
 › 2 snapshots written.

Snapshot Summary
 › 2 snapshots written in 1 test suite.

Test Suites: 2 passed, 2 total
Tests:       5 passed, 5 total
Snapshots:   2 added, 4 passed, 6 total
Time:        3.055s, estimated 6s
Ran all test suites

Writing tests with Jest

We've created test examples with jest-ts in src/components/screen/__tests__ and src/components/shared/__tests__. Since react is component oriented, we've designed to focus on writing test in same level of directory with component. You can simply run npm test to test if it succeeds and look more closer opening the source.

Localization

We've defined Localization strings in STRINGS.js which is in root dir. We used react-native-localization pacakage for this one.

import * as Localization from 'expo-localization';
import i18n from 'i18n-js';

const en = {
  HELLO: 'Hello',
  LOGIN: 'Login',
  EMAIL: 'Email',
  PASSWORD: 'Password',
  SIGNUP: 'SIGN UP',
  FORGOT_PW: 'Forgot password?',
  NAVIGATE: 'Navigate',
  CHANGE_THEME: 'Change theme',
};

const ko = {
  HELLO: '안녕하세요',
  LOGIN: '로그인',
  EMAIL: '이메일',
  PASSWORD: '패스워드',
  SIGNUP: '회원가입',
  FORGOT_PW: '비밀번호를 잊어버리셨나요?',
  NAVIGATE: '이동하기',
  CHANGE_THEME: '테마변경',
};

i18n.fallbacks = true;
i18n.translations = { en, ko };
i18n.locale = Localization.locale;

export const getString = (param: string, mapObj?: object) => {
  if (mapObj) {
    i18n.t(param, mapObj);
  }
  return i18n.t(param);
};

Android

  1. Create new Android project
  2. Set package name com.dooboolab.whatssub
  3. Set SHA1 or SHA256 hash keys from expo fetch:android:hashes
  4. Download google-services.json to whatssub root folder

iOS

  1. Create new iOS project
  2. Set bundleIdentifier com.dooboolab.whatssub
  3. Download GoogleService-Info.plist to whatssub root folder

Expo version

33

React navigation

3

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Hyo Chan Jang
Hyo Chan Jang

💻 ⚠️ 📖
Youngsu Han
Youngsu Han

💻 ⚠️
Dong-Kyun Ko
Dong-Kyun Ko

📖
Hwasung Kim
Hwasung Kim

💻 ⚠️
Choi, Jongtaek
Choi, Jongtaek

💻 ⚠️ 📖
Huy, Tae Young
Huy, Tae Young

💻 ⚠️ 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

whatssub's People

Contributors

hyochan avatar allcontributors[bot] avatar heyman333 avatar jongtaekchoi avatar godon019 avatar kty1965 avatar marsinearth avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.