After Pull:
yarn install
Additional step (for iOS):
4. cd ios
5. pod install
6. cd ..
react-native run-ios
/ react-native run-android
Project information:
Packages Include:
Included Examples:
Custom Libraries:
/**
* Load / Display registered label
*/
...
import lang from 'path/to/Helpers/Language';
...
...
render() {
return(
<Text>{ lang('title.home') }</Text>
);
}
...
/**
* Set current language
*/
...
import { setLanguage } from 'path/to/Helpers/Language';
...
...
changeLanguage() {
setLanguage('id');
}
...
/**
* Get current language
*/
...
import { getLanguage } from 'path/to/Helpers/Language';
...
...
getCurrentLang() {
let currentLang = getLanguage();
}
...
If you want to add another language (eg. French), here the steps:<br>
1\. Create file `fr.js` with JSON variables inside Folder `Helpers/Language`
```javascript
export const encoding = 'fr';
export const lang = {
label1: 'Label 1',
nestedLabel: {
label2: 'Nested Label 2'
}
}
2. Import fr.js
to Helpers/Language/index.js
import * as french from './fr';
3. add french
into availLang
’s array
export const availLang = [
...
...
french
];
4. Ta da, your new language is available to be displayed
* Hooks helpers, helper for your own custom functions
Code Examples:
```js
// Import all
import * as Hooks from 'path/to/Helpers/Hooks';
...
let myValue = Hooks.yourCustomFunctionName(yourParams);
let myOtherValue = Hooks.yourOtherCustomFunctionName(yourOtherParams);
...
// Or
import {
yourCustomFunctionName,
yourOtherCustomFunctionName
} from 'path/to/Helpers/Hooks';
...
let myValue = yourCustomFunctionName(yourParams);
let myOtherValue = yourOtherCustomFunctionName(yourOtherParams);
...
// Always Prepare Session when the app is started (usually in Splash Screen)
import * as Session from 'path/to/Helpers/Session';
...
Session.prepare().then((sessionData) => {
// Do something with existed sessionData
}).catch((err) => {
console.log("Session Prepare Error", err.message);
});
...
// Set Session Value
...
let yourValue = 'my Name is Ajul';
Session.setValue(Session.YOUR_KEY, yourValue);
...
// Get Session Value
...
let myName = Session.getValue(Session.YOUR_KEY, 'default value');
...
...
import HttpRequest from 'path/to/Helpers/Http';
...
...
let myRequest = {
link: 'myapi/endpoints',
method: 'POST',
data: {
id: 1,
name: 'my name is'
}
}
HttpRequest(myRequest).then((response) => {
// Do something with the response
}).catch((error) => {
// Do something with the error
});
...
Author: brian-AyooDev
Source Code: https://github.com/brian-AyooDev/Lemonilo-test
#react-native #react #mobile-apps