Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49313aca authored by Bryce Lee's avatar Bryce Lee
Browse files

Clear remove button coordinates when not enabled.

Previously, the remove button coordinates were only updated upon
positioning. This led to the possibility coordinates for a previously
visible button would be considered when removing became enabled. This
changelist fixes the issue by clearing it when removing is disabled and
likewise only updating when enabled.

Test: manual
Fixes: 341072351
Flag: EXEMPT bugfix
Change-Id: I53d2536e487ad0937400d771e61ffb04ecadef7e
parent b6325f3a
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -612,10 +612,14 @@ private fun Toolbar(
    removeEnabled: Boolean,
    onRemoveClicked: () -> Unit,
    setToolbarSize: (toolbarSize: IntSize) -> Unit,
    setRemoveButtonCoordinates: (coordinates: LayoutCoordinates) -> Unit,
    setRemoveButtonCoordinates: (coordinates: LayoutCoordinates?) -> Unit,
    onOpenWidgetPicker: () -> Unit,
    onEditDone: () -> Unit
) {
    if (!removeEnabled) {
        // Clear any existing coordinates when remove is not enabled.
        setRemoveButtonCoordinates(null)
    }
    val removeButtonAlpha: Float by
        animateFloatAsState(
            targetValue = if (removeEnabled) 1f else 0.5f,
@@ -655,7 +659,13 @@ private fun Toolbar(
                contentPadding = Dimensions.ButtonPadding,
                modifier =
                    Modifier.graphicsLayer { alpha = removeButtonAlpha }
                        .onGloballyPositioned { setRemoveButtonCoordinates(it) }
                        .onGloballyPositioned {
                            // It's possible for this callback to fire after remove has been
                            // disabled. Check enabled state before setting.
                            if (removeEnabled) {
                                setRemoveButtonCoordinates(it)
                            }
                        }
            ) {
                Row(
                    horizontalArrangement =