Skip to content

Instantly share code, notes, and snippets.

View renso3x's full-sized avatar
🎯
Focusing

Renso3x renso3x

🎯
Focusing
View GitHub Profile
@renso3x
renso3x / rn-compose-login.js
Created August 2, 2017 13:17
Recompose RN login form
import React from 'react';
import PropTypes from 'prop-types';
import {
compose,
withHandlers,
withState,
setStatic,
setPropTypes
} from 'recompose';
import { View } from 'react-native';
@renso3x
renso3x / location.js
Created August 8, 2017 05:28
Flatten a nested object and sort by alphabetical order.
const obj = [
{
city: "Kampong Thom",
suburbs: [
{
suburb: "Stueng Saen",
suburbs: [
"Achar Leak",
"Damrei Choan Khla",
"Kampong Krabau",
import React, { PropTypes } from 'react';
import { View, Platform } from 'react-native';
import { Surface, Shape, Path, Group } from '../../react-native/Libraries/ART/ReactNativeART';
import MetricsPath from 'art/metrics/path';
export default class CircularProgress extends React.Component {
circlePath(cx, cy, r, startDegree, endDegree) {
let p = Path();
@renso3x
renso3x / Play.js
Last active September 21, 2017 06:57
import moment from 'moment';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import {
View,
Text,
StyleSheet,
Image,
ImageBackground
} from 'react-native';
@renso3x
renso3x / validate.test.js
Created September 15, 2017 02:16
ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. eg: validatePIN("1234") === true validatePIN("12345") === false validatePIN("a234") === false
function validatePIN (pin) {
const checkLength = pin.length === 4 || pin.length === 6;
const numMatch = /^[0-9]/g
if (checkLength && pin.match(numMatch)){
return true;
}
return false;
@renso3x
renso3x / Picker
Created September 18, 2017 13:10
import React from 'react';
import { View, Platform, PickerIOS, Text } from 'react-native';
import PickerAndroid from 'react-native-picker-android';
import styles from './styles/LanguagePickerStyles';
let PickerList = Platform.OS === 'ios' ? PickerIOS : PickerAndroid;
let PickerItem = PickerList.Item;
const LANGUAGES = [
{ name: 'Chinese(Mandarin)', key: 'cn' },
@renso3x
renso3x / CircularPr
Created September 21, 2017 05:23
Stroke Cap is not centered.
import React from 'react';
import PropTypes from 'prop-types';
import { View, ART } from 'react-native';
const { Surface, Shape, Path, Group } = ART;
export default class CircularProgress extends React.Component {
circlePath(cx, cy, r, startDegree, endDegree) {
let p = Path();
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
PixelRatio,
TouchableOpacity,
Image,
Alert,
import React,{ Component } from 'react';
import { PanResponder, View, Platform } from 'react-native';
import Svg,{ Path, Circle, G,Text } from 'react-native-svg';
class CircularSlider extends Component {
constructor(props){
super(props);
this.handlePanResponderMove = this.handlePanResponderMove.bind(this);
this.cartesianToPolar = this.cartesianToPolar.bind(this);
this.polarToCartesian = this.polarToCartesian.bind(this);
import React from 'react';
import { Animated } from 'react-native';
import CircularProgress from './CircularProgress';
const AnimatedProgress = Animated.createAnimatedComponent(CircularProgress);
class AnimatedCircularProgress extends React.Component {
constructor() {
super();
this._animatedValue = new Animated.Value(0);