Skip to content

Commit a740c7a

Browse files
authored
fix: theming fixes (avatar, reaction pill, force message alignment) (#3728)
## 🎯 Goal A few small fixes for issues spotted during AI skill tests: - `avatar` theming key wasn't used and had an outdated shape. It's technically a breaking change, but since the shape is broken currently, it should be fine - Adds theme keys to fully style the reaction pill's selected and pressed states (previously only the background could've been changed) - Two small fix for `forceAlignMessages="'left'"` setting ## 🛠 Implementation details <!-- Provide a description of the implementation --> ## 🎨 UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## 🧪 Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## ☑️ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent dbecc8e commit a740c7a

6 files changed

Lines changed: 27 additions & 27 deletions

File tree

package/src/components/Message/MessageItemView/MessageContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const MessageContentWithContext = (props: MessageContentPropsWithContext) => {
190190
let computedBottomRightRadius = components.messageBubbleRadiusGroupBottom;
191191
if (isBottomOrSingle) {
192192
// add relevant sharp corner (the "tail")
193-
if (isMyMessage) {
193+
if (alignment === 'right') {
194194
computedBottomRightRadius = components.messageBubbleRadiusTail;
195195
} else {
196196
computedBottomLeftRadius = components.messageBubbleRadiusTail;
@@ -208,14 +208,14 @@ const MessageContentWithContext = (props: MessageContentPropsWithContext) => {
208208

209209
return style;
210210
}, [
211+
alignment,
211212
backgroundColor,
212213
borderBottomLeftRadius,
213214
borderBottomRightRadius,
214215
borderRadius,
215216
borderTopLeftRadius,
216217
borderTopRightRadius,
217218
groupStyles,
218-
isMyMessage,
219219
]);
220220

221221
const { setNativeScrollability } = useMessageListItemContext();

package/src/components/Message/MessageItemView/MessageItemView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const MessageItemViewWithContext = (props: MessageItemViewPropsWithContext) => {
221221
<View
222222
style={[
223223
styles.contentContainer,
224-
isMyMessage ? styles.rightAlignItems : styles.leftAlignItems,
224+
alignment === 'right' ? styles.rightAlignItems : styles.leftAlignItems,
225225
isMessageErrorType ? errorContainer : {},
226226
]}
227227
testID='message-components'

package/src/components/Message/MessageItemView/ReactionList/ReactionListItemWrapper.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export const ReactionListItemWrapper = (props: ReactionListItemWrapperProps) =>
2828
? semantics.backgroundUtilityPressed
2929
: semantics.reactionBg,
3030
},
31+
selected && styles.containerSelected,
32+
pressed && styles.containerPressed,
3133
style,
3234
]}
3335
{...rest}
@@ -43,7 +45,7 @@ const useStyles = () => {
4345
theme: {
4446
semantics,
4547
messageItemView: {
46-
reactionListItemWrapper: { wrapper, container },
48+
reactionListItemWrapper: { wrapper, container, containerSelected, containerPressed },
4749
},
4850
},
4951
} = useTheme();
@@ -61,11 +63,17 @@ const useStyles = () => {
6163
gap: primitives.spacingXxs,
6264
...container,
6365
},
66+
containerPressed: {
67+
...containerPressed,
68+
},
69+
containerSelected: {
70+
...containerSelected,
71+
},
6472
wrapper: {
6573
backgroundColor: semantics.reactionBg,
6674
borderRadius: primitives.radiusMax,
6775
...wrapper,
6876
},
6977
});
70-
}, [semantics, wrapper, container]);
78+
}, [semantics, wrapper, container, containerSelected, containerPressed]);
7179
};

package/src/components/ui/Avatar/Avatar.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const Avatar = (props: AvatarProps) => {
8585

8686
const useStyles = () => {
8787
const {
88-
theme: { semantics },
88+
theme: { avatar, semantics },
8989
} = useTheme();
9090
const { borderCoreOpacitySubtle } = semantics;
9191
return useMemo(
@@ -94,15 +94,19 @@ const useStyles = () => {
9494
border: {
9595
borderColor: borderCoreOpacitySubtle,
9696
borderWidth: 1,
97+
...avatar.border,
9798
},
9899
container: {
99100
alignItems: 'center',
100101
borderRadius: primitives.radiusMax,
101102
justifyContent: 'center',
102103
overflow: 'hidden',
104+
...avatar.container,
105+
},
106+
image: {
107+
...avatar.image,
103108
},
104-
image: {},
105109
}),
106-
[borderCoreOpacitySubtle],
110+
[avatar.border, avatar.container, avatar.image, borderCoreOpacitySubtle],
107111
);
108112
};

package/src/components/ui/Avatar/AvatarGroup.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { UserAvatar, UserAvatarProps } from './UserAvatar';
1111

1212
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
1313
import { PeopleIcon } from '../../../icons/users';
14-
import { primitives } from '../../../theme';
1514
import { BadgeCount, BadgeCountProps, OnlineIndicator, OnlineIndicatorProps } from '../Badge';
1615

1716
export type AvatarGroupProps = {
@@ -217,7 +216,6 @@ const useUserAvatarGroupStyles = () => {
217216
userAvatarWrapper: {
218217
borderWidth: 2,
219218
borderColor: semantics.borderCoreInverse,
220-
borderRadius: primitives.radiusMax,
221219
},
222220
onlineIndicatorWrapper: {
223221
position: 'absolute',

package/src/contexts/themeContext/utils/theme.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
type TextStyle,
66
type ViewStyle,
77
} from 'react-native';
8-
import type { CircleProps } from 'react-native-svg';
98

109
import type { IconProps } from '../../../icons/utils/base';
1110
import { primitives, lightSemantics, darkSemantics } from '../../../theme';
@@ -139,11 +138,9 @@ export type Theme = {
139138
speedChangeButtonText: TextStyle;
140139
};
141140
avatar: {
142-
BASE_AVATAR_SIZE: number;
141+
border: ViewStyle;
143142
container: ViewStyle;
144143
image: ImageStyle;
145-
presenceIndicator: CircleProps;
146-
presenceIndicatorContainer: ViewStyle;
147144
};
148145
avatarStack: {
149146
userAvatarWrapper: ViewStyle;
@@ -967,6 +964,8 @@ export type Theme = {
967964
reactionListItemWrapper: {
968965
wrapper: ViewStyle;
969966
container: ViewStyle;
967+
containerSelected: ViewStyle;
968+
containerPressed: ViewStyle;
970969
};
971970
reactionListTop: {
972971
container: ViewStyle;
@@ -1256,20 +1255,9 @@ export const defaultTheme: Theme = {
12561255
speedChangeButtonText: {},
12571256
},
12581257
avatar: {
1259-
BASE_AVATAR_SIZE,
1258+
border: {},
12601259
container: {},
1261-
image: {
1262-
borderRadius: 16,
1263-
height: 32,
1264-
width: 32,
1265-
},
1266-
presenceIndicator: {
1267-
cx: 6,
1268-
cy: 6,
1269-
r: 5,
1270-
strokeWidth: 2,
1271-
},
1272-
presenceIndicatorContainer: {},
1260+
image: {},
12731261
},
12741262
avatarStack: {
12751263
userAvatarWrapper: {},
@@ -2062,6 +2050,8 @@ export const defaultTheme: Theme = {
20622050
reactionListItemWrapper: {
20632051
wrapper: {},
20642052
container: {},
2053+
containerSelected: {},
2054+
containerPressed: {},
20652055
},
20662056
reactionListTop: {
20672057
container: {},

0 commit comments

Comments
 (0)