-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
577 additions
and
241 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
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); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -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, | ||
}, | ||
}); |
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,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); | ||
}; |
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,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, | ||
}, | ||
}); |