|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Stream.io Inc. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Stream License; |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://github.com/GetStream/stream-chat-android/blob/main/LICENSE |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.getstream.chat.android.compose.sample.ui.component |
| 18 | + |
| 19 | +import androidx.compose.foundation.background |
| 20 | +import androidx.compose.foundation.layout.Arrangement |
| 21 | +import androidx.compose.foundation.layout.PaddingValues |
| 22 | +import androidx.compose.foundation.layout.Row |
| 23 | +import androidx.compose.foundation.layout.RowScope |
| 24 | +import androidx.compose.foundation.layout.fillMaxWidth |
| 25 | +import androidx.compose.foundation.layout.padding |
| 26 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 27 | +import androidx.compose.material3.Text |
| 28 | +import androidx.compose.runtime.Composable |
| 29 | +import androidx.compose.ui.Modifier |
| 30 | +import androidx.compose.ui.graphics.RectangleShape |
| 31 | +import androidx.compose.ui.unit.dp |
| 32 | +import io.getstream.chat.android.compose.ui.theme.ChatTheme |
| 33 | + |
| 34 | +@Composable |
| 35 | +internal fun PaneTitle( |
| 36 | + text: String, |
| 37 | + padding: PaddingValues = PaddingValues( |
| 38 | + top = 24.dp, |
| 39 | + start = 16.dp, |
| 40 | + bottom = 8.dp, |
| 41 | + end = 16.dp, |
| 42 | + ), |
| 43 | +) { |
| 44 | + Text( |
| 45 | + modifier = Modifier.padding(padding), |
| 46 | + text = text, |
| 47 | + style = ChatTheme.typography.footnote, |
| 48 | + color = ChatTheme.colors.textLowEmphasis, |
| 49 | + ) |
| 50 | +} |
| 51 | + |
| 52 | +@Composable |
| 53 | +internal fun PaneRow( |
| 54 | + index: Int, |
| 55 | + lastIndex: Int, |
| 56 | + content: @Composable RowScope.() -> Unit, |
| 57 | +) { |
| 58 | + Row( |
| 59 | + modifier = Modifier |
| 60 | + .fillMaxWidth() |
| 61 | + .run { |
| 62 | + val shape = when (index) { |
| 63 | + 0 -> if (lastIndex == 0) { |
| 64 | + // Single item in the list |
| 65 | + RoundedCornerShape(12.dp) |
| 66 | + } else { |
| 67 | + // Top item in the list |
| 68 | + RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp) |
| 69 | + } |
| 70 | + // Bottom item in the list |
| 71 | + lastIndex -> RoundedCornerShape(bottomStart = 12.dp, bottomEnd = 12.dp) |
| 72 | + // Middle item in the list |
| 73 | + else -> RectangleShape |
| 74 | + } |
| 75 | + background( |
| 76 | + color = ChatTheme.colors.barsBackground, |
| 77 | + shape = shape, |
| 78 | + ) |
| 79 | + } |
| 80 | + .padding(horizontal = 16.dp, vertical = 8.dp), |
| 81 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 82 | + content = content, |
| 83 | + ) |
| 84 | +} |
0 commit comments