react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Offset in bottomTabs?

Open bneigher opened this issue 7 years ago • 6 comments

Issue Description

Is there any way to set offsets for the padding or margins in the bottom tabs? Having a rough time getting a good grasp on the bottom tabs since we can't pass custom components for the icon slots

image

Steps to Reproduce / Code Snippets / Screenshots

export const MainStack = () => {
  return {
    stack: {
      children: [
        {
          component: {
            id: "Diary",
            name: "Diary"
          }
        }
      ]
    },
    bottomTabs: {
      options: {
        bottomTabs: {
          animate: true,
          drawBehind: false,
          backgroundColor: PRIMARY.DARK,
          selectedIconColor: PRIMARY.LIGHT
        }
      },
      children: [
        {
          stack: {
            children: [
              {
                component: {
                  name: "Profile"
                }
              }
            ],
            options: {
              bottomTab: {
                text: "Profile",
                icon: userIcon,
                iconColor: GRAY_SCALE.GRAY,
                selectedIconColor: PRIMARY.LIGHT,
                textColor: GRAY_SCALE.GRAY,
                selectedTextColor: PRIMARY.LIGHT
              }
            }
          }
        },
        {
          stack: {
            children: [
              {
                component: {
                  name: "Add"
                }
              }
            ],
            options: {
              bottomTab: {
                icon: require("../assets/img/icons/add-icon-75.png")
              }
            }
          }
        },
        {
          stack: {
            children: [
              {
                component: {
                  name: "Diary"
                }
              }
            ],
            options: {
              bottomTab: {
                text: "Diary",
                icon: calendarIcon,
                iconColor: GRAY_SCALE.GRAY,
                selectedIconColor: PRIMARY.LIGHT,
                textColor: GRAY_SCALE.GRAY,
                selectedTextColor: PRIMARY.LIGHT
              }
            }
          }
        }
      ]
    }
  };
};

The text is not the culpret

image

Desired:

Screen Shot 2019-08-01 at 5 44 36 PM

Environment

  • React Native Navigation version: 3.0.0-alpha.8
  • React Native version: 0.60.4
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator / Physical iPhone X. Debug/Release

bneigher avatar Aug 01 '19 21:08 bneigher

options: {
    bottomTab: {
        iconInsets: { top: 2, left: 0, bottom: 0, right: 0 },
    }
}

bneigher avatar Aug 06 '19 17:08 bneigher

Hi @bneigher How you have manage the center round icon as it is too small in android .

iparshantnagpal avatar Aug 27 '19 16:08 iparshantnagpal

@ParshantAroras yea it's a very common use case that it seems is not possible without a "hack"

If your application always has the bottomTabs showing this should be a good enough solution: I have an absolutely positioned overlay which is the circular round button, and it's position is always over the center (invisible) icon in the middle position on the bottom tabs. Its nice because now you'll have complete control over the icon (mine rotates when on a specific screen)

If your application sometimes doesn't show the bottomTabs, like mine, we've got to do a bit of work in tapping into each scene change event, and having a smart way to make the component in the overlay invisible when it should be hidden, mapping as closely to it feeling like it's just part of the bottomTabs. It's not perfect and there is some delay in showing / hiding the circular icon against when the bottomTabs show / hide, but it's pretty darn close.

bneigher avatar Aug 27 '19 18:08 bneigher

Hi @bneigher Can you please share your code . How you handle that . So that it would be easy for me to implement that

parshantnagpalSmartData avatar Aug 29 '19 11:08 parshantnagpalSmartData

@ParshantAroras It's all going to be pretty subjective...

But in general:

This piece controls opening my custom circle button component (you need to build this)

Navigation.showOverlay({
    component: {
      name: 'common.AddIcon',
      passProps: {},
      options: {
        statusBar: {},
        overlay: {
          interceptTouchOutside: false,
        },
      },
    },
  });

And the circle component:

...
const StyledAddButtonContainer = styled(View)`
  position: absolute;
  justify-content: center;
  align-items: center;
  left: ${screenWidth / 2 - 35};

  bottom: ${getBottomSpace() ? 30 : 0};
  width: 70;
  height: 70;
  margin: auto;
`;
const AddIconContainer = styled(Animated.View)`
  background-color: 'purple';
  border-radius: 50;
  height: 70;
  width: 70;
  border-color: 'black';
  border-width: 6;
  justify-content: center;
  align-items: center;
`;
...
render () {
   return (
    <StyledAddButtonContainer>
        <TouchableWithoutFeedback
          onPress={() => {
           console.log('my thing')
          }}>
          <AddIconContainer
            style={{
              transform: [{ rotate }],
            }}>
            <FontAwesome5
              solid
              size={32}
              name="plus"
              color={GRAY_SCALE.WHITE}
            />
          </AddIconContainer>
        </TouchableWithoutFeedback>
      </StyledAddButtonContainer>
   )
}

bneigher avatar Aug 29 '19 20:08 bneigher

Thanks @bneigher for reply.

iparshantnagpal avatar Aug 30 '19 15:08 iparshantnagpal