Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[ensu] Restore model download onboarding UI

setalpeafd5cb81e43
diff --git a/mobile/native/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatMessages.kt b/mobile/native/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatMessages.kt
index 6e3df0ec67..cc6e566976 100644
--- a/mobile/native/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatMessages.kt
+++ b/mobile/native/android/apps/ensu/app/src/main/java/io/ente/ensu/chat/ChatMessages.kt
@@ -410,92 +410,88 @@ private fun DownloadOnboarding(
val downloadAccent = EnsuColor.accentDark
val downloadButtonTextColor = Color.Black
val sizeText = modelDownloadSizeBytes?.let { "Approx. ${formatBytes(it)}" } ?: "Approx. size varies by model"
- Column(modifier = modifier.fillMaxSize()) {
- Box(
- modifier = Modifier
- .weight(1f)
- .fillMaxWidth(),
- contentAlignment = Alignment.Center
- ) {
- Column(horizontalAlignment = Alignment.CenterHorizontally) {
+ Box(
+ modifier = modifier.fillMaxSize(),
+ contentAlignment = Alignment.Center
+ ) {
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
+ Text(
+ text = "Download to begin using the Chat",
+ style = EnsuTypography.large,
+ color = EnsuColor.textPrimary(),
+ textAlign = TextAlign.Center
+ )
+ Spacer(modifier = Modifier.height(EnsuSpacing.md.dp))
+ if (isDownloading) {
+ val isLoadingModel = downloadPhase == DownloadPhase.Loading
+ val showProgress = downloadPercent != null || isLoadingModel
+ val statusText = when {
+ isLoadingModel -> downloadStatus
+ modelDownloadSizeBytes != null && downloadPercent != null && downloadPercent >= 0 -> {
+ val downloadedBytes = (modelDownloadSizeBytes * (downloadPercent / 100f)).roundToLong()
+ "Downloading... ${formatBytes(downloadedBytes)} / ${formatBytes(modelDownloadSizeBytes)}"
+ }
+ !downloadStatus.isNullOrBlank() -> downloadStatus
+ else -> "Downloading..."
+ }
Text(
- text = "Download models to begin using Chat",
- style = EnsuTypography.large,
- color = EnsuColor.textPrimary(),
+ text = statusText ?: "Downloading...",
+ style = EnsuTypography.body.copy(fontFeatureSettings = "tnum"),
+ color = EnsuColor.textMuted(),
textAlign = TextAlign.Center
)
- Spacer(modifier = Modifier.height(EnsuSpacing.md.dp))
- if (isDownloading) {
- val isLoadingModel = downloadPhase == DownloadPhase.Loading
- val showProgress = downloadPercent != null || isLoadingModel
- val statusText = when {
- isLoadingModel -> downloadStatus
- modelDownloadSizeBytes != null && downloadPercent != null && downloadPercent >= 0 -> {
- val downloadedBytes = (modelDownloadSizeBytes * (downloadPercent / 100f)).roundToLong()
- "Downloading... ${formatBytes(downloadedBytes)} / ${formatBytes(modelDownloadSizeBytes)}"
- }
- !downloadStatus.isNullOrBlank() -> downloadStatus
- else -> "Downloading..."
+ if (showProgress) {
+ Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
+ val clamped = downloadPercent?.coerceIn(0, 100)
+ if (clamped != null) {
+ LinearProgressIndicator(
+ progress = { clamped / 100f },
+ color = downloadAccent,
+ trackColor = EnsuColor.border(),
+ modifier = Modifier
+ .fillMaxWidth(0.6f)
+ .height(6.dp)
+ )
+ } else {
+ LinearProgressIndicator(
+ color = downloadAccent,
+ trackColor = EnsuColor.border(),
+ modifier = Modifier
+ .fillMaxWidth(0.6f)
+ .height(6.dp)
+ )
}
+ }
+ } else {
+ if (!downloadStatus.isNullOrBlank()) {
Text(
- text = statusText ?: "Downloading...",
- style = EnsuTypography.body.copy(fontFeatureSettings = "tnum"),
- color = EnsuColor.textMuted(),
- textAlign = TextAlign.Center
- )
- if (showProgress) {
- Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
- val clamped = downloadPercent?.coerceIn(0, 100)
- if (clamped != null) {
- LinearProgressIndicator(
- progress = { clamped / 100f },
- color = downloadAccent,
- trackColor = EnsuColor.border(),
- modifier = Modifier
- .fillMaxWidth(0.6f)
- .height(6.dp)
- )
+ text = downloadStatus,
+ style = EnsuTypography.body,
+ color = if (downloadPhase == DownloadPhase.Failed) {
+ EnsuColor.error
} else {
- LinearProgressIndicator(
- color = downloadAccent,
- trackColor = EnsuColor.border(),
- modifier = Modifier
- .fillMaxWidth(0.6f)
- .height(6.dp)
- )
- }
- }
- } else {
- if (!downloadStatus.isNullOrBlank()) {
- Text(
- text = downloadStatus,
- style = EnsuTypography.body,
- color = if (downloadPhase == DownloadPhase.Failed) {
- EnsuColor.error
- } else {
- EnsuColor.textMuted()
- },
- textAlign = TextAlign.Center
- )
- Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
- }
- Button(
- onClick = {
- haptic.perform(HapticFeedbackType.TextHandleMove)
- onDownload()
+ EnsuColor.textMuted()
},
- shape = RoundedCornerShape(EnsuCornerRadius.button.dp),
- colors = ButtonDefaults.buttonColors(containerColor = downloadAccent)
- ) {
- Text(text = "Download", style = EnsuTypography.body, color = downloadButtonTextColor)
- }
- Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
- Text(
- text = sizeText,
- style = EnsuTypography.small,
- color = EnsuColor.textMuted()
+ textAlign = TextAlign.Center
)
+ Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
+ }
+ Button(
+ onClick = {
+ haptic.perform(HapticFeedbackType.TextHandleMove)
+ onDownload()
+ },
+ shape = RoundedCornerShape(EnsuCornerRadius.button.dp),
+ colors = ButtonDefaults.buttonColors(containerColor = downloadAccent)
+ ) {
+ Text(text = "Download", style = EnsuTypography.body, color = downloadButtonTextColor)
}
+ Spacer(modifier = Modifier.height(EnsuSpacing.sm.dp))
+ Text(
+ text = sizeText,
+ style = EnsuTypography.small,
+ color = EnsuColor.textMuted()
+ )
}
}
}
diff --git a/mobile/native/apple/apps/ensu/Ensu/Chat/Components/ChatViewComponents.swift b/mobile/native/apple/apps/ensu/Ensu/Chat/Components/ChatViewComponents.swift
index 492f508a9f..6d26e66c91 100644
--- a/mobile/native/apple/apps/ensu/Ensu/Chat/Components/ChatViewComponents.swift
+++ b/mobile/native/apple/apps/ensu/Ensu/Chat/Components/ChatViewComponents.swift
@@ -10,54 +10,51 @@ struct DownloadOnboardingView: View {
let onDownload: () -> Void
var body: some View {
- VStack(spacing: 0) {
- VStack(spacing: EnsuSpacing.md) {
- Text("Download models to begin using Chat")
- .font(EnsuTypography.large)
- .foregroundStyle(EnsuColor.textPrimary)
- .multilineTextAlignment(.center)
-
- if isDownloading {
- let statusLine: String = {
- if let statusText, isLoadingModel {
- return statusText
- }
- if let totalBytes, let percent = downloadPercent {
- let clamped = min(max(percent, 0), 100)
- let downloaded = Int64(Double(totalBytes) * Double(clamped) / 100.0)
- return "Downloading... \(downloaded.formattedFileSize) / \(totalBytes.formattedFileSize)"
- }
- if let statusText, !statusText.isEmpty {
- return statusText
- }
- return "Downloading..."
- }()
-
- StableDownloadStatusText(
- text: statusLine,
- font: EnsuTypography.body,
- color: EnsuColor.textMuted
- )
+ VStack(spacing: EnsuSpacing.md) {
+ Text("Download to begin using the Chat")
+ .font(EnsuTypography.large)
+ .foregroundStyle(EnsuColor.textPrimary)
+ .multilineTextAlignment(.center)
- progressView
- } else {
- Button("Download") {
- hapticMedium()
- onDownload()
+ if isDownloading {
+ let statusLine: String = {
+ if let statusText, isLoadingModel {
+ return statusText
}
- .font(EnsuTypography.body)
- .foregroundStyle(Color.black)
- .frame(maxWidth: 200)
- .padding(.vertical, EnsuSpacing.md)
- .background(EnsuColor.accent)
- .clipShape(RoundedRectangle(cornerRadius: EnsuCornerRadius.button))
+ if let totalBytes, let percent = downloadPercent {
+ let clamped = min(max(percent, 0), 100)
+ let downloaded = Int64(Double(totalBytes) * Double(clamped) / 100.0)
+ return "Downloading... \(downloaded.formattedFileSize) / \(totalBytes.formattedFileSize)"
+ }
+ if let statusText, !statusText.isEmpty {
+ return statusText
+ }
+ return "Downloading..."
+ }()
+
+ StableDownloadStatusText(
+ text: statusLine,
+ font: EnsuTypography.body,
+ color: EnsuColor.textMuted
+ )
- Text(sizeText)
- .font(EnsuTypography.small)
- .foregroundStyle(EnsuColor.textMuted)
+ progressView
+ } else {
+ Button("Download") {
+ hapticMedium()
+ onDownload()
}
+ .font(EnsuTypography.body)
+ .foregroundStyle(Color.black)
+ .frame(maxWidth: 200)
+ .padding(.vertical, EnsuSpacing.md)
+ .background(EnsuColor.accent)
+ .clipShape(RoundedRectangle(cornerRadius: EnsuCornerRadius.button))
+
+ Text(sizeText)
+ .font(EnsuTypography.small)
+ .foregroundStyle(EnsuColor.textMuted)
}
- .frame(maxWidth: .infinity, maxHeight: .infinity)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.padding(.horizontal, EnsuSpacing.pageHorizontal)