
Implements a simple top app bar with a navigation back button and kebab menu, facilitating seamless navigation and interaction in applications.
A simple TopAppBar for Android and Compose Multiplatrorm, include navigate back button and kebab menu button.
app/build.gradle.kts
dependencies {
...
+ implementation("dev.yuyuyuyuyu:simpletopappbar:0.3.1")
}composeApp/build.gradle.kts
kotlin {
...
sourceSets {
...
commonMain.dependencies {
...
+ implementation("dev.yuyuyuyuyu:simpletopappbar:0.3.1")
}
}
}
app/src/main/java/dev/yuyuyuyuyu/simpletopappbar/example/android/ui/App.kt
@Composable
fun App(
navController: NavHostController = rememberNavController(),
) {
val backStackEntry by navController.currentBackStackEntryAsState()
val currentScreen = NavigateDestination.valueOf(
value = backStackEntry?.destination?.route
?: NavigateDestination.SimpleTopAppBarExample.name,
)
SimpleTopAppBarTheme {
Scaffold(
topBar = {
SimpleTopAppBar(
title = currentScreen.name,
navigateBackIsPossible = navController.previousBackStackEntry != null,
onNavigateBackButtonClick = { navController.navigateUp() },
onOpenSourceLicensesButtonClick = {
if (currentScreen != NavigateDestination.OpenSourceLicenses) {
navController.navigate(NavigateDestination.OpenSourceLicenses.name)
}
},
)
},
) { innerPadding ->
NavHost(
navController = navController,
startDestination = NavigateDestination.SimpleTopAppBarExample.name,
modifier = Modifier.padding(innerPadding),
) {
composable(route = NavigateDestination.SimpleTopAppBarExample.name) {
SimpleTopAppBarExampleScreen()
}
composable(route = NavigateDestination.OpenSourceLicenses.name) {
OpenSourceLicensesScreen()
}
}
}
}
}composeApp/src/commonMain/kotlin/dev/yuyuyuyuyu/simpletopappbar/example/multiplatform/ui/App.kt
fun App(
navController: NavHostController = rememberNavController(),
) {
val backStackEntry by navController.currentBackStackEntryAsState()
val currentScreen = NavigateDestination.valueOf(
value = backStackEntry?.destination?.route
?: NavigateDestination.SimpleTopAppBarExample.name,
)
MaterialTheme {
Scaffold(
topBar = {
SimpleTopAppBar(
title = currentScreen.name,
navigateBackIsPossible = navController.previousBackStackEntry != null,
onNavigateBackButtonClick = { navController.navigateUp() },
onOpenSourceLicensesButtonClick = {
if (currentScreen != NavigateDestination.OpenSourceLicenses) {
navController.navigate(NavigateDestination.OpenSourceLicenses.name)
}
},
)
},
) { innerPadding ->
NavHost(
navController = navController,
startDestination = NavigateDestination.SimpleTopAppBarExample.name,
modifier = Modifier.padding(innerPadding),
) {
composable(route = NavigateDestination.SimpleTopAppBarExample.name) {
SimpleTopAppBarExampleScreen()
}
composable(route = NavigateDestination.OpenSourceLicenses.name) {
OpenSourceLicensesScreen()
}
}
}
}
}Apache License 2.0
Copyright 2025 yu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
A simple TopAppBar for Android and Compose Multiplatrorm, include navigate back button and kebab menu button.
app/build.gradle.kts
dependencies {
...
+ implementation("dev.yuyuyuyuyu:simpletopappbar:0.3.1")
}composeApp/build.gradle.kts
kotlin {
...
sourceSets {
...
commonMain.dependencies {
...
+ implementation("dev.yuyuyuyuyu:simpletopappbar:0.3.1")
}
}
}
app/src/main/java/dev/yuyuyuyuyu/simpletopappbar/example/android/ui/App.kt
@Composable
fun App(
navController: NavHostController = rememberNavController(),
) {
val backStackEntry by navController.currentBackStackEntryAsState()
val currentScreen = NavigateDestination.valueOf(
value = backStackEntry?.destination?.route
?: NavigateDestination.SimpleTopAppBarExample.name,
)
SimpleTopAppBarTheme {
Scaffold(
topBar = {
SimpleTopAppBar(
title = currentScreen.name,
navigateBackIsPossible = navController.previousBackStackEntry != null,
onNavigateBackButtonClick = { navController.navigateUp() },
onOpenSourceLicensesButtonClick = {
if (currentScreen != NavigateDestination.OpenSourceLicenses) {
navController.navigate(NavigateDestination.OpenSourceLicenses.name)
}
},
)
},
) { innerPadding ->
NavHost(
navController = navController,
startDestination = NavigateDestination.SimpleTopAppBarExample.name,
modifier = Modifier.padding(innerPadding),
) {
composable(route = NavigateDestination.SimpleTopAppBarExample.name) {
SimpleTopAppBarExampleScreen()
}
composable(route = NavigateDestination.OpenSourceLicenses.name) {
OpenSourceLicensesScreen()
}
}
}
}
}composeApp/src/commonMain/kotlin/dev/yuyuyuyuyu/simpletopappbar/example/multiplatform/ui/App.kt
fun App(
navController: NavHostController = rememberNavController(),
) {
val backStackEntry by navController.currentBackStackEntryAsState()
val currentScreen = NavigateDestination.valueOf(
value = backStackEntry?.destination?.route
?: NavigateDestination.SimpleTopAppBarExample.name,
)
MaterialTheme {
Scaffold(
topBar = {
SimpleTopAppBar(
title = currentScreen.name,
navigateBackIsPossible = navController.previousBackStackEntry != null,
onNavigateBackButtonClick = { navController.navigateUp() },
onOpenSourceLicensesButtonClick = {
if (currentScreen != NavigateDestination.OpenSourceLicenses) {
navController.navigate(NavigateDestination.OpenSourceLicenses.name)
}
},
)
},
) { innerPadding ->
NavHost(
navController = navController,
startDestination = NavigateDestination.SimpleTopAppBarExample.name,
modifier = Modifier.padding(innerPadding),
) {
composable(route = NavigateDestination.SimpleTopAppBarExample.name) {
SimpleTopAppBarExampleScreen()
}
composable(route = NavigateDestination.OpenSourceLicenses.name) {
OpenSourceLicensesScreen()
}
}
}
}
}Apache License 2.0
Copyright 2025 yu
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.