Skip to content

Instantly share code, notes, and snippets.

View krizzu's full-sized avatar

Krzysztof Borowy krizzu

View GitHub Profile
@krizzu
krizzu / AppDelegate.m
Last active August 24, 2017 20:59
Changing background color of iOS rootView
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"YourReactApp"
initialProperties:nil
launchOptions:launchOptions];
// This line
rootView.backgroundColor = [[UIColor alloc] initWithRed:0.39 green:0.58 blue:0.67 alpha:1];
@krizzu
krizzu / colors.xml
Last active August 24, 2017 19:50
Colors resource file for android
<resources>
<!-- We'll use 'background' name to reference this color -->
<!-- Replace #HEX_VALUE with Your color -->
<color name="background">#HEX_VALUE</color>
</resources>
@krizzu
krizzu / styles.xml
Last active August 25, 2017 14:31
Setting background color
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- @color is a reference to resource colors.xml -->
<!-- and 'background' is a name of the resource -->
<item name="android:windowBackground">@color/background</item>
</style>
</resources>
#This will be different
target 'YouAppNameHere' do
#Firebase and RNFirebase pods
pod 'Firebase/Core'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
# Authentication module for RNFirebase
pod 'Firebase/Auth'
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
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"
}
// 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() {
@krizzu
krizzu / firebase.js
Created October 1, 2017 21:01
firebase_initialization_example
import RNFirebase from 'react-native-firebase'
// to check out init options, head to https://invertase.io/react-native-firebase/#/v2/usage?id=configuration-options
const initOptions = {}
const firebase = RNFirebase.initializeApp(initOptions);
export default firebase;
@krizzu
krizzu / App.js
Created October 2, 2017 07:52
Example for simple authentication using RNFirebase
// ...
// Inside our Component's class
_authenticateUser = async () => {
const { firebase } = this.props; // Parent passes reference to Firebase through props
const { userPassword, userEmail } = this.state;
let userInfo = null;
try {
userInfo = await firebase.auth().signInWithEmailAndPassword(userEmail, userPassword)
@krizzu
krizzu / AuthHoc.js
Created October 2, 2017 08:02
Example of HoC that check if user is authorised
import React, { Component } from 'react';
import firebase from './firebase'
// Child is our Wrapped component
export default (Child) => (
class AuthHoC extends Component {
state = {
isAuthenticated: false
}