n

    Nick

    2 years ago
    Hi people, I'm hoping to use Google Sign-in in a compose app by using the
    AndroidView
    Composable, but I can't seem to get it working. Has anyone else had luck embedding an old-style view on the
    alpha-02
    build? It doesn't necessarily need to be Google Sign-in, it could be any other view. I've watched the alpha video where they embed the Google Maps view but that did not help me!
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    What's not working for you? Can you share any code?
    n

    Nick

    2 years ago
    Hi, the problem I have is that I'm not understanding the signature of the
    AndroidView
    Composable. I don't know what I am supposed to pass to the
    viewBlock
    parameter. Initially I thought I could pass an activity or a fragment, but having thought about it for a while, I think that I somehow need to be able to pass just the GSI button, which is of class
    com.google.android.gms.common.SignInButton
    . Any thoughts?
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    It's the view constructor. Most often you can just pass a function reference (e.g.
    ::SignInButton
    ), but that's basically the same as passing a lambda:
    { context -> SignInButton(context) }
    n

    Nick

    2 years ago
    <2 days later> Thanks for the help @Zach Klippenstein (he/him) [MOD], in the end, I just implemented the Google Sign-in as a separate Activity. The ability to mix and match old-style UI and Compose is pretty neat. I feel sure that in the future, Google will get around to creating a native Compose GSI component and I'll switch over at that point.
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Maybe, but I wouldn't count on it. They've said there are certain components they're never going to port because it isn't worth it. Idk if this is one of them but it's not a standard material component so I can't imagine it's very high priority. I'm curious though, why didn't you end up just using
    AndroidView
    ?
    n

    Nick

    2 years ago
    Re-using an existing activity from an earlier build made for quicker progress. I can always come back to it. User experience is basically the same...