Skip to content

Commit f896513

Browse files
committed
Remove ComposerLinkPreviewTheme and ComposerCancelIconStyle
1 parent 6b4556f commit f896513

File tree

4 files changed

+33
-181
lines changed

4 files changed

+33
-181
lines changed

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/ComposerCancelIcon.kt

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import androidx.compose.foundation.background
2020
import androidx.compose.foundation.border
2121
import androidx.compose.foundation.layout.padding
2222
import androidx.compose.foundation.layout.size
23+
import androidx.compose.foundation.shape.CircleShape
2324
import androidx.compose.material3.Icon
2425
import androidx.compose.runtime.Composable
2526
import androidx.compose.ui.Modifier
27+
import androidx.compose.ui.res.painterResource
2628
import androidx.compose.ui.res.stringResource
2729
import androidx.compose.ui.tooling.preview.Preview
2830
import androidx.compose.ui.unit.dp
@@ -41,29 +43,18 @@ public fun ComposerCancelIcon(
4143
modifier: Modifier = Modifier,
4244
onClick: () -> Unit,
4345
) {
44-
val style = ChatTheme.messageComposerTheme.attachmentCancelIcon
46+
val colors = ChatTheme.colors
47+
4548
Icon(
4649
modifier = modifier
47-
.then(
48-
if (style.border != null) {
49-
Modifier.border(style.border, style.backgroundShape)
50-
} else {
51-
Modifier
52-
},
53-
)
50+
.border(2.dp, colors.controlRemoveBorder, CircleShape)
5451
.padding(2.dp)
55-
.background(
56-
shape = style.backgroundShape,
57-
color = style.backgroundColor,
58-
)
52+
.background(color = colors.controlRemoveBg, shape = CircleShape)
5953
.size(20.dp)
60-
.clickable(
61-
bounded = false,
62-
onClick = onClick,
63-
),
64-
painter = style.painter,
65-
contentDescription = stringResource(id = R.string.stream_compose_cancel),
66-
tint = style.tint,
54+
.clickable(bounded = false, onClick = onClick),
55+
painter = painterResource(R.drawable.stream_compose_ic_cross),
56+
contentDescription = stringResource(R.string.stream_compose_cancel),
57+
tint = colors.controlRemoveIcon,
6758
)
6859
}
6960

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/composer/ComposerLinkPreview.kt

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ import androidx.compose.foundation.layout.Arrangement
3030
import androidx.compose.foundation.layout.Box
3131
import androidx.compose.foundation.layout.Column
3232
import androidx.compose.foundation.layout.Row
33-
import androidx.compose.foundation.layout.Spacer
34-
import androidx.compose.foundation.layout.height
3533
import androidx.compose.foundation.layout.offset
3634
import androidx.compose.foundation.layout.padding
3735
import androidx.compose.foundation.layout.size
36+
import androidx.compose.foundation.shape.RoundedCornerShape
3837
import androidx.compose.material3.Text
3938
import androidx.compose.runtime.Composable
4039
import androidx.compose.runtime.CompositionLocalProvider
@@ -51,6 +50,8 @@ import androidx.compose.ui.graphics.toArgb
5150
import androidx.compose.ui.layout.ContentScale
5251
import androidx.compose.ui.platform.LocalContext
5352
import androidx.compose.ui.platform.testTag
53+
import androidx.compose.ui.text.TextStyle
54+
import androidx.compose.ui.text.style.TextOverflow
5455
import androidx.compose.ui.tooling.preview.Preview
5556
import androidx.compose.ui.unit.dp
5657
import androidx.core.net.toUri
@@ -59,7 +60,7 @@ import coil3.compose.LocalAsyncImagePreviewHandler
5960
import io.getstream.chat.android.compose.R
6061
import io.getstream.chat.android.compose.ui.components.ComposerCancelIcon
6162
import io.getstream.chat.android.compose.ui.theme.ChatTheme
62-
import io.getstream.chat.android.compose.ui.theme.TextComponentStyle
63+
import io.getstream.chat.android.compose.ui.theme.StreamColors
6364
import io.getstream.chat.android.compose.ui.util.AsyncImagePreviewHandler
6465
import io.getstream.chat.android.compose.ui.util.StreamAsyncImage
6566
import io.getstream.chat.android.models.Attachment
@@ -95,7 +96,9 @@ public fun ComposerLinkPreview(
9596

9697
val context = LocalContext.current
9798
val attachment = linkPreview.attachment
98-
val theme = ChatTheme.messageComposerTheme.linkPreview
99+
val colors = ChatTheme.colors
100+
val typography = ChatTheme.typography
101+
val textColor = colors.textHighEmphasis
99102

100103
Box {
101104
Row(
@@ -105,31 +108,30 @@ public fun ComposerLinkPreview(
105108
interactionSource = remember { MutableInteractionSource() },
106109
onClick = { handleLinkPreviewClick(onClick, context, linkPreview) },
107110
)
108-
.background(theme.background, theme.shape)
111+
.background(colors.chatBgOutgoing, ChatTheme.shapes.attachment)
112+
// TODO [G.] point to spacings
109113
.padding(start = 8.dp, end = 16.dp, top = 8.dp, bottom = 8.dp),
110114
horizontalArrangement = Arrangement.spacedBy(8.dp),
111115
) {
112-
ComposerLinkImagePreview(attachment)
116+
ComposerLinkImagePreview(attachment, colors)
113117
Column(
114118
modifier = Modifier
115119
.weight(1f)
116120
.align(Alignment.CenterVertically),
117121
) {
118122
ComposerLinkPreviewText(
119123
text = attachment.title,
120-
style = theme.title,
124+
style = typography.footnoteBold.copy(color = textColor),
121125
testTag = "Stream_LinkPreviewTitle",
122126
)
123-
Spacer(modifier = Modifier.height(theme.titleToSubtitle))
124-
125127
ComposerLinkPreviewText(
126128
text = attachment.text,
127-
style = theme.subtitle,
129+
style = typography.footnote.copy(color = textColor),
128130
testTag = "Stream_LinkPreviewDescription",
129131
)
130132
ComposerLinkPreviewText(
131133
text = linkPreview.resolveUrl(),
132-
style = theme.url,
134+
style = typography.footnote.copy(color = textColor),
133135
testTag = "Stream_LinkPreviewUrl",
134136
)
135137
}
@@ -143,31 +145,31 @@ public fun ComposerLinkPreview(
143145
}
144146

145147
@Composable
146-
private fun ComposerLinkImagePreview(attachment: Attachment) {
148+
private fun ComposerLinkImagePreview(attachment: Attachment, colors: StreamColors) {
147149
val imagePreviewUrl = attachment.imagePreviewUrl ?: return
148-
val theme = ChatTheme.messageComposerTheme.linkPreview
150+
// TODO [G.] point to radii
151+
val shape = RoundedCornerShape(8.dp)
149152
StreamAsyncImage(
150153
data = imagePreviewUrl,
151154
modifier = Modifier
152-
.size(width = theme.imageSize.width, height = theme.imageSize.height)
153-
.clip(theme.imageShape)
154-
.border(theme.imageBorder, theme.imageShape)
155+
.size(width = 40.dp, height = 40.dp)
156+
.clip(shape)
157+
.border(1.dp, colors.borderCoreImage, shape)
155158
.testTag("Stream_LinkPreviewImage"),
156159
contentDescription = null,
157160
contentScale = ContentScale.Crop,
158161
)
159162
}
160163

161164
@Composable
162-
private fun ComposerLinkPreviewText(text: String?, style: TextComponentStyle, testTag: String) {
165+
private fun ComposerLinkPreviewText(text: String?, style: TextStyle, testTag: String) {
163166
text ?: return
164167
Text(
165168
modifier = Modifier.testTag(testTag),
166169
text = text,
167-
style = style.style,
168-
color = style.color,
169-
maxLines = style.maxLines,
170-
overflow = style.overflow,
170+
style = style,
171+
maxLines = 1,
172+
overflow = TextOverflow.Ellipsis,
171173
)
172174
}
173175

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/MessageComposerTheme.kt

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@
1616

1717
package io.getstream.chat.android.compose.ui.theme
1818

19-
import androidx.compose.foundation.BorderStroke
2019
import androidx.compose.foundation.isSystemInDarkTheme
21-
import androidx.compose.foundation.shape.CircleShape
22-
import androidx.compose.foundation.shape.RoundedCornerShape
2320
import androidx.compose.runtime.Composable
2421
import androidx.compose.runtime.Immutable
2522
import androidx.compose.ui.graphics.Color
2623
import androidx.compose.ui.graphics.Shape
27-
import androidx.compose.ui.graphics.painter.Painter
2824
import androidx.compose.ui.res.painterResource
2925
import androidx.compose.ui.text.SpanStyle
3026
import androidx.compose.ui.text.TextStyle
3127
import androidx.compose.ui.text.style.TextDirection
32-
import androidx.compose.ui.text.style.TextOverflow
33-
import androidx.compose.ui.unit.Dp
3428
import androidx.compose.ui.unit.dp
3529
import io.getstream.chat.android.compose.R
3630
import io.getstream.chat.android.compose.ui.theme.messages.composer.AudioRecordingTheme
@@ -39,16 +33,12 @@ import io.getstream.chat.android.ui.common.feature.messages.composer.mention.Men
3933

4034
/**
4135
* Represents the theming for the message composer.
42-
* @param attachmentCancelIcon The theming for the cancel icon used in the message composer.
43-
* @param linkPreview The theming for the link preview in the message composer.
4436
* @param inputField The theming for the input field in the message composer.
4537
* @param actionsTheme The theming for the different composer actions.
4638
* @param audioRecording The theming for the audio recording in the message composer.
4739
* @param attachmentsPreview The theming for the attachments preview in the message composer.
4840
*/
4941
public data class MessageComposerTheme(
50-
val attachmentCancelIcon: ComposerCancelIconStyle,
51-
val linkPreview: ComposerLinkPreviewTheme,
5242
val inputField: ComposerInputFieldTheme,
5343
val actionsTheme: ComposerActionsTheme,
5444
val audioRecording: AudioRecordingTheme,
@@ -73,8 +63,6 @@ public data class MessageComposerTheme(
7363
},
7464
): MessageComposerTheme {
7565
return MessageComposerTheme(
76-
attachmentCancelIcon = ComposerCancelIconStyle.defaultStyle(colors),
77-
linkPreview = ComposerLinkPreviewTheme.defaultTheme(typography, shapes, colors),
7866
inputField = ComposerInputFieldTheme.defaultTheme(typography, shapes, colors),
7967
actionsTheme = ComposerActionsTheme.defaultTheme(colors),
8068
audioRecording = AudioRecordingTheme.defaultTheme(isInDarkMode, typography, colors),
@@ -84,119 +72,6 @@ public data class MessageComposerTheme(
8472
}
8573
}
8674

87-
/**
88-
* Represents the theming for the cancel icon used in the message composer.
89-
*
90-
* @param backgroundShape The shape of the background for the cancel icon.
91-
* @param backgroundColor The background color for the cancel icon.
92-
* @param border The border for the cancel icon.
93-
* @param painter The painter for the cancel icon.
94-
* @param tint The tint color for the cancel icon.
95-
*/
96-
public data class ComposerCancelIconStyle(
97-
val backgroundShape: Shape,
98-
val backgroundColor: Color,
99-
val border: BorderStroke?,
100-
val painter: Painter,
101-
val tint: Color,
102-
) {
103-
public companion object {
104-
105-
/**
106-
* Builds the default cancel icon style.
107-
*
108-
* @return A [ComposerCancelIconStyle] instance holding the default theming.
109-
*/
110-
@Composable
111-
public fun defaultStyle(
112-
colors: StreamColors = when (isSystemInDarkTheme()) {
113-
true -> StreamColors.defaultDarkColors()
114-
else -> StreamColors.defaultColors()
115-
},
116-
): ComposerCancelIconStyle {
117-
return ComposerCancelIconStyle(
118-
backgroundShape = CircleShape,
119-
backgroundColor = colors.controlRemoveBg,
120-
border = BorderStroke(width = 2.dp, color = colors.controlRemoveBorder),
121-
painter = painterResource(R.drawable.stream_compose_ic_cross),
122-
tint = colors.controlRemoveIcon,
123-
)
124-
}
125-
}
126-
}
127-
128-
/**
129-
* Represents the theming for the link preview in the message composer.
130-
*
131-
* @param background The background color for the link preview.
132-
* @param shape The shape of the link preview.
133-
* @param imageSize The size of the image in the link preview.
134-
* @param imageShape The shape of the image in the link preview.
135-
* @param imageBorder The border for the image in the link preview.
136-
* @param imagePadding The padding for the image in the link preview.
137-
* @param title The theming for the title in the link preview.
138-
* @param titleToSubtitle The vertical space between the title and the subtitle in the link preview.
139-
* @param subtitle The theming for the subtitle in the link preview.
140-
* @param url The theming for the URL in the link preview.
141-
* @param cancelIcon The theming for the cancel icon in the link preview.
142-
*/
143-
public data class ComposerLinkPreviewTheme(
144-
val background: Color,
145-
val shape: Shape,
146-
val imageSize: ComponentSize,
147-
val imageShape: Shape,
148-
val imageBorder: BorderStroke,
149-
val imagePadding: Dp,
150-
val title: TextComponentStyle,
151-
val titleToSubtitle: Dp,
152-
val subtitle: TextComponentStyle,
153-
val url: TextComponentStyle,
154-
val cancelIcon: ComposerCancelIconStyle,
155-
) {
156-
public companion object {
157-
158-
@Suppress("DEPRECATION_ERROR")
159-
@Composable
160-
public fun defaultTheme(
161-
typography: StreamTypography = StreamTypography.defaultTypography(),
162-
shapes: StreamShapes = StreamShapes.defaultShapes(),
163-
colors: StreamColors = when (isSystemInDarkTheme()) {
164-
true -> StreamColors.defaultDarkColors()
165-
else -> StreamColors.defaultColors()
166-
},
167-
): ComposerLinkPreviewTheme {
168-
return ComposerLinkPreviewTheme(
169-
background = colors.chatBgOutgoing,
170-
shape = shapes.attachment,
171-
imageSize = ComponentSize(width = 40.dp, height = 40.dp),
172-
imageShape = RoundedCornerShape(8.dp),
173-
imageBorder = BorderStroke(1.dp, colors.borderCoreImage),
174-
imagePadding = 4.dp,
175-
title = TextComponentStyle(
176-
color = colors.textHighEmphasis,
177-
style = typography.footnoteBold,
178-
maxLines = 1,
179-
overflow = TextOverflow.Ellipsis,
180-
),
181-
titleToSubtitle = 0.dp,
182-
subtitle = TextComponentStyle(
183-
color = colors.textHighEmphasis,
184-
style = typography.footnote,
185-
maxLines = 1,
186-
overflow = TextOverflow.Ellipsis,
187-
),
188-
url = TextComponentStyle(
189-
color = colors.textHighEmphasis,
190-
style = typography.footnote,
191-
maxLines = 1,
192-
overflow = TextOverflow.Ellipsis,
193-
),
194-
cancelIcon = ComposerCancelIconStyle.defaultStyle(colors),
195-
)
196-
}
197-
}
198-
}
199-
20075
/**
20176
* Represents the theming for the input field in the message composer.
20277
*

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/TextStyle.kt renamed to stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/TextContainerStyle.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,6 @@ package io.getstream.chat.android.compose.ui.theme
1818

1919
import androidx.compose.ui.graphics.Color
2020
import androidx.compose.ui.text.TextStyle
21-
import androidx.compose.ui.text.style.TextOverflow
22-
23-
/**
24-
* Represents the styling for the text component.
25-
*
26-
* @param color The color of the component.
27-
* @param style The style of the component.
28-
* @param maxLines The maximum number of lines the component can have.
29-
* @param overflow The overflow behavior of the component.
30-
*/
31-
public data class TextComponentStyle(
32-
val color: Color,
33-
val style: TextStyle,
34-
val maxLines: Int = Int.MAX_VALUE,
35-
val overflow: TextOverflow = TextOverflow.Clip,
36-
)
3721

3822
/**
3923
* Represents the styling for the text component.

0 commit comments

Comments
 (0)