Skip to content

Commit

Permalink
Fix menus
Browse files Browse the repository at this point in the history
  • Loading branch information
cl3m committed Jan 27, 2021
1 parent 89159c1 commit bc672e9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import platform.CoreGraphics.CGSizeMake
import platform.UIKit.*
import kotlin.math.max

val DEBUG_COMPOSE = true
val DEBUG_COMPOSE = false

open class HostingController(val controller: UIViewController, val content: @Composable () -> Unit, val imageViewLoader: (UIImageView, String) -> Unit) {
@ThreadLocal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.rouge41.kmm.compose.test

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
Expand All @@ -10,8 +11,11 @@ import androidx.compose.ui.Modifier
import androidx.navigation.compose.*
import com.rouge41.kmm.compose.runtime.MutableState
import com.rouge41.kmm.compose.foundation.ScrollableColumn
import com.rouge41.kmm.compose.foundation.layout.Spacer
import com.rouge41.kmm.compose.ui.clickable
import com.rouge41.kmm.compose.test.demos.*
import com.rouge41.kmm.compose.ui.preferredHeight
import com.rouge41.kmm.compose.ui.unit.dp

@Composable
fun DrawerNavigation(state: MutableState<Boolean>, resources: Resources) {
Expand All @@ -37,20 +41,29 @@ fun DrawerNavigation(state: MutableState<Boolean>, resources: Resources) {
)
},
drawerContent = {
Menu(state) { route ->
navController.navigate(route) {
launchSingleTop = true
LazyColumn {
items(Demo.values().dropLast(4)) { item ->
ListItem(text = { Text(item.toString()) }, modifier = Modifier.clickable {
navController.navigate(item.toString()) {
launchSingleTop = true
}
scaffoldState.drawerState.close()
})
Divider()
}
item {
ListItem(
text = { Text("Raw mode") },
modifier = Modifier.clickable(
onClick = {
state.value = false
}
)
)
Spacer(modifier = Modifier.preferredHeight(60.dp))
}
scaffoldState.drawerState.close()
}
ListItem(
text = { Text("Raw mode") },
modifier = Modifier.clickable(
onClick = {
state.value = false
}
)
)

},
scaffoldState = scaffoldState
) {
Expand Down
19 changes: 0 additions & 19 deletions test/src/commonMain/kotlin/com/rouge41/kmm/compose/test/Menu.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@ package com.rouge41.kmm.compose.test.demos

import com.rouge41.kmm.compose.*
import com.rouge41.kmm.compose.foundation.layout.Column
import com.rouge41.kmm.compose.foundation.layout.Spacer
import com.rouge41.kmm.compose.material.Text
import com.rouge41.kmm.compose.material.TextField
import com.rouge41.kmm.compose.runtime.Composable
import com.rouge41.kmm.compose.runtime.mutableStateOf
import com.rouge41.kmm.compose.runtime.*
import com.rouge41.kmm.compose.ui.Modifier
import com.rouge41.kmm.compose.ui.background
import com.rouge41.kmm.compose.ui.fillMaxWidth
import com.rouge41.kmm.compose.ui.*
import com.rouge41.kmm.compose.ui.graphics.Color
import com.rouge41.kmm.compose.ui.padding
import com.rouge41.kmm.compose.ui.unit.dp

//FROM https://raw.githubusercontent.com/vinaygaba/Learn-Jetpack-Compose-By-Example/master/app/src/main/java/com/example/jetpackcompose/text/TextFieldActivity.kt

@Composable
fun TextFields() {
Column(modifier = Modifier.fillMaxWidth()) {
TitleComponent("This is a filled TextInput field based on Material Design")
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
Text("This is a filled TextInput field based on Material Design")
MaterialTextInputComponent()
}
}
Expand All @@ -29,12 +27,12 @@ fun TextFields() {
fun MaterialTextInputComponent() {
var textValue by remember { mutableStateOf("") }

Text("Text is ${textValue}", modifier = Modifier.padding(16.dp))
Text("Text is ${textValue}", modifier = Modifier)
Spacer(modifier = Modifier.preferredHeight(10.dp))
TextField(
value = textValue,
onValueChange = { textValue = it },
label = { Text("Enter Your Name") },
placeholder = { Text(text = "John Doe") },
modifier = Modifier.background(Color.LightGray).padding(16.dp).fillMaxWidth()
placeholder = { Text(text = "John Doe") }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.rouge41.kmm.compose.test
import com.rouge41.kmm.compose.navigation.*
import com.rouge41.kmm.compose.foundation.ScrollableColumn
import com.rouge41.kmm.compose.foundation.layout.Column
import com.rouge41.kmm.compose.foundation.lazy.LazyColumn
import com.rouge41.kmm.compose.ios.SafeArea
import com.rouge41.kmm.compose.material.Button
import com.rouge41.kmm.compose.material.Divider
import com.rouge41.kmm.compose.material.ListItem
import com.rouge41.kmm.compose.material.Text
import com.rouge41.kmm.compose.runtime.Composable
Expand All @@ -27,17 +29,19 @@ actual fun Navigation(state: MutableState<Boolean>, resources: Resources) {
}) { Text ("Trailing") }
}) {
SafeArea {
Menu(state) { route ->
navController.navigate(route)
LazyColumn {
items(Demo.values().dropLast(4)) { item ->
Text(
item.toString(),
modifier = Modifier.clickable { navController.navigate(item.toString()) })
Divider()
}
item {
Text(
"Raw mode",
modifier = Modifier.clickable { state.value = false })
}
}
ListItem(
text = { Text("Raw mode") },
modifier = Modifier.clickable(
onClick = {
state.value = false
}
)
)
}
}
Demo.values().dropLast(4).forEach { screen ->
Expand Down

0 comments on commit bc672e9

Please sign in to comment.