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

Commit 5a074ec6 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

[Spa search] Bring the search result into view

Bug: 411421672
Flag: EXEMPT bug fix
Test: manual - search "Automatic data switching"
Change-Id: Ia07e72fdc8559f014ec3a64d09958334e82483db
parent c582e387
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import androidx.compose.animation.core.snap
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.relocation.BringIntoViewRequester
import androidx.compose.foundation.relocation.bringIntoViewRequester
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
@@ -31,6 +33,7 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
@@ -72,9 +75,15 @@ internal fun Modifier.highlightBackground(
        highlightItemKey != null && navController.isHighLightItem(highlightItemKey)
    }

    val bringIntoViewRequester = remember { BringIntoViewRequester() }
    LaunchedEffect(Unit) { if (isHighLight) bringIntoViewRequester.bringIntoView() }

    val animateColor by animateBackgroundColor(isHighLight, originalColor)

    then(Modifier.background(color = animateColor, shape = shape))
    then(
        Modifier.background(color = animateColor, shape = shape)
            .bringIntoViewRequester(bringIntoViewRequester)
    )
}

/**