-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40ac440
commit ee3ba75
Showing
10 changed files
with
249 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
composeApp/src/androidMain/kotlin/org/michaelbel/template/Template.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.michaelbel.template | ||
|
||
actual val TemplateName: String | ||
get() = "Android Template" |
221 changes: 210 additions & 11 deletions
221
composeApp/src/commonMain/kotlin/org/michaelbel/template/App.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,225 @@ | ||
@file:OptIn(ExperimentalMaterial3Api::class) | ||
|
||
package org.michaelbel.template | ||
|
||
import androidx.compose.animation.AnimatedVisibility | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
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.fillMaxSize | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.BadgedBox | ||
import androidx.compose.material3.BottomAppBar | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.SnackbarHost | ||
import androidx.compose.material3.SnackbarHostState | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Email | ||
import androidx.compose.material.icons.outlined.Home | ||
import androidx.compose.material.icons.outlined.Phone | ||
import androidx.compose.material.icons.outlined.Settings | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.NavigationBarItem | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.rememberNavController | ||
import kotlinx.coroutines.launch | ||
import kotlinx.serialization.Serializable | ||
|
||
@Composable | ||
fun App() { | ||
MaterialTheme { | ||
Box( | ||
modifier = Modifier.fillMaxSize(), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Button( | ||
onClick = {} | ||
val navHostController = rememberNavController() | ||
var selectedRoute by remember { mutableStateOf<Navigation>(Navigation.Home) } | ||
val snackbarHostState = remember { SnackbarHostState() } | ||
val coroutineScope = rememberCoroutineScope() | ||
|
||
MaterialTheme( | ||
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme() | ||
) { | ||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { | ||
Text( | ||
text = TemplateName | ||
) | ||
} | ||
) | ||
}, | ||
bottomBar = { | ||
BottomAppBar { | ||
NavigationBarItem( | ||
selected = selectedRoute == Navigation.Home, | ||
onClick = { selectedRoute = Navigation.Home }, | ||
icon = { | ||
Icon( | ||
imageVector = Icons.Outlined.Home, | ||
contentDescription = null | ||
) | ||
}, | ||
label = { | ||
Text( | ||
text = "Home" | ||
) | ||
} | ||
) | ||
|
||
NavigationBarItem( | ||
selected = selectedRoute == Navigation.Chat, | ||
onClick = { selectedRoute = Navigation.Chat }, | ||
icon = { | ||
BadgedBox( | ||
badge = { | ||
this@BottomAppBar.AnimatedVisibility( | ||
visible = selectedRoute != Navigation.Chat, | ||
enter = fadeIn(), | ||
exit = fadeOut() | ||
) { | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = Modifier | ||
.size(24.dp) | ||
.background(color = Color.Red, shape = CircleShape) | ||
) { | ||
Text( | ||
text = "12", | ||
color = Color.White, | ||
fontSize = 12.sp, | ||
fontWeight = FontWeight.Medium | ||
) | ||
} | ||
} | ||
} | ||
) { | ||
Icon( | ||
imageVector = Icons.Outlined.Email, | ||
contentDescription = null | ||
) | ||
} | ||
}, | ||
label = { | ||
Text( | ||
text = "Chat" | ||
) | ||
} | ||
) | ||
|
||
NavigationBarItem( | ||
selected = selectedRoute == Navigation.Settings, | ||
onClick = { selectedRoute = Navigation.Settings }, | ||
icon = { | ||
Icon( | ||
imageVector = Icons.Outlined.Settings, | ||
contentDescription = null | ||
) | ||
}, | ||
label = { | ||
Text( | ||
text = "Settings" | ||
) | ||
} | ||
) | ||
} | ||
}, | ||
snackbarHost = { | ||
SnackbarHost( | ||
hostState = snackbarHostState | ||
) | ||
}, | ||
floatingActionButton = { | ||
Button( | ||
onClick = { | ||
coroutineScope.launch { | ||
snackbarHostState.showSnackbar( | ||
message = "Single-line snackbar with action", | ||
actionLabel = "Action" | ||
) | ||
} | ||
} | ||
) { | ||
Icon( | ||
imageVector = Icons.Outlined.Phone, | ||
contentDescription = null | ||
) | ||
} | ||
} | ||
) { innerPadding -> | ||
NavHost( | ||
navController = navHostController, | ||
startDestination = selectedRoute, | ||
modifier = Modifier.padding(innerPadding) | ||
) { | ||
Text("Print Log") | ||
composable<Navigation.Home> { | ||
Box( | ||
modifier = Modifier.fillMaxSize(), | ||
contentAlignment = Alignment.Center | ||
) { | ||
Text( | ||
text = "Home" | ||
) | ||
} | ||
} | ||
composable<Navigation.Chat> { | ||
Row( | ||
modifier = Modifier.fillMaxSize(), | ||
horizontalArrangement = Arrangement.Center, | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Text( | ||
text = "Chat" | ||
) | ||
} | ||
} | ||
composable<Navigation.Settings> { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text( | ||
text = "Settings" | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
sealed interface Navigation { | ||
|
||
@Serializable | ||
data object Home: Navigation | ||
|
||
@Serializable | ||
data object Chat: Navigation | ||
|
||
@Serializable | ||
data object Settings: Navigation | ||
} |
3 changes: 3 additions & 0 deletions
3
composeApp/src/commonMain/kotlin/org/michaelbel/template/Template.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.michaelbel.template | ||
|
||
expect val TemplateName: String |
4 changes: 4 additions & 0 deletions
4
composeApp/src/iosMain/kotlin/org/michaelbel/template/Template.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.michaelbel.template | ||
|
||
actual val TemplateName: String | ||
get() = "iOS Template" |
4 changes: 4 additions & 0 deletions
4
composeApp/src/jsMain/kotlin/org/michaelbel/template/Template.js.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.michaelbel.template | ||
|
||
actual val TemplateName: String | ||
get() = "JS Template" |
4 changes: 4 additions & 0 deletions
4
composeApp/src/jvmMain/kotlin/org/michaelbel/template/Template.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.michaelbel.template | ||
|
||
actual val TemplateName: String | ||
get() = "JVM Template" |
4 changes: 4 additions & 0 deletions
4
composeApp/src/wasmJsMain/kotlin/org/michaelbel/template/Template.wasm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.michaelbel.template | ||
|
||
actual val TemplateName: String | ||
get() = "WASM Template" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters