madeveloper: rebuild every screen on the shared design system
- Commit
0265d2b7ce75e8d93025b4df6827846efa45fd22- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 15:52 UTC (18 days ago)
- Parents
079a49c
The Developer screens were functional but plain: bare text rows, a separate button under every list item, raw dp literals, and no loading, empty or error states beyond a spinner and red text. This rebuilds the presentation of all eight screens on the shared library/ui design system without changing any route, view-model contract or behaviour: - Home is now a dashboard: DashboardSection cards for push status (with a semantic StatusChip), the latest CI run (status chip, monospace short hash, coverage), quick links to Tests/Catalog/Push plus issue and PR counts, an activity preview, and the repository list with language, branch, short-hash and relative-time chips. Pull-to-refresh via AppPullToRefreshBox, a top-bar refresh action, LoadingState while loading and ErrorState with retry on failure. - Repo browsing uses section cards for the clone URL and branch selector, CommitRow for recent commits, and a file tree whose entries are lazy rows with file-type icons from the new FileKind mapping, a breadcrumb path row and the existing filter. Commits are lazy CommitRows with author, relative time and monospace short hash, Load more preserved. - Commit detail is a readable card (subject, full monospace SHA, author and time rows, body) with an EmptyState when the commit is outside the loaded pages; the git-host link-out remains, as the API has no diff endpoint. - File view shows the repo-relative path in monospace, the code in a surface card with line numbers and horizontal scroll, and ErrorState with retry; binary/truncated notices are kept. - Tests splits running, latest and history runs with status chips; Catalog and Push use section cards, status chips and a progress indicator for downloading/verifying installs. The Install button still only appears for READY pushes. - New shared components StatusChip and CommitRow, each the one public composable in its file; all icons go through library/ui IconXxx(), spacing through Spacing tokens, and no screen uses a raw Scaffold, Toast or material icon. Compose tests were updated where they asserted on the old chrome (per-row buttons, prefixed labels) and gained a clickable-row helper plus a Home empty-state test. The store screenshot was re-rendered with :madeveloper:metadata (1 image, phone bucket). Verified: :madeveloper:testDevUnitTest (47 tests, 0 failures), :madeveloper:lintDev and :madeveloper:detekt all green; :madeveloper:updateScreenshotTest renders the home preview successfully. No pushes.
Diff
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.ktindex ed33bbb875..75c7330f14 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CatalogScreen.kt@@ -1,14 +1,20 @@ package com.vayunmathur.madeveloper.ui import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier-import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.IconApps+import com.vayunmathur.library.ui.IconInfo import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.platform.MaDevUiState@@ -16,16 +22,60 @@ import com.vayunmathur.madeveloper.platform.MaDevUiState /** Read-only catalog of available builds; installs arrive by server push. */ @Composable fun CatalogScreen(state: MaDevUiState, onBack: () -> Unit) {- AppScaffold(title = "Available builds", onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior()) { padding ->- LazyColumn(Modifier.padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {- item { Text("Read-only: installs are pushed from the server and confirmed here.") }- items(state.catalog) { app ->- ListItem(- headlineContent = { Text(app.name) },- supportingContent = { Text(app.packageName + " · " + (app.versionName ?: "") + " (" + app.versionCode + ") · " + app.sizeLabel) },- )+ AppScaffold(+ title = "Available builds",+ subtitle = "Read-only catalog",+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ item {+ DashboardSection(+ title = "About this catalog",+ leadingIcon = { modifier, tint -> IconInfo(modifier, tint) },+ ) {+ Text(+ "Read-only: installs are pushed from the server and confirmed here.",+ modifier = Modifier.padding(Spacing.lg),+ style = MaterialTheme.typography.bodyMedium,+ )+ }+ }+ item {+ DashboardSection(+ title = "Builds",+ leadingIcon = { modifier, tint -> IconApps(modifier, tint) },+ ) {+ if (state.catalog.isEmpty()) {+ Text(+ "No catalog loaded yet.",+ modifier = Modifier.padding(Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ state.catalog.forEachIndexed { index, app ->+ if (index > 0) DashboardSectionDivider()+ ListItem(+ headlineContent = { Text(app.name) },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ if (app.summary.isNotBlank()) Text(app.summary, maxLines = 2)+ Text(+ app.packageName + " · " + (app.versionName ?: "") ++ " (" + app.versionCode + ") · " + app.sizeLabel,+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ },+ leadingContent = { IconApps() },+ )+ }+ } }- if (state.catalog.isEmpty()) item { Text("No catalog loaded yet.") } } } }
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitRow.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitRow.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitRow.ktnew file mode 100644index 0000000000..756e23dace--- /dev/null+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitRow.kt@@ -0,0 +1,58 @@+package com.vayunmathur.madeveloper.ui++import androidx.compose.foundation.clickable+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.padding+import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.text.font.FontFamily+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.IconChevronRight+import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Text+import com.vayunmathur.madeveloper.domain.DevPresentation+import com.vayunmathur.madeveloper.domain.GitCommit++/** One commit as a tappable list row: subject, author, relative time and short hash. */+@Composable+fun CommitRow(commit: GitCommit, onClick: () -> Unit, modifier: Modifier = Modifier) {+ val now = remember { System.currentTimeMillis() }+ val relative = DevPresentation.relativeTimeLabel(commit.time, now)+ ListItem(+ headlineContent = {+ Text(commit.subject.ifBlank { commit.shortSha }, maxLines = 2)+ },+ supportingContent = {+ Column {+ Row(verticalAlignment = Alignment.CenterVertically) {+ Text(+ commit.shortSha.ifBlank { DevPresentation.shortSha(commit.sha) },+ style = MaterialTheme.typography.bodySmall,+ fontFamily = FontFamily.Monospace,+ color = MaterialTheme.colorScheme.primary,+ )+ if (commit.author.isNotBlank()) {+ Text(+ " · " + commit.author,+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ if (relative.isNotBlank()) {+ Text(+ " · " + relative,+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ }+ },+ trailingContent = { IconChevronRight() },+ modifier = modifier.clickable(onClick = onClick).padding(horizontal = 4.dp),+ )+}
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.ktindex bc00fa6bb2..f796bf0eb1 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitScreen.kt@@ -8,15 +8,26 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect+import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.unit.dp+import androidx.compose.ui.text.font.FontFamily import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.EmptyState import com.vayunmathur.library.ui.ExternalIntents+import com.vayunmathur.library.ui.IconGlobe+import com.vayunmathur.library.ui.IconHistory+import com.vayunmathur.library.ui.IconPerson+import com.vayunmathur.library.ui.IconSchedule+import com.vayunmathur.library.ui.ListItem import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.platform.MaDevViewModel /**@@ -30,27 +41,76 @@ fun CommitScreen(repoName: String, sha: String, viewModel: MaDevViewModel, onBac LaunchedEffect(repoName) { viewModel.loadRepo(repoName) } // The commit is identified by the route's sha alone; no VM selection state. val commit = viewModel.browser(repoName)?.commits?.firstOrNull { it.sha == sha }+ val now = remember { System.currentTimeMillis() } AppScaffold(- title = commit?.shortSha?.ifBlank { sha.take(8) } ?: sha.take(8),- onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior(),+ title = commit?.shortSha?.ifBlank { sha.take(SHORT_SHA_LENGTH) } ?: sha.take(SHORT_SHA_LENGTH),+ subtitle = repoName,+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(), ) { padding -> Column(- Modifier.padding(padding).padding(16.dp).verticalScroll(rememberScrollState()),- verticalArrangement = Arrangement.spacedBy(8.dp),+ Modifier.padding(padding).verticalScroll(rememberScrollState()),+ verticalArrangement = Arrangement.spacedBy(Spacing.md), ) { if (commit == null) {- Text("Commit not in the loaded pages. Open the commits list and load more, or view it on the git host.")+ EmptyState(+ title = "Commit not loaded",+ message = "Commit not in the loaded pages. Open the commits list and load more, or view it on the git host.",+ ) } else {- Text(commit.subject.ifBlank { commit.shortSha }, style = MaterialTheme.typography.titleMedium)- Text("Author: " + commit.author)- Text("Time: " + commit.time)- Text("SHA: " + commit.sha)- if (commit.body.isNotBlank()) Text(commit.body)+ DashboardSection(+ title = "Commit",+ leadingIcon = { modifier, tint -> IconHistory(modifier, tint) },+ ) {+ Column(+ modifier = Modifier.padding(Spacing.lg),+ verticalArrangement = Arrangement.spacedBy(Spacing.sm),+ ) {+ Text(+ commit.subject.ifBlank { commit.shortSha },+ style = MaterialTheme.typography.titleMedium,+ )+ Text(+ commit.sha,+ style = MaterialTheme.typography.bodySmall,+ fontFamily = FontFamily.Monospace,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ DashboardSectionDivider()+ ListItem(+ headlineContent = { Text(commit.author.ifBlank { "Unknown author" }) },+ supportingContent = { Text("Author") },+ leadingContent = { IconPerson() },+ )+ DashboardSectionDivider()+ ListItem(+ headlineContent = {+ val relative = DevPresentation.relativeTimeLabel(commit.time, now)+ Text(relative.ifBlank { commit.time }.ifBlank { "Unknown time" })+ },+ supportingContent = { Text(commit.time) },+ leadingContent = { IconSchedule() },+ )+ if (commit.body.isNotBlank()) {+ DashboardSectionDivider()+ Text(+ commit.body,+ modifier = Modifier.padding(Spacing.lg),+ style = MaterialTheme.typography.bodyMedium,+ )+ }+ } } Button( onClick = { ExternalIntents.openUrl(context, "https://git.maproj.org/$repoName") },- modifier = Modifier.fillMaxWidth(),- ) { Text("View on git host") }+ modifier = Modifier.fillMaxWidth().padding(horizontal = Spacing.lg),+ ) {+ IconGlobe()+ Text("View on git host", modifier = Modifier.padding(start = Spacing.sm))+ } } } }++private const val SHORT_SHA_LENGTH = 8
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.ktindex 119c4e1c35..24962ac54b 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/CommitsScreen.kt@@ -1,8 +1,9 @@ package com.vayunmathur.madeveloper.ui import androidx.compose.foundation.layout.Arrangement-import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items@@ -10,10 +11,14 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppPullToRefreshBox import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.ErrorState+import com.vayunmathur.library.ui.LoadingState import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior import com.vayunmathur.madeveloper.platform.MaDevViewModel@@ -32,34 +37,57 @@ fun CommitsScreen( viewModel.loadRepo(repoName) if (browser != null && browser.commits.isEmpty()) viewModel.loadCommits(repoName, loadMore = false) }- AppScaffold(title = "Commits · $branch", onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior()) { padding ->- LazyColumn(Modifier.padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {- viewModel.state.repoError?.let { error ->- item { Text(error, color = MaterialTheme.colorScheme.error) }- }- if (browser == null) {- item { Text("Loading commits…") }- } else {- items(browser.commits) { commit ->- Column {- ListItem(- headlineContent = { Text(commit.subject.ifBlank { commit.shortSha }) },- supportingContent = {- Text(commit.shortSha + " · " + commit.author + " · " + commit.time)- },+ AppScaffold(+ title = "Commits",+ subtitle = "$repoName · $branch",+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ AppPullToRefreshBox(+ isRefreshing = false,+ onRefresh = { viewModel.loadCommits(repoName, loadMore = false) },+ modifier = Modifier.fillMaxSize(),+ ) {+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ viewModel.state.repoError?.let { error ->+ item {+ ErrorState(+ title = "Could not load commits",+ message = error,+ retryLabel = "Retry",+ onRetry = { viewModel.loadCommits(repoName, loadMore = false) }, )- Button(onClick = { onOpenCommit(commit.sha) }, modifier = Modifier.fillMaxWidth()) {- Text("View commit")- } } }- if (browser.commits.isEmpty()) item { Text("No commits loaded yet.") }- if (!browser.commitsExhausted) {+ if (browser == null) {+ if (viewModel.state.repoError == null) {+ item { LoadingState(message = "Loading commits…", modifier = Modifier.fillMaxWidth().height(160.dp)) }+ }+ } else { item {- Button(- onClick = { viewModel.loadCommits(repoName, loadMore = true) },- modifier = Modifier.fillMaxWidth(),- ) { Text("Load more") }+ DashboardSection(title = "Commits on $branch") {+ if (browser.commits.isEmpty()) {+ Text(+ "No commits",+ modifier = Modifier.padding(Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ }+ items(browser.commits) { commit ->+ CommitRow(commit = commit, onClick = { onOpenCommit(commit.sha) })+ }+ if (!browser.commitsExhausted && browser.commits.isNotEmpty()) {+ item {+ Button(+ onClick = { viewModel.loadCommits(repoName, loadMore = true) },+ modifier = Modifier.fillMaxWidth().padding(horizontal = Spacing.lg),+ ) { Text("Load more") }+ } } } }
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.ktindex 1a32e6762d..eb830b4a6f 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/FileScreen.kt@@ -1,7 +1,11 @@ package com.vayunmathur.madeveloper.ui +import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll@@ -13,10 +17,19 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp+import androidx.compose.ui.text.font.FontFamily import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.ErrorState+import com.vayunmathur.library.ui.IconDescription+import com.vayunmathur.library.ui.LoadingState import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing+import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.GitFile import com.vayunmathur.madeveloper.platform.MaDevViewModel @@ -25,31 +38,85 @@ import com.vayunmathur.madeveloper.platform.MaDevViewModel fun FileScreen(repoName: String, path: String, branch: String, viewModel: MaDevViewModel, onBack: () -> Unit) { var file by remember { mutableStateOf<GitFile?>(null) } var error by remember { mutableStateOf<String?>(null) }- LaunchedEffect(repoName, path, branch) {+ var reloadTick by remember { mutableStateOf(0) }+ LaunchedEffect(repoName, path, branch, reloadTick) { error = null file = runCatching { viewModel.file(repoName, branch, path) } .getOrElse { error = it.message; null } }- AppScaffold(title = path.substringAfterLast('/'), onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior()) { padding ->+ val fileName = path.substringAfterLast('/')+ AppScaffold(+ title = fileName,+ subtitle = "$repoName · $branch",+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding -> Column(- Modifier.padding(padding).padding(16.dp).verticalScroll(rememberScrollState()),- verticalArrangement = Arrangement.spacedBy(8.dp),+ Modifier.padding(padding).verticalScroll(rememberScrollState()),+ verticalArrangement = Arrangement.spacedBy(Spacing.md), ) {- error?.let { Text(it, color = MaterialTheme.colorScheme.error) }+ Text(+ path,+ style = MaterialTheme.typography.bodySmall,+ fontFamily = FontFamily.Monospace,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ modifier = Modifier.padding(horizontal = Spacing.lg, vertical = Spacing.sm),+ )+ error?.let {+ ErrorState(+ title = "Could not load this file",+ message = it,+ retryLabel = "Retry",+ onRetry = { reloadTick++ },+ )+ } val loaded = file when {- loaded == null && error == null -> Text("Loading file…")+ loaded == null && error == null -> LoadingState(message = "Loading file…", modifier = Modifier.fillMaxWidth().height(160.dp)) loaded == null -> Unit- loaded.isBinary -> Text("Binary file · ${loaded.size} B · ${loaded.sha.take(8)}")- else -> {- if (loaded.truncated) Text("File truncated by the server · ${loaded.size} B")+ loaded.isBinary -> DashboardSection(+ title = "Binary file",+ leadingIcon = { modifier, tint -> IconDescription(modifier, tint) },+ ) { Text(- (loaded.content ?: "").lines()- .mapIndexed { index, line -> (index + 1).toString().padStart(4) + " " + line }- .joinToString("\n"),+ "Binary file · ${loaded.size} B · ${DevPresentation.shortSha(loaded.sha)}",+ modifier = Modifier.padding(Spacing.lg), ) }++ else -> {+ if (loaded.truncated) {+ Text(+ "File truncated by the server · ${loaded.size} B",+ color = MaterialTheme.colorScheme.error,+ modifier = Modifier.padding(horizontal = Spacing.lg),+ )+ }+ Surface(+ modifier = Modifier.fillMaxWidth().padding(horizontal = Spacing.lg),+ shape = MaterialTheme.shapes.medium,+ color = MaterialTheme.colorScheme.surfaceContainerLow,+ ) {+ Row(Modifier.horizontalScroll(rememberScrollState())) {+ Text(+ (loaded.content ?: "").lines()+ .mapIndexed { index, line ->+ (index + 1).toString().padStart(LINE_NUMBER_WIDTH) + " " + line+ }+ .joinToString("\n"),+ style = MaterialTheme.typography.bodySmall,+ fontFamily = FontFamily.Monospace,+ modifier = Modifier.padding(Spacing.md),+ )+ }+ }+ if ((loaded.content ?: "").isBlank()) {+ EmptyState(title = "Empty file", message = "This file has no text content.")+ }+ } } } } }++private const val LINE_NUMBER_WIDTH = 4
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.ktindex 1577ff2632..261d62046f 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/HomeScreen.kt@@ -1,69 +1,286 @@ package com.vayunmathur.madeveloper.ui +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable+import androidx.compose.runtime.remember+import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp+import androidx.compose.ui.text.font.FontFamily+import com.vayunmathur.library.ui.AppPullToRefreshBox import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.Card-import com.vayunmathur.library.ui.CircularProgressIndicator+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.ErrorState+import com.vayunmathur.library.ui.IconApps+import com.vayunmathur.library.ui.IconBugReport+import com.vayunmathur.library.ui.IconButton+import com.vayunmathur.library.ui.IconCheckCircle+import com.vayunmathur.library.ui.IconChevronRight import com.vayunmathur.library.ui.IconCode+import com.vayunmathur.library.ui.IconHistory+import com.vayunmathur.library.ui.IconInstall+import com.vayunmathur.library.ui.IconMerge+import com.vayunmathur.library.ui.IconRefresh import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.LoadingState import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.madeveloper.domain.CiStatus+import com.vayunmathur.madeveloper.domain.DevPresentation+import com.vayunmathur.madeveloper.domain.GitRepo import com.vayunmathur.madeveloper.platform.MaDevUiState -/** Home: push status, CI summary and the hosted repositories. */+/** Home dashboard: push status, CI summary, quick links and hosted repositories. */ @Composable-fun HomeScreen(state: MaDevUiState, onRefresh: () -> Unit, onOpenRepo: (String) -> Unit, onOpenTests: () -> Unit, onOpenCatalog: () -> Unit, onOpenPush: () -> Unit) {- AppScaffold(title = "Developer", scrollBehavior = appBarScrollBehavior()) { padding ->- LazyColumn(Modifier.padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {- item {- Card(Modifier.fillMaxWidth()) {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {- Text(if (state.connected) "Push socket connected" else "Push socket offline", style = MaterialTheme.typography.titleMedium)- Text(if (state.paired) "This device is paired for pushed installs." else "Pairing code: " + state.pairingCode)- Button(onClick = onOpenPush) { Text("Pushed installs") }+fun HomeScreen(+ state: MaDevUiState,+ onRefresh: () -> Unit,+ onOpenRepo: (String) -> Unit,+ onOpenTests: () -> Unit,+ onOpenCatalog: () -> Unit,+ onOpenPush: () -> Unit,+) {+ AppScaffold(+ title = "MA Developer",+ scrollBehavior = appBarScrollBehavior(),+ actions = {+ IconButton(onClick = onRefresh) { IconRefresh() }+ },+ ) { padding ->+ AppPullToRefreshBox(+ isRefreshing = state.loading,+ onRefresh = onRefresh,+ modifier = Modifier.fillMaxSize(),+ ) {+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ item { PushStatusSection(state, onOpenPush) }+ state.tests?.latest?.let { latest ->+ item {+ DashboardSection(+ title = "Continuous integration",+ leadingIcon = { modifier, tint -> IconCheckCircle(modifier, tint) },+ ) {+ ListItem(+ headlineContent = { Text(latest.subject.ifBlank { "Latest run" }) },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ Text(+ DevPresentation.shortSha(latest.sha),+ fontFamily = FontFamily.Monospace,+ style = MaterialTheme.typography.bodySmall,+ )+ state.tests.coveragePct?.let {+ Text("Coverage %.1f%%".format(it))+ }+ }+ },+ trailingContent = {+ StatusChip(latest.status, DevPresentation.ciStatusOf(latest.status))+ },+ modifier = Modifier.clickable(onClick = onOpenTests),+ )+ }+ }+ }+ item { QuickLinksSection(state, onOpenTests, onOpenCatalog, onOpenPush) }+ if (state.loading && state.repos.isEmpty()) {+ item { LoadingState(message = "Loading repositories…", modifier = Modifier.fillMaxWidth().height(160.dp)) }+ }+ state.error?.let { error ->+ if (state.repos.isEmpty()) {+ item {+ ErrorState(+ title = "Could not load the git host",+ message = error,+ retryLabel = "Retry",+ onRetry = onRefresh,+ )+ } } }- }- state.tests?.latest?.let { latest -> item {- Card(Modifier.fillMaxWidth()) {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {- Text("CI: " + latest.status, style = MaterialTheme.typography.titleMedium)- Text(latest.subject)- state.tests.coveragePct?.let { Text("Coverage %.1f%%".format(it)) }- Button(onClick = onOpenTests) { Text("Test history") }+ DashboardSection(+ title = "Repositories",+ leadingIcon = { modifier, tint -> IconCode(modifier, tint) },+ ) {+ if (state.repos.isEmpty() && !state.loading) {+ Text(+ "No repositories",+ modifier = Modifier.padding(Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ state.repos.forEachIndexed { index, repo ->+ if (index > 0) DashboardSectionDivider()+ RepoRow(repo = repo, onClick = { onOpenRepo(repo.name) }) } } }+ if (state.issues.isNotEmpty() || state.prs.isNotEmpty()) {+ item { ActivitySection(state) }+ } }- item { Button(onClick = onOpenCatalog, modifier = Modifier.fillMaxWidth()) { Text("Available builds (read-only catalog)") } }- item { Button(onClick = onRefresh, modifier = Modifier.fillMaxWidth()) { Text("Refresh") } }- if (state.loading) item { CircularProgressIndicator() }- state.error?.let { error -> item { Text(error, color = MaterialTheme.colorScheme.error) } }- items(state.repos) { repo ->- ListItem(- headlineContent = { Text(repo.name) },- supportingContent = {- Text(- listOf(repo.defaultBranch, repo.shortHeadSha, repo.headSubject)- .filter { it.isNotBlank() }.joinToString(" · ").ifBlank { repo.cloneUrl },- )+ }+ }+}++@Composable+private fun PushStatusSection(state: MaDevUiState, onOpenPush: () -> Unit) {+ DashboardSection(+ title = "Pushed installs",+ actionLabel = "Open",+ onAction = onOpenPush,+ leadingIcon = { modifier, tint -> IconInstall(modifier, tint) },+ ) {+ ListItem(+ headlineContent = {+ Text(if (state.connected) "Push socket connected" else "Push socket offline")+ },+ supportingContent = {+ Text(+ if (state.paired) {+ "This device is paired for pushed installs."+ } else {+ "Pairing code: " + state.pairingCode },- leadingContent = { IconCode() },- modifier = Modifier.fillMaxWidth(), )- Button(onClick = { onOpenRepo(repo.name) }, modifier = Modifier.fillMaxWidth()) { Text("Open " + repo.name) }- }+ },+ leadingContent = { IconInstall() },+ trailingContent = {+ StatusChip(+ label = if (state.connected) "Connected" else "Offline",+ status = if (state.connected) CiStatus.Passed else CiStatus.Unknown,+ )+ },+ modifier = Modifier.clickable(onClick = onOpenPush),+ )+ }+}++@Composable+private fun QuickLinksSection(+ state: MaDevUiState,+ onOpenTests: () -> Unit,+ onOpenCatalog: () -> Unit,+ onOpenPush: () -> Unit,+) {+ DashboardSection(+ title = "Quick links",+ leadingIcon = { modifier, tint -> IconApps(modifier, tint) },+ ) {+ QuickLinkRow("Test history", "CI runs and coverage", onOpenTests) { IconHistory() }+ DashboardSectionDivider()+ QuickLinkRow("Available builds", "Read-only catalog", onOpenCatalog) { IconApps() }+ DashboardSectionDivider()+ QuickLinkRow("Pushed installs", "Pairing and pending installs", onOpenPush) { IconInstall() }+ if (state.issues.isNotEmpty()) {+ DashboardSectionDivider()+ QuickLinkRow("Issues", "${state.issues.size} open across hosted repos", {}) { IconBugReport() }+ }+ if (state.prs.isNotEmpty()) {+ DashboardSectionDivider()+ QuickLinkRow("Pull requests", "${state.prs.size} open across hosted repos", {}) { IconMerge() } } } }++@Composable+private fun QuickLinkRow(+ title: String,+ subtitle: String,+ onClick: () -> Unit,+ icon: @Composable () -> Unit,+) {+ ListItem(+ headlineContent = { Text(title) },+ supportingContent = { Text(subtitle) },+ leadingContent = icon,+ trailingContent = { IconChevronRight() },+ modifier = Modifier.clickable(onClick = onClick),+ )+}++@Composable+private fun ActivitySection(state: MaDevUiState) {+ DashboardSection(title = "Recent activity") {+ state.issues.take(3).forEach { issue ->+ ListItem(+ headlineContent = { Text(issue.title, maxLines = 1) },+ supportingContent = {+ Text("${issue.repo} #${issue.number} · ${issue.author}")+ },+ leadingContent = { IconBugReport() },+ )+ }+ state.prs.take(3).forEach { pr ->+ ListItem(+ headlineContent = { Text(pr.title, maxLines = 1) },+ supportingContent = { Text("${pr.repo} #${pr.number} · ${pr.author}") },+ leadingContent = { IconMerge() },+ )+ }+ }+}++@Composable+private fun RepoRow(repo: GitRepo, onClick: () -> Unit) {+ val now = remember { System.currentTimeMillis() }+ val relative = DevPresentation.relativeTimeLabel(repo.headTime, now)+ ListItem(+ headlineContent = { Text(repo.name) },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ if (repo.headSubject.isNotBlank()) Text(repo.headSubject, maxLines = 1)+ Row(+ horizontalArrangement = Arrangement.spacedBy(Spacing.sm),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ Text(+ DevPresentation.repoLanguage(repo.name),+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.primary,+ )+ if (repo.defaultBranch.isNotBlank()) {+ Text(+ repo.defaultBranch,+ style = MaterialTheme.typography.labelSmall,+ fontFamily = FontFamily.Monospace,+ )+ }+ if (repo.shortHeadSha.isNotBlank()) {+ Text(+ repo.shortHeadSha,+ style = MaterialTheme.typography.labelSmall,+ fontFamily = FontFamily.Monospace,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ if (relative.isNotBlank()) {+ Text(+ relative,+ style = MaterialTheme.typography.labelSmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ }+ },+ leadingContent = { IconCode() },+ trailingContent = { IconChevronRight() },+ modifier = Modifier.fillMaxWidth().clickable(onClick = onClick),+ )+}
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.ktindex 7dbcbd680e..6f57e2deeb 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/PushScreen.kt@@ -2,60 +2,142 @@ package com.vayunmathur.madeveloper.ui import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier-import androidx.compose.ui.unit.dp import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button-import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider import com.vayunmathur.library.ui.IconInstall+import com.vayunmathur.library.ui.LinearProgressIndicator import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.madeveloper.domain.CiStatus+import com.vayunmathur.madeveloper.domain.DevPresentation import com.vayunmathur.madeveloper.domain.InstallPhase import com.vayunmathur.madeveloper.platform.MaDevUiState /** Pairing state and pending server-pushed installs. */ @Composable fun PushScreen(state: MaDevUiState, onInstall: (String) -> Unit, onBack: () -> Unit) {- AppScaffold(title = "Pushed installs", onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior()) { padding ->- LazyColumn(Modifier.padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(12.dp)) {+ AppScaffold(+ title = "Pushed installs",+ subtitle = if (state.connected) "Connected" else "Offline",+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) { item {- Card(Modifier.fillMaxWidth()) {- Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {- Text(- when {- state.paired -> "Paired"- state.pairingCode.isNotBlank() -> "Pairing code: " + state.pairingCode- else -> "Registering this device…"- },- )+ DashboardSection(+ title = "Pairing",+ leadingIcon = { modifier, tint -> IconInstall(modifier, tint) },+ ) {+ ListItem(+ headlineContent = {+ Text(+ when {+ state.paired -> "Paired"+ state.pairingCode.isNotBlank() -> "Pairing code: " + state.pairingCode+ else -> "Registering this device…"+ },+ )+ },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ Text(+ if (state.connected) {+ "Socket connected to api.maproj.org"+ } else if (state.awaitingApproval) {+ "Waiting for approval in the server's /dev panel"+ } else {+ "Socket offline; reconnecting with backoff"+ },+ )+ Text("Approve the pairing code in the server's /dev panel to activate this device.")+ }+ },+ trailingContent = {+ StatusChip(+ label = if (state.connected) "Connected" else "Offline",+ status = if (state.connected) CiStatus.Passed else CiStatus.Unknown,+ )+ },+ )+ }+ }+ item {+ DashboardSection(+ title = "Pending installs",+ leadingIcon = { modifier, tint -> IconInstall(modifier, tint) },+ ) {+ if (state.pending.isEmpty()) { Text(- when {- state.connected -> "Socket connected to api.maproj.org"- state.awaitingApproval -> "Waiting for approval in the server's /dev panel"- else -> "Socket offline; reconnecting with backoff"- },+ "No pushed installs yet. Installs always need your tap; nothing installs silently.",+ modifier = Modifier.padding(Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant, )- Text("Approve the pairing code in the server's /dev panel to activate this device.")+ }+ state.pending.forEachIndexed { index, pending ->+ if (index > 0) DashboardSectionDivider()+ Column {+ ListItem(+ headlineContent = { Text(pending.pkg) },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ Text(+ DevPresentation.installPhaseLabel(pending.phase) ++ " · version " + pending.versionCode,+ )+ pending.error?.let {+ Text(it, color = MaterialTheme.colorScheme.error)+ }+ }+ },+ leadingContent = { IconInstall() },+ trailingContent = {+ StatusChip(+ label = DevPresentation.installPhaseLabel(pending.phase),+ status = when (pending.phase) {+ InstallPhase.READY, InstallPhase.DONE -> CiStatus.Passed+ InstallPhase.FAILED -> CiStatus.Failed+ InstallPhase.DOWNLOADING, InstallPhase.VERIFYING,+ InstallPhase.INSTALLING,+ -> CiStatus.Running++ InstallPhase.PUSHED -> CiStatus.Unknown+ },+ )+ },+ )+ if (pending.phase == InstallPhase.DOWNLOADING ||+ pending.phase == InstallPhase.VERIFYING+ ) {+ LinearProgressIndicator(+ progress = { pending.progress.coerceIn(0f, 1f) },+ modifier = Modifier.fillMaxWidth().padding(horizontal = Spacing.lg),+ )+ }+ if (pending.phase == InstallPhase.READY) {+ Button(+ onClick = { onInstall(pending.pkg) },+ modifier = Modifier.fillMaxWidth()+ .padding(horizontal = Spacing.lg, vertical = Spacing.sm),+ ) { Text("Install") }+ }+ } } } }- items(state.pending) { pending ->- ListItem(- headlineContent = { Text(pending.pkg) },- supportingContent = { Text(pending.phase.name + " · version " + pending.versionCode + (pending.error?.let { " · " + it } ?: "")) },- leadingContent = { IconInstall() },- )- if (pending.phase == InstallPhase.READY) {- Button(onClick = { onInstall(pending.pkg) }, modifier = Modifier.fillMaxWidth()) { Text("Install") }- }- }- if (state.pending.isEmpty()) item { Text("No pushed installs yet. Installs always need your tap; nothing installs silently.") } } } }
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.ktindex e864ce4ab4..15fd47a40a 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/RepoScreen.kt@@ -1,9 +1,11 @@ package com.vayunmathur.madeveloper.ui +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items@@ -13,18 +15,37 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue+import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier-import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp+import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.text.font.FontFamily import com.vayunmathur.library.ui.AppScaffold import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.ErrorState import com.vayunmathur.library.ui.ExternalIntents+import com.vayunmathur.library.ui.IconChevronRight+import com.vayunmathur.library.ui.IconCode+import com.vayunmathur.library.ui.IconDescription+import com.vayunmathur.library.ui.IconFile+import com.vayunmathur.library.ui.IconFolder+import com.vayunmathur.library.ui.IconGlobe+import com.vayunmathur.library.ui.IconHistory+import com.vayunmathur.library.ui.IconImage+import com.vayunmathur.library.ui.IconLink import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.LoadingState import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.SelectDropdown+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton import com.vayunmathur.library.ui.TextField import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.madeveloper.domain.DevPresentation+import com.vayunmathur.madeveloper.domain.FileKind import com.vayunmathur.madeveloper.domain.TreeEntry import com.vayunmathur.madeveloper.platform.MaDevViewModel @@ -45,95 +66,230 @@ fun RepoScreen( var entries by remember { mutableStateOf<List<TreeEntry>>(emptyList()) } var filter by remember { mutableStateOf("") } var treeError by remember { mutableStateOf<String?>(null) }+ var treeLoading by remember { mutableStateOf(false) } LaunchedEffect(repoName) { viewModel.loadRepo(repoName) } LaunchedEffect(repoName, browser?.branch, browser?.path) { val branch = browser?.branch ?: return@LaunchedEffect treeError = null+ treeLoading = true entries = runCatching { viewModel.tree(repoName, branch, browser.path) } .getOrElse { treeError = it.message; emptyList() }+ treeLoading = false }- AppScaffold(title = repoName, onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior()) { padding ->- LazyColumn(Modifier.padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {- item { Text("Clone: " + (repo?.cloneUrl ?: "https://git.maproj.org/$repoName.git")) }- state.repoError?.let { error -> item { Text(error, color = MaterialTheme.colorScheme.error) } }+ AppScaffold(+ title = repoName,+ subtitle = repo?.defaultBranch?.takeIf { it.isNotBlank() }?.let { "Default branch $it" },+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ LazyColumn(+ Modifier.padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ state.repoError?.let { error ->+ item {+ ErrorState(+ title = "Could not load this repository",+ message = error,+ retryLabel = "Retry",+ onRetry = { viewModel.loadRepo(repoName) },+ )+ }+ } if (browser == null) {- item { Text("Loading repository…") }+ if (state.repoError == null) {+ item { LoadingState(message = "Loading repository…", modifier = Modifier.fillMaxWidth().height(160.dp)) }+ } } else { item {- Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {- Text("Branch:", style = MaterialTheme.typography.titleMedium)- SelectDropdown(- label = browser.branch.ifBlank { "—" },- options = browser.branches.map { it.name },- selected = browser.branch,- itemLabel = { it },- onSelect = { viewModel.selectBranch(repoName, it) },- )- }- }- item { Text("Recent commits", style = MaterialTheme.typography.titleMedium) }- items(browser.commits.take(5)) { commit ->- Column {+ DashboardSection(+ title = "Repository",+ leadingIcon = { modifier, tint -> IconCode(modifier, tint) },+ ) { ListItem(- headlineContent = { Text(commit.subject.ifBlank { commit.shortSha }) },- supportingContent = { Text(commit.shortSha + " · " + commit.author + " · " + commit.time) },+ headlineContent = {+ Text(+ repo?.cloneUrl ?: "https://git.maproj.org/$repoName.git",+ fontFamily = FontFamily.Monospace,+ style = MaterialTheme.typography.bodySmall,+ )+ },+ supportingContent = { Text("Clone URL") },+ leadingContent = { IconLink() }, )- Button(- onClick = { onOpenCommit(browser.branch, commit.sha) },- modifier = Modifier.fillMaxWidth(),- ) { Text("View commit") }+ DashboardSectionDivider()+ Row(+ modifier = Modifier.fillMaxWidth().padding(Spacing.lg),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(Spacing.sm),+ ) {+ Text("Branch", style = MaterialTheme.typography.titleSmall)+ SelectDropdown(+ label = browser.branch.ifBlank { "—" },+ options = browser.branches.map { it.name },+ selected = browser.branch,+ itemLabel = { it },+ onSelect = { viewModel.selectBranch(repoName, it) },+ )+ } } } item {- Button(onClick = { onOpenCommits(browser.branch) }, modifier = Modifier.fillMaxWidth()) {- Text("All commits")+ DashboardSection(+ title = "Recent commits",+ actionLabel = "All commits",+ onAction = { onOpenCommits(browser.branch) },+ leadingIcon = { modifier, tint -> IconHistory(modifier, tint) },+ ) {+ if (browser.commits.isEmpty()) {+ Text(+ "No commits",+ modifier = Modifier.padding(Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ browser.commits.take(RECENT_COMMITS).forEachIndexed { index, commit ->+ if (index > 0) DashboardSectionDivider()+ CommitRow(+ commit = commit,+ onClick = { onOpenCommit(browser.branch, commit.sha) },+ )+ } } }- item { Text("Files", style = MaterialTheme.typography.titleMedium) } item {- TextField(- value = filter, onValueChange = { filter = it },- label = { Text("Filter files") }, modifier = Modifier.fillMaxWidth(),- )- }- if (browser.path.isNotEmpty()) {- item {- Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {- Button(onClick = { viewModel.navigateTree(repoName, "") }) { Text("Root") }- for ((label, target) in browser.breadcrumbs) {- Button(onClick = { viewModel.navigateTree(repoName, target) }) { Text(label) }+ DashboardSection(+ title = "Files",+ leadingIcon = { modifier, tint -> IconFolder(modifier, tint) },+ ) {+ Column(+ modifier = Modifier.padding(Spacing.lg),+ verticalArrangement = Arrangement.spacedBy(Spacing.sm),+ ) {+ TextField(+ value = filter, onValueChange = { filter = it },+ label = { Text("Filter files") }, modifier = Modifier.fillMaxWidth(),+ )+ BreadcrumbRow(+ path = browser.path,+ breadcrumbs = browser.breadcrumbs,+ onNavigate = { viewModel.navigateTree(repoName, it) },+ onUp = {+ viewModel.navigateTree(+ repoName,+ browser.path.substringBeforeLast('/', ""),+ )+ },+ )+ treeError?.let { error ->+ Text(error, color = MaterialTheme.colorScheme.error) }- Button(onClick = {- viewModel.navigateTree(repoName, browser.path.substringBeforeLast('/', ""))- }) { Text("Up") } } } }- treeError?.let { error -> item { Text(error, color = MaterialTheme.colorScheme.error) } }- items(entries.filter { it.name.contains(filter, ignoreCase = true) }) { entry ->- Column {- ListItem(- headlineContent = { Text(entry.name) },- supportingContent = {- Text(if (entry.isDir) "Folder" else (entry.size?.let { "$it B" } ?: "File"))- },+ if (treeLoading) {+ item {+ LoadingState(+ message = "Loading files…",+ modifier = Modifier.fillMaxWidth().height(120.dp), )- Button(+ }+ } else {+ val visible = entries.filter { it.name.contains(filter, ignoreCase = true) }+ if (visible.isEmpty()) {+ item {+ Text(+ if (filter.isBlank()) "No files" else "No files match \"$filter\".",+ modifier = Modifier.padding(horizontal = Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ items(visible) { entry ->+ TreeEntryRow(+ entry = entry, onClick = {- if (entry.isDir) viewModel.navigateTree(repoName, entry.path)- else onOpenFile(browser.branch, entry.path)+ if (entry.isDir) {+ viewModel.navigateTree(repoName, entry.path)+ } else {+ onOpenFile(browser.branch, entry.path)+ } },- modifier = Modifier.fillMaxWidth(),- ) { Text(if (entry.isDir) "Open folder" else "Read file") }+ ) } } item { Button(- onClick = { ExternalIntents.openUrl(context, "https://git.maproj.org/$repoName") },- modifier = Modifier.fillMaxWidth(),- ) { Text("View on git host") }+ onClick = {+ ExternalIntents.openUrl(context, "https://git.maproj.org/$repoName")+ },+ modifier = Modifier.fillMaxWidth().padding(horizontal = Spacing.lg),+ ) {+ IconGlobe()+ Text("View on git host", modifier = Modifier.padding(start = Spacing.sm))+ } } } } } }++private const val RECENT_COMMITS = 5++@Composable+private fun BreadcrumbRow(+ path: String,+ breadcrumbs: List<Pair<String, String>>,+ onNavigate: (String) -> Unit,+ onUp: () -> Unit,+) {+ if (path.isEmpty()) {+ Text(+ "Repository root",+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ return+ }+ Row(+ horizontalArrangement = Arrangement.spacedBy(Spacing.xs),+ verticalAlignment = Alignment.CenterVertically,+ modifier = Modifier.fillMaxWidth(),+ ) {+ TextButton(onClick = { onNavigate("") }) { Text("Root") }+ for ((label, target) in breadcrumbs) {+ Text("/", color = MaterialTheme.colorScheme.onSurfaceVariant)+ TextButton(onClick = { onNavigate(target) }) { Text(label) }+ }+ TextButton(onClick = onUp) { Text("Up") }+ }+}++@Composable+private fun TreeEntryRow(entry: TreeEntry, onClick: () -> Unit) {+ val kind = DevPresentation.fileKindFor(entry.name, entry.isDir)+ ListItem(+ headlineContent = { Text(entry.name) },+ supportingContent = {+ Text(+ when {+ entry.isDir -> "Folder"+ entry.size != null -> "${entry.size} B"+ else -> "File"+ },+ )+ },+ leadingContent = {+ when (kind) {+ FileKind.Folder -> IconFolder()+ FileKind.Code -> IconCode()+ FileKind.Markup, FileKind.Text -> IconDescription()+ FileKind.Image -> IconImage()+ FileKind.Archive, FileKind.Data -> IconFile()+ FileKind.Other -> IconFile()+ }+ },+ trailingContent = { IconChevronRight() },+ modifier = Modifier.clickable(onClick = onClick),+ )+}
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/StatusChip.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/StatusChip.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/StatusChip.ktnew file mode 100644index 0000000000..f4c657a451--- /dev/null+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/StatusChip.kt@@ -0,0 +1,55 @@+package com.vayunmathur.madeveloper.ui++import androidx.compose.foundation.layout.Row+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.layout.size+import androidx.compose.runtime.Composable+import androidx.compose.ui.Alignment+import androidx.compose.ui.Modifier+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.IconCheckCircle+import com.vayunmathur.library.ui.IconInfo+import com.vayunmathur.library.ui.IconSchedule+import com.vayunmathur.library.ui.IconWarning+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Surface+import com.vayunmathur.library.ui.Text+import com.vayunmathur.madeveloper.domain.CiStatus++/** Small pill showing a CI/install status in its semantic container colour. */+@Composable+fun StatusChip(label: String, status: CiStatus, modifier: Modifier = Modifier) {+ val colors = MaterialTheme.colorScheme+ val container = when (status) {+ CiStatus.Passed -> colors.tertiaryContainer+ CiStatus.Failed -> colors.errorContainer+ CiStatus.Running -> colors.secondaryContainer+ CiStatus.Unknown -> colors.surfaceContainerHigh+ }+ val content = when (status) {+ CiStatus.Passed -> colors.onTertiaryContainer+ CiStatus.Failed -> colors.onErrorContainer+ CiStatus.Running -> colors.onSecondaryContainer+ CiStatus.Unknown -> colors.onSurfaceVariant+ }+ Surface(modifier = modifier, shape = MaterialTheme.shapes.small, color = container, contentColor = content) {+ Row(+ modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ val iconModifier = Modifier.size(14.dp)+ when (status) {+ CiStatus.Passed -> IconCheckCircle(iconModifier, tint = content)+ CiStatus.Failed -> IconWarning(iconModifier, tint = content)+ CiStatus.Running -> IconSchedule(iconModifier, tint = content)+ CiStatus.Unknown -> IconInfo(iconModifier, tint = content)+ }+ Text(+ label,+ style = MaterialTheme.typography.labelMedium,+ color = content,+ modifier = Modifier.padding(start = 4.dp),+ )+ }+ }+}
madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt
diff --git a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.ktindex 481abc5b98..f2c419733e 100644--- a/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt+++ b/madeveloper/src/main/java/com/vayunmathur/madeveloper/ui/TestsScreen.kt@@ -1,28 +1,114 @@ package com.vayunmathur.madeveloper.ui import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn-import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier-import androidx.compose.ui.unit.dp+import androidx.compose.ui.text.font.FontFamily import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.DashboardSection+import com.vayunmathur.library.ui.DashboardSectionDivider+import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconCheckCircle+import com.vayunmathur.library.ui.IconHistory+import com.vayunmathur.library.ui.IconSchedule import com.vayunmathur.library.ui.ListItem+import com.vayunmathur.library.ui.MaterialTheme+import com.vayunmathur.library.ui.Spacing import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.appBarScrollBehavior+import com.vayunmathur.madeveloper.domain.DevPresentation+import com.vayunmathur.madeveloper.domain.TestRun import com.vayunmathur.madeveloper.platform.MaDevUiState /** CI history from the git host tests page. */ @Composable fun TestsScreen(state: MaDevUiState, onBack: () -> Unit) {- AppScaffold(title = "CI tests", onNavigateBack = onBack, scrollBehavior = appBarScrollBehavior()) { padding ->- LazyColumn(Modifier.padding(padding).padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {- state.tests?.running?.let { item { ListItem(headlineContent = { Text("Running: " + it.subject) }, supportingContent = { Text(it.sha.take(8)) }) } }- items(state.tests?.history.orEmpty()) { run ->- ListItem(headlineContent = { Text(run.subject) }, supportingContent = { Text(run.status + " · failed " + run.failed + " · " + run.sha.take(8)) })+ AppScaffold(+ title = "CI tests",+ subtitle = state.tests?.coveragePct?.let { "Coverage %.1f%%".format(it) },+ onNavigateBack = onBack,+ scrollBehavior = appBarScrollBehavior(),+ ) { padding ->+ LazyColumn(+ Modifier.fillMaxSize().padding(padding),+ verticalArrangement = Arrangement.spacedBy(Spacing.md),+ ) {+ if (state.tests == null) {+ item {+ EmptyState(+ title = "No CI data loaded yet.",+ message = "Pull to refresh from Home once the git host is reachable.",+ )+ }+ } else {+ state.tests.running?.let { running ->+ item {+ DashboardSection(+ title = "Running now",+ leadingIcon = { modifier, tint -> IconSchedule(modifier, tint) },+ ) {+ TestRunRow(running)+ }+ }+ }+ state.tests.latest?.let { latest ->+ item {+ DashboardSection(+ title = "Latest",+ leadingIcon = { modifier, tint -> IconCheckCircle(modifier, tint) },+ ) {+ TestRunRow(latest)+ }+ }+ }+ item {+ DashboardSection(+ title = "History",+ leadingIcon = { modifier, tint -> IconHistory(modifier, tint) },+ ) {+ if (state.tests.history.isEmpty()) {+ Text(+ "No previous runs",+ modifier = Modifier.padding(Spacing.lg),+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ state.tests.history.forEachIndexed { index, run ->+ if (index > 0) DashboardSectionDivider()+ TestRunRow(run)+ }+ }+ } }- if (state.tests == null) item { Text("No CI data loaded yet.") } } } }++@Composable+private fun TestRunRow(run: TestRun) {+ val status = DevPresentation.ciStatusOf(run.status)+ ListItem(+ headlineContent = { Text(run.subject.ifBlank { "CI run" }, maxLines = 2) },+ supportingContent = {+ Column(verticalArrangement = Arrangement.spacedBy(Spacing.xs)) {+ Text(+ buildString {+ append(run.sha.take(SHORT_SHA_LENGTH))+ if (run.tests > 0) append(" · ${run.tests} tests")+ if (run.failed > 0) append(" · failed ${run.failed}")+ run.durationSecs?.let { append(" · ${it}s") }+ },+ fontFamily = FontFamily.Monospace,+ style = MaterialTheme.typography.bodySmall,+ )+ }+ },+ trailingContent = { StatusChip(run.status, status) },+ )+}++private const val SHORT_SHA_LENGTH = 8
madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt
diff --git a/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt b/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.ktindex 59258d4cc8..35d1ccb4df 100644--- a/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt+++ b/madeveloper/src/test/java/com/vayunmathur/madeveloper/ui/MaDevScreensTest.kt@@ -4,10 +4,12 @@ import android.app.Application import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.compose.ui.test.assertIsDisplayed+import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider@@ -77,6 +79,16 @@ class MaDevScreensTest { rule.onAllNodesWithText(text, useUnmergedTree = true)[0].performClick() } + /** Clicks the tappable row/button that contains [text]. */+ private fun clickRow(text: String) {+ val matcher = androidx.compose.ui.test.hasClickAction() and+ androidx.compose.ui.test.hasText(text)+ rule.onNode(androidx.compose.ui.test.hasScrollAction())+ .performScrollToNode(androidx.compose.ui.test.hasText(text))+ rule.waitForIdle()+ rule.onAllNodes(matcher)[0].performScrollTo().performClick()+ }+ private fun state() = MaDevUiState( pairingCode = "ABC234", tests = TestsStatus(@@ -113,15 +125,13 @@ class MaDevScreensTest { rule.onNodeWithText("Developer").assertIsDisplayed() rule.onNodeWithText("Push socket offline").assertIsDisplayed() rule.onNodeWithText("Pairing code: ABC234").assertIsDisplayed()- rule.onNodeWithText("CI: passed").assertIsDisplayed()+ rule.onNodeWithText("passed").assertIsDisplayed() rule.onNodeWithText("Coverage 50.0%").assertIsDisplayed()- rule.onNode(androidx.compose.ui.test.hasScrollAction())- .performScrollToNode(androidx.compose.ui.test.hasText("Open Modern-Apps"))- clickButton("Pushed installs")- clickButton("Test history")- clickButton("Available builds (read-only catalog)")- clickButton("Refresh")- clickButton("Open Modern-Apps")+ clickRow("Pushed installs")+ clickRow("Test history")+ clickRow("Available builds")+ rule.onNodeWithContentDescription("Refresh").performClick()+ clickRow("Modern-Apps") assertEquals("Modern-Apps", openedRepo) assertEquals(1, testsOpened) assertEquals(1, catalogOpened)@@ -136,9 +146,20 @@ class MaDevScreensTest { {}, {}, {}, {}, {}, ) }+ rule.onNode(androidx.compose.ui.test.hasScrollAction())+ .performScrollToNode(androidx.compose.ui.test.hasText("HTTP 404 for repos")) rule.onNodeWithText("HTTP 404 for repos").assertIsDisplayed() } + @Test fun homeEmptyAndLanguageChipRender() {+ rule.setContent {+ HomeScreen(MaDevUiState(pairingCode = "ABC234"), {}, {}, {}, {}, {})+ }+ rule.onNode(androidx.compose.ui.test.hasScrollAction())+ .performScrollToNode(androidx.compose.ui.test.hasText("No repositories"))+ rule.onNodeWithText("No repositories").assertIsDisplayed()+ }+ @Test fun testsAndCatalogScreensListTheirRows() { var page by androidx.compose.runtime.mutableStateOf(0) rule.setContent {@@ -149,7 +170,7 @@ class MaDevScreensTest { else -> CatalogScreen(MaDevUiState()) {} } }- rule.onNodeWithText("Running: running now").assertIsDisplayed()+ rule.onNodeWithText("running now").assertIsDisplayed() rule.onNodeWithText("old run").assertIsDisplayed() rule.runOnIdle { page = 1 } rule.onNodeWithText("Example").assertIsDisplayed()@@ -212,16 +233,14 @@ class MaDevScreensTest { ) {} } await("repo loaded") { viewModel.browser("Modern-Apps") != null }- rule.onNodeWithText("Clone: https://git.maproj.org/Modern-Apps.git").assertIsDisplayed()+ rule.onNodeWithText("https://git.maproj.org/Modern-Apps.git").assertIsDisplayed() rule.onNodeWithText("Recent commits").assertIsDisplayed() rule.onNodeWithText("recent work").assertIsDisplayed() rule.onNode(androidx.compose.ui.test.hasScrollAction()) .performScrollToNode(androidx.compose.ui.test.hasText("src")) rule.onNodeWithText("src").assertIsDisplayed() // Descend into the folder, then read the file inside it.- rule.onNode(androidx.compose.ui.test.hasScrollAction())- .performScrollToNode(androidx.compose.ui.test.hasText("Open folder"))- clickButton("Open folder")+ clickRow("src") await("descended") { viewModel.browser("Modern-Apps")!!.path == "src" } rule.onNodeWithText("Main.kt").assertIsDisplayed() clickButton("Root")@@ -232,7 +251,7 @@ class MaDevScreensTest { assertEquals(0, rule.onAllNodesWithText("src").fetchSemanticsNodes().size) rule.onNodeWithText("README.md").assertIsDisplayed() // Commit + commits navigation callbacks fire.- clickButton("View commit")+ clickRow("recent work") assertEquals("main", openedCommit!!.first) clickButton("All commits") assertEquals("main", openedCommits)@@ -254,13 +273,13 @@ class MaDevScreensTest { } await("commits loaded") { viewModel.browser("Modern-Apps")?.commits?.isNotEmpty() == true } rule.onNodeWithText("recent work").assertIsDisplayed()- clickButton("View commit")+ clickRow("recent work") assertEquals("recent0001aaaa", openedCommit) rule.runOnIdle { page = 1 } rule.onNodeWithText("recent work").assertIsDisplayed()- rule.onNodeWithText("Author: vayun").assertIsDisplayed()- rule.onNodeWithText("SHA: recent0001aaaa").assertIsDisplayed()+ rule.onNodeWithText("vayun").assertIsDisplayed()+ rule.onNodeWithText("recent0001aaaa").assertIsDisplayed() rule.onNodeWithText("notes").assertIsDisplayed() rule.runOnIdle { page = 2 }
metadata_data/photos/madeveloper/phone/1.png
diff --git a/metadata_data/photos/madeveloper/phone/1.png b/metadata_data/photos/madeveloper/phone/1.pngnew file mode 100644index 0000000000..b5770d226cBinary files /dev/null and b/metadata_data/photos/madeveloper/phone/1.png differ