forked from cl3m/multiplatform-compose
-
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.
Refactor demos, add ListItem and clickable modifier
- Loading branch information
Showing
27 changed files
with
222 additions
and
130 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
6 changes: 6 additions & 0 deletions
6
multiplatform-compose/src/androidMain/kotlin/com/rouge41/kmm/compose/ListItem.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,6 @@ | ||
package com.rouge41.kmm.compose | ||
|
||
import androidx.compose.material.ListItem as _ListItem | ||
|
||
@Composable | ||
actual fun ListItem(modifier: Modifier, text: @Composable () -> Unit) = _ListItem(modifier = modifier, text = text) |
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
multiplatform-compose/src/commonMain/kotlin/com/rouge41/kmm/compose/ListItem.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 com.rouge41.kmm.compose | ||
|
||
@Composable | ||
expect fun ListItem(modifier: Modifier, text: @Composable () -> Unit) |
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
11 changes: 11 additions & 0 deletions
11
multiplatform-compose/src/iosX64Main/kotlin/com/rouge41/kmm/compose/ListItem.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,11 @@ | ||
package com.rouge41.kmm.compose | ||
|
||
@Composable | ||
actual fun ListItem(modifier: Modifier, text: @Composable () -> Unit) { | ||
Column( | ||
modifier = modifier.fillMaxWidth().padding(15.dp), | ||
verticalArrangement = Arrangement.Top, | ||
horizontalAlignment = Alignment.Start) { | ||
text.invoke() | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
9 changes: 9 additions & 0 deletions
9
test/src/commonMain/kotlin/com/rouge41/kmm/compose/test/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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.rouge41.kmm.compose.test | ||
|
||
import com.rouge41.kmm.compose.Composable | ||
import com.rouge41.kmm.compose.MutableState | ||
|
||
@Composable | ||
fun App(state: MutableState<Boolean>, resources: Resources) { | ||
BottomNavigation(state, 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
50 changes: 12 additions & 38 deletions
50
test/src/commonMain/kotlin/com/rouge41/kmm/compose/test/Content.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,59 +1,33 @@ | ||
package com.rouge41.kmm.compose.test | ||
|
||
import com.rouge41.kmm.compose.* | ||
import com.rouge41.kmm.compose.test.demos.* | ||
|
||
data class Resources(val logo: ImageResource) | ||
|
||
@Composable | ||
fun Content(resources: Resources) { | ||
Theme { | ||
val state = remember { ContentState() } | ||
when (state.current) { | ||
ContentType.Root -> SafeArea { Root(state) } | ||
ContentType.HelloPlatform -> SafeArea { HelloPlatform() } | ||
ContentType.Lorem -> SafeArea { ScrollableColumn { Lorem() } } | ||
ContentType.Counter -> SafeArea { Counter() } | ||
ContentType.BackPress -> SafeArea { BackPress() } | ||
ContentType.Layout -> SafeArea { Layout() } | ||
ContentType.TextStyles -> SafeArea { TextStyles() } | ||
ContentType.Images -> SafeArea { Images(resources) } | ||
ContentType.BottomNavigation -> BottomNavigation() | ||
ContentType.Navigation -> Navigation(resources) | ||
var state = remember { mutableStateOf(true) } | ||
if (state.value) { | ||
App(state, resources) | ||
} else { | ||
Raw(state, resources) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun Root(state: ContentState) { | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
verticalArrangement = Arrangement.Top, | ||
horizontalAlignment = Alignment.Start) { | ||
Text("ROOT") | ||
Button(modifier = Modifier.background(Color.Green).fillMaxWidth(), onClick = { state.current = ContentType.Navigation }, colors = ButtonDefaults.buttonColors()) { Text("Navigation", style = TextStyle(color = Color.White)) } | ||
Spacer(modifier = Modifier.preferredHeight(16.dp)) | ||
for (content in contents()) { | ||
Button(onClick = { state.current = content }) { Text(content.toString()) } | ||
Spacer(modifier = Modifier.preferredHeight(16.dp)) | ||
} | ||
} | ||
} | ||
|
||
class ContentState { | ||
var current by mutableStateOf(ContentType.Root) | ||
} | ||
|
||
enum class ContentType { | ||
Root, | ||
enum class Demo { | ||
HelloPlatform, | ||
Lorem, | ||
Counter, | ||
BackPress, | ||
Layout, | ||
TextStyles, | ||
Images, | ||
// Below are dropped in navigation demos | ||
BottomNavigation, | ||
Navigation | ||
} | ||
|
||
fun contents() = ContentType.values().toMutableList().drop(1).dropLast(1) | ||
Navigation, | ||
App, | ||
Raw, | ||
} |
Oops, something went wrong.