Skip to content

Instantly share code, notes, and snippets.

View m4har's full-sized avatar
💭
i like food

Mahardika m4har

💭
i like food
View GitHub Profile
@m4har
m4har / index.js
Last active May 15, 2019 14:39
component button
// src/components/Button/index.js
import React from "react";
import { TouchableOpacity, Text } from "react-native";
const Button = ({ onPress, style, title, ...props }) => (
<TouchableOpacity
{...props}
onPress={onPress}
style={[styles.container, style]}
>
@m4har
m4har / index.js
Created May 15, 2019 14:45
component formInput
// src/components/FormInput/index.js
import React from "react";
import { TextInput, View } from "react-native";
const FormInput = ({ secureTextEntry, ...props }) => (
<View style={styles.container}>
<TextInput
style={styles.textInput}
secureTextEntry={secureTextEntry}
@m4har
m4har / index.js
Created May 15, 2019 14:47
component Gradient View
// src/components/Gradient/index.js
// contoh disini dengan gambar
import React from "react";
import { ImageBackground, StatusBar } from "react-native";
const Gradient = ({ children, style }) => (
<ImageBackground
source={require("../../assets/img/bg.png")}
style={style}
@m4har
m4har / index.js
Last active May 15, 2019 14:56
component Modal / Popup
// src/components/Modal/index.js
import React from "react";
import { Modal, View } from "react-native";
const ModalView = ({ visible, onDismiss, children, onRequestClose }) => (
<Modal
visible={visible}
onDismiss={onDismiss}
transparent
@m4har
m4har / index.js
Created May 15, 2019 14:57
component Loading Indicator
// src/components/Loading/index.js
import React from "react";
import { ActivityIndicator, Platform } from "react-native";
import Modal from "../Modal";
const Loading = ({ onDismiss, visible, onRequestClose }) => (
<Modal
visible={visible}
@m4har
m4har / index.js
Created May 15, 2019 15:16
views Login
// src/views/Login/index.js
import React, { PureComponent } from "react";
import { View } from "react-native";
// component
import Gradient from "../../components/Gradient";
import FormInput from "../../components/FormInput";
import Button from "../../components/Button";
import Loading from "../../components/Loading";
@m4har
m4har / App.js
Created May 15, 2019 15:19
App.js
// App.js
import React from "react";
import Login from "./src/views/Login";
const LoginScreen = () => <Login />;
export default LoginScreen;
@m4har
m4har / LazyView.js
Last active August 6, 2019 02:25
kalo banyak component view di rn, pasti navigasinya agak lama
import React, { PureComponent } from 'react'
import { View, ViewPropTypes, Animated } from 'react-native'
import { withNavigationFocus } from 'react-navigation'
// import PropTypes from 'prop-types';
class LazyView extends PureComponent {
state = {
show: false,
refresh: false
};
@m4har
m4har / Pin.js
Created August 1, 2019 10:44
pin ajaib
import React, { PureComponent } from 'react'
import { Text, View, FlatList, TouchableOpacity } from 'react-native'
const Button = [
{ name: '1', icon: '' },
{ name: '2', icon: '' },
{ name: '3', icon: '' },
{ name: '4', icon: '' },
{ name: '5', icon: '' },
{ name: '6', icon: '' },
@m4har
m4har / test.json
Last active January 22, 2020 11:03
test
{
"id":555,
"name":"Kucing Ganteng",
"role":"admin",
"profile":"https://www.rd.com/wp-content/uploads/2017/09/01-shutterstock_476340928-Irina-Bg-1024x683.jpg"
}