Skip to content

Instantly share code, notes, and snippets.

View streetsmartdev's full-sized avatar

streetsmartdev

View GitHub Profile
@streetsmartdev
streetsmartdev / RN-RNav-7-DrawerNavigator.js
Created September 3, 2017 08:01
RN-RNav- 7 - Implementing DrawerNavigator for Android
import React from "react";
import {Text, TouchableOpacity} from "react-native";
import {DrawerNavigator} from "react-navigation";
import HomeScreen from "./Home";
import AboutScreen from "./About";
import {Ionicons} from '@expo/vector-icons';
const Internal = DrawerNavigator(
{
Home: {screen: HomeScreen},
@streetsmartdev
streetsmartdev / RN-RNav-8-NavigationHelper.js
Created September 3, 2017 08:16
RN-RNav- 8 - Implement navigationOptions and call them in individual screens
// NavigationHelper.js -----------------------------------------------
import React from "react";
import {Platform} from "react-native";
import {Ionicons} from '@expo/vector-icons';
export const getNavigationOption = (title, icon) => ({
title,
...Platform.select({
ios: {
tabBarIcon: ({tintColor}) => (
...
import {NavigationActions} from "react-navigation";
class LoginScreen extends React.Component {
render() {
const reset = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: "Internal" })]
});
return (
@streetsmartdev
streetsmartdev / RN-RNav-10-RootNavigatorUpdate.js
Created September 3, 2017 08:20
RN-RNav - 10 - Updating RootNavigator
import React from "react";
import {StackNavigator} from "react-navigation";
import LoginScreen from "./external/Login";
import Internal from "./internal";
export default StackNavigator(
{
External: {screen: LoginScreen},
Internal: {screen: Internal}
},
import React, { Component } from "react";
import { Text } from "react-native";
import { Card } from "react-native-elements";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
data: data
};
import React, { Component } from "react";
import { FlatList, Text } from "react-native";
import { Card } from "react-native-elements";
const data = [
{
imageUrl: "http://via.placeholder.com/160x160",
title: "something"
},
{
import React, { Component } from "react";
import { FlatList, Text } from "react-native";
import { Card } from "react-native-elements";
const data = [
{
imageUrl: "http://via.placeholder.com/160x160",
title: "something"
},
{
val client = OkHttpClient()
val okRequest = Request.Builder()
.url("https://httpbin.org/get")
.build()
val responseResource: Response = client.newCall(okRequest).execute()
return responseResource.use {
responseResource.body?.string()!!
fun main(args: Array<String>) {
val apiResult = runBlocking(Dispatchers.Default) {
val asyncResult = async { callApi() }
asyncResult.await()
}
println(apiResult)
}
fun callApi(): String {
fun main(args: Array<String>) {
val methodTime = measureTimeMillis {
val apiResult = runBlocking(Dispatchers.Default) {
val asyncResult = async { callApi() }
asyncResult.await()
}
println(apiResult)
}
println("Time: ${methodTime}ms")