Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
iVanPan committed Jan 10, 2017
1 parent 5486d2c commit dcbeba0
Show file tree
Hide file tree
Showing 9 changed files with 577 additions and 241 deletions.
15 changes: 15 additions & 0 deletions demo/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React, { Component } from 'react';
import {
AppRegistry,
View
} from 'react-native';
import Navigation from './navigation';
import MainPage from './mainPage'
export default class Test extends Component {
render() {
return (
<Navigation initialRoute={{component: MainPage}} />
)
}
}
AppRegistry.registerComponent('Test', () => Test);
101 changes: 101 additions & 0 deletions demo/QQFavorite.js

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions demo/QQShare.js

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions demo/QQZoneShare.js

Large diffs are not rendered by default.

120 changes: 1 addition & 119 deletions demo/index.android.js

Large diffs are not rendered by default.

123 changes: 1 addition & 122 deletions demo/index.ios.js

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions demo/mainPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
ScrollView,
Alert,
Dimensions,
Button,
Navigator,
StatusBar,
View
} from 'react-native';
import * as QQ from "react-native-qqsdk";
import NavigationBar from './navigationBar';
import resolveAssetSource from 'resolveAssetSource';
import QQShare from './QQShare';
import QQZone from './QQZoneShare';
import Favorite from './QQFavorite';
export default class MainPage extends Component {
static propTypes = {
navigator: Navigator.propTypes.navigator,
};
render() {
return (
<View style={styles.container}>
<NavigationBar
navBarTitle="QQ Demo"
/>
<ScrollView
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
bounces={false}
>
<View style={styles.whiteView}/>
<Button
onPress={this.checkClient.bind(this)}
title="检查客户端是否安装"
color="#841584"
/>
<View style={styles.whiteView}/>
<Button
onPress={this.Login.bind(this)}
title="QQ 登录"
color="#841584"
/>
<View style={styles.whiteView}/>
<Button
onPress={this.Logout.bind(this)}
title="QQ登出"
color="#841584"
/>
<View style={styles.whiteView}/>
<Button
onPress={this.QQShare.bind(this)}
title="QQ分享"
color="#841584"
/>
<View style={styles.whiteView}/>
<Button
onPress={this.QQZoneShare.bind(this)}
title="QQZone分享"
color="#841584"
/>
<View style={styles.whiteView}/>
<Button
onPress={this.QQFavorites.bind(this)}
title="QQ收藏"
color="#841584"
/>
</ScrollView>
</View>
);
}
checkClient() {
QQ.isQQClientInstalled()
.then(()=>{
Alert.alert('检查客户端是否安装结果','Intsalled');
}).catch((error)=>{
Alert.alert('检查客户端是否安装结果',''+error);
});
}
Login() {
QQ.ssoLogin()
.then((result)=>{
Alert.alert('QQ登录结果','userid is '+result.userid+'\n token is '+result.access_token+'\n expires_time is '+ new Date(parseInt(result.expires_time)));
}).catch((error)=>{
Alert.alert('QQ登录结果',''+error);
});
}
Logout() {
QQ.logout()
.then((result)=>{
Alert.alert('QQ登出',''+result);
}).catch((error)=>{
Alert.alert('QQ登出',''+error);
});
}
QQShare() {
this.props.navigator.push({component: QQShare});
}
QQZoneShare(){
this.props.navigator.push({component: QQZone});
}
QQFavorites() {
this.props.navigator.push({component: Favorite});
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
whiteView: {
width:Dimensions.get('window').width,
height:16,
},
});
58 changes: 58 additions & 0 deletions demo/navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, {
Component,
PropTypes,
} from 'react';
import {
Navigator,
Platform,
BackAndroid,
} from 'react-native';

let _navigator;
export default class Navigation extends Component {
static propTypes = {
initialRoute: PropTypes.object.isRequired,
};
componentDidMount() {
if (Platform.OS === 'android') {
BackAndroid.addEventListener('hardwareBackPress', () => {
const routesList = _navigator.getCurrentRoutes();
if (routesList.length > 1) {
_navigator.pop();
return true;
}
return false;
});
}
}
componentWillUnmount() {
BackAndroid.removeEventListener('hardwareBackPress');
}
configureScene(route) {
if (route.sceneConfig) {
return route.sceneConfig;
}
return Navigator.SceneConfigs.PushFromRight;
}
render() {
return (
<Navigator
style={{flex: 1}}
initialRoute={this.props.initialRoute}
ref={(navigator) => {
_navigator = navigator;
}}
configureScene={this.configureScene.bind(this)}
renderScene={(route, navigator) => {
return <route.component navigator={navigator} {...route} {...route.passProps} />;
}}
/>
);
}
}
export const push = (route) => {
_navigator && _navigator.push(route);
};
export const resetTo = (route) => {
_navigator && _navigator.resetTo(route);
};
70 changes: 70 additions & 0 deletions demo/navigationBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, {
Component,
PropTypes,
} from 'react';
import {
StyleSheet,
View,
Text,
Dimensions,
Platform,
TouchableWithoutFeedback,
} from 'react-native';
export default class NavigationBar extends Component {
static propTypes = {
navBarTitle: PropTypes.string,
LeftButtonTitle: PropTypes.string,
LeftButtonOnPress: TouchableWithoutFeedback.propTypes.onPress,
};
render() {
return (
<View style={styles.navbar}>
<View style={styles.navBarButtonContainer}>
<Text style={styles.navBarButton} onPress = {this.props.LeftButtonOnPress} >{this.props.LeftButtonTitle}</Text>
</View>
<View style={styles.navBarTitleContainer}>
<Text style={styles.navbarTitle}>{this.props.navBarTitle}</Text>
</View>
<View style={styles.navBarButtonContainer}>
<Text style={styles.navBarButton}></Text>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
navbar: {
justifyContent: 'space-between',
flexDirection: 'row',
alignItems: 'stretch',
height:44,
marginTop:Platform.OS === 'ios'? 20:0,
width:Dimensions.get('window').width,
backgroundColor:'#ffffff',
borderBottomWidth:1,
borderBottomColor: '#C8C8C8'
},
navBarTitleContainer:{
justifyContent: 'center',
alignItems: 'center',
},
navbarTitle:{
fontSize: 17,
letterSpacing: 0.5,
color: '#333',
fontWeight: '500',
},
navBarButtonContainer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
navBarButton:{
fontSize: 17,
letterSpacing: 0.5,
color: '#333',
fontWeight: '500',
marginLeft:16,
marginRight:16,
},
});

0 comments on commit dcbeba0

Please sign in to comment.