Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanshar committed Feb 3, 2020
2 parents be42c44 + a6f0546 commit 7a584cb
Show file tree
Hide file tree
Showing 47 changed files with 786 additions and 317 deletions.
7 changes: 7 additions & 0 deletions demo.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
require('./demo/src/index');
require('./demo/src/demoApp'); // this is separated from demo/src/index by purpose

// comment out when measuring performance
// if (process.env.NODE_ENV !== 'production') {
// const whyDidYouRender = require('@welldone-software/why-did-you-render');
// const React = require('react');
// whyDidYouRender(React);
// }
1 change: 1 addition & 0 deletions demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ I18nManager.allowRTL(true);

module.exports = {
name: 'unicorn demo app',
ExampleScreenPresenter: require('./screens/ExampleScreenPresenter')
};
72 changes: 72 additions & 0 deletions demo/src/screens/ExampleScreenPresenter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import {View, Text, Checkbox, RadioGroup, RadioButton, ColorPalette, Colors, Slider} from 'react-native-ui-lib';
import _ from 'lodash';

export function renderBooleanOption(title, key) {
const value = this.state[key];
return (
<View row centerV spread marginB-s4>
<Text text70M style={{flex: 1}}>
{title}
</Text>
<Checkbox useCustomTheme textID={key} value={value} onValueChange={value => this.setState({[key]: value})}/>
</View>
);
}

export function renderRadioGroup(title, key, options) {
const value = this.state[key];
return (
<View marginB-s2>
<Text text70M marginB-s2>
{title}
</Text>
<RadioGroup initialValue={value} onValueChange={value => this.setState({[key]: value})}>
{_.map(options, (value, key) => {
return <RadioButton useCustomTheme testID={key} key={key} marginB-s2 label={value} value={options[key]}/>;
})}
</RadioGroup>
</View>
);
}

export function renderColorOption(title,
key,
colors = ['transparent', Colors.blue30, Colors.grey10, Colors.yellow30, Colors.green30, Colors.purple30]) {
const value = this.state[key];
return (
<View marginV-s2>
<Text text70M>{title}</Text>
<ColorPalette
value={value}
colors={colors}
onValueChange={value => this.setState({[key]: value === 'transparent' ? undefined : value})}
/>
</View>
);
}

