Skip to content

Commit fb4c0db

Browse files
author
tfomkin
committed
fix: disable ScreenWrapper scroll when isKeyboardAvoiding is true, custom bottom offset added
1 parent d65d74b commit fb4c0db

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

apps/mobile/app/(main)/chat/create.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function CreateChatScreen(): ReactElement {
4747
header: <AppHeader title={translate('TEXT_NEW_CHAT')} onGoBack={handleBackPress} />,
4848
}}
4949
safeAreaProps={{ edges: [] }}
50-
keyBoardAvoidingProps={{ enabled: !isBottomSheetInputFocused }}>
50+
keyBoardAvoidingProps={{ enabled: !isBottomSheetInputFocused, bottomOffset: 60 }}>
5151
<NoConnectionBanner isVisible={isOfflineMode} />
5252
<CreateChat
5353
onChatCreated={handleChatCreated}

libs/mobile/shared/ui/keyboard-avoiding-view/src/lib/component.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import { ComponentType } from 'react';
22
import { ScrollViewProps, StyleProp, ViewStyle } from 'react-native';
33
import { KeyboardAwareScrollView } from 'react-native-keyboard-controller';
4-
import { commonStyle } from '@open-webui-react-native/mobile/shared/ui/styles';
54

65
export type AppKeyboardAvoidingViewProps = Omit<ScrollViewProps, 'onFocus'> & {
76
onFocus?: ((event: any) => void) | null;
87
contentContainerStyleKeyboardShown?: StyleProp<ViewStyle>;
98
enabled?: boolean;
9+
bottomOffset?: number;
1010
};
1111

1212
// TODO: Research how use nativewind here
1313
export const AppKeyboardAvoidingView: ComponentType<AppKeyboardAvoidingViewProps> = ({ children, ...props }) => {
14-
const { onFocus, ...restProps } = props;
14+
const { onFocus, contentContainerStyle, bottomOffset, ...restProps } = props;
1515

1616
return (
1717
<KeyboardAwareScrollView
1818
keyboardShouldPersistTaps='handled'
1919
showsVerticalScrollIndicator={false}
20-
contentContainerStyle={commonStyle.fullFlex}
20+
contentContainerStyle={[{ flexGrow: 1 }, contentContainerStyle]}
21+
bottomOffset={bottomOffset}
2122
onFocus={onFocus ?? undefined}
2223
{...restProps}>
2324
{children}

libs/mobile/shared/ui/screen-wrapper/src/lib/component.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,20 @@ export function ScreenWrapper({
2525
isKeyboardAvoiding,
2626
keyBoardAvoidingProps,
2727
}: PropsWithChildren<ScreenWrapperProps>): ReactElement {
28-
const { header, ...restScreenProps } = screenProps || {};
28+
const { header, scrollDisabled, ...restScreenProps } = screenProps || {};
29+
30+
const effectiveScrollDisabled = isKeyboardAvoiding ? true : scrollDisabled;
31+
2932
const content = isKeyboardAvoiding ? (
3033
<AppKeyboardAvoidingView {...keyBoardAvoidingProps}>
31-
<AppScreen {...restScreenProps}>{children}</AppScreen>
34+
<AppScreen scrollDisabled={effectiveScrollDisabled as boolean} {...(restScreenProps as AppScreenProps)}>
35+
{children}
36+
</AppScreen>
3237
</AppKeyboardAvoidingView>
3338
) : (
34-
<AppScreen {...restScreenProps}>{children}</AppScreen>
39+
<AppScreen scrollDisabled={scrollDisabled as boolean} {...(restScreenProps as AppScreenProps)}>
40+
{children}
41+
</AppScreen>
3542
);
3643

3744
return (

0 commit comments

Comments
 (0)