Actionsheet.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React from "react";
  2. import { StyleSheet, View, Text } from "react-native";
  3. import {
  4. Menu,
  5. MenuItem,
  6. Layout,
  7. SelectItem,
  8. Icon,
  9. } from "@ui-kitten/components";
  10. import { useModel } from "flooks";
  11. import { Dimensions } from "react-native";
  12. import { Actionsheet } from "beeshell";
  13. const selects = (list, selectAction) => {
  14. return list.map((item) => {
  15. return <MenuItem title={item} key={item} />;
  16. });
  17. };
  18. const ForwardIcon = (props) => <Icon {...props} name='arrow-ios-forward' />;
  19. export default function myActionsheet({ list, onChange, value }) {
  20. const { cancel } = useModel("wordsModel");
  21. const datas = React.useMemo(() => {
  22. if (list && list.length > 0) {
  23. return list.map((item) => {
  24. return { label: item, value: item };
  25. });
  26. } else {
  27. return [];
  28. }
  29. }, [list]);
  30. const [bottomModalX, changeBottomModalx] = React.useState("");
  31. return (
  32. <>
  33. <SelectItem
  34. appearance='form'
  35. style={{ flex: 1 }}
  36. accessoryRight={ForwardIcon}
  37. title={value || " "}
  38. onPress={() => {
  39. bottomModalX.open();
  40. }}
  41. />
  42. <Actionsheet
  43. ref={(c) => {
  44. changeBottomModalx(c);
  45. }}
  46. header={<View />}
  47. data={list}
  48. cancelable={true}
  49. maxShowNum={4}
  50. useSafeAreaView={true}
  51. onPressConfirm={(item) => {
  52. onChange(item);
  53. }}
  54. onPressCancel={() => {
  55. console.log("cancel");
  56. }}
  57. renderItem={(item, index) => {
  58. return (
  59. <View style={styles.item}>
  60. <Text style={styles.text}>{item}</Text>
  61. </View>
  62. );
  63. }}
  64. ></Actionsheet>
  65. </>
  66. );
  67. }
  68. const styles = StyleSheet.create({
  69. backdrop: {
  70. backgroundColor: "rgba(0, 0, 0, 0.5)",
  71. },
  72. menu: {
  73. bottom: 0,
  74. },
  75. modal: {},
  76. layout: {
  77. position: "absolute",
  78. top: 0,
  79. left: 0,
  80. bottom: 0,
  81. right: 0,
  82. },
  83. text: {
  84. fontSize: 12,
  85. },
  86. item: {
  87. flexDirection: "row",
  88. paddingVertical: 10,
  89. alignItems: "center",
  90. justifyContent: "center",
  91. backgroundColor: "#fff",
  92. borderBottomWidth: 1,
  93. borderColor: "rgb(228, 233, 242)",
  94. },
  95. });