Skip to content

Commit a3def28

Browse files
muhsin-kiamsivin
andauthored
feat: Image bubble improvements (#928)
* chore: image scaling issues * chore: remove lightbox * Update pnpm-lock.yaml * chore: Update version --------- Co-authored-by: iamsivin <[email protected]>
1 parent 02ccfea commit a3def28

File tree

9 files changed

+128
-154
lines changed

9 files changed

+128
-154
lines changed

app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default ({ config }: ConfigContext): ExpoConfig => {
44
return {
55
name: 'Chatwoot',
66
slug: process.env.EXPO_PUBLIC_APP_SLUG || 'chatwoot-mobile',
7-
version: '4.0.17',
7+
version: '4.0.18',
88
orientation: 'portrait',
99
icon: './assets/icon.png',
1010
userInterfaceStyle: 'light',

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chatwoot/mobile-app",
3-
"version": "4.0.17",
3+
"version": "4.0.18",
44
"scripts": {
55
"start": "expo start --dev-client",
66
"start:production": "expo start --no-dev --minify",
@@ -33,12 +33,12 @@
3333
"adb:connect": "adb reverse tcp:9090 tcp:9090"
3434
},
3535
"dependencies": {
36-
"@alantoa/lightbox": "0.3.1",
3736
"@chatwoot/markdown-to-txt": "^2.0.4",
3837
"@chatwoot/react-native-widget": "^0.0.21",
3938
"@chatwoot/utils": "^0.0.33",
4039
"@gorhom/bottom-sheet": "^5.1.2",
4140
"@kesha-antonov/react-native-action-cable": "^1.1.5",
41+
"@nandorojo/galeria": "^1.2.0",
4242
"@notifee/react-native": "^9.1.1",
4343
"@react-native-async-storage/async-storage": "^1.23.1",
4444
"@react-native-clipboard/clipboard": "^1.6.1",
@@ -154,7 +154,6 @@
154154
"react-native-autoheight-webview",
155155
"redux-persist",
156156
"rn-fetch-blob",
157-
"@alantoa/lightbox",
158157
"ffmpeg-kit-react-native",
159158
"@chatwoot/markdown-to-txt",
160159
"@chatwoot/react-native-widget",

pnpm-lock.yaml

Lines changed: 53 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/screens/chat-screen/ChatScreen.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useEffect } from 'react';
22
import PagerView, { PagerViewOnPageSelectedEvent } from 'react-native-pager-view';
33
import Animated from 'react-native-reanimated';
44
import { SafeAreaView } from 'react-native-safe-area-context';
5-
import { LightBoxProvider } from '@alantoa/lightbox';
65
import { NativeStackScreenProps } from '@react-navigation/native-stack';
76

87
import { ChatHeaderContainer } from './components';
@@ -86,12 +85,7 @@ const ChatScreenWrapper = (props: ChatScreenProps) => {
8685

8786
return (
8887
<React.Fragment>
89-
<ChatHeaderContainer
90-
name={name || ''}
91-
imageSrc={{
92-
uri: thumbnail || '',
93-
}}
94-
/>
88+
<ChatHeaderContainer name={name || ''} imageSrc={{ uri: thumbnail || '' }} />
9589
<ConversationPagerView {...props} />
9690
</React.Fragment>
9791
);
@@ -143,11 +137,9 @@ const ChatScreen = (props: ChatScreenProps) => {
143137
if (conversation) {
144138
return (
145139
<SafeAreaView edges={['top']} style={tailwind.style('flex-1 bg-white')}>
146-
<LightBoxProvider>
147-
<ChatWindowProvider conversationId={conversationId}>
148-
<ChatScreenWrapper {...props} />
149-
</ChatWindowProvider>
150-
</LightBoxProvider>
140+
<ChatWindowProvider conversationId={conversationId}>
141+
<ChatScreenWrapper {...props} />
142+
</ChatWindowProvider>
151143
<ActionBottomSheet />
152144
</SafeAreaView>
153145
);
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
import React from 'react';
2-
import Animated from 'react-native-reanimated';
3-
import { LightBox, LightBoxProps } from '@alantoa/lightbox';
42
import { Image } from 'expo-image';
3+
import { Galeria } from '@nandorojo/galeria';
54
import { tailwind } from '@/theme';
65

7-
const AnimatedExpoImage = Animated.createAnimatedComponent(Image);
8-
96
type ImageCellProps = {
107
imageSrc: string;
118
};
129

13-
type ImageContainerProps = Pick<ImageCellProps, 'imageSrc'> &
14-
Pick<LightBoxProps, 'width' | 'height'>;
10+
type ImageContainerProps = Pick<ImageCellProps, 'imageSrc'> & {
11+
width?: number;
12+
height?: number;
13+
};
1514

1615
export const ImageBubbleContainer = (props: ImageContainerProps) => {
17-
const { imageSrc, height: lightboxH, width: lightboxW } = props;
16+
const { imageSrc, height = 215, width = 400 } = props;
1817

1918
return (
20-
<LightBox
21-
width={lightboxW}
22-
height={lightboxH}
23-
imgLayout={{ width: lightboxW, height: lightboxH }}
24-
tapToClose={true}>
25-
<AnimatedExpoImage
26-
source={{ uri: imageSrc }}
27-
contentFit="cover"
28-
style={[tailwind.style('h-full w-full bg-gray-100 overflow-hidden')]}
29-
/>
30-
</LightBox>
19+
<Galeria urls={[imageSrc]}>
20+
<Galeria.Image>
21+
<Image
22+
source={{ uri: imageSrc }}
23+
contentFit="cover"
24+
style={[
25+
tailwind.style('h-full w-full bg-gray-100 overflow-hidden'),
26+
{ width: width, height: height },
27+
]}
28+
/>
29+
</Galeria.Image>
30+
</Galeria>
3131
);
3232
};
3333

@@ -36,7 +36,7 @@ export const ImageBubble = (props: ImageCellProps) => {
3636

3737
return (
3838
<React.Fragment>
39-
<ImageBubbleContainer {...{ imageSrc }} width={300} height={215} />
39+
<ImageBubbleContainer {...{ imageSrc }} />
4040
</React.Fragment>
4141
);
4242
};

src/screens/chat-screen/components/message-components/ImageCell.tsx

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react';
2-
import { Dimensions, Text } from 'react-native';
2+
import { Text } from 'react-native';
33
import Animated, { Easing, FadeIn } from 'react-native-reanimated';
4-
import { LightBox, LightBoxProps } from '@alantoa/lightbox';
5-
import { Image, ImageBackground } from 'expo-image';
4+
import { ImageBackground } from 'expo-image';
65
import { tailwind } from '@/theme';
76
import { Channel, Message, MessageStatus, UnixTimestamp } from '@/types';
87
import { unixTimestampToReadableTime } from '@/utils';
@@ -11,10 +10,6 @@ import { MenuOption, MessageMenu } from '../message-menu';
1110
import { MESSAGE_TYPES } from '@/constants';
1211
import { DeliveryStatus } from './DeliveryStatus';
1312

14-
const { width, height } = Dimensions.get('screen');
15-
16-
const AnimatedExpoImage = Animated.createAnimatedComponent(Image);
17-
1813
type ImageCellProps = {
1914
imageSrc: string;
2015
shouldRenderAvatar: boolean;
@@ -29,28 +24,8 @@ type ImageCellProps = {
2924
errorMessage?: string;
3025
};
3126

32-
type ImageContainerProps = Pick<ImageCellProps, 'imageSrc'> &
33-
Pick<LightBoxProps, 'width' | 'height'>;
34-
35-
export const ImageContainer = (props: ImageContainerProps) => {
36-
const { imageSrc, height: lightboxH, width: lightboxW } = props;
37-
return (
38-
<LightBox
39-
width={lightboxW}
40-
height={lightboxH}
41-
imgLayout={{ height: height * 0.8, width: width * 0.8 }}
42-
tapToClose={false}>
43-
<AnimatedExpoImage
44-
source={{ uri: imageSrc }}
45-
contentFit="contain"
46-
style={[tailwind.style('h-full w-full bg-gray-100 overflow-hidden')]}
47-
/>
48-
</LightBox>
49-
);
50-
};
5127
export const ImageCell = (props: ImageCellProps) => {
5228
const {
53-
imageSrc,
5429
shouldRenderAvatar,
5530
messageType,
5631
sender,
@@ -111,7 +86,6 @@ export const ImageCell = (props: ImageCellProps) => {
11186
: ''
11287
: '',
11388
)}>
114-
<ImageContainer {...{ imageSrc }} width={300} height={215} />
11589
<Animated.View pointerEvents={'none'}>
11690
<ImageBackground
11791
source={require('../../../../assets/local/ImageCellTimeStampOverlay.png')}

src/screens/chat-screen/components/message-list/stories/EmailMessageList.stories.tsx

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { configureStore, createSlice } from '@reduxjs/toolkit';
88
import { tailwind } from '@/theme';
99
import { MessagesList } from '../MessagesList';
1010
import { EMAIL_MESSAGES } from './mock-data/simpleEmail';
11-
import { LightBoxProvider } from '@alantoa/lightbox';
1211
import { ChatWindowProvider, RefsProvider } from '@/context';
1312
import { Provider } from 'react-redux';
1413
import { getAllGroupedMessages } from './mock-data/helper';
@@ -33,12 +32,7 @@ const mockConversationSlice = createSlice({
3332
initialState: {
3433
ids: [29],
3534
entities: {
36-
29: {
37-
id: 29,
38-
status: 'open',
39-
channel: 'Channel::Email',
40-
messages: ALL_MESSAGES_MOCKDATA,
41-
},
35+
29: { id: 29, status: 'open', channel: 'Channel::Email', messages: ALL_MESSAGES_MOCKDATA },
4236
},
4337
},
4438
reducers: {},
@@ -67,22 +61,20 @@ export const EmailMessageList: Story = {
6761
<BottomSheetModalProvider>
6862
<RefsProvider>
6963
<KeyboardProvider>
70-
<LightBoxProvider>
71-
<ChatWindowProvider conversationId={29}>
72-
<ScrollView contentContainerStyle={tailwind.style('flex')}>
73-
<PlatformSpecificKeyboardWrapperComponent
74-
style={tailwind.style('flex-1 bg-white')}
75-
interpolator="linear">
76-
<MessagesList
77-
messages={ALL_MESSAGES_MOCKDATA}
78-
isFlashListReady={false}
79-
setFlashListReady={() => {}}
80-
onEndReached={() => {}}
81-
/>
82-
</PlatformSpecificKeyboardWrapperComponent>
83-
</ScrollView>
84-
</ChatWindowProvider>
85-
</LightBoxProvider>
64+
<ChatWindowProvider conversationId={29}>
65+
<ScrollView contentContainerStyle={tailwind.style('flex')}>
66+
<PlatformSpecificKeyboardWrapperComponent
67+
style={tailwind.style('flex-1 bg-white')}
68+
interpolator="linear">
69+
<MessagesList
70+
messages={ALL_MESSAGES_MOCKDATA}
71+
isFlashListReady={false}
72+
setFlashListReady={() => {}}
73+
onEndReached={() => {}}
74+
/>
75+
</PlatformSpecificKeyboardWrapperComponent>
76+
</ScrollView>
77+
</ChatWindowProvider>
8678
</KeyboardProvider>
8779
</RefsProvider>
8880
</BottomSheetModalProvider>

0 commit comments

Comments
 (0)