Actionsheet.js 1.6 KB

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