-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from just4fun/v1.6.0
v1.6.0
- Loading branch information
Showing
44 changed files
with
907 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "stuhome", | ||
"version": "1.5.2", | ||
"version": "1.6.0", | ||
"description": "An iOS client for http://bbs.uestc.edu.cn/ written in React Native with Redux.", | ||
"author": "just4fun <[email protected]>", | ||
"scripts": { | ||
|
@@ -34,6 +34,7 @@ | |
"react-native-scrollable-tab-view": "0.8.0", | ||
"react-native-search-bar": "3.1.0", | ||
"react-native-smart-emoji-picker": "0.1.0", | ||
"react-native-smart-timer-enhance": "^1.0.3", | ||
"react-native-sticky-keyboard-accessory": "0.1.1", | ||
"react-native-vector-icons": "4.4.3", | ||
"react-navigation": "1.0.3", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createAction } from 'redux-actions'; | ||
|
||
export const REQUEST = Symbol(); | ||
export const INVALIDATE = Symbol(); | ||
export const fetchFriendList = createAction(REQUEST); | ||
export const invalidateFriendList = createAction(INVALIDATE); | ||
|
||
export const REQUEST_STARTED = Symbol(); | ||
export const REQUEST_COMPELTED = Symbol(); | ||
export const REQUEST_FAILED = Symbol(); | ||
export const request = createAction(REQUEST_STARTED); | ||
// return 2nd argument as `meta` field | ||
export const success = createAction(REQUEST_COMPELTED, null, (...args) => args[1]); | ||
export const failure = createAction(REQUEST_FAILED); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
import React, { | ||
Component, | ||
} from 'react' | ||
import { | ||
View, | ||
Modal, | ||
StyleSheet, | ||
Animated, | ||
Easing, | ||
Dimensions, | ||
ActivityIndicator, | ||
ActivityIndicatorIOS, | ||
ProgressBarAndroid, | ||
} from 'react-native' | ||
|
||
import TimerEnhance from 'react-native-smart-timer-enhance' | ||
|
||
const styles = StyleSheet.create({ | ||
overlay: { | ||
position: 'absolute', | ||
left: 0, | ||
top: 0, | ||
zIndex: 998, | ||
}, | ||
container: { | ||
backgroundColor: 'rgba(0, 0, 0, 0.8)', | ||
position: 'absolute', | ||
borderRadius: 8, | ||
padding: 20.5, | ||
left: -9999, | ||
top: -9999, | ||
zIndex: 999, | ||
}, | ||
}) | ||
const noop = () => {} | ||
|
||
class LoadingSpinnerOverlay extends Component { | ||
|
||
static defaultProps = { | ||
duration: 255, | ||
delay: 0, | ||
marginTop: 0, | ||
modal: true, | ||
} | ||
|
||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
visible: false, | ||
opacity: new Animated.Value(0), | ||
children: props.children, | ||
modal: props.modal, | ||
marginTop: props.marginTop, | ||
} | ||
this._loadingSpinnerWidth = null | ||
this._loadingSpinnerHeight = null | ||
this._loadingSpinnerShowAnimation = null | ||
this._loadingSpinnerHideAnimation = null | ||
this._loadingSpinnerAnimationToggle = null | ||
} | ||
|
||
render() { | ||
let loadingSpinner = this._renderLoadingSpinner() | ||
return this._renderOverLay(loadingSpinner) | ||
} | ||
|
||
_renderOverLay(loadingSpinner) { | ||
let {width: deviceWidth, height: deviceHeight,} = Dimensions.get('window') | ||
return ( | ||
this.state.modal ? | ||
(this.state.marginTop === 0 ? | ||
<Modal animationType={'none'} transparent={true} visible={this.state.visible} onRequestClose={noop}> | ||
{loadingSpinner} | ||
</Modal> : | ||
(this.state.visible ? | ||
<View | ||
style={[ styles.overlay, {marginTop: this.props.marginTop, width: deviceWidth, height: deviceHeight - this.props.marginTop,}, this.props.overlayStyle, ]}> | ||
{loadingSpinner} | ||
</View> : null)) | ||
: loadingSpinner | ||
) | ||
} | ||
|
||
_renderLoadingSpinner() { | ||
let children | ||
if(this.state.children == null) { | ||
children = this._renderActivityIndicator() | ||
} | ||
else { | ||
children = React.Children.map(this.state.children, (child) => { | ||
if (!React.isValidElement(child)) { | ||
return null | ||
} | ||
return child | ||
}) | ||
} | ||
return ( | ||
this.state.visible ? | ||
<Animated.View | ||
ref={ component => this._container = component } | ||
onLayout={this._onLoadingSpinnerLayout} | ||
style={[styles.container, this.props.style, {opacity:this.state.opacity, }]}> | ||
{children} | ||
</Animated.View> : null | ||
) | ||
} | ||
|
||
show({modal = this.state.modal, marginTop = this.state.marginTop, children = this.state.children, duration = this.props.duration, easing = Easing.linear, delay = this.props.delay, animationEnd,} | ||
= {modal: this.state.modal, marginTop: this.state.marginTop, children: this.state.children, duration: this.props.duration, easing: Easing.linear, delay: this.props.delay,}) { | ||
|
||
this._loadingSpinnerShowAnimation && this._loadingSpinnerShowAnimation.stop() | ||
this._loadingSpinnerHideAnimation && this._loadingSpinnerHideAnimation.stop() | ||
this._loadingSpinnerAnimationToggle && this.clearTimeout(this._loadingSpinnerAnimationToggle) | ||
|
||
if(this.state.visible) { | ||
this._setLoadingSpinnerOverlayPosition({modal, marginTop}) | ||
} | ||
|
||
this.setState({ | ||
children, | ||
modal, | ||
marginTop, | ||
visible: true, | ||
}) | ||
|
||
this._loadingSpinnerShowAnimation = Animated.timing( | ||
this.state.opacity, | ||
{ | ||
toValue: 1, | ||
duration, | ||
easing, | ||
delay, | ||
} | ||
) | ||
this._loadingSpinnerShowAnimation.start(() => { | ||
this._loadingSpinnerShowAnimation = null | ||
animationEnd && animationEnd() | ||
}) | ||
} | ||
|
||
hide({duration = this.props.duration, easing = Easing.linear, delay = this.props.delay, animationEnd,} | ||
= {duration: this.props.duration, easing: Easing.linear, delay: this.props.delay,}) { | ||
|
||
this._loadingSpinnerShowAnimation && this._loadingSpinnerShowAnimation.stop() | ||
this._loadingSpinnerHideAnimation && this._loadingSpinnerHideAnimation.stop() | ||
this.clearTimeout(this._loadingSpinnerAnimationToggle) | ||
|
||
this._loadingSpinnerHideAnimation = Animated.timing( | ||
this.state.opacity, | ||
{ | ||
toValue: 0, | ||
duration, | ||
easing, | ||
delay, | ||
} | ||
) | ||
this._loadingSpinnerHideAnimation.start( () => { | ||
this._loadingSpinnerHideAnimation = null | ||
this.setState({ | ||
visible: false, | ||
}) | ||
animationEnd && animationEnd() | ||
}) | ||
} | ||
|
||
_onLoadingSpinnerLayout = (e) => { | ||
this._loadingSpinnerWidth = e.nativeEvent.layout.width | ||
this._loadingSpinnerHeight = e.nativeEvent.layout.height | ||
this._setLoadingSpinnerOverlayPosition() | ||
} | ||
|
||
_setLoadingSpinnerOverlayPosition({modal, marginTop} = {modal: this.state.modal, marginTop: this.state.marginTop}) { | ||
if(!this._loadingSpinnerWidth || !this._loadingSpinnerHeight) { | ||
return | ||
} | ||
let {width: deviceWidth, height: deviceHeight,} = Dimensions.get('window') | ||
let left = (deviceWidth - this._loadingSpinnerWidth) / 2 | ||
let top = (deviceHeight - this._loadingSpinnerHeight) / 2 - (modal && marginTop === 0 ? 0 : marginTop) | ||
this._container.setNativeProps({ | ||
style: { | ||
left, | ||
top, | ||
} | ||
}) | ||
} | ||
|
||
_renderActivityIndicator() { | ||
return ActivityIndicator ? ( | ||
<ActivityIndicator | ||
style={{position: 'relative', left: 1, top: 1,}} | ||
animating={true} | ||
color={'#fff'} | ||
size={'large'}/> | ||
) : Platform.OS == 'android' ? | ||
( | ||
<ProgressBarAndroid | ||
color={'#fff'} | ||
styleAttr={'large'}/> | ||
|
||
) : ( | ||
<ActivityIndicatorIOS | ||
animating={true} | ||
color={'#fff'} | ||
size={'large'}/> | ||
) | ||
} | ||
|
||
} | ||
|
||
export default TimerEnhance(LoadingSpinnerOverlay) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.