|
|
'use strict';
|
|
|
|
|
|
import React from 'react';
|
|
|
import {AppRegistry, Platform, StyleSheet, Dimensions, Text, Alert} from 'react-native';
|
|
|
import ReactNative, {
|
|
|
AppRegistry,
|
|
|
Platform,
|
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
View,
|
|
|
Text,
|
|
|
Image,
|
|
|
Alert,
|
|
|
Animated,
|
|
|
} from 'react-native';
|
|
|
|
|
|
import {
|
|
|
Provider,
|
...
|
...
|
@@ -35,9 +46,13 @@ import NavBar from './components/NavBar'; |
|
|
import {
|
|
|
setPlatform,
|
|
|
setContianer,
|
|
|
setDot
|
|
|
setChannel,
|
|
|
} from './reducers/app/appActions';
|
|
|
|
|
|
import {
|
|
|
syncUser,
|
|
|
} from './reducers/home/homeActions';
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
...
|
...
|
@@ -70,6 +85,8 @@ export default function community(platform) { |
|
|
|
|
|
store.dispatch(setPlatform(platform));
|
|
|
store.dispatch(setContianer(this.props.container));
|
|
|
store.dispatch(setChannel(this.props.channel));
|
|
|
|
|
|
// setup the router table with App selected as the initial component
|
|
|
return (
|
|
|
<Provider store={store}>
|
...
|
...
|
@@ -80,9 +97,12 @@ export default function community(platform) { |
|
|
hideTabBar={true}
|
|
|
navBar={NavBar}
|
|
|
titleStyle={styles.navTitle}
|
|
|
leftButtonStyle={styles.button}
|
|
|
rightButtonStyle={styles.button}
|
|
|
getSceneStyle={(props) => {
|
|
|
return this.navPushStyle(props);
|
|
|
}}
|
|
|
getChannel={() => store.getState().app.channel}
|
|
|
>
|
|
|
<Scene
|
|
|
key="Home"
|
...
|
...
|
@@ -92,10 +112,13 @@ export default function community(platform) { |
|
|
initial={true}
|
|
|
leftTitle={null}
|
|
|
leftButtonImage={require('./images/home/menu_burger.png')}
|
|
|
onLeft={() => {}}
|
|
|
onLeft={() => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.toggleDrawer();
|
|
|
}}
|
|
|
rightTitle={null}
|
|
|
rightButtonImage={require('./images/home/menu_write.png')}
|
|
|
onRight={() => {Actions.Posting();}}
|
|
|
onRight={this.homeOnRight}
|
|
|
renderTitle={this.renderHomeTitle}
|
|
|
/>
|
|
|
|
|
|
<Scene
|
...
|
...
|
@@ -164,6 +187,51 @@ export default function community(platform) { |
|
|
);
|
|
|
},
|
|
|
|
|
|
renderHomeTitle(navProps) {
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let distance = Math.ceil(width * 90 / 375);
|
|
|
let distance2 = Math.ceil(width * 60 / 375);
|
|
|
let distance3 = Math.ceil(width * 35 / 375);
|
|
|
let line = 375 - (distance + distance2);
|
|
|
|
|
|
return (
|
|
|
<Animated.View style={[styles.title,]}>
|
|
|
<TouchableOpacity onPress={() => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(0);
|
|
|
}}>
|
|
|
<Text style={[styles.text, {flex: 0, marginLeft: distance,}]}>逛</Text>
|
|
|
</TouchableOpacity>
|
|
|
<Text style={[styles.text, {flex: 0, marginLeft: distance2,}]}>社区</Text>
|
|
|
<TouchableOpacity onPress={() => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.hideRNNavBar(2);
|
|
|
}}>
|
|
|
<Image style={{marginLeft: distance3,}} source={require('./images/home/sd_show_ic.png')}/>
|
|
|
</TouchableOpacity>
|
|
|
<View style={{
|
|
|
backgroundColor: 'white',
|
|
|
position: 'absolute',
|
|
|
width: 45,
|
|
|
height: 2,
|
|
|
left: 165,
|
|
|
top: 30,
|
|
|
}}/>
|
|
|
</Animated.View>
|
|
|
);
|
|
|
},
|
|
|
|
|
|
homeOnRight(state) {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.uid()
|
|
|
.then(uid => {
|
|
|
state.dispatch(syncUser(uid));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.login()
|
|
|
.then(uid => {
|
|
|
state.dispatch(syncUser(uid));
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/*
|
|
|
* 自定义导航push动画
|
|
|
*
|
...
|
...
|
@@ -214,13 +282,16 @@ export default function community(platform) { |
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
scene: {
|
|
|
backgroundColor:'#F0F0F0',
|
|
|
backgroundColor: '#F0F0F0',
|
|
|
},
|
|
|
navTitle: {
|
|
|
color: 'white',
|
|
|
marginLeft: 60,
|
|
|
marginRight: 60,
|
|
|
},
|
|
|
button: {
|
|
|
width: 60,
|
|
|
},
|
|
|
rightButton: {
|
|
|
width: 100,
|
|
|
height: 37,
|
...
|
...
|
@@ -242,4 +313,30 @@ let styles = StyleSheet.create({ |
|
|
textAlign: 'right',
|
|
|
fontSize: 17,
|
|
|
},
|
|
|
title: {
|
|
|
flexDirection: 'row',
|
|
|
// justifyContent: 'space-around',
|
|
|
alignItems: 'center',
|
|
|
|
|
|
marginTop: 12,
|
|
|
// width: Dimensions.get('window').width - 2 * 50,
|
|
|
position: 'absolute',
|
|
|
...Platform.select({
|
|
|
ios: {
|
|
|
top: 20,
|
|
|
},
|
|
|
android: {
|
|
|
top: 5,
|
|
|
},
|
|
|
}),
|
|
|
left: 0,
|
|
|
right: 0,
|
|
|
backgroundColor: 'transparent',
|
|
|
},
|
|
|
text: {
|
|
|
textAlign: 'center',
|
|
|
fontSize: 18,
|
|
|
fontWeight: 'bold',
|
|
|
color: '#ffffff',
|
|
|
},
|
|
|
}); |
...
|
...
|
|