This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slugify(string) { | |
let str = string.replace(/^\s+|\s+$/g, ''); // trim | |
str = str.toLowerCase(); | |
// remove accents, swap ñ for n, etc | |
const from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;'; | |
const to = 'aaaaeeeeiiiioooouuuunc------'; | |
for (let i=0, l=from.length ; i<l ; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Storage | |
// Check if data is stored locallyget new | |
this.storage.ready().then(() => { | |
this.storage.get('articles').then((value) => { | |
if (value === null) { | |
this.article.loadData().then((data) => { | |
this.storage.set('articles', data) | |
this.newsData = data; | |
}); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'assets', 'www'); | |
exports.ANDROID_PLATFORM_PATH = path.join('platforms', 'android', 'app', 'src', 'main', 'assets', 'www'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*imports | |
import { Component, ViewChild } from '@angular/core'; | |
@ViewChild('focusInput') myInput; | |
*html | |
<ion-textarea #focusInput></ion-textarea> | |
ionViewDidEnter() { | |
setTimeout(() => { | |
this.keyboard.show(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use an Event to reload the page | |
this.events.subscribe('reloadPage', () => { | |
console.log('app reloaded'); | |
let component = this.navCtrl.getActive().instance; | |
// call component.ionViewDidLoad() inside whatever data you are refreshing with | |
// ionViewDidLoad() {} should be where you house your setup code | |
this.storage.set('garage', newData).then(() => { | |
component.ionViewDidLoad(); | |
}); | |
// uncomment this if it still didnt work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Put all your fonts in you React-Native project directory | |
`./assets/fonts/` | |
2. Add the following line in your package.json | |
``` | |
"rnpm": { | |
"assets": ["./assets/fonts"] | |
} | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
# Turn Off mod_dir Redirect For Existing Directories | |
DirectorySlash Off | |
# Rewrite For Public Folder | |
RewriteEngine on | |
RewriteRule ^(.*)$ public/$1 [L] | |
</IfModule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res | |
cd android | |
./gradlew app:assembleDebug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Generate Icons and SplashScreen | |
https://github.com/bamlab/generator-rn-toolbox/blob/master/generators/assets/README.md | |
https://medium.com/@pqkluan/how-to-implement-splash-screen-in-react-native-navigation-ee2184a1a96 |
OlderNewer