skiptools / skip-ui

SwiftUI for Android
https://skip.tools
GNU Lesser General Public License v3.0
128 stars 14 forks source link

Gesture : variable access from onChanged / onEnded closures #26

Closed jumartin closed 7 months ago

jumartin commented 7 months ago

Amazing tools, thanks!

This properly logs ‘i=10’ on iOS but not on Android (skip 0.8.26 / skip-ui 0.6.0) :

struct InnerView: View {
    var i: Int

    var body: some View {
        VStack {
            Text("i=\(i)")
            Text("Log i")
                .gesture(TapGesture().onEnded { _ in
                    logger.log("i=\(i)")
                })
        }
    }
}

struct ContentView: View {
    @State private var i = 0

    var body: some View {
        VStack {
            Button("Set i to 10") { i = 10 }
            InnerView(i: i)
        }
    }
}
aabewhite commented 7 months ago

Sorry for the trouble, and thanks for the report! We'll look into this and hopefully get a fix out for you later today

aabewhite commented 7 months ago

The fix is tagged! Use File->Packages->Update to Latest to get skip-ui 0.6.1

Thanks again for the report, and please let us know if you have any additional issues!

jumartin commented 7 months ago

It works great, thanks!