File tree Expand file tree Collapse file tree 12 files changed +45
-44
lines changed
org/jetbrains/storytale/example Expand file tree Collapse file tree 12 files changed +45
-44
lines changed Original file line number Diff line number Diff line change 11import android.os.Build
22
33class AndroidPlatform : Platform {
4- override val name: String = " Android ${Build .VERSION .SDK_INT } "
4+ override val name: String = " Android ${Build .VERSION .SDK_INT } "
55}
66
77actual fun getPlatform (): Platform = AndroidPlatform ()
Original file line number Diff line number Diff line change @@ -8,17 +8,17 @@ import androidx.compose.runtime.Composable
88import androidx.compose.ui.tooling.preview.Preview
99
1010class MainActivity : ComponentActivity () {
11- override fun onCreate (savedInstanceState : Bundle ? ) {
12- super .onCreate(savedInstanceState)
11+ override fun onCreate (savedInstanceState : Bundle ? ) {
12+ super .onCreate(savedInstanceState)
1313
14- setContent {
15- App ()
14+ setContent {
15+ App ()
16+ }
1617 }
17- }
1818}
1919
2020@Preview
2121@Composable
2222private fun AppAndroidPreview () {
23- App ()
23+ App ()
2424}
Original file line number Diff line number Diff line change @@ -16,21 +16,21 @@ import androidx.compose.ui.unit.dp
1616
1717@Composable
1818fun App (modifier : Modifier = Modifier ) {
19- var showContent by remember { mutableStateOf(false ) }
19+ var showContent by remember { mutableStateOf(false ) }
2020
21- MaterialTheme {
22- Column (
23- modifier = modifier.fillMaxWidth(),
24- horizontalAlignment = Alignment .CenterHorizontally ,
25- ) {
26- PrimaryButton (text = " Click Me" , onClick = { showContent = ! showContent })
27- AnimatedVisibility (showContent) {
28- val greeting = remember { Greeting ().greet() }
29- Column (Modifier .fillMaxWidth(), horizontalAlignment = Alignment .CenterHorizontally ) {
30- ComposeLogo (Modifier .size(600 .dp))
31- Text (" Compose: $greeting " )
21+ MaterialTheme {
22+ Column (
23+ modifier = modifier.fillMaxWidth(),
24+ horizontalAlignment = Alignment .CenterHorizontally ,
25+ ) {
26+ PrimaryButton (text = " Click Me" , onClick = { showContent = ! showContent })
27+ AnimatedVisibility (showContent) {
28+ val greeting = remember { Greeting ().greet() }
29+ Column (Modifier .fillMaxWidth(), horizontalAlignment = Alignment .CenterHorizontally ) {
30+ ComposeLogo (Modifier .size(600 .dp))
31+ Text (" Compose: $greeting " )
32+ }
33+ }
3234 }
33- }
3435 }
35- }
3636}
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import org.jetbrains.compose.storytale.example.compose_multiplatform
77
88@Composable
99fun ComposeLogo (
10- modifier : Modifier = Modifier ,
10+ modifier : Modifier = Modifier ,
1111) {
12- Image (
13- painter = painterResource(Res .drawable.compose_multiplatform),
14- contentDescription = " Compose Multiplatform Logo" ,
15- modifier = modifier,
16- )
12+ Image (
13+ painter = painterResource(Res .drawable.compose_multiplatform),
14+ contentDescription = " Compose Multiplatform Logo" ,
15+ modifier = modifier,
16+ )
1717}
Original file line number Diff line number Diff line change 11class Greeting {
2- private val platform = getPlatform()
2+ private val platform = getPlatform()
33
4- fun greet (): String {
5- return " Hello, ${platform.name} !"
6- }
4+ fun greet (): String {
5+ return " Hello, ${platform.name} !"
6+ }
77}
Original file line number Diff line number Diff line change 11interface Platform {
2- val name: String
2+ val name: String
33}
44
55expect fun getPlatform (): Platform
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import androidx.compose.material.Button
22import androidx.compose.material.Text
33import androidx.compose.runtime.Composable
44import androidx.compose.ui.Modifier
5- import androidx.compose.ui.unit.dp
65import androidx.compose.ui.unit.sp
76
87@Composable
@@ -30,5 +29,7 @@ fun PrimaryButton(
3029}
3130
3231enum class PrimaryButtonSize {
33- Small , Medium , Large ,
32+ Small ,
33+ Medium ,
34+ Large ,
3435}
Original file line number Diff line number Diff line change 11class JVMPlatform : Platform {
2- override val name: String = " Java ${System .getProperty(" java.version" )} "
2+ override val name: String = " Java ${System .getProperty(" java.version" )} "
33}
44
55actual fun getPlatform (): Platform = JVMPlatform ()
Original file line number Diff line number Diff line change @@ -2,10 +2,10 @@ import androidx.compose.ui.window.Window
22import androidx.compose.ui.window.application
33
44fun main () = application {
5- Window (
6- onCloseRequest = ::exitApplication,
7- title = " example" ,
8- ) {
9- App ()
10- }
5+ Window (
6+ onCloseRequest = ::exitApplication,
7+ title = " example" ,
8+ ) {
9+ App ()
10+ }
1111}
Original file line number Diff line number Diff line change 11import platform.UIKit.UIDevice
22
33class IOSPlatform : Platform {
4- override val name: String = UIDevice .currentDevice.systemName() + " " + UIDevice .currentDevice.systemVersion
4+ override val name: String = UIDevice .currentDevice.systemName() + " " + UIDevice .currentDevice.systemVersion
55}
66
77actual fun getPlatform (): Platform = IOSPlatform ()
You can’t perform that action at this time.
0 commit comments