Skip to content

Instantly share code, notes, and snippets.

View mehulgecg's full-sized avatar

Mehul Mistri mehulgecg

View GitHub Profile
@mehulgecg
mehulgecg / CustomDisclosureIndicator
Created May 10, 2018 12:15
Custom Disclosure Indicator
import UIKit
class CustomDisclosureIndicator: UIView {
@IBInspectable
public var color: UIColor = UIColor.darkGray {
didSet {
setNeedsDisplay()
}
}
@mehulgecg
mehulgecg / DetailScreen.js
Created April 17, 2018 07:14
Detail Screen
import React, {Component} from 'react';
import {
Text,
View,
StyleSheet
} from 'react-native';
class DetailScreen extends Component {
render () {
return (
@mehulgecg
mehulgecg / MainScreen.js
Created April 17, 2018 07:13
Main Screen
import React, {Component} from 'react';
import {
Text,
View,
StyleSheet,
Button
} from 'react-native';
class MainScreen extends Component {
render () {
@mehulgecg
mehulgecg / stackNav.js
Last active April 17, 2018 07:11
Stack Navigator
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View, TouchableOpacity
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import IOSIcon from "react-native-vector-icons/Ionicons";
@mehulgecg
mehulgecg / SideMenu.style.js
Created April 17, 2018 07:02
Side Menu Style
export default {
container: {
paddingTop: 20,
flex: 1
},
navItemStyle: {
padding: 10
},
navSectionStyle: {
backgroundColor: 'lightgrey'
@mehulgecg
mehulgecg / SideMenu.js
Last active April 17, 2018 07:00
Custom Side Menu
import PropTypes from 'prop-types';
import React, {Component} from 'react';
import styles from './SideMenu.style';
import {NavigationActions} from 'react-navigation';
import {ScrollView, Text, View} from 'react-native';
import { StackNavigator } from 'react-navigation';
class SideMenu extends Component {
navigateToScreen = (route) => () => {
const navigateAction = NavigationActions.navigate({
@mehulgecg
mehulgecg / index.js
Last active July 3, 2019 10:44
React Native Drawer Navigator
import React, { Component } from 'react';
import { AppRegistry, Dimensions } from 'react-native';
import { DrawerNavigator } from 'react-navigation';
import SideMenu from './SideMenu/SideMenu'
import stackNav from './app/stacknav';
const drawernav = DrawerNavigator({
Item1: {
screen: stackNav,
@mehulgecg
mehulgecg / makeAnimatedGif.m
Created September 26, 2015 10:59 — forked from mayoff/makeAnimatedGif.m
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {