Hi all, my organization's Android app has a bunch ...
# compose-ios
j
Hi all, my organization's Android app has a bunch of reusable Compose UI components that I would like to share with our iOS app, but I haven't found a way to embed the Compose UI in an existing SwiftUI without it taking up more space than it needs. For example, starting with the template (https://github.com/JetBrains/compose-multiplatform-template/blob/main/iosApp/iosApp/ContentView.swift), if I change the ContentView like this:
Copy code
struct ContentView: View {
    var body: some View {
        VStack {
            ComposeView()
                .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
            Text("Hello from SwiftUI")
        }
    }
}
I would expect the "Hello from SwiftUI" text to be immediately below the ComposeView, but instead it's forced to the bottom of the screen because the ComposeView is taking more vertical space than it needs. Is anyone aware of a way to wrap the ComposeView so it only takes the space it needs?
­čĹŹ 1
j
Depends what ComposeView has. In this case MainViewController. Does root of that using Modifier.fillMaxSize? If so test remove it or use Modifier.wrapContent
j
I'm using the rest of the template example unmodified, so the Modifier is only specifying the width: https://github.com/JetBrains/compose-multiplatform-template/blob/main/shared/src/commonMain/kotlin/App.kt#L24 However, I tried what you suggested and also added .wrapContentHeight() to the Modifier chain and that didn't change how it's displayed on iOS.
j
Hmm then not sure, probably some iOS thing how compose ui viewcontroller works.
d
j
Hi Dima, I looked at the chat app earlier and it seems to be doing something a little different than what I need. It's got a header and footer with the Compose in-between and you want the Compose to take up the rest of the space. In my use case, I want the Compose to take exactly how much space it needs, no more and no less.