export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, initial = 0}) {
const value = this.state[key];
return (
<View marginV-s2>
<Text marginB-s1 text70M>
{title}
</Text>
<View row centerV>
<Slider
testID={key}
value={initial}
containerStyle={{flex: 1}}
minimumValue={min}
maximumValue={max}
step={step}
onValueChange={value => this.setState({[key]: value})}
/>
<Text marginL-s4 text70>
text{value}
</Text>
</View>
</View>
);
}
4 changes: 3 additions & 1 deletion demo/src/screens/MenuStructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const navigationData = {
{title: 'Floating Button', tags: 'floating button', screen: 'unicorn.components.FloatingButtonScreen'},
{title: 'Feature Highlight', tags: 'feature overlay', screen: 'unicorn.components.FeatureHighlightScreen'},
{title: 'Hint', tags: 'hints tooltip', screen: 'unicorn.components.HintsScreen'},
{title: 'Image', tags: 'image cover overlay', screen: 'unicorn.components.ImageScreen'},
{title: 'Overlays', tags: 'overlay image', screen: 'unicorn.components.OverlaysScreen'},
{title: 'Page Control', tags: 'page', screen: 'unicorn.components.PageControlScreen'},
{title: 'Pan Dismissible', tags: 'pan swipe drag dismiss', screen: 'unicorn.components.PanDismissibleScreen'},
Expand All @@ -41,6 +42,7 @@ export const navigationData = {
{title: 'Shared Transition', tags: 'shared transition element', screen: 'unicorn.components.SharedTransitionScreen'},
{title: 'Stack Aggregator', tags: 'stack aggregator', screen: 'unicorn.components.StackAggregatorScreen'},
{title: 'TabBar', tags: 'tab bar', screen: 'unicorn.components.TabBarScreen'},
{title: 'Text', tags: 'text', screen: 'unicorn.components.TextScreen'},
{title: 'Toast', tags: 'toast top bottom snackbar', screen: 'unicorn.components.ToastsScreen'},
{title: 'Wheel Picker Dialog', tags: 'wheel picker dialog', screen: 'unicorn.components.WheelPickerDialogScreen'},
{title: 'Wizard', tags: 'wizard', screen: 'unicorn.components.WizardScreen'}
Expand Down Expand Up @@ -104,7 +106,7 @@ export const navigationData = {
Incubator: {
title: 'Incubator',
screens: [
{title: 'TabBarController', tags: 'tabbar controller native', screen: 'unicorn.incubator.TabControllerScreen'},
{title: 'TabController', tags: 'tabbar controller native', screen: 'unicorn.incubator.TabControllerScreen'},
{title: 'Native TouchableOpacity', tags: 'touchable native', screen: 'unicorn.incubator.TouchableOpacityScreen'}
]
},
Expand Down
12 changes: 4 additions & 8 deletions demo/src/screens/animationScreens/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {Navigation} from 'react-native-navigation';
import CardScannerScreen from './CardScannerScreen';
import ProgressBarScreen from './ProgressBarScreen';
import CardAnimationsScreen from './CardAnimationsScreen';
import ListAnimationsScreen from './ListAnimationsScreen';

Navigation.registerComponent('unicorn.animations.CardScannerScreen', () => CardScannerScreen);
Navigation.registerComponent('unicorn.animations.CardAnimationsScreen', () => CardAnimationsScreen);
Navigation.registerComponent('unicorn.animations.ListAnimationsScreen', () => ListAnimationsScreen);
Navigation.registerComponent('unicorn.animations.ProgressBarScreen', () => ProgressBarScreen);
Navigation.registerComponent('unicorn.animations.CardScannerScreen', () => require('./CardScannerScreen').default);
Navigation.registerComponent('unicorn.animations.CardAnimationsScreen', () => require('./CardAnimationsScreen').default);
Navigation.registerComponent('unicorn.animations.ListAnimationsScreen', () => require('./ListAnimationsScreen').default);
Navigation.registerComponent('unicorn.animations.ProgressBarScreen', () => require('./ProgressBarScreen').default);
9 changes: 3 additions & 6 deletions demo/src/screens/componentScreenScreens/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {Navigation} from 'react-native-navigation';
import EmptyStateScreen from './EmptyStateScreen';
import LoadingScreen from './LoadingScreen';
import ModalScreen from './ModalScreen';

Navigation.registerComponent('unicorn.screens.EmptyStateScreen', () => EmptyStateScreen);
Navigation.registerComponent('unicorn.screens.LoadingScreen', () => LoadingScreen);
Navigation.registerComponent('unicorn.screens.ModalScreen', () => ModalScreen);
Navigation.registerComponent('unicorn.screens.EmptyStateScreen', () => require('./EmptyStateScreen').default);
Navigation.registerComponent('unicorn.screens.LoadingScreen', () => require('./LoadingScreen').default);
Navigation.registerComponent('unicorn.screens.ModalScreen', () => require('./ModalScreen').default);
4 changes: 2 additions & 2 deletions demo/src/screens/componentScreens/DateTimePickerScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export default class DateTimePickerScreen extends Component {
<DateTimePicker
title={'Date'}
placeholder={'Select a date'}
dateFormat={'MMM D, YYYY'}
// dateFormat={'MMM D, YYYY'}
// value={new Date('October 13, 2014')}
/>
<DateTimePicker
mode={'time'}
title={'Time'}
placeholder={'Select time'}
timeFormat={'h:mm A'}
// timeFormat={'h:mm A'}
// value={new Date('2015-03-25T12:00:00-06:30')}
/>
</View>
Expand Down
71 changes: 71 additions & 0 deletions demo/src/screens/componentScreens/ImageScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React, {Component} from 'react';
import {View, Text, Image, Colors} from 'react-native-ui-lib';
import {renderBooleanOption, renderRadioGroup} from '../ExampleScreenPresenter';

import cameraIcon from '../../assets/icons/cameraSelected.png';

const IMAGE_URL =
'https://images.pexels.com/photos/748837/pexels-photo-748837.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260';

const DEFAULT_SIZE = 100;
class ImageScreen extends Component {
state = {
cover: true,
showOverlayContent: false,
overlayType: 'none'
};

renderOverlayContent() {
const {cover, overlayType, showOverlayContent} = this.state;
if (showOverlayContent) {
if (cover) {
return (
<View padding-20 flex bottom={overlayType === Image.overlayTypes.BOTTOM}>
<View row centerV>
<Image
style={{margin: 5, marginRight: 10}}
source={cameraIcon}
tintColor={overlayType !== 'none' ? Colors.white : undefined}
/>
<Text text30 white={overlayType !== 'none'}>
Overlay Content
</Text>
</View>
</View>
);
} else {
return <Image style={{margin: 5}} source={cameraIcon}/>;
}
}
}
render() {
const {cover, overlayType} = this.state;

return (
<View flex>
<View centerH height={250}>
<Image
source={{uri: IMAGE_URL}}
cover={cover}
overlayType={overlayType !== 'none' ? overlayType : undefined}
style={!cover && {width: DEFAULT_SIZE, height: DEFAULT_SIZE}}
customOverlayContent={this.renderOverlayContent()}
/>
</View>
<View height={2} bg-grey60/>
<View useSafeArea flex>
<View padding-20 bottom flex>
<View flex>
{renderBooleanOption.call(this, 'Show as Cover Image', 'cover')}
{renderBooleanOption.call(this, 'Show Overlay Content', 'showOverlayContent')}
{renderRadioGroup.call(this, 'Overlay Type', 'overlayType', {none: 'none', ...Image.overlayTypes})}
</View>
<Text text40>Image Screen</Text>
</View>
</View>
</View>
);
}
}

export default ImageScreen;
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/OverlaysScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class OverlaysScreen extends Component {
return (
<View centerH>
<Text dark10>{text}</Text>
<Image style={styles.image} source={image} overlayType={type} customOverlayContent={customOverylay}/>
<Image /* overlayColor={Colors.rgba(Colors.red40, 0.4)} */ style={styles.image} source={image} overlayType={type} customOverlayContent={customOverylay}/>
</View>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import React, {Component} from 'react';
import {ScrollView} from 'react-native';
import {Colors, View, Text, TextField, Slider, ColorPalette} from 'react-native-ui-lib'; //eslint-disable-line
import {Navigation} from 'react-native-navigation';

import {
renderBooleanOption,
renderRadioGroup,
renderSliderOption,
renderColorOption
} from '../../ExampleScreenPresenter';

const ERROR_STATES = {
noError: 'No Error',
bottomError: 'Bottom Error',
topError: 'Top Error'
};

const GUIDING_TEXTS = {
none: 'None',
useTitle: 'Title',
floatingPlaceholder: 'Floating Placeholder'
};

export default class BasicTextFieldScreen extends Component {
constructor(props) {
super(props);

this.state = {
hideUnderline: false,
underlineColor: undefined,
guidingText: GUIDING_TEXTS.none,
disabled: false,
centered: false,
useHelperText: false,
titleColor: undefined,
error: ERROR_STATES.noError,
multiline: false,
typography: 70,
charCount: 0
};
}

render() {
const {
hideUnderline,
underlineColor,
guidingText,
titleColor,
disabled,
centered,
useHelperText,
multiline,
charCount,
typography,
error
} = this.state;

return (
<View flex>
<View padding-20>
<Text marginB-20 text40>
TextField
</Text>
<TextField
key={centered ? 'centered' : 'not-centered'}
{...{[`text${typography}`]: true}}
placeholder={disabled ? 'Disabled' : 'Placeholder'}
hideUnderline={hideUnderline}
underlineColor={underlineColor}
title={guidingText === GUIDING_TEXTS.useTitle ? 'Title' : undefined}
titleColor={titleColor}
floatingPlaceholder={guidingText === GUIDING_TEXTS.floatingPlaceholder}
helperText={useHelperText ? 'Helper Text' : undefined}
editable={!disabled}
centered={centered}
multiline={multiline}
maxLength={charCount > 0 ? charCount : undefined}
showCharacterCounter={charCount > 0}
error={error !== ERROR_STATES.noError ? 'Custom error message' : undefined}
useTopErrors={error === ERROR_STATES.topError}
/>
</View>
<View paddingT-s1 bg-grey50/>
<ScrollView keyboardShouldPersistTaps="always">
<View padding-20>
<Text text50M marginB-s4>
Options
</Text>
{renderSliderOption.call(this, 'Typography (modifier)', 'typography', {
min: 30,
max: 100,
step: 10,
initial: 70
})}
{renderBooleanOption.call(this, 'Multiline', 'multiline')}
{renderBooleanOption.call(this, 'Disabled', 'disabled')}
{renderBooleanOption.call(this, 'Centered', 'centered')}
{renderBooleanOption.call(this, 'Hide Underline', 'hideUnderline')}
{renderColorOption.call(this, 'Underline Color', 'underlineColor')}
{renderRadioGroup.call(this, 'Guiding Text', 'guidingText', GUIDING_TEXTS)}
{renderColorOption.call(this, 'Title Color', 'titleColor')}
{renderSliderOption.call(this, 'Character Counter', 'charCount', {min: 0, max: 150, step: 3})}
{renderRadioGroup.call(this, 'Errors', 'error', ERROR_STATES)}
</View>
</ScrollView>
</View>
);
}
}

Navigation.registerComponent('unicorn.components.BasicTextFieldScreen', () => BasicTextFieldScreen);
8 changes: 5 additions & 3 deletions demo/src/screens/componentScreens/TextFieldScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import React, {Component} from 'react';
import {Colors, TouchableOpacity, Typography, View, Text} from 'react-native-ui-lib'; //eslint-disable-line
import {pushScreen} from '../../../navigation';

import './InputsScreen';
import './BasicTextFieldScreen';
import './InputValidationsScreen';
import './CustomInputsScreen';
import './InputsScreen';

const SCREENS = [
{title: 'Inputs', name: 'unicorn.components.InputsScreen'},
{title: 'TextField Kitchen-Sink', name: 'unicorn.components.BasicTextFieldScreen'},
{title: 'Custom Inputs', name: 'unicorn.components.CustomInputsScreen'},
{title: 'Validations', name: 'unicorn.components.InputValidationsScreen'}
{title: 'Validations', name: 'unicorn.components.InputValidationsScreen'},
{title: 'Inputs Variations', name: 'unicorn.components.InputsScreen'}
];

class TextFieldScreen extends Component {
Expand Down
Loading

0 comments on commit 7a584cb

Please sign in to comment.