Skip to content

Instantly share code, notes, and snippets.

View dantman's full-sized avatar

Daniel Friesen dantman

View GitHub Profile
@dantman
dantman / NavigationHeader.js
Created February 28, 2018 22:38
Overriding the left header button in a custom header
'use strict';
import React, {PureComponent} from 'react';
import {Header} from 'react-navigation';
export default class NavigationHeader extends PureComponent {
getScreenDetails = (screen, ...args) => {
const screenDetails = this.props.getScreenDetails(screen, ...args);
const {navigate, goBack} = screenDetails.navigation;
return {
@dantman
dantman / keybase.md
Created November 8, 2017 18:30
keybase.md

Keybase proof

I hereby claim:

  • I am dantman on github.
  • I am dantman (https://keybase.io/dantman) on keybase.
  • I have a public key ASC7jATCYRenYm-biehrUI-OGVElMbPiszWhH5-jXsJ6jQo

To claim this, I am signing this object:

@dantman
dantman / LoginButton.js
Created October 2, 2017 21:14
Custom MaterialDesign inspired login button used in one app
@Styles({
root: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
borderRadius: 2,
height: 48,
},
enabled: {
backgroundColor: colors.grey600,
@dantman
dantman / PersistentStore.cs
Last active September 26, 2017 14:56
VRUB Exposed classes/modules API idea
using VRUB;
[ExposedClass]
class PersistentStore : ExposedClass { // base class could use a different name
Dictionary<string, string> _temporaryStore = new Dictionary<string, string>();
Dictionary<string, string> _persistentStore = new Dictionary<string, string>();
[ExposedMethod]
public string Get(string key, bool temporary = false) {
render() {
const {styles, onLogout} = this;
const {onOverlayStateChanged} = this;
const {materialTheme, sections: rawSections, navigation, screenProps: {statusBarHeight}, user, activeCompany, company, teams} = this.props;
const {overlayOpen} = this.state;
const sections = navigation.state.routes::groupBy((route) => this._getScreenOptions(route.key).drawerSection);
const {companyList=[]} = user || {};
const children = [];
let first = true;
@dantman
dantman / example.js
Created April 25, 2017 17:36
react-navigation statusbar height example
export default class App extends PureComponent {
state = {
statusBarHeight: Platform.OS === 'android'
? StatusBar.currentHeight || (Platform.Version < 23 ? 25 : 24)
: 0,
};
render() {
const {styles} = this;
@dantman
dantman / RNMDLK-merge-plan.md
Last active July 10, 2017 14:57
React Native Material Design/Kit merge plan

React Native Material Design/Kit merge plan

Take components from react-native-material-design and react-native-material-kit and create a new library to replace both.

Ripple

Deciding how to handle ripples will be very important as both do it differently.

rnmd does it using a Ripple polyfill:

  • Pro: The native touchable feedback is used where available.
@dantman
dantman / Styles-example.js
Last active March 23, 2018 07:04
React Native `@Styles` decorator
import React, {PureComponent} from 'react';
import {View} from 'react-native';
import Styles from './Styles';
@Styles({
root: {
// ...
},
})
export default class Example extends PureComponent {
@dantman
dantman / react-native-sqlite-storage.js
Created December 20, 2016 02:06
ReactNativeSqliteStorage driver for knex.js
'use strict';
import Promise from 'bluebird';
import { map, clone } from 'lodash';
import Client_SQLite3 from 'knex/lib/dialects/sqlite3';
export default class Client_ReactNativeSqliteStorage extends Client_SQLite3 {
dialect: 'sqlite';
driverName = 'react-native-sqlite-storage';
_driver() {
@dantman
dantman / gist.css
Last active April 17, 2018 22:07
Material Design sp units (px unit that scale to the user's font settings) using rems
html {
font-size: 14px;
}
/**
* PostCSS
* Use a custom PostCSS to convert #sp to rems by dividing the number by 14 and expressing it as #rem
*/
body {