简体   繁体   English

带有 FloatingActionButton 组件的 React-Native-Popup-Menu 无法使用 MenuTrigger 触发

[英]React-Native-Popup-Menu with FloatingActionButton Component cannot trigger with MenuTrigger

I would like to use react-native-popup-menu and react-native-floating-action-button components together.我想一起使用react-native-popup-menureact-native-floating-action-button组件。 I've tried:我试过了:

<MenuTrigger>
    <FloatingActionButton
        size={56}
        textDisable
        iconName="directions"
        iconType="material-icons"
        shadowColor="#000"
        iconColor="white"
        backgroundColor="#405914"
    />
</MenuTrigger>

This code does not trigger the MenuTrigger because FloatingActionButton's onPress is triggered.此代码不会触发 MenuTrigger,因为触发了 FloatingActionButton 的 onPress。


I also tried this kinds of stuff:我也试过这种东西:

<MenuTrigger customStyles={{ TriggerTouchableComponent: FloatingActionButton }} />

This one's trigger is working with MenuTrigger but I cannot customize the FAB button's styling.这个触发器与 MenuTrigger 一起使用,但我无法自定义 FAB 按钮的样式。

Can you provide me a solution?你能给我一个解决方案吗? :) :)

Thank you谢谢

According to doc you could use triggerTouchable . 根据文档,您可以使用triggerTouchable

      <MenuTrigger
        customStyles={{
          TriggerTouchableComponent: Button,
          triggerTouchable: { title: 'Select (Custom Touchables)' },
        }}
      />

Using react-native-popup-menu version 0.15.12 I am able now to achieve this with使用react-native-popup-menu版本 0.15.12 我现在可以用

<MenuTrigger>
  <MyCustomButtonComponent>
    <Icon ...>
  </MyCustomButtonComponent>
</MenuTrigger>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM