How to update a value in a composable from SwiftUI...
# compose-ios
a
How to update a value in a composable from SwiftUI. We have
UIViewControllerRepresentable
where we can pass a
@Binding
value, but how can we update the composable when this value is updated inside
updateUIViewController
function?
👍 3
Copy code
struct ComposeView: UIViewControllerRepresentable {
   
  @Binding var value: Float
   
  func makeUIViewController(context: Context) -> UIViewController {
    return Main_iosKt.MainViewController(speed: value)
  }

  func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
  }
}

struct ContentView: View {

  @State var value: Float = 0

  var body: some View {
    VStack {
      ComposeView(value: self.$value)
          .ignoresSafeArea(.all, edges: .bottom)
      Button("Button") {
        value = 1
      }
    }
  }
}
d
a
I've looked into the code in the iosApp project. There is nothing passed to
ComposeViewControllerToSwiftUI
k
how i did it was to use a local state and when it changes, send a lambda to the composeviewcontroller and update the binding
a
Can you add some code @Kashismails
d
Hey @Dima Avdeev @Kashismails, I think this is the same as what I posted here. I ended up just writing SwiftUI for now. Is there a wrapper example in which this is solved?
👍 1