kmp-navigation
Compose Navigation for TV: state-based screen switching, BackHandler, focus-aware transitions, and drawer/sidebar patterns
Skill by giolaq
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/giolaq-kmp-navigation
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/kmp-navigation
What's inside
- Skill name
kmp-navigation- Description
- Compose Navigation for TV: state-based screen switching, BackHandler, focus-aware transitions, and drawer/sidebar patterns
- License
- MIT-0
- Instructions
- 204 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# KMP Navigation
> The kmptv template uses state-based navigation (not Jetpack Navigation Compose). This is intentional — Navigation Compose has known focus-restoration issues on TV that make it unreliable for D-pad apps.
## Navigation model
The Android TV app manages navigation via state variables in `MainScreen()`:
```kotlin
@Composable
private fun MainScreen() {
var selectedItem by remember { mutableStateOf<ContentItem?>(null) }
var showingDetail by rememberSaveable { mutableStateOf(false) }
var showingVideoPlayer by rememberSaveable { mutableStateOf(false) }
BackHandler(enabled = showingVideoPlayer || showingDetail) {
if (showingVideoPlayer) {
showingVideoPlayer = false
} else if (showingDetail) {
showingDetail = false
selectedItem = null
}
}
when {
showingVideoPlayer && selectedItem?.videoUrl != null ->
VideoPlayerScreen(item = selectedItem!!, onBack = { showingVideoPlayer = false })
showingDetail && selectedItem != null ->
ContentDetailScreen(item = selectedItem!!, onBack = { showingDetail = false })
else ->
HomeScreen(onItemClick = { item ->
selectedItem = item
showingDetail = true
})
}
}
```
### Why state-based, not NavHost
1. **Focus restoration:** NavHost loses focus position when popping the back stack. TV users expect to return to the exact card they left.
2. **Simplicity:** Three screens with boolean flags is easier to reason about than a NavGraph with arguments.
3. **Animation control:** `Crossfade` and custom transitions work naturally with `when` blocks.
4. **rememberSaveable:** Screen state survives configuration changes without NavGraph SavedState complexity.
## BackHandler — back stack behavior
```kotlin
import androidx.activity.compose.BackHandler
BackHandler(enabled = /* when this screen is active */) {
// Pop this screen
}
```
**Rules:**
- Always provide `enabled` parameter scoped to the current screen. Without it, back handling fires when it shouldn't.
- Priority: innermost enabled BackHandler wins. So the player's BackHandler fires before the detail's.
- On the home screen, don't add a BackHandler — let the system handle app exit.
### Back stack ordering
```
Home (no BackHandler — system exits app)
└── Detail (BackHandler → goes back to Home)
└── VideoPlayer (BackHandler → goes back to Detail)
```
## Adding a new screen
1. **Create the composable** in `androidtv-app/src/main/java/.../compose/`:
```kotlin
@Composable
fun NewScreen(
item: ContentItem,
onBack: () -> Unit,
) {
// Screen content
}
```
2. **Add state variable** in MainScreen:
```kotlin
var showingNewScreen by rememberSaveable { mutableStateOf(false) }
```
3. **Add to the `when` block** (order matters — more specific screens first):
```kotlin
when {
showingVideoPlayer -> VideoPlayerScreen(...)
showingNewScreen -> NewScreen(item = selectedItem!!, onBack = { showingNewScreen = false })
showingDetail -> ContentDetailScreen(...)
else -> HomeScreen(...)
}
```
4. **Add BackHandler** entry:
```kotlin
BackHandler(enabled = showingNewScreen) {
showingNewScreen = false
}
```
## Screen transitions
The template uses `Crossfade` for the hero banner. For screen transitions, the `when` block provides an instant swap. To add animated transitions:
```kotlin
AnimatedContent(
targetState = currentScreen,
transitionSpec = {
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
}
) { screen ->
when (screen) {From giolaq/tv-build-harness, MIT-0.
More from giolaq/tv-build-harness
- 0.563score
meta
giolaq
Meta skill loaded for all phases: project conventions, file modification rules, code quality standards
SkillBFreshness: B★ 4Claude Code +9 - 0.516score
kmp-compose-tv
giolaq
Compose for TV patterns: TvLazyRow/Column, focusable cards, FocusRequester, D-pad navigation, and 10-foot UI composables
SkillCFreshness: C★ 4Claude Code +9 - 0.516score
kmp-data-layer
giolaq
Kotlin data layer patterns: data classes in shared-core, repository pattern, StateFlow, CatalogService, and content wiring
SkillCFreshness: C★ 4Claude Code +9 - 0.516score
kmp-template-anatomy
giolaq
KMP TV template repo structure: shared-core, androidtv-app, appletv-app modules and where screens, theme, data, and navigation live
SkillCFreshness: C★ 4Claude Code +9 - 0.516score
creative-tv-ui
giolaq
Creative visual design patterns for TV apps: typography, color depth, focus states, animations, per-content-type personalities
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
rn-shared-ui-catalog
giolaq
Catalog of available shared-ui components: what exists in the template, how to reuse vs create new
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
10ft-ui
giolaq
10-foot UI design guidelines: safe zones, font sizes, contrast, focus indicators for TV viewing distance
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
firetv-leanback
giolaq
Fire TV leanback manifest configuration: banner icons, LEANBACK_LAUNCHER intent filter, TV-specific Android settings
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
kmp-build-commands
giolaq
Gradle build commands: assembleDebug, assembleRelease, APK output paths, and emulator installation
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
kmp-theming
giolaq
Compose MaterialTheme patterns: Color.kt, Typography, darkColorScheme, and TV-specific theming for KMP apps
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
kmp-verify-patterns
giolaq
How to verify KMP builds: compile checks, lint, common Compose compiler errors, Gradle dependency resolution issues
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
rn-manifest-wiring
giolaq
Content manifest wiring: how to connect content.json data to React Native data hooks and screen components
SkillCFreshness: C★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 0
- Open issues
- 3
- Last commit (this folder)
- Jun 24, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT-0
- Repository
- github.com/giolaq/tv-build-harness
- Website
- tv-build-harness.vercel.app
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from giolaq
- 0.563score
meta
giolaq
Meta skill loaded for all phases: project conventions, file modification rules, code quality standards
SkillBFreshness: B★ 4Claude Code +9 - 0.516score
kmp-template-anatomy
giolaq
KMP TV template repo structure: shared-core, androidtv-app, appletv-app modules and where screens, theme, data, and navigation live
SkillCFreshness: C★ 4Claude Code +9 - 0.516score
kmp-data-layer
giolaq
Kotlin data layer patterns: data classes in shared-core, repository pattern, StateFlow, CatalogService, and content wiring
SkillCFreshness: C★ 4Claude Code +9 - 0.516score
creative-tv-ui
giolaq
Creative visual design patterns for TV apps: typography, color depth, focus states, animations, per-content-type personalities
SkillCFreshness: C★ 4Claude Code +9 - 0.516score
kmp-compose-tv
giolaq
Compose for TV patterns: TvLazyRow/Column, focusable cards, FocusRequester, D-pad navigation, and 10-foot UI composables
SkillCFreshness: C★ 4Claude Code +9 - 0.513score
kmp-verify-patterns
giolaq
How to verify KMP builds: compile checks, lint, common Compose compiler errors, Gradle dependency resolution issues
SkillCFreshness: C★ 4Claude Code +9
Cite this page
kmp-navigation skill. Agent Mart. https://agentmart.dev/skills/giolaq-kmp-navigation (last updated 2026-10-24)