Commit 8f594117 by tungnq

TODO: Đã hoàn thiện giao diện điểm danh theo từng lớp học

parent 6c9b806c
...@@ -12,12 +12,13 @@ const styles = StyleSheet.create({ ...@@ -12,12 +12,13 @@ const styles = StyleSheet.create({
container:{ container:{
flex:1, flex:1,
backgroundColor:R.colors.white, backgroundColor:R.colors.white,
}, },
body:{ body:{
flex:1, flex:1,
backgroundColor:R.colors.white, backgroundColor:R.colors.white,
paddingHorizontal:15, paddingHorizontal:15,
paddingVertical:10, marginBottom:15,
}, },
textTitle:{ textTitle:{
fontSize:R.fontsize.fontsSizeTitle, fontSize:R.fontsize.fontsSizeTitle,
...@@ -26,24 +27,6 @@ const styles = StyleSheet.create({ ...@@ -26,24 +27,6 @@ const styles = StyleSheet.create({
color:R.colors.blue, color:R.colors.blue,
marginBottom:10, marginBottom:10,
}, },
summaryContainer: {
flexDirection: 'row',
justifyContent: 'space-around',
backgroundColor: R.colors.blue4,
padding: 10,
borderRadius: 8,
marginBottom: 15,
},
summaryText: {
fontSize: 14,
fontFamily: R.fonts.fontMedium,
color: R.colors.black,
},
summaryNumber: {
fontSize: 16,
fontWeight: '700',
fontFamily: R.fonts.fontBold,
},
tableContainer: { tableContainer: {
flex: 1, flex: 1,
borderWidth:1, borderWidth:1,
...@@ -59,8 +42,7 @@ const styles = StyleSheet.create({ ...@@ -59,8 +42,7 @@ const styles = StyleSheet.create({
}, },
headerCell: { headerCell: {
height: 50, height: 50,
paddingVertical: 12, paddingVertical: 10,
paddingHorizontal: 4,
borderRightWidth: 1, borderRightWidth: 1,
borderRightColor: R.colors.gray3, borderRightColor: R.colors.gray3,
borderBottomWidth: 1, borderBottomWidth: 1,
...@@ -70,7 +52,7 @@ const styles = StyleSheet.create({ ...@@ -70,7 +52,7 @@ const styles = StyleSheet.create({
backgroundColor: R.colors.blue2, backgroundColor: R.colors.blue2,
}, },
headerText: { headerText: {
fontSize: 12, fontSize: R.fontsize.fontSizeContent,
fontWeight: '600', fontWeight: '600',
fontFamily: R.fonts.fontMedium, fontFamily: R.fonts.fontMedium,
color: R.colors.black, color: R.colors.black,
...@@ -84,7 +66,6 @@ const styles = StyleSheet.create({ ...@@ -84,7 +66,6 @@ const styles = StyleSheet.create({
tableCell: { tableCell: {
height: 60, height: 60,
paddingVertical: 10, paddingVertical: 10,
paddingHorizontal: 4,
borderRightWidth: 1, borderRightWidth: 1,
borderRightColor: R.colors.gray3, borderRightColor: R.colors.gray3,
borderBottomWidth: 1, borderBottomWidth: 1,
...@@ -113,16 +94,15 @@ const styles = StyleSheet.create({ ...@@ -113,16 +94,15 @@ const styles = StyleSheet.create({
}, },
noteColumn: { noteColumn: {
width: NOTE_COLUMN, width: NOTE_COLUMN,
fontSize: 10, fontSize: R.fontsize.fontSizeContent,
}, },
statusContainer: { statusContainer: {
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },
statusText: { statusText: {
fontSize: 10, fontSize: R.fontsize.fontSizeContent,
fontFamily: R.fonts.fontMedium, fontFamily: R.fonts.fontMedium,
marginTop: 2,
textAlign: 'center', textAlign: 'center',
}, },
noteInput: { noteInput: {
...@@ -135,6 +115,11 @@ const styles = StyleSheet.create({ ...@@ -135,6 +115,11 @@ const styles = StyleSheet.create({
paddingHorizontal: 8, paddingHorizontal: 8,
paddingVertical: 4, paddingVertical: 4,
}, },
textTitleStatus:{
fontSize: R.fontsize.fontSizeContent,
fontFamily: R.fonts.fontRegular,
color: R.colors.black,
},
}) })
export default styles export default styles
\ No newline at end of file
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import {Text, View, TouchableOpacity, StyleSheet, ScrollView, FlatList, RefreshControl, Switch, TextInput} from 'react-native'; import {
Text,
View,
TouchableOpacity,
StyleSheet,
ScrollView,
FlatList,
RefreshControl,
Switch,
TextInput,
} from 'react-native';
import styles from './style'; import styles from './style';
import Header from '../../../components/Header/Header'; import Header from '../../../components/Header/Header';
import R from '../../../assets/R'; import R from '../../../assets/R';
import Button from '../../../components/Button';
const ListStudentRollCallView = props => { const ListStudentRollCallView = props => {
const {refreshing, setRefreshing, studentList, setStudentList} = props; const {refreshing, setRefreshing, studentList, setStudentList} = props;
const onRefresh = () => { const onRefresh = () => {
setRefreshing(true); setRefreshing(true);
setTimeout(() => { setTimeout(() => {
...@@ -15,36 +25,41 @@ const ListStudentRollCallView = props => { ...@@ -15,36 +25,41 @@ const ListStudentRollCallView = props => {
}, 1000); }, 1000);
}; };
const toggleAttendance = (studentId) => { const toggleAttendance = studentId => {
setStudentList(prevList => setStudentList(prevList =>
prevList.map(student => { prevList.map(student => {
if (student.id === studentId) { if (student.id === studentId) {
const newIsPresent = !student.isPresent; const newIsPresent = !student.isPresent;
// Auto-fill "nghỉ ko phép" when switching to absent if no custom note // Auto-fill "nghỉ ko phép" when switching to absent if no custom note
const newNote = !newIsPresent && (!student.note || student.note === '') const newNote =
!newIsPresent && (!student.note || student.note === '')
? 'Nghỉ không phép' ? 'Nghỉ không phép'
: (newIsPresent ? '' : student.note); : newIsPresent
? ''
: student.note;
return {...student, isPresent: newIsPresent, note: newNote}; return {...student, isPresent: newIsPresent, note: newNote};
} }
return student; return student;
}) }),
); );
}; };
const updateStudentNote = (studentId, note) => { const updateStudentNote = (studentId, note) => {
setStudentList(prevList => setStudentList(prevList =>
prevList.map(student => prevList.map(student =>
student.id === studentId student.id === studentId ? {...student, note: note} : student,
? {...student, note: note} ),
: student
)
); );
}; };
const countAttendance = () => { const countAttendance = () => {
const present = studentList.filter(studentList => studentList.isPresent).length; const present = studentList.filter(
const absent = studentList.filter(studentList => !studentList.isPresent).length; studentList => studentList.isPresent,
).length;
const absent = studentList.filter(
studentList => !studentList.isPresent,
).length;
console.log(`Có mặt: ${present}, Vắng mặt: ${absent}`); console.log(`Có mặt: ${present}, Vắng mặt: ${absent}`);
return {present, absent}; return {present, absent};
}; };
...@@ -84,14 +99,19 @@ const ListStudentRollCallView = props => { ...@@ -84,14 +99,19 @@ const ListStudentRollCallView = props => {
<View style={[styles.tableCell, styles.dateColumn]}> <View style={[styles.tableCell, styles.dateColumn]}>
<Text style={styles.cellText}>{item.date}</Text> <Text style={styles.cellText}>{item.date}</Text>
</View> </View>
<View style={[styles.tableCell, styles.statusColumn, styles.statusContainer]}> <View
style={[styles.tableCell, styles.statusColumn, styles.statusContainer]}>
<Switch <Switch
value={item.isPresent} value={item.isPresent}
onValueChange={() => toggleAttendance(item.id)} onValueChange={() => toggleAttendance(item.id)}
trackColor={{false: R.colors.red, true: R.colors.green}} trackColor={{false: R.colors.red, true: R.colors.green}}
thumbColor={item.isPresent ? R.colors.white : R.colors.white} thumbColor={item.isPresent ? R.colors.white : R.colors.white}
/> />
<Text style={[styles.statusText, {color: item.isPresent ? R.colors.green : R.colors.red}]}> <Text
style={[
styles.statusText,
{color: item.isPresent ? R.colors.green : R.colors.red},
]}>
{item.isPresent ? 'Có mặt' : 'Vắng mặt'} {item.isPresent ? 'Có mặt' : 'Vắng mặt'}
</Text> </Text>
</View> </View>
...@@ -99,7 +119,7 @@ const ListStudentRollCallView = props => { ...@@ -99,7 +119,7 @@ const ListStudentRollCallView = props => {
<TextInput <TextInput
style={styles.noteInput} style={styles.noteInput}
value={item.note || ''} value={item.note || ''}
onChangeText={(text) => updateStudentNote(item.id, text)} onChangeText={text => updateStudentNote(item.id, text)}
placeholder="Ghi chú..." placeholder="Ghi chú..."
placeholderTextColor={R.colors.gray2} placeholderTextColor={R.colors.gray2}
multiline={true} multiline={true}
...@@ -114,10 +134,8 @@ const ListStudentRollCallView = props => { ...@@ -114,10 +134,8 @@ const ListStudentRollCallView = props => {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Header title={'Điểm danh lớp: ATTT2024.P1'} isBack /> <Header title={'Điểm danh lớp: ATTT2024.P1'} isBack />
<View style={styles.body}> <ScrollView showsVerticalScrollIndicator={false} style={styles.body}>
<Text style={styles.textTitle}> <Text style={styles.textTitle}>Danh sách lp</Text>
Danh sách lp
</Text>
<View style={styles.tableContainer}> <View style={styles.tableContainer}>
<ScrollView horizontal showsHorizontalScrollIndicator={false}> <ScrollView horizontal showsHorizontalScrollIndicator={false}>
...@@ -126,7 +144,7 @@ const ListStudentRollCallView = props => { ...@@ -126,7 +144,7 @@ const ListStudentRollCallView = props => {
<FlatList <FlatList
data={studentList} data={studentList}
renderItem={renderStudentItem} renderItem={renderStudentItem}
keyExtractor={(item) => item.id.toString()} keyExtractor={item => item.id.toString()}
refreshControl={ refreshControl={
<RefreshControl <RefreshControl
refreshing={refreshing} refreshing={refreshing}
...@@ -142,7 +160,46 @@ const ListStudentRollCallView = props => { ...@@ -142,7 +160,46 @@ const ListStudentRollCallView = props => {
</View> </View>
</ScrollView> </ScrollView>
</View> </View>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginVertical: 10,
}}>
<Text style={styles.textTitleStatus}>
Có mt:{' '}
<Text style={[styles.statusText, {color: R.colors.green}]}>
{present}
</Text>
, Vng mt:{' '}
<Text style={[styles.statusText, {color: R.colors.red}]}>
{absent}
</Text>
</Text>
<Button
title="Đồng bộ kết quả "
onPress={() => {}}
containerStyle={{
paddingHorizontal: 5,
paddingVertical: 5,
borderRadius: 20,
}}
backgroundColor={R.colors.blue}
textColor={R.colors.white}
fontSize={12}
/>
</View>
<View>
<Text style={[styles.textTitleStatus ,{color:R.colors.blue, fontWeight:'600', fontFamily:R.fonts.fontMedium}]}>Ging viên lưu ý:</Text>
<Text style={styles.textTitleStatus}>
Đim danh ch được thc hin trong 15p trước và
15p sau khi đã vào tiếp (trong 30p) sau thi gian đim danh ging
viên s không được cp nht kết qu đim danh đã lưu trước đo
</Text>
</View> </View>
</ScrollView>
</View> </View>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment