Skip to content

Commit

Permalink
Merge pull request #100 from dsc-sookmyung/feature/search
Browse files Browse the repository at this point in the history
[#48] feat: change data structure & update style
  • Loading branch information
hee-suh authored Jun 1, 2022
2 parents 0cd4adb + 3aeb818 commit ec9a4cc
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 68 deletions.
43 changes: 21 additions & 22 deletions react-native/components/SearchedNotice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export default function SearchedNotice(props: Notices) {
return (
<View style={styles.container}>
<View style={styles.headerContainer}>
<Text fontWeight={700} color="white">Saved on {props?.date.replaceAll("-", ". ")}</Text>
<Text fontWeight={500} color="white">Saved on {props?.date.replaceAll("-", ". ")}</Text>
</View>
<VStack space={4}>
<VStack space={3}>
{props?.saved?.map((child, index) =>
<TouchableOpacity
key={'sc_'+index}
Expand All @@ -59,17 +59,16 @@ export default function SearchedNotice(props: Notices) {
>
<View style={{ justifyContent: "space-between" }}>
<HStack style={styles.noticeHeader}>
<Text fontWeight={500}>{i18n.t('title')}</Text>
{user.uchildren &&
<HStack style={ styles.cprofile }>
<Text fontWeight={500}>{user.uchildren.filter(uchild => uchild.cid === child.cid)[0]?.cname}</Text>
<Image style={styles.cprofileImageLg} source={cProfileImgSource[user.uchildren.filter(uchild => uchild.cid === child.cid)[0]?.cprofileImg-1]} />
<Image style={styles.cprofileImage} source={cProfileImgSource[user.uchildren.filter(uchild => uchild.cid === child.cid)[0]?.cprofileImg-1]} />
<VStack>
<Text fontSize="xs">{user.uchildren.filter(uchild => uchild.cid === child.cid)[0]?.cname}</Text>
<Text fontWeight={500} style={styles.notices}>{child?.title}</Text>
</VStack>
</HStack>
}
</HStack>
{child?.titles?.map((title, tIndex) =>
<Text key={'sct_'+tIndex} style={styles.notices}>{(tIndex + 1) + ". " + title}</Text>
)}
</HStack>
</View>
</TouchableOpacity>
)}
Expand All @@ -83,8 +82,7 @@ const styles = StyleSheet.create({
backgroundColor: theme.colors.primary,
width: '100%',
marginVertical: 8,
paddingVertical: 20,
paddingHorizontal: 28,
padding: 20,
borderRadius: 16,
shadowColor: "#acacac",
shadowOpacity: 0.2,
Expand All @@ -96,7 +94,9 @@ const styles = StyleSheet.create({
},
headerContainer: {
flexDirection: "row",
paddingBottom: 20,
paddingBottom: 12,
justifyContent: "flex-end",
width: "100%"
},
date: {
fontFamily: 'Lora_700Bold',
Expand All @@ -109,26 +109,25 @@ const styles = StyleSheet.create({
childNotice: {
backgroundColor: "#fff",
borderRadius: 16,
padding: 16,
padding: 12,
shadowColor: "#acacac",
shadowOpacity: 0.4,
shadowRadius: 8,
shadowOffset: {
height: 0,
width: 0,
height: 2,
width: 2,
}
},
cprofile: {
alignItems: "center",
alignItems: "flex-start",
width: "90%"
},
cprofileImageLg: {
width: 32,
height: 32,
marginLeft: 8
cprofileImage: {
width: 28,
height: 28,
marginRight: 10
},
noticeHeader: {
alignItems: "center",
justifyContent: "space-between",
paddingBottom: 6
}
})
4 changes: 2 additions & 2 deletions react-native/screens/SearchResultScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface SearchResultScreenProps {
name: string,
params: {
date: string,
cid: number
nid: number
},
path: string | undefined,
}
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function SearchResultScreen(props: SearchResultScreenProps) {
})

if (auth?.authData?.access_token) {
fetch(`http://localhost:8080/search/detail?date=${props.route.params.date}&cid=${props.route.params.cid}`, {
fetch(`http://localhost:8080/search/detail?nid=${props.route.params.nid}`, {
method: 'GET',
headers: {
'ACCESS-TOKEN': auth.authData.access_token
Expand Down
67 changes: 24 additions & 43 deletions react-native/screens/SearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,15 @@ export default function SearchScreen({ navigation }: Navigation) {
{
date: "2022-02-19",
saved: [
{
cid: 1,
titles: [
"17th Graduation Ceremony",
"School Day",
]
},
{
cid: 2,
titles: [
"Opening Ceremony",
]
}
{ nid: 1, cid: 1, title: "17th Graduation Ceremony" },
{ nid: 3, cid: 2, title: "School Day and school day and school day" },
]
},
{
date: "2022-02-15",
saved: [
{
cid: 1,
titles: [
"17th Graduation Ceremony",
"School Day",
]
}
{ nid: 4, cid: 1, title: "17th Graduation Ceremony" },
{ nid: 2, cid: 1, title: "Opening Ceremony" },
]
},
]
Expand All @@ -65,31 +49,15 @@ export default function SearchScreen({ navigation }: Navigation) {
{
date: "2022-02-19",
saved: [
{
cid: 1,
titles: [
"17th Graduation Ceremony",
"School Day",
]
},
{
cid: 2,
titles: [
"Opening Ceremony",
]
}
{ nid: 1, cid: 1, title: "17th Graduation Ceremony" },
{ nid: 2, cid: 1, title: "School Day" },
{ nid: 3, cid: 2, title: "Opening Ceremony" },
]
},
{
date: "2022-02-15",
saved: [
{
cid: 1,
titles: [
"17th Graduation Ceremony",
"School Day",
]
}
{ nid: 1, cid: 1, title: "17th Graduation Ceremony" }
]
},
])
Expand Down Expand Up @@ -158,7 +126,7 @@ export default function SearchScreen({ navigation }: Navigation) {
const newData = notices?.filter((notice) => {
let flag = false;
notice?.saved?.filter((item) => {
const noticeData = item.titles?.join().toUpperCase();
const noticeData = item.title?.toUpperCase();
const textData = text.toUpperCase();
if (noticeData.indexOf(textData) > -1) {
flag = true;
Expand Down Expand Up @@ -211,7 +179,6 @@ export default function SearchScreen({ navigation }: Navigation) {
onClear={() => searchFilter('')}
placeholder="Search"
value={search}
inputStyle={{ borderBottomColor: "#dddddd", borderBottomWidth: 1 }}
/>
<View>
<TouchableOpacity onPress={showDatePicker}>
Expand Down Expand Up @@ -282,7 +249,21 @@ const styles = StyleSheet.create({
},
searchWrapper: {
alignItems: 'center',
paddingRight: 12
height: 40,
paddingRight: 12,
marginHorizontal: 12,
marginBottom: 16,
backgroundColor: "#fff",
borderRadius: 16,
borderColor: theme.colors.gray,
borderWidth: 1,
shadowColor: "#acacac",
shadowOpacity: 0.2,
shadowRadius: 8,
shadowOffset: {
height: 0,
width: 0,
}
},
searchResults: {
width: '100%',
Expand Down
2 changes: 1 addition & 1 deletion react-native/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface Notice {

interface Notices {
date: string,
saved: { cid: number, titles: string[] }[]
saved: { nid: number, cid: number, title: string }[]
}

interface BottomDrawerProps {
Expand Down

0 comments on commit ec9a4cc

Please sign in to comment.