fix: Ollama detail page usage card, 5h label, real logo, widget data
- Add OllamaUsageCard to ServiceDetailScreen (5h + weekly windows) - Unify Session → 5h across dashboard/detail/widget - Download Ollama llama logo (icon-32x32.png) to drawable-nodpi - ServiceIcon: use real PNG instead of emoji - Widget: use ic_ollama_logo, fix row label to 5h
This commit is contained in:
parent
e1c2774c86
commit
2926e8ebb2
@ -102,18 +102,17 @@ fun ServiceIcon(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServiceType.OLLAMA -> {
|
ServiceType.OLLAMA -> {
|
||||||
// Ollama 暂用 emoji 占位
|
|
||||||
Box(
|
Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(size.dp)
|
.size(size.dp)
|
||||||
.clip(RoundedCornerShape(12.dp))
|
.clip(RoundedCornerShape(8.dp))
|
||||||
.background(Color(0xFF000000),
|
.background(if (isSystemInDarkTheme()) Color(0xFF1A1A1A) else Color.White),
|
||||||
),
|
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
androidx.compose.material3.Text(
|
Image(
|
||||||
text = "🦙",
|
painter = painterResource(id = R.drawable.ic_ollama_logo),
|
||||||
fontSize = (size * 0.5).sp
|
contentDescription = "Ollama Pro",
|
||||||
|
modifier = Modifier.size((size * 0.85).dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -892,7 +892,7 @@ private fun OllamaMainBalance(balance: com.rainy.token.domain.model.ServiceBalan
|
|||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Text(
|
Text(
|
||||||
text = "Session 已用",
|
text = "5h 已用",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
color = inkMuted(),
|
color = inkMuted(),
|
||||||
modifier = Modifier.padding(bottom = 6.dp)
|
modifier = Modifier.padding(bottom = 6.dp)
|
||||||
@ -918,12 +918,12 @@ private fun OllamaUsageWindows(balance: com.rainy.token.domain.model.ServiceBala
|
|||||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
if (sessionPct != null) {
|
if (sessionPct != null) {
|
||||||
CompactUsageRow(
|
CompactUsageRow(
|
||||||
label = "Session",
|
label = "5h",
|
||||||
pct = sessionPct.toInt().coerceIn(0, 100),
|
pct = sessionPct.toInt().coerceIn(0, 100),
|
||||||
resetInSec = sessionResetAt?.let { (it - System.currentTimeMillis()) / 1000 }?.takeIf { it > 0 }
|
resetInSec = sessionResetAt?.let { (it - System.currentTimeMillis()) / 1000 }?.takeIf { it > 0 }
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
CompactUsageRowEmpty(label = "Session", resetInSec = null)
|
CompactUsageRowEmpty(label = "5h", resetInSec = null)
|
||||||
}
|
}
|
||||||
if (weeklyPct != null) {
|
if (weeklyPct != null) {
|
||||||
CompactUsageRow(
|
CompactUsageRow(
|
||||||
|
|||||||
@ -138,7 +138,7 @@ fun ServiceDetailScreen(
|
|||||||
// Codex 详情:暂无专用详情卡片,用通用余额展示即可
|
// Codex 详情:暂无专用详情卡片,用通用余额展示即可
|
||||||
}
|
}
|
||||||
ServiceType.OLLAMA -> {
|
ServiceType.OLLAMA -> {
|
||||||
// Ollama 详情:暂无专用详情卡片,用通用余额展示即可
|
item { OllamaUsageCard(uiState.state) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,6 +400,59 @@ private fun formatResetInSec(sec: Long): String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ollama Pro 专属:5h + 每周用量窗口卡。
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
private fun OllamaUsageCard(state: State) {
|
||||||
|
val balance = when (state) {
|
||||||
|
is State.Fresh -> state.data
|
||||||
|
is State.Stale -> state.data
|
||||||
|
is State.Error -> state.cached
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
val extras = balance?.extras ?: return
|
||||||
|
val plan = extras["plan"] ?: "—"
|
||||||
|
|
||||||
|
Card(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
shape = RoundedCornerShape(20.dp),
|
||||||
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface),
|
||||||
|
elevation = CardDefaults.cardElevation(defaultElevation = 0.dp)
|
||||||
|
) {
|
||||||
|
Column(modifier = Modifier.padding(20.dp)) {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
|
Text(
|
||||||
|
text = "用量窗口",
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
color = inkMuted()
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Text(
|
||||||
|
text = plan,
|
||||||
|
style = MaterialTheme.typography.labelLarge,
|
||||||
|
color = StrawberryPink,
|
||||||
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
UsageWindowRow(
|
||||||
|
label = "5 小时",
|
||||||
|
pct = extras["session.pct"]?.toIntOrNull(),
|
||||||
|
resetInSec = extras["session.resetAt"]?.toLongOrNull()?.let { (it - System.currentTimeMillis()) / 1000 }?.takeIf { it > 0 }
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(14.dp))
|
||||||
|
HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant)
|
||||||
|
Spacer(modifier = Modifier.height(14.dp))
|
||||||
|
UsageWindowRow(
|
||||||
|
label = "每周",
|
||||||
|
pct = extras["weekly.pct"]?.toIntOrNull(),
|
||||||
|
resetInSec = extras["weekly.resetAt"]?.toLongOrNull()?.let { (it - System.currentTimeMillis()) / 1000 }?.takeIf { it > 0 }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MainBalanceCard(state: State, service: ServiceType) {
|
private fun MainBalanceCard(state: State, service: ServiceType) {
|
||||||
Card(
|
Card(
|
||||||
|
|||||||
@ -182,7 +182,7 @@ class OpenCodeGoWidgetProvider : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
ServiceType.DEEPSEEK -> setEmptyState(views)
|
ServiceType.DEEPSEEK -> setEmptyState(views)
|
||||||
ServiceType.OLLAMA -> {
|
ServiceType.OLLAMA -> {
|
||||||
setRowLabel(views, "Session", "每周", "Plan")
|
setRowLabel(views, "5h", "每周", "Plan")
|
||||||
populateRow(views, R.id.row1_pct, R.id.row1_bar, R.id.row1_reset,
|
populateRow(views, R.id.row1_pct, R.id.row1_bar, R.id.row1_reset,
|
||||||
pct = extras["session.pct"]?.toIntOrNull(),
|
pct = extras["session.pct"]?.toIntOrNull(),
|
||||||
resetSec = extras["session.resetAt"]?.toLongOrNull()?.let { (it - System.currentTimeMillis()) / 1000 }?.takeIf { it > 0 })
|
resetSec = extras["session.resetAt"]?.toLongOrNull()?.let { (it - System.currentTimeMillis()) / 1000 }?.takeIf { it > 0 })
|
||||||
@ -303,7 +303,7 @@ class OpenCodeGoWidgetProvider : AppWidgetProvider() {
|
|||||||
ServiceType.OPENCODE_GO, ServiceType.COMMANDCODE_GO -> R.drawable.ic_opencode_go_logo
|
ServiceType.OPENCODE_GO, ServiceType.COMMANDCODE_GO -> R.drawable.ic_opencode_go_logo
|
||||||
ServiceType.CODEX -> R.drawable.ic_codex_logo
|
ServiceType.CODEX -> R.drawable.ic_codex_logo
|
||||||
ServiceType.DEEPSEEK -> R.drawable.ic_deepseek_logo
|
ServiceType.DEEPSEEK -> R.drawable.ic_deepseek_logo
|
||||||
ServiceType.OLLAMA -> R.drawable.ic_opencode_go_logo // 复用,后续可换 Ollama logo
|
ServiceType.OLLAMA -> R.drawable.ic_ollama_logo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
BIN
app/src/main/res/drawable-nodpi/ic_ollama_logo.png
Normal file
BIN
app/src/main/res/drawable-nodpi/ic_ollama_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 890 B |
Loading…
Reference in New Issue
Block a user