-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from mori8/feature/search
[#14] Feature/search
- Loading branch information
Showing
12 changed files
with
7,739 additions
and
1,851 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
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
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,93 @@ | ||
import React, { useState } from 'react'; | ||
import { StyleSheet, Text, View, TouchableHighlight } from 'react-native'; | ||
import { useNavigation, StackActions } from '@react-navigation/native'; | ||
import type { Notice } from '../types'; | ||
import useFonts from '../hooks/useFonts' | ||
import AppLoading from 'expo-app-loading'; | ||
import { AntDesign } from '@expo/vector-icons'; | ||
import { theme } from '../core/theme'; | ||
|
||
interface SearchedNoticeProps { | ||
date: string | ||
summariedNotices: string[] | ||
} | ||
|
||
export default function SearchedNotice(props: SearchedNoticeProps) { | ||
const navigation = useNavigation<any>(); | ||
const [componentOpened, setComponentOpened] = useState<boolean>(false); | ||
const [fontsLoaded, SetFontsLoaded] = useState<boolean>(false); | ||
const LoadFontsAndRestoreToken = async () => { | ||
await useFonts(); | ||
}; | ||
|
||
const updateComponentOpened = () => { | ||
setComponentOpened(!componentOpened); | ||
} | ||
|
||
if (!fontsLoaded) { | ||
return ( | ||
<AppLoading | ||
startAsync={LoadFontsAndRestoreToken} | ||
onFinish={() => SetFontsLoaded(true)} | ||
onError={() => {}} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<View style={[styles.container, { | ||
height: componentOpened ? (80 + props.summariedNotices.length * 22): 60, | ||
paddingBottom: componentOpened ? 20: 0 | ||
}]}> | ||
<View style={styles.headerContainer}> | ||
<Text style={[styles.date, { | ||
color: componentOpened ? theme.colors.primary : "#2A2A2A", | ||
textDecorationLine: componentOpened ? "underline": "none" | ||
}]}>{props.date}</Text> | ||
<TouchableHighlight onPress={updateComponentOpened}> | ||
<AntDesign name={componentOpened ? "caretup" : "caretdown"} color={componentOpened ? theme.colors.primary : "#000"} size={14}/> | ||
</TouchableHighlight> | ||
</View> | ||
{componentOpened && ( | ||
<TouchableHighlight onPress={() => navigation.navigate('SearchResult', {date: props.date})}> | ||
<View> | ||
{props.summariedNotices.map((notice, index) => | ||
<Text style={styles.notices}>{(index + 1) + ". " + notice}</Text> | ||
)} | ||
</View> | ||
</TouchableHighlight> | ||
)} | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
backgroundColor: "#fff", | ||
width: '100%', | ||
marginVertical: 4, | ||
paddingVertical: 20, | ||
paddingHorizontal: 28, | ||
borderRadius: 16, | ||
shadowColor: "#acacac", | ||
shadowOpacity: 0.2, | ||
shadowRadius: 8, | ||
shadowOffset: { | ||
height: 0, | ||
width: 0, | ||
} | ||
}, | ||
headerContainer: { | ||
flex: 1, | ||
flexDirection: "row", | ||
justifyContent: "space-between" | ||
}, | ||
date: { | ||
fontFamily: 'Lora_700Bold', | ||
marginBottom: 12, | ||
}, | ||
notices: { | ||
lineHeight: 22, | ||
color: "#2A2A2A", | ||
} | ||
}) |
Oops, something went wrong.