|
@@ -20,7 +20,9 @@ import {
|
|
|
Button,
|
|
|
ViewPagerAndroid,
|
|
|
DeviceEventEmitter,
|
|
|
- SectionList
|
|
|
+ SectionList,
|
|
|
+ Animated,
|
|
|
+ TouchableHighlight
|
|
|
} from "react-native";
|
|
|
import Swiper from "react-native-swiper";
|
|
|
import AndroidUtil from "../../util/AndroidUtil";
|
|
@@ -35,37 +37,52 @@ import ScrollRow from "./ScrollRow";
|
|
|
export default class MainPage extends BasePage {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- this.state = {
|
|
|
- grade: '大学',
|
|
|
- text: '小伙子'
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ state = {
|
|
|
+ grade: '大学',
|
|
|
+ text: '小伙子',
|
|
|
+ ifGradeMenuShow: false,
|
|
|
+ fadeAnim: new Animated.Value(0),
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
- <View style={{ flex: 1}}>
|
|
|
- {/* 尝试切换为sectionList 分组显示 */}
|
|
|
- <SectionList
|
|
|
- sections={sectionData}
|
|
|
- renderItem={({ item }) => {
|
|
|
- return this.loadFlatItem(item);
|
|
|
- }}
|
|
|
- keyExtractor={(item, index) => item.key.toString()}
|
|
|
- ListHeaderComponent={() => this.headerorfooterComponent()}
|
|
|
- renderSectionHeader={this.sectionTitle}
|
|
|
- />
|
|
|
- <View style={styles.callUpGrade}>
|
|
|
- <View style={styles.gradeItem}>
|
|
|
- <Text style={styles.gradeText}>小学</Text>
|
|
|
- </View>
|
|
|
- <View style={styles.gradeItemMid}>
|
|
|
- <Text style={styles.gradeText}>学前</Text>
|
|
|
- </View>
|
|
|
- <View style={styles.gradeItem}>
|
|
|
- <Text style={styles.gradeText}>中学</Text>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
+ <View style={{ flex: 1 }} onPress={this.hideGradeMenu}>
|
|
|
+ {/* 尝试切换为sectionList 分组显示 */}
|
|
|
+ <SectionList
|
|
|
+ sections={sectionData}
|
|
|
+ renderItem={({ item }) => {
|
|
|
+ return this.loadFlatItem(item);
|
|
|
+ }}
|
|
|
+ keyExtractor={(item, index) => item.key.toString()}
|
|
|
+ ListHeaderComponent={() => this.headerorfooterComponent()}
|
|
|
+ renderSectionHeader={this.sectionTitle}
|
|
|
+ onScroll={this.hideGradeMenu}
|
|
|
+ />
|
|
|
+ {
|
|
|
+ this.state.ifGradeMenuShow ? (
|
|
|
+ <Animated.View
|
|
|
+ style={{
|
|
|
+ ...styles.callUpGrade,
|
|
|
+ opacity: this.state.fadeAnim
|
|
|
+ }}>
|
|
|
+ <View style={styles.gradeItem}>
|
|
|
+ <Text style={styles.gradeText}>小学</Text>
|
|
|
+ </View>
|
|
|
+ <View style={styles.gradeItemMid}>
|
|
|
+ <Text style={styles.gradeText}>学前</Text>
|
|
|
+ </View>
|
|
|
+ <View style={styles.gradeItem}>
|
|
|
+ <Text style={styles.gradeText}>中学</Text>
|
|
|
+ </View>
|
|
|
+ </Animated.View>
|
|
|
+ ) : (
|
|
|
+ null
|
|
|
+ )
|
|
|
+
|
|
|
+ }
|
|
|
+ </View>
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -79,7 +96,7 @@ export default class MainPage extends BasePage {
|
|
|
height={150}
|
|
|
username="卡通笨笨熊"
|
|
|
flowerNumber="123234"
|
|
|
- onPress={() => this.toNextPage("MainActivity")}
|
|
|
+ onPress={() => this.toNextPage("userCenter")}
|
|
|
/>
|
|
|
{/* 搜索区域 */}
|
|
|
<View style={styles.searchSection}>
|
|
@@ -88,7 +105,7 @@ export default class MainPage extends BasePage {
|
|
|
onChangeText={(text) => this.setState({ text })}
|
|
|
value={this.state.text}
|
|
|
/>
|
|
|
- <TouchableOpacity onPress={() => alert('press')}>
|
|
|
+ <TouchableOpacity onPress={this.tabCallOutHandler}>
|
|
|
<View
|
|
|
style={styles.rightBtn}
|
|
|
>
|
|
@@ -103,7 +120,7 @@ export default class MainPage extends BasePage {
|
|
|
</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
-
|
|
|
+
|
|
|
</View>
|
|
|
</View>
|
|
|
|
|
@@ -285,6 +302,30 @@ export default class MainPage extends BasePage {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 点击呼出学龄菜单
|
|
|
+ tabCallOutHandler = () => {
|
|
|
+ this.setState({
|
|
|
+ ifGradeMenuShow: !this.state.ifGradeMenuShow
|
|
|
+ }, () => {
|
|
|
+ Animated.timing(
|
|
|
+ this.state.fadeAnim,
|
|
|
+ {
|
|
|
+ toValue: this.state.ifGradeMenuShow ? 1 : 0,
|
|
|
+ duration: 300,
|
|
|
+ }
|
|
|
+ ).start();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果切换学龄在显示状态,那么在它失去焦点时将它隐藏
|
|
|
+ hideGradeMenu = () => {
|
|
|
+ if (this.state.ifGradeMenuShow) {
|
|
|
+ this.setState({
|
|
|
+ ifGradeMenuShow: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
@@ -341,25 +382,25 @@ const styles = StyleSheet.create({
|
|
|
position: 'absolute',
|
|
|
right: 9,
|
|
|
top: 125,
|
|
|
- zIndex:999,
|
|
|
+ zIndex: 999,
|
|
|
elevation: 999,
|
|
|
backgroundColor: '#fff',
|
|
|
flexDirection: 'column'
|
|
|
},
|
|
|
- gradeItem:{
|
|
|
- zIndex:999,
|
|
|
- flex:1,
|
|
|
+ gradeItem: {
|
|
|
+ zIndex: 999,
|
|
|
+ flex: 1,
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
|
},
|
|
|
- gradeItemMid:{
|
|
|
- zIndex:999,
|
|
|
- flex:1,
|
|
|
+ gradeItemMid: {
|
|
|
+ zIndex: 999,
|
|
|
+ flex: 1,
|
|
|
alignItems: 'center',
|
|
|
justifyContent: 'center',
|
|
|
borderTopWidth: 1,
|
|
|
borderBottomWidth: 1,
|
|
|
- borderColor : '#f0f1f5'
|
|
|
+ borderColor: '#f0f1f5'
|
|
|
},
|
|
|
gradeText: {
|
|
|
color: '#151515',
|