-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
33 changed files
with
179 additions
and
94 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
11 changes: 0 additions & 11 deletions
11
app/src/androidMain/kotlin/co/zsmb/requirektx/MainActivity.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public fun publicjvmapi() { | ||
|
||
} |
File renamed without changes.
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
14 changes: 14 additions & 0 deletions
14
sample/src/androidMain/kotlin/co/zsmb/requirektx/MainActivity.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,14 @@ | ||
package co.zsmb.requirektx | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.core.bundle.Bundle | ||
|
||
class MainActivity : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
App() | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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 @@ | ||
<resources> | ||
<string name="app_name">requireKTX sample</string> | ||
</resources> |
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,94 @@ | ||
package co.zsmb.requirektx | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.* | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.automirrored.filled.ArrowBack | ||
import androidx.compose.material.icons.filled.ArrowBack | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavHostController | ||
import androidx.navigation.compose.* | ||
import androidx.compose.ui.unit.sp | ||
import androidx.navigation.NavType | ||
import androidx.navigation.navArgument | ||
import org.jetbrains.compose.ui.tooling.preview.Preview | ||
|
||
@Composable | ||
fun App() { | ||
val navController: NavHostController = rememberNavController() | ||
NavHost( | ||
navController, | ||
startDestination = "home" | ||
) { | ||
composable("home") { | ||
Home(onSelectNumber = { number -> navController.navigate("detail/$number") }) | ||
} | ||
composable( | ||
"detail/{param}", | ||
arguments = listOf(navArgument("param") { type = NavType.IntType }), | ||
) { backStackEntry -> | ||
val args = backStackEntry.requireArguments() | ||
val number = args.requireInt("param") | ||
Detail(number = number, onNavigateBack = { navController.popBackStack() }) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun DetailPreview() { | ||
Detail(42, {}) | ||
} | ||
|
||
@Composable | ||
fun Detail(number: Int, onNavigateBack: () -> Unit) { | ||
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
IconButton(onClick = { onNavigateBack() }, modifier = Modifier.align(Alignment.TopStart)) { | ||
Icon(Icons.AutoMirrored.Default.ArrowBack, "Back") | ||
} | ||
Text("Your number was $number", fontSize = 20.sp) | ||
} | ||
} | ||
|
||
@Composable | ||
@Preview | ||
fun HomePreview() { | ||
Home(onSelectNumber = {}) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun Home(onSelectNumber: (Int) -> Unit) { | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(16.dp), | ||
verticalArrangement = Arrangement.Center, | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text("Enter a number", fontSize = 24.sp) | ||
|
||
Spacer(Modifier.height(20.dp)) | ||
|
||
var inputState by remember { mutableStateOf("") } | ||
val number = inputState.toIntOrNull() | ||
|
||
TextField( | ||
value = inputState, | ||
onValueChange = { inputState = it }, | ||
) | ||
|
||
Spacer(Modifier.height(20.dp)) | ||
|
||
Button( | ||
onClick = { onSelectNumber(number!!) }, | ||
enabled = number != null, | ||
) { | ||
Text("Send") | ||
} | ||
} | ||
} | ||
|
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,13 @@ | ||
package co.zsmb.requirektx | ||
|
||
import androidx.compose.ui.window.Window | ||
import androidx.compose.ui.window.application | ||
|
||
fun main() = application { | ||
Window( | ||
onCloseRequest = ::exitApplication, | ||
title = "requireKTX sample", | ||
) { | ||
App() | ||
} | ||
} |
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