Skip to content

Commit a427753

Browse files
committed
ui: improve top app bar in ChatActivity.kt
- truncate the chat title with ellipsis - centre the chat title and model name for a more 'spaced out' layout
1 parent 5391b0c commit a427753

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/src/main/java/io/shubham0204/smollmandroid/ui/components/Text.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import androidx.compose.material3.Text
2121
import androidx.compose.runtime.Composable
2222
import androidx.compose.ui.Modifier
2323
import androidx.compose.ui.text.font.FontWeight
24+
import androidx.compose.ui.text.style.TextOverflow
2425

2526
@Composable
2627
fun MediumLabelText(
@@ -56,5 +57,7 @@ fun AppBarTitleText(
5657
style = MaterialTheme.typography.titleMedium,
5758
modifier = modifier,
5859
fontWeight = FontWeight.Bold,
60+
maxLines = 1,
61+
overflow = TextOverflow.Ellipsis,
5962
)
6063
}

app/src/main/java/io/shubham0204/smollmandroid/ui/screens/chat/ChatActivity.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,12 @@ fun ChatActivityScreenUI(
233233
topBar = {
234234
TopAppBar(
235235
title = {
236-
Column(modifier = Modifier.fillMaxWidth()) {
236+
Column(
237+
modifier = Modifier.fillMaxWidth(),
238+
horizontalAlignment = Alignment.CenterHorizontally,
239+
) {
237240
AppBarTitleText(
238241
currChat?.name ?: stringResource(R.string.chat_select_chat),
239-
modifier = Modifier.fillMaxWidth(),
240242
)
241243
Text(
242244
if (currChat != null && currChat?.llmModelId != -1L) {
@@ -246,7 +248,7 @@ fun ChatActivityScreenUI(
246248
} else {
247249
""
248250
},
249-
fontSize = 12.sp,
251+
style = MaterialTheme.typography.labelSmall,
250252
)
251253
}
252254
},

0 commit comments

Comments
 (0)