Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: dynamicSzing doesn't work in Android with Bottom Sheet Modal #2053

Open
zhrgns opened this issue Nov 20, 2024 · 2 comments
Open

[Bug]: dynamicSzing doesn't work in Android with Bottom Sheet Modal #2053

zhrgns opened this issue Nov 20, 2024 · 2 comments
Labels
bug Something isn't working no-issue-activity

Comments

@zhrgns
Copy link

zhrgns commented Nov 20, 2024

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

Android

What happened?

I have an issue with Bottom Sheet Modal on Android. Created a component for CustomBottomSheet. Then Used Provider in screen where i want to call my custom sheet component. And when i click to open sheet, sheet extends to full screen size, it happens only in android simulator. Here are snapshots.

Screenshot_1732114551

Simulator Screenshot - iPhone 15 Pro - 2024-11-20 at 17 56 00

Reproduction steps

    type Props = {
  icon?: FC<SvgProps> | string;
  iconColor?: string;
  title: string;
  subtitle?: string;
  iconContainerStyle?: ViewStyle;
  children?: React.ReactNode;
  button1Props?: ButtonProps;
  button2Props?: ButtonProps;
  enablePanDownToClose?: boolean;
  disableDraggableIcon?: boolean;
  onChange?: (...args: any) => void;
} & Omit<BottomSheetModalProps, 'children'>;

const DynamicBottomSheet = React.forwardRef<RefObject<any>, Props>(
  (
    {
      icon: Icon,
      iconColor,
      title,
      subtitle,
      iconContainerStyle,
      children,
      button1Props,
      button2Props,
      enablePanDownToClose = true,
      disableDraggableIcon = false,
      onChange,
      ...rest
    },
    ref: Ref<any> | undefined
  ) => {
    const { bottomWithPadding } = useSafeArea();

    const renderBackdrop = useCallback(
      (props: any) => (
        <BottomSheetBackdrop
          {...props}
          disappearsOnIndex={-1}
          appearsOnIndex={1}
        />
      ),
      []
    );

    return (
      <BottomSheetModal
        ref={ref}
        onChange={onChange}
        enablePanDownToClose={enablePanDownToClose}
        backdropComponent={renderBackdrop}
        handleIndicatorStyle={
          disableDraggableIcon
            ? styles.disabledDraggableIcon
            : styles.draggableIcon
        }
        {...rest}>
        <BottomSheetView
          style={[
            styles.contentContainer,
            paddingBottom(bottomWithPadding(24)),
            { maxHeight: 330 },
          ]}>
          {Icon ? (
            <View style={[styles.icon, iconContainerStyle]}>
              {typeof Icon === 'string' &&
              Icon?.toString().startsWith('http') ? (
                <Image
                  svgType="normal"
                  image={Icon}
                  style={[width(24), height(24)]}
                />
              ) : (
                <Icon height={24} width={24} color={iconColor} />
              )}
            </View>
          ) : null}
          <Text pl semibold style={marginTop(20)}>
            {title}
          </Text>
          {subtitle ? (
            <Text ps regular style={styles.subText}>
              {subtitle}
            </Text>
          ) : null}
          {children}
          <View style={marginTop(24)}>
            {button1Props ? <Button size="l" {...button1Props} /> : null}
            {button2Props ? (
              <>
                <Separator size={12} type="vertical" />
                <Button size="l" {...button2Props} />
              </>
            ) : null}
          </View>
        </BottomSheetView>
      </BottomSheetModal>
    );
  }
);

export default DynamicBottomSheet;

Reproduction sample

https://snack.expo.dev/6HM9hNjYc88gceakoz9bN

Relevant log output

No response

@zhrgns zhrgns added the bug Something isn't working label Nov 20, 2024
@zhrgns
Copy link
Author

zhrgns commented Nov 20, 2024

i had a style named contentContainer which includes flex:1, it causes this issue in android. removed and fixed this bug.

@zhrgns zhrgns closed this as completed Nov 20, 2024
@zhrgns zhrgns reopened this Nov 20, 2024
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity
Projects
None yet
Development

No branches or pull requests

1 participant