Actionsheet.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React from "react";
  2. import { StyleSheet, View, Text } from "react-native";
  3. import {
  4. SelectItem,
  5. Icon,
  6. } from "@ui-kitten/components";
  7. import { Actionsheet } from "beeshell";
  8. const styles = StyleSheet.create({
  9. backdrop: {
  10. backgroundColor: "rgba(0, 0, 0, 0.5)",
  11. },
  12. menu: {
  13. bottom: 0,
  14. },
  15. modal: {},
  16. layout: {
  17. position: "absolute",
  18. top: 0,
  19. left: 0,
  20. bottom: 0,
  21. right: 0,
  22. },
  23. text: {
  24. fontSize: 12,
  25. },
  26. item: {
  27. flexDirection: "row",
  28. paddingVertical: 10,
  29. alignItems: "center",
  30. justifyContent: "center",
  31. backgroundColor: "#fff",
  32. borderBottomWidth: 1,
  33. borderColor: "rgb(228, 233, 242)",
  34. },
  35. });
  36. const ForwardIcon = (props) => <Icon {...props} name='arrow-ios-forward' />;
  37. export default function myActionsheet({ list, onChange, value }) {
  38. const [bottomModalX, changeBottomModalx] = React.useState("");
  39. return (
  40. <>
  41. <SelectItem
  42. appearance='form'
  43. style={{ flex: 1 }}
  44. accessoryRight={ForwardIcon}
  45. title={value || " "}
  46. onPress={() => {
  47. bottomModalX.open();
  48. }}
  49. />
  50. <Actionsheet
  51. ref={(c) => {
  52. changeBottomModalx(c);
  53. }}
  54. header={<View />}
  55. data={list}
  56. cancelable
  57. maxShowNum={4}
  58. useSafeAreaView
  59. onPressConfirm={(item) => {
  60. onChange(item);
  61. }}
  62. onPressCancel={() => {
  63. }}
  64. renderItem={(item) => {
  65. return (
  66. <View style={styles.item}>
  67. <Text style={styles.text}>{item}</Text>
  68. </View>
  69. );
  70. }}
  71. />
  72. </>
  73. );
  74. }