Skip to content

Commit

Permalink
검색필터조건
Browse files Browse the repository at this point in the history
  • Loading branch information
aerain committed Aug 23, 2019
1 parent 6bc54cf commit bfeb749
Showing 3 changed files with 48 additions and 21 deletions.
53 changes: 32 additions & 21 deletions components/drawer/jnuservice/dreamy/LecturePlan.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState, useEffect, Fragment} from 'react'
import { View, Text, ScrollView, FlatList, ActivityIndicator, TouchableOpacity, StyleSheet} from 'react-native';
import { View, Text, ScrollView, FlatList, ActivityIndicator, TouchableOpacity, StyleSheet, Alert} from 'react-native';
import { Input, Button } from 'react-native-elements';
import { getLecturePlanList } from '../../../../service/jedaeroService';
import colorPalette from '../../../styles/colorPalette';
@@ -13,16 +13,24 @@ const LecturePlan = ({navigation}) => {
const [semester, setSemester] = useState([21, 10, 10, 10, 10, 10, 11, 20, 20, 20, 20, 20][date.getMonth()]);
const [classCode, setClassCode] = useState('');
const [professorName, setProfessorName] = useState('');
const [lectureName, setLectureName] = useState('');
const [lectureName, setLectureName] = useState('보안시스템개론');
const [data, setData] = useState([]);
const [isLoading, setLoading] = useState(false);

const getData = async () => {
if(!(year.trim() && (professorName.trim() || lectureName.trim() || classCode.trim()))) {
Alert.alert("검색어를 정확히 입력해주세요.");
return;
}
await setLoading(true);
await setData(await getLecturePlanList({year, semester, search:{classCode, professorName, lectureName}}));
await setLoading(false);
}

useEffect(() => {
getData()
} ,[]);

const LectureItem = ({item: {classCode, credit, professorName, takeName, lectureCode, lectureName, time}}) => (
<TouchableOpacity style={styles.lecture} onPress={() => navigation.navigate("LecturePlanDetail", { year, semester, classCode, lectureCode })}>
<View style={styles.lectureHeader}>
@@ -42,11 +50,7 @@ const LecturePlan = ({navigation}) => {
</TouchableOpacity>
)

return isLoading ? (
<View style={{alignItems: 'center', paddingTop:20, flex:1}}>
<ActivityIndicator size='large' color={colorPalette.mainColor}/>
</View>
) : (
return (
<Fragment>
<View style={styles.header}>
<Text>년도 및 학기</Text>
@@ -69,20 +73,27 @@ const LecturePlan = ({navigation}) => {
Icon={() => (<Icon name="md-arrow-dropdown" size={24} color={colorPalette.mainColor} style={{marginRight: 5}} />)}
/>
</View>
<ScrollView>
<View style={styles.searchHeader}>
<Input label="수강반번호" value={classCode} onChangeText={classCode => setClassCode(classCode)} labelStyle={styles.label} containerStyle={styles.searchContainer} inputStyle={styles.searchInput}/>
<Input label="교수이름" value={professorName} onChangeText={professorName => setProfessorName(professorName)} labelStyle={styles.label} containerStyle={styles.searchContainer} inputStyle={styles.searchInput}/>
<Input label="강의명" value={lectureName} onChangeText={lectureName => setLectureName(lectureName)} labelStyle={styles.label} containerStyle={styles.searchContainer} inputStyle={styles.searchInput}/>
<Button title="조회" type="solid" color={colorPalette.mainColor} buttonStyle={{backgroundColor: colorPalette.mainColor, margin: 8}} onPress={getData}/>
</View>
<FlatList
data={data}
renderItem = {LectureItem}
keyExtractor={item => item.classCode}
nestedScrollEnabled={true}
/>
</ScrollView>
{
isLoading ? (
<View style={{alignItems: 'center', paddingTop:20, flex:1}}>
<ActivityIndicator size='large' color={colorPalette.mainColor}/>
</View>
) : (<ScrollView>
<View style={styles.searchHeader}>
<Input label="수강반번호" value={classCode} onChangeText={classCode => setClassCode(classCode)} labelStyle={styles.label} containerStyle={styles.searchContainer} inputStyle={styles.searchInput}/>
<Input label="교수이름" value={professorName} onChangeText={professorName => setProfessorName(professorName)} labelStyle={styles.label} containerStyle={styles.searchContainer} inputStyle={styles.searchInput}/>
<Input label="강의명" value={lectureName} onChangeText={lectureName => setLectureName(lectureName)} labelStyle={styles.label} containerStyle={styles.searchContainer} inputStyle={styles.searchInput}/>
<Button title="조회" type="solid" color={colorPalette.mainColor} buttonStyle={{backgroundColor: colorPalette.mainColor, margin: 8}} onPress={getData}/>
</View>
<FlatList
data={data}
renderItem = {LectureItem}
keyExtractor={item => item.classCode}
nestedScrollEnabled={true}
/>
</ScrollView>
)
}
</Fragment>

)
12 changes: 12 additions & 0 deletions components/drawer/jnuservice/dreamy/LecturePlanDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, {useState, useEffect} from 'react'
import { View, Text } from 'react-native';

const LecturePlanDetail = () => {
return (
<View>
<Text>상세 ㅎㅇ</Text>
</View>
)
}

export default LecturePlanDetail;
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import LectureItemBoard from '../../drawer/jnuservice/dreamy/LectureItemBoard';
import LecturePost from '../../drawer/jnuservice/dreamy/LecturePost';
import PassDormitory from '../../drawer/jnuservice/dreamy/PassDormitory';
import LecturePlan from '../../drawer/jnuservice/dreamy/LecturePlan';
import LecturePlanDetail from '../../drawer/jnuservice/dreamy/LecturePlanDetail';

const DreamyStackNavigation = createStackNavigator({
DreamyHome: {
@@ -41,6 +42,9 @@ const DreamyStackNavigation = createStackNavigator({
},
LecturePlan: {
screen: LecturePlan,
},
LecturePlanDetail: {
screen: LecturePlanDetail
}
}, {...stackNavigationConfig, initialRouteName: "LecturePlan"})

0 comments on commit bfeb749

Please sign in to comment.