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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```

## File-type icons from opencode and the Material Icon Theme

Vendored in `icons/file-types/` and generated into the Android and iOS
file-type icon sets. The SVGs and the file-name lookup tables come from
[opencode](https://github.com/anomalyco/opencode) (MIT License, Copyright (c)
2025 opencode); the artwork is from the
[Material Icon Theme](https://github.com/material-extensions/vscode-material-icon-theme)
(MIT License, Copyright (c) Philipp Kief).

```text
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

## Oniguruma

Downloaded and compiled at build time by
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/java/dev/opencode/mobile/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import dev.opencode.mobile.ui.componentgallery.components.EmptyStateGalleryScree
import dev.opencode.mobile.ui.componentgallery.components.FileTabsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.FilterTabsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.HunkNavigationPillGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.FileIconGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.IconsGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.InlineNoticeGalleryScreen
import dev.opencode.mobile.ui.componentgallery.components.KeyValueRowGalleryScreen
Expand Down Expand Up @@ -718,6 +719,7 @@ fun MainNavigation() {
ComponentGalleryEntryId.Colors -> ColorGalleryScreen()
ComponentGalleryEntryId.Typography -> TypographyGalleryScreen()
ComponentGalleryEntryId.Icons -> IconsGalleryScreen()
ComponentGalleryEntryId.FileIcon -> FileIconGalleryScreen()
ComponentGalleryEntryId.SkeletonIllustration ->
SkeletonIllustrationGalleryScreen()
ComponentGalleryEntryId.PageIndicator -> PageIndicatorGalleryScreen()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum class ComponentGalleryEntryId {
Colors,
Typography,
Icons,
FileIcon,
SkeletonIllustration,
PageIndicator,
BottomFade,
Expand Down Expand Up @@ -101,6 +102,12 @@ val ComponentGalleryEntries =
description = "Lucide catalog synced from icons/manifest.yaml.",
category = ComponentGalleryCategory.Foundations,
),
ComponentGalleryEntry(
id = ComponentGalleryEntryId.FileIcon,
title = "File Icon",
description = "Colour file-type and folder icons picked from a path, as in opencode.",
category = ComponentGalleryCategory.Foundations,
),
ComponentGalleryEntry(
id = ComponentGalleryEntryId.SkeletonIllustration,
title = "Skeleton Illustration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.ui.components.OpenCodeComposerSuggestionItem
import dev.opencode.mobile.ui.components.OpenCodeComposerSuggestionLeadingIcon
import dev.opencode.mobile.ui.components.OpenCodeComposerSuggestionOverlay
import dev.opencode.mobile.ui.icons.OpenCodeFileIconKind
import dev.opencode.mobile.ui.icons.OpenCodeIcons

@Composable
fun ComposerSuggestionOverlayGalleryScreen(modifier: Modifier = Modifier) {
Expand Down Expand Up @@ -41,6 +44,36 @@ fun ComposerSuggestionOverlayGalleryScreen(modifier: Modifier = Modifier) {
onSelect = {},
)

Text(
text = "Mentions",
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
OpenCodeComposerSuggestionOverlay(
items =
listOf(
OpenCodeComposerSuggestionItem(
id = "build",
title = "@build",
subtitle = "Default agent",
leadingIcon = OpenCodeComposerSuggestionLeadingIcon.Icon(OpenCodeIcons.Agent),
),
) +
listOf("Package.swift", "app/build.gradle", "src/main.kt", "web/App.tsx", "README.md", "src").map { path ->
OpenCodeComposerSuggestionItem(
id = "file:$path",
title = path,
subtitle = "File",
leadingIcon =
OpenCodeComposerSuggestionLeadingIcon.File(
path = path,
kind = if ('.' in path) OpenCodeFileIconKind.File else OpenCodeFileIconKind.Directory,
),
)
},
onSelect = {},
)

Text(
text = "Empty",
style = MaterialTheme.typography.titleSmall,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package dev.opencode.mobile.ui.componentgallery.components

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.BoxWithConstraints
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.width
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
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.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.theme.openCodeColor
import dev.opencode.mobile.ui.components.OpenCodeChoiceBadge
import dev.opencode.mobile.ui.icons.OpenCodeFileIcon
import dev.opencode.mobile.ui.icons.OpenCodeFileIconKind
import kotlin.math.max

private val FileIconCellMinWidth = 96.dp
private val FileIconGridSpacing = 12.dp

private val FileIconGalleryFiles =
listOf(
"Package.swift",
"App.swift",
"build.gradle",
"Main.kt",
"package.json",
"index.ts",
"App.tsx",
"foo.test.ts",
"README.md",
"Dockerfile",
".gitignore",
"notes.zzz",
)

private val FileIconGalleryFolders = listOf("src", "tests", ".github", "docs", "node_modules", "assets")

@Composable
fun FileIconGalleryScreen(modifier: Modifier = Modifier) {
var mono by rememberSaveable { mutableStateOf(false) }
Column(
modifier = modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
Text(
text = "Picked from the file name or extension, like opencode's FileIcon.",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
OpenCodeChoiceBadge(label = "Colour", selected = !mono, onClick = { mono = false })
OpenCodeChoiceBadge(label = "Mono", selected = mono, onClick = { mono = true })
}
CompositionLocalProvider(LocalContentColor provides openCodeColor("icon-strong-base")) {
FileIconGrid(title = "Files", labels = FileIconGalleryFiles) { path ->
OpenCodeFileIcon(path = path, mono = mono)
}
FileIconGrid(title = "Folders, collapsed and expanded", labels = FileIconGalleryFolders) { path ->
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
OpenCodeFileIcon(path = path, kind = OpenCodeFileIconKind.Directory, mono = mono)
OpenCodeFileIcon(path = path, kind = OpenCodeFileIconKind.Directory, expanded = true, mono = mono)
}
}
}
}
}

@Composable
private fun FileIconGrid(
title: String,
labels: List<String>,
icon: @Composable (String) -> Unit,
) {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(
text = title,
style = MaterialTheme.typography.titleSmall,
color = openCodeColor("text-strong"),
)
BoxWithConstraints(modifier = Modifier.fillMaxWidth()) {
val columns =
max(1, ((maxWidth + FileIconGridSpacing) / (FileIconCellMinWidth + FileIconGridSpacing)).toInt())
val cellWidth = (maxWidth - FileIconGridSpacing * (columns - 1)) / columns
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
labels.chunked(columns).forEach { row ->
Row(horizontalArrangement = Arrangement.spacedBy(FileIconGridSpacing)) {
row.forEach { label ->
Column(
modifier = Modifier.width(cellWidth),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(6.dp),
) {
Row(
modifier = Modifier.height(32.dp),
verticalAlignment = Alignment.CenterVertically,
) { icon(label) }
Text(
text = label,
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fun IconsGalleryScreen(modifier: Modifier = Modifier) {
"description" to OpenCodeIcons.Description,
"edit" to OpenCodeIcons.Edit,
"expand_content" to OpenCodeIcons.ExpandContent,
"agent" to OpenCodeIcons.Agent,
"folder" to OpenCodeIcons.Folder,
"create_new_folder" to OpenCodeIcons.CreateNewFolder,
"folder_check" to OpenCodeIcons.FolderCheck,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.opencode.mobile.ui.components.OpenCodeTreeRow
import dev.opencode.mobile.ui.components.OpenCodeTreeRowDisclosure
import dev.opencode.mobile.ui.components.OpenCodeTreeRowIcon
import dev.opencode.mobile.ui.components.OpenCodeTreeRowState
import dev.opencode.mobile.ui.icons.OpenCodeIcons

Expand All @@ -22,27 +23,27 @@ fun TreeRowGalleryScreen(modifier: Modifier = Modifier) {
var expanded by rememberSaveable { mutableStateOf(true) }
var selected by rememberSaveable { mutableStateOf("src/main.kt") }
Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text("Interactive", style = MaterialTheme.typography.titleMedium)
Text("Interactive, file-type icons", style = MaterialTheme.typography.titleMedium)
Column {
OpenCodeTreeRow(
title = "src",
icon = OpenCodeIcons.Folder,
icon = OpenCodeTreeRowIcon.FileType("src"),
disclosure = if (expanded) OpenCodeTreeRowDisclosure.Expanded else OpenCodeTreeRowDisclosure.Collapsed,
onClick = { expanded = !expanded },
)
if (expanded) {
listOf("src/main.kt", "src/Util.kt").forEach { path ->
OpenCodeTreeRow(
title = path.substringAfterLast('/'),
icon = OpenCodeIcons.Description,
icon = OpenCodeTreeRowIcon.FileType(path),
depth = 1,
state = if (selected == path) OpenCodeTreeRowState.Selected else OpenCodeTreeRowState.Normal,
onClick = { selected = path },
)
}
}
}
Text("States", style = MaterialTheme.typography.titleMedium)
Text("States, generic icons", style = MaterialTheme.typography.titleMedium)
Column {
OpenCodeTreeRow(title = "README.md", icon = OpenCodeIcons.Description)
OpenCodeTreeRow(title = "Selected.kt", icon = OpenCodeIcons.Description, state = OpenCodeTreeRowState.Selected)
Expand Down
Loading