Commit 45dfc3f6 by tungnq

TODO: Thêm màn hình tạo thông báo với hỗ trợ danh sách thả xuống và đính kèm tệp

parent 27da74cf
...@@ -59,6 +59,7 @@ const images = { ...@@ -59,6 +59,7 @@ const images = {
icDrop: require('./icon/icon_png/arrow_drop.png'), icDrop: require('./icon/icon_png/arrow_drop.png'),
icSearchHeader:require('./icon/icon_png/icon_search_header.png'), icSearchHeader:require('./icon/icon_png/icon_search_header.png'),
icSearch: require('./icon/icon_png/icon_search.png'), icSearch: require('./icon/icon_png/icon_search.png'),
icDocument: require('./icon/icon_png/ic_document.png'),
//Image Logo //Image Logo
igLogo: require('./images/logo.png'), igLogo: require('./images/logo.png'),
......
import React, { useState } from 'react'; import React, {useState} from 'react';
import { View, Text, TouchableOpacity, StyleSheet, FlatList, Image } from 'react-native'; import {
View,
Text,
TouchableOpacity,
StyleSheet,
FlatList,
Image,
ScrollView,
} from 'react-native';
import R from '../../assets/R'; import R from '../../assets/R';
const Dropdown = ({ items, placeholder = "Chọn...", onSelect }) => { const Dropdown = ({items, placeholder = 'Chọn...', onSelect}) => {
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [selected, setSelected] = useState(null); const [selected, setSelected] = useState(null);
const handleSelect = (item) => { const handleSelect = item => {
setSelected(item); setSelected(item);
setIsOpen(false); setIsOpen(false);
if (onSelect) onSelect(item); if (onSelect) onSelect(item);
...@@ -16,19 +24,22 @@ const Dropdown = ({ items, placeholder = "Chọn...", onSelect }) => { ...@@ -16,19 +24,22 @@ const Dropdown = ({ items, placeholder = "Chọn...", onSelect }) => {
{/* Nút hiển thị */} {/* Nút hiển thị */}
<TouchableOpacity <TouchableOpacity
style={styles.dropdownHeader} style={styles.dropdownHeader}
onPress={() => setIsOpen(!isOpen)} onPress={() => setIsOpen(!isOpen)}>
>
<Text style={styles.dropdownHeaderText}> <Text style={styles.dropdownHeaderText}>
{selected ? selected.label : placeholder} {selected ? selected.label : placeholder}
</Text> </Text>
<Image source={R.images.icDrop} style={styles.imageIcon} /> <Image source={R.images.icDrop} style={styles.imageIcon} />
</TouchableOpacity> </TouchableOpacity>
{/* Danh sách xổ xuống */} {/* Danh sách xổ xuống */}
{isOpen && ( {isOpen && (
<View style={[styles.dropdownList, { position: 'absolute', top: 35, left: 0, right: 0, zIndex: 999 }]}> <View
<FlatList style={[
styles.dropdownList,
{position: 'absolute', top: 35, left: 0, right: 0, zIndex: 999},
]}>
{/* <FlatList
nestedScrollEnabled={true}
data={items} data={items}
keyExtractor={(item) => item.id.toString()} keyExtractor={(item) => item.id.toString()}
renderItem={({ item }) => ( renderItem={({ item }) => (
...@@ -39,7 +50,17 @@ const Dropdown = ({ items, placeholder = "Chọn...", onSelect }) => { ...@@ -39,7 +50,17 @@ const Dropdown = ({ items, placeholder = "Chọn...", onSelect }) => {
<Text style={styles.dropdownItemText}>{item.label}</Text> <Text style={styles.dropdownItemText}>{item.label}</Text>
</TouchableOpacity> </TouchableOpacity>
)} )}
/> /> */}
<ScrollView style={{maxHeight: 200}}>
{items.map(item => (
<TouchableOpacity
key={item.id.toString()}
style={styles.dropdownItem}
onPress={() => handleSelect(item)}>
<Text style={styles.dropdownItemText}>{item.label}</Text>
</TouchableOpacity>
))}
</ScrollView>
</View> </View>
)} )}
</View> </View>
...@@ -52,7 +73,7 @@ const styles = StyleSheet.create({ ...@@ -52,7 +73,7 @@ const styles = StyleSheet.create({
container: { container: {
width: '100%', width: '100%',
}, },
dropdownHeader: { dropdownHeader: {
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'space-between', justifyContent: 'space-between',
alignItems: 'center', alignItems: 'center',
...@@ -60,14 +81,12 @@ dropdownHeader: { ...@@ -60,14 +81,12 @@ dropdownHeader: {
borderColor: '#ccc', borderColor: '#ccc',
borderRadius: 5, borderRadius: 5,
backgroundColor: '#fff', backgroundColor: '#fff',
height:35, height: 35,
paddingHorizontal:15 paddingHorizontal: 15,
}, },
dropdownHeaderText: { dropdownHeaderText: {
fontSize: 12, fontSize: 12,
color: '#333', color: '#333',
}, },
dropdownList: { dropdownList: {
borderWidth: 1, borderWidth: 1,
...@@ -83,10 +102,10 @@ dropdownHeader: { ...@@ -83,10 +102,10 @@ dropdownHeader: {
fontSize: 12, fontSize: 12,
color: '#333', color: '#333',
}, },
imageIcon:{ imageIcon: {
width:20, width: 20,
height:20, height: 20,
resizeMode:'contain', resizeMode: 'contain',
tintColor:'#333', tintColor: '#333',
} },
}); });
...@@ -16,13 +16,46 @@ const NotificationAdd = (props) => { ...@@ -16,13 +16,46 @@ const NotificationAdd = (props) => {
{ id: 2, label: 'Option 2' }, { id: 2, label: 'Option 2' },
{ id: 3, label: 'Option 3' }, { id: 3, label: 'Option 3' },
]; ];
const [dataList, setDataList] = useState([
{ id: 1, name: 'Nguyễn Minh Đức' },
{ id: 2, name: 'Trần Văn Hùng' },
{ id: 3, name: 'Lê Thị Mai' },
{ id: 4, name: 'Phạm Quốc Khánh' },
{ id: 5, name: 'Hoàng Anh Tuấn' },
{ id: 6, name: 'Vũ Thị Hằng' },
{ id: 7, name: 'Ngô Văn Nam' },
{ id: 8, name: 'Đinh Thị Lan' },
{ id: 9, name: 'Bùi Văn Phúc' },
{ id: 10, name: 'Lý Thị Hoa' },
{ id: 11, name: 'Phan Minh Hoàng' },
{ id: 12, name: 'Tạ Thị Hương' },
{ id: 13, name: 'Đoàn Văn Dũng' },
{ id: 14, name: 'Nguyễn Thị Vân' },
{ id: 15, name: 'Trương Văn Long' },
{ id: 16, name: 'Mai Thị Ngọc' },
{ id: 17, name: 'Huỳnh Quốc Việt' },
{ id: 18, name: 'Lâm Thị Thu' },
{ id: 19, name: 'Nguyễn Hữu Tài' },
{ id: 20, name: 'Phạm Thị Kim' }
]);
const [selectedValue2, setSelectedValue2] = useState('1');
const options2 = [
{label: 'Gửi hẹn thời gian', value: '1'},
{label: 'Gửi lập tức', value: '2'},
];
const onValueChange2 = value => {
setSelectedValue2(value);
};
return ( return (
<NotificationAddView <NotificationAddView
options={options} options={options}
selectedValue={selectedValue} selectedValue={selectedValue}
onValueChange={onValueChange} onValueChange={onValueChange}
items={items} items={items}
dataList={dataList}
options2={options2}
selectedValue2={selectedValue2}
onValueChange2={onValueChange2}
/> />
); );
}; };
......
...@@ -41,10 +41,11 @@ const styles = StyleSheet.create({ ...@@ -41,10 +41,11 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
// position: 'relative', // position: 'relative',
paddingLeft: 10, paddingLeft: 10,
paddingRight:10,
height: 25, height: 25,
borderRadius: 10, borderRadius: 10,
marginBottom:10, marginBottom:10,
marginHorizontal:5, marginRight:5,
// top: 10, // top: 10,
// left: 10, // left: 10,
backgroundColor: R.colors.blue2, backgroundColor: R.colors.blue2,
...@@ -74,6 +75,29 @@ const styles = StyleSheet.create({ ...@@ -74,6 +75,29 @@ const styles = StyleSheet.create({
flexDirection:'row', flexDirection:'row',
marginBottom:15, marginBottom:15,
}, },
flatListSelect:{
flexDirection:'row',
flexWrap:'wrap',
},
sizedBox:{
height:15,
},
card:{
alignItems:'center',
justifyContent:'center',
padding:10,
borderRadius:10,
backgroundColor:R.colors.white,
borderWidth:1,
borderColor:R.colors.blue,
height:90
},
txtCard:{
fontSize:12,
fontWeight:'300',
fontFamily:R.fonts.fontRegular,
color:R.colors.blueTextChip,
},
//ContainerBtn //ContainerBtn
containerBtn:{ containerBtn:{
flexDirection:'row', flexDirection:'row',
......
import React from 'react'; import React from 'react';
import {Text, View, FlatList, ScrollView} from 'react-native'; import {
Text,
View,
FlatList,
ScrollView,
TouchableOpacity,
Image,
} from 'react-native';
import styles from './style'; import styles from './style';
import Header from '../../../components/Header/Header'; import Header from '../../../components/Header/Header';
import TextField from '../../../components/Input/TextField'; import TextField from '../../../components/Input/TextField';
...@@ -22,18 +29,21 @@ const NotificationDetailView = props => { ...@@ -22,18 +29,21 @@ const NotificationDetailView = props => {
direction, direction,
dataList, dataList,
items, items,
options2,
selectedValue2,
onValueChange2,
} = props; } = props;
const renderItem = ({item, onPress}) => { const renderItem = ({item, onPress}) => {
return ( return (
<View style={styles.chip}> <View style={styles.chip}>
{/* <TouchableOpacity style={styles.containerIcon} onPress={onPress}> <TouchableOpacity style={styles.containerIcon} onPress={onPress}>
<Image <Image
resizeMode="cover" resizeMode="cover"
source={R.images.icCancel} source={R.images.icCancel}
style={styles.imageIcon} style={styles.imageIcon}
/> />
</TouchableOpacity> */} </TouchableOpacity>
<Text style={styles.text}> {`${item.id}, ${item.name}`}</Text> <Text style={styles.text}> {`${item.id}, ${item.name}`}</Text>
</View> </View>
); );
...@@ -42,9 +52,7 @@ const NotificationDetailView = props => { ...@@ -42,9 +52,7 @@ const NotificationDetailView = props => {
return ( return (
<View style={styles.safeArea}> <View style={styles.safeArea}>
<Header isBack title={'Tạo mới thông báo'} /> <Header isBack title={'Tạo mới thông báo'} />
<ScrollView <ScrollView contentContainerStyle={{paddingBottom: 20}}>
showsVerticalScrollIndicator={false}
contentContainerStyle={{paddingBottom: 20}}>
<View style={styles.container}> <View style={styles.container}>
<TextField <TextField
containerMarginTop={15} containerMarginTop={15}
...@@ -87,7 +95,6 @@ const NotificationDetailView = props => { ...@@ -87,7 +95,6 @@ const NotificationDetailView = props => {
fontSizePlaceHolder={R.sizes.sm} fontSizePlaceHolder={R.sizes.sm}
required required
containerMarginBottom={15} containerMarginBottom={15}
editable={false}
/> />
<RadioGroup <RadioGroup
...@@ -105,7 +112,10 @@ const NotificationDetailView = props => { ...@@ -105,7 +112,10 @@ const NotificationDetailView = props => {
containerMarginBottom={15} containerMarginBottom={15}
editable={true} editable={true}
/> />
<Text style={[styles.text]}>Chn nhng sinh viên nhn thông báo <Text style={{color: R.colors.red}}>*</Text></Text> <Text style={[styles.text, {marginBottom: 5}]}>
Chn nhng sinh viên nhn thông báo{' '}
<Text style={{color: R.colors.red}}>*</Text>
</Text>
<View style={styles.containerDropdown}> <View style={styles.containerDropdown}>
<Dropdown <Dropdown
items={items} items={items}
...@@ -113,10 +123,35 @@ const NotificationDetailView = props => { ...@@ -113,10 +123,35 @@ const NotificationDetailView = props => {
onSelect={item => console.log('Bạn đã chọn:', item)} onSelect={item => console.log('Bạn đã chọn:', item)}
/> />
</View> </View>
<Text style={[styles.text]}> Danh sách đã chn :</Text> <Text style={[styles.text, {marginBottom: 5}]}>
<View> Danh sách đã chn :
</Text>
<View style={styles.flatListSelect}>
{dataList.map((items, index) => (
<View
style={styles.flatListSelect}
key={items.id?.toString() || index}>
{renderItem({item: items, onPress: () => {}})}
</View>
))}
</View> </View>
<View style={styles.sizedBox}></View>
<RadioGroup
options={options2}
selectedValue={selectedValue2}
onValueChange={onValueChange2}
disabled={false}
size={20}
backgroundBoxColor={R.colors.blue}
borderBoxColor={R.colors.black}
direction={'row'}
marginBtnAndLabel={10}
// justifyContent={'space-between'}
containerMarginRight={39}
containerMarginBottom={15}
editable={true}
/>
<View style={styles.containerBtn}> <View style={styles.containerBtn}>
<View style={styles.containerInput}> <View style={styles.containerInput}>
...@@ -124,13 +159,11 @@ const NotificationDetailView = props => { ...@@ -124,13 +159,11 @@ const NotificationDetailView = props => {
title="Ngày gửi" title="Ngày gửi"
value={title} value={title}
onChangeText={onTitleChange} onChangeText={onTitleChange}
backgroundColor={R.colors.blue1}
color={R.colors.white} color={R.colors.white}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
onFocus={() => {}} onFocus={() => {}}
fontSizeTitle={R.sizes.sm} fontSizeTitle={R.sizes.sm}
containerMarginBottom={15} containerMarginBottom={15}
editable={false}
/> />
</View> </View>
<View style={{flex: 1}}></View> <View style={{flex: 1}}></View>
...@@ -139,20 +172,18 @@ const NotificationDetailView = props => { ...@@ -139,20 +172,18 @@ const NotificationDetailView = props => {
title="Thời gian gửi" title="Thời gian gửi"
value={title} value={title}
onChangeText={onTitleChange} onChangeText={onTitleChange}
backgroundColor={R.colors.blue1}
color={R.colors.white} color={R.colors.white}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
onFocus={() => {}} onFocus={() => {}}
fontSizeTitle={R.sizes.sm} fontSizeTitle={R.sizes.sm}
containerMarginBottom={15} containerMarginBottom={15}
editable={false}
/> />
</View> </View>
</View> </View>
<Text style={[styles.txtSubtitle]}>Tài liu đính kèm</Text> <Text style={[styles.txtSubtitle]}>Tài liu đính kèm</Text>
<View> <View style={{marginBottom: 15}}>
<Button <Button
title="Thêm tài liệu" title="Mẫu văn bản.PDF"
onPress={() => {}} onPress={() => {}}
backgroundColor={R.colors.blue1} backgroundColor={R.colors.blue1}
fontSize={R.sizes.sm} fontSize={R.sizes.sm}
...@@ -163,7 +194,7 @@ const NotificationDetailView = props => { ...@@ -163,7 +194,7 @@ const NotificationDetailView = props => {
textColor={R.colors.blue} textColor={R.colors.blue}
fontWeight={'600'} fontWeight={'600'}
fontFamily={R.fonts.fontMedium} fontFamily={R.fonts.fontMedium}
icon={R.images.icDownload} icon={R.images.icCancel}
iconStyle={{ iconStyle={{
width: 15, width: 15,
height: 15, height: 15,
...@@ -173,6 +204,29 @@ const NotificationDetailView = props => { ...@@ -173,6 +204,29 @@ const NotificationDetailView = props => {
}} }}
/> />
</View> </View>
<View style={styles.card}>
<Image
source={R.images.icDocument}
resizeMode="contain"
style={{width: 30, height: 30}}
/>
<Text style={styles.txtCard}>Mu văn bn.PDF</Text>
</View>
<View style={{marginVertical:15}}>
<Button
title="Tạo thông báo"
onPress={() => {}}
backgroundColor={R.colors.blue}
fontSize={R.sizes.sm}
editable={false}
height={30}
borderRadius={10}
textColor={R.colors.white}
fontWeight={'600'}
fontFamily={R.fonts.fontMedium}
/>
</View>
</View> </View>
</ScrollView> </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