ModalOption.js 5.47 KB
Newer Older
Giang Tran committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import React, {useState} from 'react';
import {
  Alert,
  Modal,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import {
  getFontXD,
  HEIGHTXD,
  WIDTH,
  HEIGHT,
  WIDTHXD,
} from '../../config/Functions';
import R from '../../assets/R';
import Block from '../Block';
import DropDownPicker from 'react-native-dropdown-picker';
import Icon from 'react-native-vector-icons/Ionicons';
21 22
import I18n from '../../helper/i18/i18n';
import AppText from '../AppText';
Giang Tran committed
23 24 25 26 27 28
// import DateTimePickerModal from 'react-native-modal-datetime-picker';

const ModalOption = (props) => {
  const {isOpen, closeModal, onChangePicker, onClick} = props;
  const [isDatePickerVisible, setDatePickerVisibility] = useState(false);

Giang Tran committed
29
  const dateConfirm = (props) => {};
Giang Tran committed
30 31 32 33 34 35 36 37 38 39 40 41 42

  return (
    <View style={styles.centeredView}>
      <Modal animationType="slide" transparent={true} visible={isOpen}>
        <View style={styles.centeredView}>
          <View style={styles.container}>
            <View
              style={{
                flexDirection: 'row',
                justifyContent: 'space-between',
                alignItems: 'center',
              }}>
              <View />
43
              <AppText style={styles.modalText} i18nKey={('RequestFilter')}/>
Giang Tran committed
44 45 46 47 48 49
              <TouchableOpacity onPress={closeModal}>
                <Icon name={'close-outline'} size={22} />
              </TouchableOpacity>
            </View>

            <View style={{flex: 1, paddingVertical: 10}}>
50
              <AppText style={styles.txtTitle} i18nKey={('Status')}/>
Giang Tran committed
51 52 53
              <DropDownPicker
                zIndex={5}
                items={[
54 55 56
                  {label: I18n.t('Waiting'), value: 1},
                  {label: I18n.t('Success'), value: 2},
                  {label: I18n.t('Failed'), value: 3},
Giang Tran committed
57 58 59 60 61 62
                ]}
                selectedLabelStyle={{
                  color: R.colors.black,
                  fontSize: getFontXD(42),
                }}
                containerStyle={{height: HEIGHT(40)}}
63
                placeholder={I18n.t('SelectRequestStatus')}
Giang Tran committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77
                style={{backgroundColor: '#fafafa', marginTop: 4}}
                itemStyle={{
                  justifyContent: 'flex-start',
                  color: R.colors.black,
                }}
                placeholderStyle={{color: 'black'}}
                dropDownStyle={{
                  backgroundColor: '#fafafa',
                }}
                onChangeItem={(item) => onChangePicker(item.value)}
              />
              <View style={{marginTop: 10}}>
                <Block row>
                  <Block>
78
                    <AppText style={styles.txtTitle} i18nKey={('FromDate')}/>
Giang Tran committed
79 80 81 82 83 84 85
                    <TouchableOpacity
                      onPress={() => setDatePickerVisibility(true)}
                      style={styles.datePicker}>
                      <Text>20/01/2020</Text>
                    </TouchableOpacity>
                  </Block>
                  <Block>
86
                    <AppText style={styles.txtTitle} i18nKey={('ToDate')}/>
Giang Tran committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
                    <TouchableOpacity
                      onPress={() => setDatePickerVisibility(true)}
                      style={styles.datePicker}>
                      <Text>20/01/2020</Text>
                    </TouchableOpacity>
                  </Block>
                </Block>
              </View>
            </View>

            {/*<DateTimePickerModal*/}
            {/*  isVisible={isDatePickerVisible}*/}
            {/*  mode="date"*/}
            {/*  maximumDate={new Date()}*/}
            {/*  onConfirm={dateConfirm}*/}
            {/*  onCancel={() => setDatePickerVisibility(false)}*/}
            {/*/>*/}

            <View
              style={{
                flexDirection: 'row',
                justifyContent: 'center',
                alignItems: 'center',
              }}>
              <TouchableOpacity onPress={onClick}>
112
                <Text style={styles.txtBtn}>{I18n.t('Ok')}</Text>
Giang Tran committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
              </TouchableOpacity>
            </View>
          </View>
        </View>
      </Modal>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    width: WIDTHXD(800),
    height: HEIGHTXD(800),
    backgroundColor: 'white',
    padding: 10,
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,
    elevation: 3,
    borderRadius: 10,
  },
  centeredView: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'rgba(0, 0, 0, 0.3)',
  },
  modalView: {
    margin: 20,
    backgroundColor: 'white',
    borderRadius: 20,
    padding: 35,
    alignItems: 'center',
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,
    elevation: 3,
  },
  openButton: {
    backgroundColor: '#F194FF',
    borderRadius: 20,
    elevation: 2,
  },
  textStyle: {
    color: 'white',
    fontWeight: 'bold',
    textAlign: 'center',
  },
  modalText: {
    fontSize: getFontXD(52),
    color: R.colors.txtMain,
    fontWeight: 'bold',
  },
  txtBtn: {
    fontSize: getFontXD(52),
    color: R.colors.main,
    fontWeight: 'bold',
  },
  txtTitle: {
    fontSize: getFontXD(36),
    color: R.colors.color777,
  },
  datePicker: {
    marginTop: 5,
    width: WIDTH(100),
    borderWidth: 0.8,
    borderColor: R.colors.borderGray,
    paddingVertical: 5,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 5,
    height: 30,
  },
});

export default ModalOption;