Datepicker.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React from "react";
  2. import PropTypes from "prop-types";
  3. import {
  4. StyleSheet,
  5. TouchableOpacity,
  6. LayoutAnimation,
  7. Platform,
  8. UIManager,
  9. View,
  10. } from "react-native";
  11. import {
  12. CheckBox,
  13. Layout,
  14. Modal,
  15. Button,
  16. Card,
  17. Text,
  18. MenuItem,
  19. Icon,
  20. SelectItem,
  21. } from "@ui-kitten/components";
  22. import { Datepicker, BottomModal } from "beeshell";
  23. import moment from "moment";
  24. import * as TimeUtil from "../Utils/TimeUtil";
  25. const ForwardIcon = props => <Icon {...props} name='arrow-ios-forward' />;
  26. export default function MyDatepicker(props) {
  27. const { value, chooseDate } = props || {};
  28. const [dateValue, chooseValue] = React.useState();
  29. const [bottomModal, setBottomModal] = React.useState();
  30. return (
  31. <>
  32. <SelectItem
  33. appearance='form'
  34. style={{ flex: 1, height: 32 }}
  35. accessoryRight={ForwardIcon}
  36. title={value || " "}
  37. onPress={() => {
  38. bottomModal.open();
  39. }}
  40. />
  41. <BottomModal
  42. title=''
  43. cancelable={true}
  44. ref={c => setBottomModal(c)}
  45. rightCallback={() => {
  46. chooseDate(dateValue);
  47. }}
  48. >
  49. <View
  50. style={{
  51. height: 200,
  52. marginBottom: 50,
  53. minHeight: 200,
  54. }}
  55. >
  56. <Datepicker
  57. proportion={[1, 1, 1]}
  58. startYear={TimeUtil.getNowYear()}
  59. numberOfYears={10}
  60. date={TimeUtil.getDateStr()}
  61. onChange={date => {
  62. chooseValue(date);
  63. }}
  64. />
  65. </View>
  66. </BottomModal>
  67. </>
  68. );
  69. }