@@ -23,6 +23,8 @@ import androidx.compose.animation.core.VisibilityThreshold
2323import androidx.compose.animation.core.spring
2424import androidx.compose.animation.fadeIn
2525import androidx.compose.animation.fadeOut
26+ import androidx.compose.animation.scaleIn
27+ import androidx.compose.animation.scaleOut
2628import androidx.compose.animation.slideInVertically
2729import androidx.compose.foundation.background
2830import androidx.compose.foundation.layout.Arrangement
@@ -78,21 +80,22 @@ import androidx.compose.ui.res.dimensionResource
7880import androidx.compose.ui.res.stringResource
7981import androidx.compose.ui.semantics.contentDescription
8082import androidx.compose.ui.semantics.semantics
83+ import androidx.compose.ui.text.font.FontWeight
8184import androidx.compose.ui.text.style.TextAlign
8285import androidx.compose.ui.unit.IntOffset
8386import androidx.compose.ui.unit.dp
87+ import androidx.compose.ui.unit.sp
8488import com.google.ai.edge.gallery.R
8589import com.google.ai.edge.gallery.data.BuiltInTaskId
8690import com.google.ai.edge.gallery.data.Model
8791import com.google.ai.edge.gallery.data.Task
8892import com.google.ai.edge.gallery.ui.common.AudioAnimation
8993import com.google.ai.edge.gallery.ui.common.ErrorDialog
9094import com.google.ai.edge.gallery.ui.common.FloatingBanner
95+ import com.google.ai.edge.gallery.ui.common.RotationalLoader
9196import com.google.ai.edge.gallery.ui.modelmanager.ModelInitializationStatusType
9297import com.google.ai.edge.gallery.ui.modelmanager.ModelManagerViewModel
9398import com.google.ai.edge.gallery.ui.theme.customColors
94- import com.google.ai.edge.gallery.ui.theme.emptyStateContent
95- import com.google.ai.edge.gallery.ui.theme.emptyStateTitle
9699import kotlinx.coroutines.delay
97100
98101/* * Composable function for the main chat panel, displaying messages and handling user input. */
@@ -483,30 +486,44 @@ fun ChatPanel(
483486
484487 // Show empty state.
485488 if (messages.isEmpty() && pickedImagesCount == 0 && pickedAudioClipsCount == 0 ) {
486- if (
487- modelInitializationStatus?.status == ModelInitializationStatusType .INITIALIZING &&
488- modelInitializationStatus.isFirstInitialization(selectedModel)
489+ emptyStateComposable(selectedModel)
490+ }
491+ // Loading screen when model is initialized for that first time.
492+ val isFirstInitializing =
493+ modelInitializationStatus?.status == ModelInitializationStatusType .INITIALIZING &&
494+ modelInitializationStatus.isFirstInitialization(selectedModel)
495+ Column (
496+ horizontalAlignment = Alignment .CenterHorizontally ,
497+ verticalArrangement = Arrangement .Center ,
498+ ) {
499+ AnimatedVisibility (
500+ isFirstInitializing,
501+ enter = fadeIn() + scaleIn(initialScale = 0.9f ),
502+ exit = fadeOut() + scaleOut(targetScale = 0.9f ),
489503 ) {
490- Box (modifier = Modifier .fillMaxSize()) {
504+ Box (modifier = Modifier .background( MaterialTheme .colorScheme.surface). fillMaxSize()) {
491505 Column (
492- modifier =
493- Modifier .align(Alignment .Center )
494- .padding(horizontal = 48 .dp)
495- .padding(bottom = 48 .dp),
506+ modifier = Modifier .align(Alignment .Center ),
496507 horizontalAlignment = Alignment .CenterHorizontally ,
497- verticalArrangement = Arrangement .spacedBy(12 .dp),
508+ verticalArrangement = Arrangement .spacedBy(8 .dp),
498509 ) {
499- Text (stringResource(R .string.aichat_initializing_title), style = emptyStateTitle)
510+ RotationalLoader (size = 32 .dp)
511+ Text (
512+ stringResource(R .string.aichat_initializing_title),
513+ style =
514+ MaterialTheme .typography.headlineLarge.copy(
515+ fontSize = 24 .sp,
516+ fontWeight = FontWeight .Bold ,
517+ ),
518+ )
500519 Text (
501520 stringResource(R .string.aichat_initializing_content),
502- style = emptyStateContent ,
521+ style = MaterialTheme .typography.bodyMedium ,
503522 color = MaterialTheme .colorScheme.onSurfaceVariant,
504523 textAlign = TextAlign .Center ,
505524 )
506525 }
507526 }
508- } else {
509- emptyStateComposable(selectedModel)
510527 }
511528 }
512529 }
0 commit comments