@@ -85,6 +85,7 @@ import androidx.compose.ui.graphics.Color
8585import androidx.compose.ui.graphics.toArgb
8686import androidx.compose.ui.platform.LocalContext
8787import androidx.compose.ui.platform.LocalSoftwareKeyboardController
88+ import androidx.compose.ui.res.stringResource
8889import androidx.compose.ui.text.input.KeyboardCapitalization
8990import androidx.compose.ui.text.style.TextAlign
9091import androidx.compose.ui.unit.dp
@@ -94,6 +95,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
9495import androidx.navigation.compose.NavHost
9596import androidx.navigation.compose.composable
9697import androidx.navigation.compose.rememberNavController
98+ import io.shubham0204.smollmandroid.R
9799import io.shubham0204.smollmandroid.data.Chat
98100import io.shubham0204.smollmandroid.ui.components.AppBarTitleText
99101import io.shubham0204.smollmandroid.ui.components.MediumLabelText
@@ -174,7 +176,7 @@ fun ChatActivityScreenUI(
174176 title = {
175177 Column (modifier = Modifier .fillMaxWidth()) {
176178 AppBarTitleText (
177- currChat?.name ? : " Select a chat " ,
179+ currChat?.name ? : stringResource( R .string.chat_select_chat) ,
178180 modifier = Modifier .fillMaxWidth(),
179181 )
180182 Text (
@@ -193,7 +195,7 @@ fun ChatActivityScreenUI(
193195 IconButton (onClick = { scope.launch { drawerState.open() } }) {
194196 Icon (
195197 Icons .Default .Menu ,
196- contentDescription = " View Chats " ,
198+ contentDescription = stringResource( R .string.chat_view_chats) ,
197199 )
198200 }
199201 },
@@ -282,7 +284,7 @@ private fun ColumnScope.MessagesList(
282284 context.getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
283285 val clip = ClipData .newPlainText(" Copied message" , chatMessage.message)
284286 clipboard.setPrimaryClip(clip)
285- Toast .makeText(context, " Message copied " , Toast .LENGTH_SHORT ).show()
287+ Toast .makeText(context, context.getString( R .string.chat_message_copied) , Toast .LENGTH_SHORT ).show()
286288 },
287289 onShareClicked = {
288290 context.startActivity(
@@ -321,7 +323,7 @@ private fun ColumnScope.MessagesList(
321323 tint = MaterialTheme .colorScheme.primary,
322324 )
323325 Text (
324- text = " Thinking ... " ,
326+ text = stringResource( R .string.chat_thinking) ,
325327 modifier =
326328 Modifier
327329 .fillMaxWidth()
@@ -377,13 +379,13 @@ private fun LazyItemScope.MessageListItem(
377379 Row (verticalAlignment = Alignment .CenterVertically ) {
378380 Spacer (modifier = Modifier .width(16 .dp))
379381 Text (
380- text = " Copy " ,
382+ text = stringResource( R .string.chat_message_copy) ,
381383 modifier = Modifier .clickable { onCopyClicked() },
382384 fontSize = 8 .sp,
383385 )
384386 Spacer (modifier = Modifier .width(8 .dp))
385387 Text (
386- text = " Share " ,
388+ text = stringResource( R .string.chat_message_share) ,
387389 modifier = Modifier .clickable { onShareClicked() },
388390 fontSize = 8 .sp,
389391 )
@@ -422,7 +424,7 @@ private fun LazyItemScope.MessageListItem(
422424 Row (
423425 modifier =
424426 Modifier
425- .fillMaxWidth()
427+ .fillMaxWidth()
426428 .animateItem(),
427429 horizontalArrangement = Arrangement .End ,
428430 ) {
@@ -431,7 +433,7 @@ private fun LazyItemScope.MessageListItem(
431433 Modifier
432434 .padding(8 .dp)
433435 .background(MaterialTheme .colorScheme.primary, RoundedCornerShape (16 .dp))
434- .padding(8 .dp)
436+ .padding(8 .dp)
435437 .widthIn(max = 250 .dp),
436438 textColor = android.graphics.Color .WHITE ,
437439 textSize = 16f ,
@@ -451,7 +453,7 @@ private fun MessageInput(
451453 if ((currChat?.llmModelId ? : - 1L ) == - 1L ) {
452454 Text (
453455 modifier = Modifier .padding(8 .dp),
454- text = " Select a model ... " ,
456+ text = stringResource( R .string.chat_select_model) ,
455457 )
456458 } else {
457459 var questionText by remember { mutableStateOf(" " ) }
@@ -461,22 +463,22 @@ private fun MessageInput(
461463 ChatScreenViewModel .ModelLoadingState .IN_PROGRESS -> {
462464 Text (
463465 modifier = Modifier .padding(8 .dp),
464- text = " Loading model... " ,
466+ text = stringResource( R .string.chat_loading_model) ,
465467 )
466468 }
467469
468470 ChatScreenViewModel .ModelLoadingState .FAILURE -> {
469471 Text (
470472 modifier = Modifier .padding(8 .dp),
471- text = " The model selected for the chat cannot be loaded " ,
473+ text = stringResource( R .string.chat_model_cannot_be_loaded) ,
472474 )
473475 }
474476
475477 ChatScreenViewModel .ModelLoadingState .SUCCESS -> {
476478 TextField (
477479 modifier =
478480 Modifier
479- .fillMaxWidth()
481+ .fillMaxWidth()
480482 .weight(1f ),
481483 value = questionText,
482484 onValueChange = { questionText = it },
@@ -490,7 +492,7 @@ private fun MessageInput(
490492 ),
491493 placeholder = {
492494 Text (
493- text = " Ask a question " ,
495+ text = stringResource( R .string.chat_ask_question) ,
494496 )
495497 },
496498 keyboardOptions =
@@ -554,7 +556,7 @@ private fun TasksListBottomSheet(viewModel: ChatScreenViewModel) {
554556 if (tasks.isEmpty()) {
555557 Spacer (modifier = Modifier .height(24 .dp))
556558 Text (
557- " No tasks created " ,
559+ stringResource( R .string.chat_no_task_created) ,
558560 modifier = Modifier .fillMaxWidth(),
559561 style = MaterialTheme .typography.labelMedium,
560562 textAlign = TextAlign .Center ,
@@ -568,11 +570,11 @@ private fun TasksListBottomSheet(viewModel: ChatScreenViewModel) {
568570 }
569571 },
570572 ) {
571- MediumLabelText (" Create a task " )
573+ MediumLabelText (stringResource( R .string.chat_create_task) )
572574 }
573575 Spacer (modifier = Modifier .height(24 .dp))
574576 } else {
575- AppBarTitleText (" Select A Task " )
577+ AppBarTitleText (stringResource( R .string.chat_select_task) )
576578 TasksList (
577579 tasks.map {
578580 val modelName =
@@ -607,6 +609,7 @@ private fun TasksListBottomSheet(viewModel: ChatScreenViewModel) {
607609@Composable
608610private fun SelectModelsList (viewModel : ChatScreenViewModel ) {
609611 val showSelectModelsListDialog by viewModel.showSelectModelListDialogState.collectAsStateWithLifecycle()
612+ val context = LocalContext .current
610613 if (showSelectModelsListDialog) {
611614 val modelsList by
612615 viewModel.modelsRepository.getAvailableModels().collectAsState(emptyList())
@@ -623,7 +626,7 @@ private fun SelectModelsList(viewModel: ChatScreenViewModel) {
623626 Toast
624627 .makeText(
625628 viewModel.context,
626- " Model ' ${ model.name} ' deleted " ,
629+ context.getString( R .string.chat_model_deleted, model.name) ,
627630 Toast .LENGTH_LONG ,
628631 ).show()
629632 },
0 commit comments