Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…olutionChallenge into feature/home
  • Loading branch information
mori8 committed Jun 4, 2022
2 parents 1f89f9a + f64205c commit 670e731
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 113 deletions.
2 changes: 1 addition & 1 deletion react-native/components/BottomDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function BottomDrawer(props: BottomDrawerProps) {

useEffect(() => {
if (props.openSaveForm && firstCid) {
setResultsForm({ cid: firstCid, title: 'title' });
setResultsForm({ cid: firstCid, title: props?.results?.title ? props.results.title : 'title' });
}
}, [props?.openSaveForm])

Expand Down
4 changes: 3 additions & 1 deletion react-native/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ export default {
searchResult: "Search Result",
noEvent: "There is no event today!",
saveFirst: "Click the Save button to save the results first!",
eventNotFound: "No event found"
eventNotFound: "No event found",
noResults: "There are no results yet",
translateFirst: "Translate and save the results."
}
4 changes: 3 additions & 1 deletion react-native/locales/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ export default {
searchResult: "検索結果",
noEvent: "今日はイベントはありません!",
saveFirst: "保存ボタンを押して結果を保存してください!",
eventNotFound: "イベントが見つかりませんでした"
eventNotFound: "イベントが見つかりませんでした",
noResults: "まだ結果はありません。",
translateFirst: "結果を翻訳して保存する。"
}
4 changes: 3 additions & 1 deletion react-native/locales/km.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ export default {
searchResult: "លទ្ធផលស្វែងរក",
noEvent: "មិនមានព្រឹត្តិការណ៍ថ្ងៃនេះទេ!",
saveFirst: "ចុចប៊ូតុង Save ដើម្បីរក្សាទុកលទ្ធផលជាមុន!",
eventNotFound: "រកមិនឃើញព្រឹត្តិការណ៍ទេ។"
eventNotFound: "រកមិនឃើញព្រឹត្តិការណ៍ទេ។",
noResults: "មិនទាន់មានលទ្ធផលនៅឡើយទេ។",
translateFirst: "បកប្រែ និងរក្សាទុកលទ្ធផល។"
}
4 changes: 3 additions & 1 deletion react-native/locales/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ export default {
searchResult: "검색 결과",
noEvent: "오늘은 이벤트가 없어요!",
saveFirst: "저장 버튼을 눌러서 결과 저장을 먼저 해주세요!",
eventNotFound: "이벤트를 찾지 못했어요"
eventNotFound: "이벤트를 찾지 못했어요",
noResults: "아직 결과가 없습니다.",
translateFirst: "번역을 한 후에 결과를 저장해주세요."
}
4 changes: 3 additions & 1 deletion react-native/locales/th.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ export default {
searchResult: "ผลการค้นหา",
noEvent: "วันนี้ไม่มีกิจกรรม!",
saveFirst: "คลิกปุ่มบันทึกเพื่อบันทึกผลลัพธ์ก่อน!",
eventNotFound: "ไม่พบกิจกรรม"
eventNotFound: "ไม่พบกิจกรรม",
noResults: "ยังไม่มีผลลัพธ",
translateFirst: "แปลและบันทึกผลลัพธ์"
}
4 changes: 3 additions & 1 deletion react-native/locales/vn.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ export default {
searchResult: "Kết quả tìm kiếm",
noEvent: "Không có sự kiện hôm nay!",
saveFirst: "Nhấp vào nút Lưu để lưu kết quả trước!",
eventNotFound: "Không tìm thấy sự kiện nào"
eventNotFound: "Không tìm thấy sự kiện nào",
noResults: "Chưa có kết quả.",
translateFirst: "Dịch và lưu kết quả."
}
4 changes: 3 additions & 1 deletion react-native/locales/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ export default {
searchResult: "搜索结果",
noEvent: "今天没有活动!",
saveFirst: "单击保存按钮首先保存结果!",
eventNotFound: "未找到任何事件"
eventNotFound: "未找到任何事件",
noResults: "目前还没有结果。",
translateFirst: "翻译并保存结果。"
}
14 changes: 7 additions & 7 deletions react-native/screens/JoinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function JoinScreen({ navigation }: Navigation) {
// 1 3 4 5 7 10
const [joinForm, setJoinForm] = useState<JoinData>({
uid: undefined,
uprofileImg: 1,
uprofileImg: 0,
username: '',
ulanguage: '',
uchildren: colors.map(color => ({ cname: '', cprofileImg: 1, color: color?.id }))
uchildren: colors.map(color => ({ cname: '', cprofileImg: 0, color: color?.id }))
})
const [open, setOpen] = useState(-1);

Expand Down Expand Up @@ -136,8 +136,8 @@ export default function JoinScreen({ navigation }: Navigation) {
<FormControl.Label>{i18n.t('profileImage')}</FormControl.Label>
<ScrollView horizontal={true}>
{Array.from(Array(Number(7)).keys()).map((num, index) =>
<Button key={'ub_'+index} variant="unstyled" onPress={handleProfileImg(index+1)}>
<Image style={[styles.uprofileImage, joinForm.uprofileImg!==index+1 && styles.disabled]} source={uProfileImgSource[index]} />
<Button key={'ub_'+index} variant="unstyled" onPress={handleProfileImg(index)}>
<Image style={[styles.uprofileImage, joinForm.uprofileImg!==index && styles.disabled]} source={uProfileImgSource[index]} />
</Button>
)}
</ScrollView>
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function JoinScreen({ navigation }: Navigation) {
trigger={triggerProps => {
return <Button {...triggerProps} variant="unstyled" onPress={() => setOpen(child)}>
{joinForm && joinForm.uchildren &&
<Image style={[styles.cprofileImage]} source={cProfileImgSource[joinForm.uchildren[child]?.cprofileImg-1]} />
<Image style={[styles.cprofileImage]} source={cProfileImgSource[joinForm.uchildren[child]?.cprofileImg]} />
}
</Button>
}}
Expand All @@ -240,9 +240,9 @@ export default function JoinScreen({ navigation }: Navigation) {
<FormControl.Label>{i18n.t('profileImage')}</FormControl.Label>
<ScrollView horizontal={true}>
{Array.from(Array(Number(9)).keys()).map((num, i) =>
<Button key={'cb_'+num} variant="unstyled" onPress={handleChildrenProfileImg(child, num+1)}>
<Button key={'cb_'+num} variant="unstyled" onPress={handleChildrenProfileImg(child, num)}>
{joinForm && joinForm.uchildren &&
<Image style={[styles.uprofileImage, joinForm?.uchildren[child]?.cprofileImg!==num+1 && styles.disabled]} source={cProfileImgSource[num]} />
<Image style={[styles.uprofileImage, joinForm?.uchildren[child]?.cprofileImg!==num && styles.disabled]} source={cProfileImgSource[num]} />
}
</Button>
)}
Expand Down
95 changes: 37 additions & 58 deletions react-native/screens/SearchResultScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,18 @@ export default function SearchResultScreen(props: SearchResultScreenProps) {
const auth = useAuth();
const navigation = useNavigation();

const [notices, setNotices] = useState<Notice>({date: "", results: []});
const [notice, setNotice] = useState<Notice>({
imageUri: '',
fullText: [
{id: 1, eid: 1, content: "1. Schedule of the closing ceremony and diploma presentation ceremony: Friday, January 4, 2019 at 9 o'clock for students to go to school.\n1) ", date: "", highlight: false, registered: false},
{id: 2, eid: -1, content: "Closing ceremony", date: "2022-01-04", highlight: true, registered: false}
],
korean: "희망찬 새해를 맞이하여 학부모님의 가정에 건강과 행복이 함께 하시기를 기원합니다."
});
const [showKorean, setShowKorean] = useState<boolean>(false);
const [isFullDrawer, setFullDrawer] = useState<boolean>(false);

useEffect(() => {
// TODO: Fetch API
// mockup data
setNotices({
date: "2022-02-10",
results: [{
id: 1,
imageUri: '',
fullText: [
{id: 1, eid: 1, content: "1. Schedule of the closing ceremony and diploma presentation ceremony: Friday, January 4, 2019 at 9 o'clock for students to go to school.\n1) ", date: "", highlight: false, registered: false},
{id: 2, eid: -1, content: "Closing ceremony", date: "2022-01-04", highlight: true, registered: false}
],
korean: "희망찬 새해를 맞이하여 학부모님의 가정에 건강과 행복이 함께 하시기를 기원합니다."
}, {
id: 2,
imageUri: '',
fullText: [
{id: 1, eid: -1, content: "1. Schedule of the closing ceremony and diploma presentation ceremony: Friday, January 4, 2019 at 9 o'clock for students to go to school.\n1) ", date: "", highlight: false, registered: false},
{id: 2, eid: 2, content: "Closing ceremony", date: "2022-01-04", highlight: true, registered: false}
],
korean: "개학일은 3월 2일이며, 개학식에 참여하고자 하는 학부모님께서는 10시까지 강당으로 오시기 바랍니다.",
trans_full: ""
}]
})

if (auth?.authData?.access_token) {
fetch(`http://localhost:8080/search/detail?nid=${props.route.params.nid}`, {
method: 'GET',
Expand All @@ -65,7 +48,7 @@ export default function SearchResultScreen(props: SearchResultScreenProps) {
.then(response => response.json())
.then(data => {
if (data?.date && data?.results.length) {
setNotices(data);
setNotice(data);
}
})
.catch(function (error) {
Expand All @@ -86,38 +69,34 @@ export default function SearchResultScreen(props: SearchResultScreenProps) {

return (
<View style={styles.container}>
<Swiper>
{notices?.results && notices.results.length > 0 && notices.results.map((notice, index) =>
<ImageBackground style={styles.container} resizeMode="cover" imageStyle={{ opacity: 0.5 }} source={{ uri: notice?.imageUri }} key={"ib_" + index}>
<SwipeUpDown
itemMini={
<BottomDrawer
results={notice}
showKorean={showKorean}
isFullDrawer={isFullDrawer}
isTranslateScreen={false}
handleKorean={handleKorean}
/>
}
itemFull={
<BottomDrawer
results={notice}
showKorean={showKorean}
isFullDrawer={isFullDrawer}
isTranslateScreen={false}
handleKorean={handleKorean}
/>
}
onShowMini={() => setFullDrawer(false)}
onShowFull={() => setFullDrawer(true)}
animation="easeInEaseOut"
disableSwipeIcon
extraMarginTop={10}
swipeHeight={Dimensions.get('window').height*0.5}
/>
</ImageBackground>
)}
</Swiper>
<ImageBackground style={styles.container} resizeMode="cover" imageStyle={{ opacity: 0.5 }} source={{ uri: notice?.imageUri }}>
<SwipeUpDown
itemMini={
<BottomDrawer
results={notice}
showKorean={showKorean}
isFullDrawer={isFullDrawer}
isTranslateScreen={false}
handleKorean={handleKorean}
/>
}
itemFull={
<BottomDrawer
results={notice}
showKorean={showKorean}
isFullDrawer={isFullDrawer}
isTranslateScreen={false}
handleKorean={handleKorean}
/>
}
onShowMini={() => setFullDrawer(false)}
onShowFull={() => setFullDrawer(true)}
animation="easeInEaseOut"
disableSwipeIcon
extraMarginTop={10}
swipeHeight={Dimensions.get('window').height*0.5}
/>
</ImageBackground>
</View>
);
}
Expand Down
37 changes: 27 additions & 10 deletions react-native/screens/SearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useAuth } from '../contexts/Auth';
import { StackActions } from '@react-navigation/native';
import i18n from 'i18n-js'
import '../locales/i18n';
import { colors } from 'react-native-elements';


export default function SearchScreen({ navigation }: Navigation) {
Expand Down Expand Up @@ -81,10 +82,8 @@ export default function SearchScreen({ navigation }: Navigation) {
})
.then(response => response.json())
.then(data => {
if (data?.date && data?.saved?.length) {
setNotices(data);
setFilteredNotices(data);
}
setNotices(data);
setFilteredNotices(data);
})
.catch(function (error) {
console.log(error)
Expand Down Expand Up @@ -206,7 +205,7 @@ export default function SearchScreen({ navigation }: Navigation) {
<TouchableOpacity key={'n_'+index} style={[styles.childButton, {
backgroundColor: nowSelectedChildId === child.cid ? theme.colors.primary : "#ffffff",
}]} onPress={() => handleNowSelectedChildId(child.cid)}>
<Image style={styles.cprofileImage} source={cProfileImgSource[child.cprofileImg-1]} />
<Image style={styles.cprofileImage} source={cProfileImgSource[child.cprofileImg]} />
<Text fontWeight={500} style={[{
color: nowSelectedChildId !== child.cid ? theme.colors.primary : "#ffffff",
}]}>{child.cname}</Text>
Expand All @@ -218,15 +217,21 @@ export default function SearchScreen({ navigation }: Navigation) {
<Text style={styles.smallDescription}>{i18n.t('results_cap')}</Text>

<ScrollView style={styles.searchResults}>
{filteredNotices && filteredNotices.length > 0 && (
{filteredNotices && filteredNotices.length > 0 ? (
filteredNotices?.map((notice, index) =>
<SearchedNotice key={"nt_" + index} date={notice?.date} saved={notice?.saved} />
)
)}
{/* TODO: empty icon
)
: (
<Text>There are no results yet. Translate and save the results.</Text>
)} */}
<View style={{ alignItems: "center" }}>
<Image source={require("../assets/images/empty.png")} style={styles.imageStyle} />
<Text>{i18n.t('noResults')}</Text>
<Text>{i18n.t('translateFirst')}</Text>
<TouchableOpacity style={styles.navigateButton} onPress={() => navigation.navigate('Translate')}>
<Text fontWeight={500} color={"#fff"}>Go to {i18n.t('translate')}</Text>
</TouchableOpacity>
</View>
)}
</ScrollView>
</View>
);
Expand Down Expand Up @@ -299,4 +304,16 @@ const styles = StyleSheet.create({
height: 20,
marginRight: 12
},
imageStyle: {
width: 80,
height: 80,
margin: 20,
},
navigateButton: {
margin: 20,
backgroundColor: theme.colors.primary,
paddingVertical: 8,
paddingHorizontal: 16,
borderRadius: 8,
}
})
Loading

0 comments on commit 670e731

Please sign in to comment.