Skip to content

Commit e1e671c

Browse files
authored
Update design of unsupported attachments (#6368)
1 parent 7466f90 commit e1e671c

4 files changed

Lines changed: 70 additions & 18 deletions

File tree

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/UnsupportedAttachmentContent.kt

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ import androidx.compose.foundation.layout.fillMaxWidth
2323
import androidx.compose.foundation.layout.padding
2424
import androidx.compose.foundation.layout.size
2525
import androidx.compose.foundation.shape.RoundedCornerShape
26+
import androidx.compose.material3.Icon
2627
import androidx.compose.material3.Text
2728
import androidx.compose.runtime.Composable
2829
import androidx.compose.ui.Alignment
2930
import androidx.compose.ui.Modifier
31+
import androidx.compose.ui.res.painterResource
3032
import androidx.compose.ui.res.stringResource
3133
import androidx.compose.ui.text.style.TextOverflow
3234
import androidx.compose.ui.tooling.preview.Preview
3335
import androidx.compose.ui.unit.dp
3436
import io.getstream.chat.android.compose.R
3537
import io.getstream.chat.android.compose.state.messages.attachments.AttachmentState
36-
import io.getstream.chat.android.compose.ui.components.attachments.files.FileTypeIcon
3738
import io.getstream.chat.android.compose.ui.theme.ChatTheme
3839
import io.getstream.chat.android.compose.ui.theme.MessageStyling
3940
import io.getstream.chat.android.compose.ui.theme.StreamTokens
40-
import io.getstream.chat.android.compose.ui.util.MimeTypeIconProvider
4141
import io.getstream.chat.android.compose.ui.util.applyIf
4242
import io.getstream.chat.android.compose.ui.util.shouldBeDisplayedAsFullSizeAttachment
4343
import io.getstream.chat.android.models.Attachment
@@ -68,12 +68,19 @@ public fun UnsupportedAttachmentContent(
6868
padding(MessageStyling.messageSectionPadding)
6969
.background(color, RoundedCornerShape(StreamTokens.radiusLg))
7070
}
71-
.padding(StreamTokens.spacingSm),
71+
.padding(
72+
start = StreamTokens.spacingSm,
73+
top = StreamTokens.spacingMd,
74+
end = StreamTokens.spacingMd,
75+
bottom = StreamTokens.spacingMd,
76+
),
7277
verticalAlignment = Alignment.CenterVertically,
7378
) {
74-
FileTypeIcon(
75-
data = MimeTypeIconProvider.getIcon(attachment.mimeType),
76-
modifier = Modifier.size(height = 40.dp, width = 35.dp),
79+
Icon(
80+
painter = painterResource(R.drawable.stream_design_ic_unsupported_attachment),
81+
tint = ChatTheme.colors.textPrimary,
82+
contentDescription = null,
83+
modifier = Modifier.size(20.dp),
7784
)
7885

7986
Text(
@@ -82,7 +89,7 @@ public fun UnsupportedAttachmentContent(
8289
color = MessageStyling.textColor(outgoing = state.isMine),
8390
maxLines = 2,
8491
overflow = TextOverflow.Ellipsis,
85-
modifier = Modifier.padding(horizontal = StreamTokens.spacingSm),
92+
modifier = Modifier.padding(horizontal = StreamTokens.spacingXs),
8693
)
8794
}
8895
}
@@ -99,20 +106,25 @@ private val supportedAttachmentTypes = setOf(
99106
AttachmentType.AUDIO_RECORDING,
100107
)
101108

109+
@Composable
110+
internal fun UnsupportedAttachmentContent(isMine: Boolean) {
111+
UnsupportedAttachmentContent(
112+
state = AttachmentState(
113+
message = Message(
114+
attachments = mutableListOf(
115+
Attachment(type = "unknown"),
116+
Attachment(type = "custom_type"),
117+
),
118+
),
119+
isMine = isMine,
120+
),
121+
)
122+
}
123+
102124
@Preview(showBackground = true)
103125
@Composable
104126
private fun OwnUnsupportedAttachmentContentPreview() {
105127
ChatTheme {
106-
UnsupportedAttachmentContent(
107-
state = AttachmentState(
108-
message = Message(
109-
attachments = mutableListOf(
110-
Attachment(type = "unknown"),
111-
Attachment(type = "custom_type"),
112-
),
113-
),
114-
isMine = true,
115-
),
116-
)
128+
UnsupportedAttachmentContent(isMine = true)
117129
}
118130
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (c) 2014-2026 Stream.io Inc. All rights reserved.
4+
5+
Licensed under the Stream License;
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:width="20dp"
19+
android:height="20dp"
20+
android:viewportWidth="20"
21+
android:viewportHeight="20">
22+
<path
23+
android:pathData="M11.875,2.5H4.375C4.209,2.5 4.05,2.566 3.933,2.683C3.816,2.8 3.75,2.959 3.75,3.125V16.875C3.75,17.041 3.816,17.2 3.933,17.317C4.05,17.434 4.209,17.5 4.375,17.5H15.625C15.791,17.5 15.95,17.434 16.067,17.317C16.184,17.2 16.25,17.041 16.25,16.875V6.875M11.875,2.5L16.25,6.875M11.875,2.5V6.875H16.25M8.125,10L11.875,13.75M11.875,10L8.125,13.75"
24+
android:strokeLineJoin="round"
25+
android:strokeWidth="1.5"
26+
android:fillColor="#00000000"
27+
android:strokeColor="#FF000000"
28+
android:strokeLineCap="round"
29+
/>
30+
</vector>

stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/ui/attachments/content/AttachmentsContentTest.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,14 @@ internal class AttachmentsContentTest : PaparazziComposeTest {
9797
AudioRecordAttachmentContentItemUploading()
9898
}
9999
}
100+
101+
@Test
102+
fun `unsupported attachment content`() {
103+
snapshotWithDarkMode {
104+
Column {
105+
UnsupportedAttachmentContent(isMine = true)
106+
UnsupportedAttachmentContent(isMine = false)
107+
}
108+
}
109+
}
100110
}
Loading

0 commit comments

Comments
 (0)