Datepicker.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React from "react";
  2. import { View } from "react-native";
  3. import { Icon, SelectItem } from "@ui-kitten/components";
  4. import { Datepicker, BottomModal } from "beeshell";
  5. import * as TimeUtil from "../Utils/TimeUtil";
  6. const ForwardIcon = props => <Icon {...props} name="arrow-ios-forward" />;
  7. export default function MyDatepicker(props) {
  8. const { value, chooseDate } = props || {};
  9. const [dateValue, chooseValue] = React.useState();
  10. const bottomRef = React.useRef();
  11. return (
  12. <>
  13. <SelectItem
  14. appearance="form"
  15. style={{ flex: 1, height: 32 }}
  16. accessoryRight={ForwardIcon}
  17. title={value || " "}
  18. onPress={() => {
  19. chooseValue(value);
  20. bottomRef.current.open();
  21. }}
  22. />
  23. <BottomModal
  24. title=""
  25. cancelable
  26. ref={bottomRef}
  27. rightCallback={() => {
  28. chooseDate(dateValue);
  29. }}
  30. >
  31. <View
  32. style={{
  33. height: 200,
  34. marginBottom: 50,
  35. minHeight: 200,
  36. }}
  37. >
  38. <Datepicker
  39. proportion={[1, 1, 1]}
  40. startYear={TimeUtil.getNowYear()}
  41. numberOfYears={10}
  42. date={dateValue}
  43. onChange={date => {
  44. console.log(date);
  45. chooseValue(date);
  46. }}
  47. />
  48. </View>
  49. </BottomModal>
  50. </>
  51. );
  52. }