Skip to content

Instantly share code, notes, and snippets.

View krizzu's full-sized avatar

Krzysztof Borowy krizzu

View GitHub Profile
@krizzu
krizzu / React_pod_instructions.md
Last active July 11, 2019 18:14
How to use React as pod.

This gist will show you how to install and use React from Pods.

Podfile

target 'yourAppNameHere' do

  pod "Yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'BatchedBridge', # Required For React Native 0.45.0+
 'Core',
// All necessary imports
class AppAuthScreen extends Component {
async componentDidMount() {
const { navigation } = this.props;
const currentEmail = await AsyncStorage.getItem(
'@footballApp:currentEmail' // key used to save email during user singup
);
// @flow
import firebase from 'react-native-firebase';
export const DB = firebase.firestore();
export const USER_COLLECTION = 'users'; // name of collection in Firestore
export async function createUserDataBaseEntry(userId: string) {
// creating a new transaction
@krizzu
krizzu / MainActivity.java
Last active July 5, 2018 11:22
[Article] Standard Android code for RN
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "kotlin_app";
}
}
@krizzu
krizzu / MainActivity.kt
Created July 5, 2018 11:19
[Article] Kotlin version of standard RN android code
import com.facebook.react.ReactActivity
class MainActivity : ReactActivity() {
override fun getMainComponentName(): String? {
return "kotlin_app"
}
}
@krizzu
krizzu / build.gradle
Created July 5, 2018 10:16
[Article] App level build file
//...
apply plugin: "kotlin-android" // apply plugin
dependencies {
// ...
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // add dependency
}
// ...
@krizzu
krizzu / KotlinSyntaxCheatSheet.kt
Last active July 5, 2018 10:13
Small Cheatsheet for kotlin
/*
Variables
- Must be initialized with value
- Can be either immutable or mutable
- Can be null, but need to be declared with nullable type (more later)
- Various in Kotlin
- Numbers
- Byte
- Short
@krizzu
krizzu / build.gradle
Created July 5, 2018 10:06
[Article] Top level build gradle
buildscript {
ext.kotlin_version = '1.2.31' // add version
// ...
dependencies {
// ...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Add kotlin dependency
}
}
// ...
// This will vary
package com.example.application;
// Core RNFirebase
import io.invertase.firebase.RNFirebasePackage;
public class MainApplication extends Application implements ReactApplication {
@Override
protected List<ReactPackage> getPackages() {
dependencies {
// Add to dependencies
compile(project(':react-native-firebase')) {
transitive = false
}
compile "com.google.firebase:firebase-core:11.4.2"
// If you are receiving Google Play API availability issues, add the following dependency
compile "com.google.android.gms:play-services-base:11.4.2"
}