Skip to content

Commit

Permalink
fix: sample-app crash because of viewport changes (#2313)
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 authored Nov 15, 2023
1 parent 26d1d44 commit be241e1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions examples/SampleApp/src/components/BottomSheetOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Animated, {
withSpring,
withTiming,
} from 'react-native-reanimated';
import { KeyboardCompatibleView, useTheme, vh } from 'stream-chat-react-native';
import { KeyboardCompatibleView, useTheme, useViewport } from 'stream-chat-react-native';

import { AddMemberBottomSheet } from './AddMemberBottomSheet';
import { ConfirmationBottomSheet } from './ConfirmationBottomSheet';
Expand All @@ -44,12 +44,12 @@ export type BottomSheetOverlayProps = {
visible: boolean;
};

const screenHeight = vh(100);

export const BottomSheetOverlay = (props: BottomSheetOverlayProps) => {
const { overlayOpacity, visible } = props;

const { overlay, setOverlay } = useAppOverlayContext();
const { vh } = useViewport();
const screenHeight = vh(100);

const { reset } = useBottomSheetOverlayContext();

Expand Down
12 changes: 6 additions & 6 deletions examples/SampleApp/src/components/ChannelInfoOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import {
User,
UserMinus,
useTheme,
vh,
vw,
useViewport,
} from 'stream-chat-react-native';

import { useAppOverlayContext } from '../context/AppOverlayContext';
Expand Down Expand Up @@ -94,10 +93,6 @@ const styles = StyleSheet.create({
},
});

const screenHeight = vh(100);
const halfScreenHeight = vh(50);
const width = vw(100) - 60;

export type ChannelInfoOverlayProps = {
overlayOpacity: Animated.SharedValue<number>;
visible?: boolean;
Expand All @@ -109,6 +104,11 @@ export const ChannelInfoOverlay = (props: ChannelInfoOverlayProps) => {
const { overlay, setOverlay } = useAppOverlayContext();
const { setData } = useBottomSheetOverlayContext();
const { data, reset } = useChannelInfoOverlayContext();
const { vh, vw } = useViewport();

const screenHeight = vh(100);
const halfScreenHeight = vh(50);
const width = vw(100) - 60;

const { channel, clientId, navigation } = data || {};

Expand Down
9 changes: 5 additions & 4 deletions examples/SampleApp/src/components/UserInfoOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
User,
UserMinus,
useTheme,
vh,
useViewport,
} from 'stream-chat-react-native';

import { useAppOverlayContext } from '../context/AppOverlayContext';
Expand Down Expand Up @@ -96,9 +96,6 @@ const styles = StyleSheet.create({
},
});

const screenHeight = vh(100);
const halfScreenHeight = vh(50);

export type UserInfoOverlayProps = {
overlayOpacity: Animated.SharedValue<number>;
visible?: boolean;
Expand All @@ -111,6 +108,10 @@ export const UserInfoOverlay = (props: UserInfoOverlayProps) => {
const { client } = useChatContext<StreamChatGenerics>();
const { setData } = useBottomSheetOverlayContext();
const { data, reset } = useUserInfoOverlayContext();
const { vh } = useViewport();

const screenHeight = vh(100);
const halfScreenHeight = vh(50);

const { channel, member, navigation } = data || {};

Expand Down
1 change: 1 addition & 0 deletions package/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './useAppStateListener';
export * from './useStreami18n';
export * from './useViewport';

0 comments on commit be241e1

Please sign in to comment.