Skip to content

Commit 23bc296

Browse files
authored
Merge pull request #37 from RonasIT/PRD-2157-modal-close-button-behavior-fix
PRD-2157: modal close button on scroll behavior fix
2 parents 7d6327e + 58e9622 commit 23bc296

4 files changed

Lines changed: 54 additions & 7 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ReactElement } from 'react';
2+
import { PressableProps as GesturePressableProps } from 'react-native-gesture-handler';
3+
import { cn } from '@open-webui-react-native/mobile/shared/ui/styles';
4+
import { Icon, IconProps } from '../icon/component';
5+
import { IconName } from '../icon/types';
6+
import { GestureAppPressable } from '../pressable';
7+
import { AppSpinner } from '../spinner';
8+
9+
export interface GesturePressableIconButtonProps extends GesturePressableProps {
10+
iconName: IconName;
11+
iconProps?: Omit<IconProps, 'name'>;
12+
isLoading?: boolean;
13+
className?: string;
14+
}
15+
16+
export function GesturePressableIconButton({
17+
iconName,
18+
iconProps,
19+
isLoading,
20+
disabled,
21+
className,
22+
...pressableProps
23+
}: GesturePressableIconButtonProps): ReactElement {
24+
return (
25+
<GestureAppPressable
26+
{...pressableProps}
27+
hitSlop={8}
28+
disabled={disabled || isLoading}
29+
className={cn('p-8 disabled:opacity-30 items-center justify-center', className)}>
30+
{isLoading ? <AppSpinner size='small' /> : <Icon name={iconName} {...iconProps} />}
31+
</GestureAppPressable>
32+
);
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './component';

libs/mobile/shared/ui/ui-kit/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ export * from './sheet-header';
4141
export * from './keyboard-aware-scroll-view';
4242
export * from './pressable-search-input';
4343
export * from './full-screen-search-modal';
44+
export * from './gesture-pressable-icon-button';

libs/mobile/shared/ui/ui-kit/src/modal/component.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useState, ReactElement, PropsWithChildren, useImperativeHandle, ForwardedRef } from 'react';
2+
import { Platform } from 'react-native';
23
import Modal, { ModalProps } from 'react-native-modal';
4+
import { GesturePressableIconButton } from '../gesture-pressable-icon-button';
35
import { IconButton } from '../icon-button';
46
import { AppToast } from '../toast';
57
import { View } from '../view';
@@ -37,13 +39,23 @@ export function AppModal({ modalRef, children, ...modalProps }: AppModalProps):
3739
{isVisible && (
3840
<View className='bg-background-primary px-24 py-20 rounded-xl border border-text-secondary'>
3941
{children}
40-
<IconButton
41-
iconName='close'
42-
hitSlop={8}
43-
onPress={close}
44-
className='absolute active:opacity-1 active:bg-background-secondary bg-background-primary border border-text-secondary p-0 rounded-full items-center justify-center w-[24] h-[24] top-4 right-4'
45-
iconProps={{ className: 'color-text-primary', width: 16 }}
46-
/>
42+
{Platform.OS === 'ios' ? (
43+
<GesturePressableIconButton
44+
iconName='close'
45+
hitSlop={8}
46+
onPress={close}
47+
className='absolute active:opacity-1 active:bg-background-secondary bg-background-primary border border-text-secondary p-0 rounded-full items-center justify-center w-[24] h-[24] top-4 right-4'
48+
iconProps={{ className: 'color-text-primary', width: 16 }}
49+
/>
50+
) : (
51+
<IconButton
52+
iconName='close'
53+
hitSlop={8}
54+
onPress={close}
55+
className='absolute active:opacity-1 active:bg-background-secondary bg-background-primary border border-text-secondary p-0 rounded-full items-center justify-center w-[24] h-[24] top-4 right-4'
56+
iconProps={{ className: 'color-text-primary', width: 16 }}
57+
/>
58+
)}
4759
</View>
4860
)}
4961
<AppToast />

0 commit comments

Comments
 (0)