Skip to content

Commit

Permalink
Adding spinner / loader
Browse files Browse the repository at this point in the history
  • Loading branch information
corymsmith committed Aug 4, 2015
1 parent f1025e2 commit c5559f6
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 34 deletions.
82 changes: 48 additions & 34 deletions Example/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@ var {
StyleSheet,
Text,
View,
ScrollView
} = React;
ScrollView,
//Animated
} = React;


var BrandColors = {
Facebook: '#3b5998',
Twitter: '#55acee'
};

var { Icon, TabBarIOS, } = require('react-native-icons');
var { Icon, TabBarIOS, Spinner} = require('react-native-icons');
var TabBarItemIOS = TabBarIOS.Item;

var Example = React.createClass({
getInitialState: function() {
getInitialState: function () {
return {
selectedTab: 'home',
notifCount: 0,
presses: 0,
//rotation: Animated.Value(0)
};
},
render: function () {
Expand All @@ -52,41 +54,41 @@ var Example = React.createClass({
{this._renderContent()}
</TabBarItemIOS>
<TabBarItemIOS
name="articles"
iconName={'ion|ios-paper-outline'}
title={''}
iconSize={32}
accessibilityLabel="Articles Tab"
selected={this.state.selectedTab === 'articles'}
onPress={() => {
name="articles"
iconName={'ion|ios-paper-outline'}
title={''}
iconSize={32}
accessibilityLabel="Articles Tab"
selected={this.state.selectedTab === 'articles'}
onPress={() => {
this.setState({
selectedTab: 'articles',
});
}}>
{this._renderContent()}
</TabBarItemIOS>
<TabBarItemIOS
name="messages"
iconName={'ion|chatboxes'}
title={''}
iconSize={32}
accessibilityLabel="Messages Tab"
selected={this.state.selectedTab === 'messages'}
onPress={() => {
name="messages"
iconName={'ion|chatboxes'}
title={''}
iconSize={32}
accessibilityLabel="Messages Tab"
selected={this.state.selectedTab === 'messages'}
onPress={() => {
this.setState({
selectedTab: 'messages',
});
}}>
{this._renderContent()}
</TabBarItemIOS>
<TabBarItemIOS
name="settings"
iconName={'ion|ios-gear'}
title={''}
iconSize={32}
accessibilityLabel="Settings Tab"
selected={this.state.selectedTab === 'settings'}
onPress={() => {
name="settings"
iconName={'ion|ios-gear'}
title={''}
iconSize={32}
accessibilityLabel="Settings Tab"
selected={this.state.selectedTab === 'settings'}
onPress={() => {
this.setState({
selectedTab: 'settings',
});
Expand All @@ -105,19 +107,19 @@ var Example = React.createClass({
size={40}
color='#887700'
style={styles.beer}
/>
/>
<Icon
name='zocial|github'
name='material|face'
size={40}
color='black'
style={styles.github}
/>
/>
<Icon
name='fontawesome|facebook-square'
size={40}
color={BrandColors.Facebook}
style={styles.facebook}
/>
/>
<Icon
name='foundation|lightbulb'
size={40}
Expand All @@ -128,11 +130,22 @@ var Example = React.createClass({
{'Material Icons'}
</Text>

<Icon name='material|face' size={90} style={{width:90, height: 90}} color='gray' />
<View style={styles.topContainer}>

<Spinner name='fontawesome|spinner' size={24} style={{width: 24, height: 24, backgroundColor: 'transparent'}}
color='#777'/>
<Spinner name='ion|load-a' size={24} style={{width: 24, height: 24, backgroundColor: 'transparent'}}
color='#777'/>
<Spinner name='ion|load-b' size={24} style={{width: 24, height: 24, backgroundColor: 'transparent'}}
color='#777'/>
<Spinner name='ion|load-c' size={24} style={{width: 24, height: 24, backgroundColor: 'transparent'}}
color='#777'/>
<Spinner name='ion|load-d' size={24} style={{width: 24, height: 24, backgroundColor: 'transparent'}}
color='#777'/>
</View>

<Text style={styles.header}>
{'Stacked Icons!'}
{'Stacked Icons!'}
</Text>
<Icon
name='fontawesome|square'
Expand All @@ -143,11 +156,11 @@ var Example = React.createClass({
name='fontawesome|twitter'
size={40}
color='#ffffff'
style={[styles.twitterIcon, {backgroundColor: 'transparent'}]} />
style={[styles.twitterIcon, {backgroundColor: 'transparent'}]}/>
</Icon>

<Text style={styles.header}>
{'Create social sign in buttons'}
{'Create social sign in buttons'}
</Text>
<View
style={styles.signInWithTwitterButton}>
Expand Down Expand Up @@ -178,8 +191,9 @@ var Example = React.createClass({
}
});


var styles = StyleSheet.create({
tabBar : {
tabBar: {
backgroundColor: '#dfdfdf',
flex: 1,
color: '#ff0000',
Expand Down
124 changes: 124 additions & 0 deletions SMXLoadingImage.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/**
*
* @providesModule SMXLoadingImage
* @flow
*/
'use strict';

var React = require('react-native');
var { StyleSheet, View, requireNativeComponent, Animated, Easing } = React;

var merge = require('merge');

var shimAssert = require('./shim-assert');

var ICON_REF = 'icon';

var TIMES = 400;

var SMXLoadingImage = React.createClass({
propTypes: {
name: React.PropTypes.string,
size: React.PropTypes.number,
color: React.PropTypes.string,

/**
* accessible - Whether this element should be revealed as an accessible
* element.
*/
accessible: React.PropTypes.bool,
/**
* accessibilityLabel - Custom string to display for accessibility.
*/
accessibilityLabel: React.PropTypes.string,

/**
* testID - A unique identifier for this element to be used in UI Automation
* testing scripts.
*/
testID: React.PropTypes.string,
icon: React.PropTypes.object
},

getInitialState: function () {
return {
theta: new Animated.Value(45),
rotate: new Animated.Value('0deg'),
enter: new Animated.Value(0),
angle: new Animated.Value(0)
};
},

setNativeProps(props) {
console.warn('setNativeProps');
console.warn(props);
this.refs[ICON_REF].setNativeProps(props);
},

_animate: function () {
this.state.angle.setValue(0);
this._anim = Animated.timing(this.state.angle, {
toValue: 360 * TIMES,
duration: 1200 * TIMES,
easing: Easing.linear
}).start(this._animate);
},

componentDidMount: function () {
this._animate();
},

_animateEntrance: function () {
Animated.spring(
this.state.enter,
{toValue: 1, friction: 8}
).start();
},

render: function () {
var transformStyle = {
transform: [
{
rotate: this.state.angle.interpolate({
inputRange: [0, 360],
outputRange: ['0deg', '360deg']
})
}
]
};

var style = [styles.base, this.props.style];
console.log(style);

shimAssert.basic(style, 'style must be initialized');

var name = this.props.name;
shimAssert.basic(name, 'name must be initialized');

var size = this.props.size;
shimAssert.basic(size, 'size must be initialized');

var color = this.props.color;

var nativeProps = merge(this.props, {
icon: {
name: name,
size: size,
color: color
}
});
return <Animated.View style={[styles.base, style, transformStyle]}>
<SMXLoadingImageView style={{backgroundColor: 'transparent'}} {...nativeProps} />
</Animated.View>;
}
});


var styles = StyleSheet.create({
base: {
overflow: 'hidden'
}
});
var SMXLoadingImageView = requireNativeComponent('FAKIconImage', SMXLoadingImage);

module.exports = SMXLoadingImage;
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
Icon: require('./SMXIconImage.ios'),
TabBarIOS: require('./SMXTabBarIOS.ios'),
Spinner: require('./SMXLoadingImage.ios')
};

0 comments on commit c5559f6

Please sign in to comment.