Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions android/app/src/main/java/dev/opencode/mobile/theme/Radius.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import androidx.compose.ui.unit.dp
object OpenCodeRadius {
val small = 8.dp
val medium = 12.dp

/** A floating pill's corner (half its 36 dp height), for cards anchored to a pill. */
val large = 18.dp
val pill = 999.dp
}

val OpenCodeSmallShape = RoundedCornerShape(OpenCodeRadius.small)
val OpenCodeMediumShape = RoundedCornerShape(OpenCodeRadius.medium)
val OpenCodeLargeShape = RoundedCornerShape(OpenCodeRadius.large)
val OpenCodePillShape = RoundedCornerShape(OpenCodeRadius.pill)
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ val ComponentGalleryEntries =
ComponentGalleryEntry(
id = ComponentGalleryEntryId.SessionBranchPill,
title = "Session Branch Pill",
description = "Floating worktree branch and uncommitted line counts.",
description = "Floating branch pill with uncommitted line counts and a branch details popover.",
category = ComponentGalleryCategory.Session,
),
ComponentGalleryEntry(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,85 +1,95 @@
package dev.opencode.mobile.ui.componentgallery.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.theme.openCodeColor
import dev.opencode.mobile.ui.components.OpenCodeAnchoredCardLayout
import dev.opencode.mobile.ui.components.OpenCodeChoiceBadge
import dev.opencode.mobile.ui.components.OpenCodeFloatingPill
import dev.opencode.mobile.ui.components.OpenCodeFloatingPillLayout
import dev.opencode.mobile.ui.components.OpenCodeFloatingPillState
import dev.opencode.mobile.ui.components.OpenCodeSessionBranchPill
import dev.opencode.mobile.ui.components.OpenCodeSessionBranchPopoverContent
import dev.opencode.mobile.ui.components.SessionBranchPopoverWidth
import dev.opencode.mobile.ui.icons.OpenCodeIcons
import dev.opencode.mobile.ui.components.SessionBranchPillPreviewCase

@Composable
fun SessionBranchPillGalleryScreen(modifier: Modifier = Modifier) {
var enabled by rememberSaveable { mutableStateOf(true) }
var sample by rememberSaveable { mutableStateOf(SessionBranchPillGallerySample.Mixed) }
var sample by rememberSaveable { mutableStateOf(SessionBranchPillPreviewCase.Changes) }
var copiedCount by rememberSaveable { mutableIntStateOf(0) }

Column(modifier = modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(text = "Interactive", style = MaterialTheme.typography.titleMedium)
Text(
text = "Review mixed, additions-only, deletions-only, clean, long-branch, and disabled states.",
text =
"Tap the pill to open its popover. With changes it shows the line counts; without, " +
"the icon only. Worktree sessions use the worktree icon.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
OpenCodeChoiceBadge(
"Mixed",
sample == SessionBranchPillGallerySample.Mixed,
onClick = { sample = SessionBranchPillGallerySample.Mixed },
SessionBranchPillPreviewCase.entries.forEach { option ->
OpenCodeChoiceBadge(option.galleryLabel, sample == option, onClick = { sample = option })
}
}
// As in the Session Chat top-left corner: the branch first, then todos.
Row(horizontalArrangement = Arrangement.spacedBy(OpenCodeAnchoredCardLayout.Gap)) {
OpenCodeSessionBranchPill(
summary = sample.summary,
onViewAllChanges = {},
onBranchNameCopied = { copiedCount += 1 },
)
OpenCodeChoiceBadge(
"+ only",
sample == SessionBranchPillGallerySample.AdditionsOnly,
onClick = { sample = SessionBranchPillGallerySample.AdditionsOnly },
OpenCodeFloatingPill(
layout = OpenCodeFloatingPillLayout.IconLabel(OpenCodeIcons.List, "2/5"),
state = OpenCodeFloatingPillState.Ready,
accessibilityLabel = "Todos, 2 of 5 done",
onClick = {},
)
OpenCodeChoiceBadge(
"− only",
sample == SessionBranchPillGallerySample.DeletionsOnly,
onClick = { sample = SessionBranchPillGallerySample.DeletionsOnly },
}
if (copiedCount > 0) {
Text(
text = "Branch name copied ($copiedCount)",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}

Text(text = "All pills", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(top = 8.dp))
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
OpenCodeChoiceBadge(
"Clean",
sample == SessionBranchPillGallerySample.Clean,
onClick = { sample = SessionBranchPillGallerySample.Clean },
)
OpenCodeChoiceBadge(
"Long",
sample == SessionBranchPillGallerySample.LongBranch,
onClick = { sample = SessionBranchPillGallerySample.LongBranch },
)
OpenCodeChoiceBadge("Enabled", enabled, onClick = { enabled = !enabled })
SessionBranchPillPreviewCase.entries.forEach { option ->
OpenCodeSessionBranchPill(summary = option.summary, onViewAllChanges = {})
}
}
Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
OpenCodeSessionBranchPill(
branch = sample.branch,
additions = sample.additions,
deletions = sample.deletions,
enabled = enabled,
onClick = {},

Text(text = "Popover open", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(top = 8.dp))
Surface(
modifier = Modifier.widthIn(max = SessionBranchPopoverWidth),
shape = OpenCodeAnchoredCardLayout.Shape,
color = openCodeColor("surface-raised-base"),
border = BorderStroke(1.dp, openCodeColor("border-weak-base")),
) {
OpenCodeSessionBranchPopoverContent(
summary = sample.summary,
onViewAllChanges = {},
onCopyBranchName = {},
)
}
}
}

private enum class SessionBranchPillGallerySample(
val branch: String,
val additions: Int,
val deletions: Int,
) {
Mixed("feature/session-branch", 12, 3),
AdditionsOnly("feature/session-branch", 12, 0),
DeletionsOnly("feature/session-branch", 0, 3),
Clean("main", 0, 0),
LongBranch("feature/very-long-worktree-branch-name-that-must-ellipsis", 48, 2),
}
Loading