Thread
#compose
    Timo Drick

    Timo Drick

    2 years ago
    In Scaffold you can define a bottomBar with a cutout for the FAB. I would like to get the fabButtonBounds in the body to be able to archive something like in this screenshot. (I was already able to hack something together to get it working. But the code is very messy. Also the current cutout path calculation for rounded edges only works when the cutout is at the top)
    matvei

    matvei

    2 years ago
    Hey! Nice use case. For now
    ScaffoldState
    only provides
    floatingActionButtonSize
    it seems. I see now how bounds can be useful as well. One of the solutions might be to make
    ScaffoldGeomerty
    public in
    ScaffoldState
    . Will this solve your usecase? If so, please, file a feature request 🙂
    Timo Drick

    Timo Drick

    2 years ago
    Unfortunatly the current ScaffoldGeometry only contains the relative coords inside the parent. Which does not really help. So i will try a different approach using the global coords. But i think it is not necessary to export this because i can add a Modifier.onPosition by myself to the FAB.
    Ok problem with the Modifier.onPosition is in my usecase that i get the positions 1 frame behind. Because my Surface which gets cut is animated and than the cutout get distorted.
    matvei

    matvei

    2 years ago
    Yeah, onPositioned being frame behind makes think it mostly useless for much animations. For the reference, I have the same problem with bottomBar and cutout, if you will animate FAB to go to the left or right, you will see you cutouts is 1 frame behind, haha We're working on the proper API for such usecases so this shouldn't be the case later
    Still curious why you have this jump. FAB size doesn't change there, so if you can just cache the shape itself and reapply it to any container you have above the fab -- this lag should go away
    Timo Drick

    Timo Drick

    2 years ago
    The surface view is changing size and then the height of the view changes for the next frame. I calculate the offset for the cutout in the onPositioned modifier which is one frame behing. For now to get it working i will calculate the offset from the bottom than it should work. But would be nice to have an other API to work with absolute coordinates.
    matvei

    matvei

    2 years ago
    Yeah, agree. I see what I can do to make it easier, thanks for feedback. If you want to track when it's done, feel free to file a bug 🙂
    Timo Drick

    Timo Drick

    2 years ago
    Maybe to be more specific. I do the cutout using a SurfaceView and define the shape as a custom Shape. Inside of the Shape API i do not have access do global coordinates. Thats why i have to calculate the offset inside of the onPositioned function.
    I don''t think it is a bug.
    But maybe it would be nice to have also access to global coordinates in modifiers and maybe in shape calculation. I don't know if this is possible just dreaming 😃