Loading packages/SystemUI/src/com/android/systemui/flashlight/ui/composable/VerticalFlashlightSlider.kt +23 −12 Original line number Diff line number Diff line Loading @@ -29,11 +29,8 @@ import androidx.compose.foundation.interaction.collectIsDraggedAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon Loading @@ -51,16 +48,19 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.BlurredEdgeTreatment import androidx.compose.ui.draw.blur import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.draw.rotate import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Rect import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.ClipOp import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Outline import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.hideFromAccessibility Loading @@ -82,6 +82,7 @@ import com.android.systemui.flashlight.ui.composable.Specs.BLUR_Y import com.android.systemui.flashlight.ui.composable.Specs.EdgeTreatment import com.android.systemui.flashlight.ui.composable.Specs.MAX_TRACK_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.MIN_TRACK_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.THUMB_CENTER_TO_GAP_OUTSIDE import com.android.systemui.flashlight.ui.composable.Specs.THUMB_MAX_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.THUMB_MIN_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.THUMB_WIDTH Loading Loading @@ -177,26 +178,34 @@ fun VerticalFlashlightSlider( colors = colors, thumb = { Row(verticalAlignment = Alignment.CenterVertically) { Spacer( modifier = Modifier.width(THUMB_WIDTH / 2).fillMaxHeight() // TODO(440617960): this should match dialog bg ) SliderDefaults.Thumb( interactionSource = interactionSource, colors = colors, thumbSize = DpSize(THUMB_WIDTH, thumbHeight(value / floatValueRange.endInclusive)), ) Spacer( Modifier.width(THUMB_WIDTH / 2).fillMaxHeight() // TODO(440617960): this should match dialog bg ) } }, track = { sliderState -> TrapezoidTrack( modifier = Modifier Modifier.drawWithContent { // Cut a gap around the thumb. The is pre-rotation and horizontal, // hence we use the left-right gap metrics instead of top-bottom. clipRect( left = size.width * (sliderState.coercedValueAsFraction) - THUMB_CENTER_TO_GAP_OUTSIDE.toPx(), top = 0f, bottom = size.height, right = size.width * (sliderState.coercedValueAsFraction) + THUMB_CENTER_TO_GAP_OUTSIDE.toPx(), clipOp = ClipOp.Difference, ) { this@drawWithContent.drawContent() } } // TODO(440620729): gradient blur from top to bottom. or no bottom blur. .blur( BLUR_X, Loading Loading @@ -343,6 +352,8 @@ private object Specs { val THUMB_MIN_HEIGHT = 48.dp val THUMB_MAX_HEIGHT = 120.dp val THUMB_WIDTH = 4.dp val THUMB_GAP = 2.dp val THUMB_CENTER_TO_GAP_OUTSIDE = THUMB_WIDTH / 2 + THUMB_GAP val BLUR_X = 20.dp // max 60 val BLUR_Y = 5.dp // max 30 val EdgeTreatment = BlurredEdgeTreatment(BeamShape()) Loading packages/SystemUI/tests/goldens/VerticalFlashlightSlider_trackChanges.json +55 −54 Original line number Diff line number Diff line Loading @@ -52,33 +52,33 @@ 1, 1, 1, 0.99497724, 0.9812278, 0.9620522, 0.93871295, 0.9133147, 0.8860553, 0.85823995, 0.8345371, 0.812059, 0.7888985, 0.7637981, 0.7376584, 0.71011096, 0.6822003, 0.6534556, 0.62476915, 0.60055894, 0.57778704, 0.5544573, 0.5292598, 0.5030645, 0.4754855, 0.4475569, 0.41880202, 0.3901099, 0.36589646, 0.34312266, 0.9924659, 0.9768645, 0.9555721, 0.9313418, 0.90474665, 0.877308, 0.8513069, 0.82960844, 0.8087622, 0.7867776, 0.7624702, 0.73684335, 0.70961833, 0.68190616, 0.65328157, 0.6246671, 0.6004995, 0.5777526, 0.55443746, 0.52924836, 0.5030581, 0.4754818, 0.44755483, 0.4188009, 0.39010924, 0.36589605, 0.34312248, 0.19822222 ] }, Loading @@ -95,33 +95,33 @@ 0, 0, 0, 0.79907274, 2.986481, 6.0371423, 9.750208, 13.79084, 18.127565, 22.552736, 26.323647, 29.899708, 33.584328, 37.57757, 41.736164, 46.118713, 50.55904, 55.132065, 59.695816, 63.54744, 67.17024, 70.8818, 74.89049, 79.057915, 83.44549, 87.88867, 92.46332, 97.02797, 100.88011, 104.50321, 1.1986091, 3.680649, 7.0680733, 10.9228945, 15.153937, 19.519176, 23.655724, 27.10775, 30.424194, 33.921745, 37.788837, 41.86583, 46.197086, 50.60584, 55.159744, 59.71205, 63.5569, 67.17572, 70.88495, 74.8923, 79.058945, 83.446075, 87.889, 92.4635, 97.02808, 100.88017, 104.50324, 127.55556 ] }, Loading Loading @@ -170,3 +170,4 @@ } ] } Loading
packages/SystemUI/src/com/android/systemui/flashlight/ui/composable/VerticalFlashlightSlider.kt +23 −12 Original line number Diff line number Diff line Loading @@ -29,11 +29,8 @@ import androidx.compose.foundation.interaction.collectIsDraggedAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon Loading @@ -51,16 +48,19 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.BlurredEdgeTreatment import androidx.compose.ui.draw.blur import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.draw.rotate import androidx.compose.ui.geometry.Offset import androidx.compose.ui.geometry.Rect import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.ClipOp import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Outline import androidx.compose.ui.graphics.Path import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.drawscope.clipRect import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.hideFromAccessibility Loading @@ -82,6 +82,7 @@ import com.android.systemui.flashlight.ui.composable.Specs.BLUR_Y import com.android.systemui.flashlight.ui.composable.Specs.EdgeTreatment import com.android.systemui.flashlight.ui.composable.Specs.MAX_TRACK_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.MIN_TRACK_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.THUMB_CENTER_TO_GAP_OUTSIDE import com.android.systemui.flashlight.ui.composable.Specs.THUMB_MAX_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.THUMB_MIN_HEIGHT import com.android.systemui.flashlight.ui.composable.Specs.THUMB_WIDTH Loading Loading @@ -177,26 +178,34 @@ fun VerticalFlashlightSlider( colors = colors, thumb = { Row(verticalAlignment = Alignment.CenterVertically) { Spacer( modifier = Modifier.width(THUMB_WIDTH / 2).fillMaxHeight() // TODO(440617960): this should match dialog bg ) SliderDefaults.Thumb( interactionSource = interactionSource, colors = colors, thumbSize = DpSize(THUMB_WIDTH, thumbHeight(value / floatValueRange.endInclusive)), ) Spacer( Modifier.width(THUMB_WIDTH / 2).fillMaxHeight() // TODO(440617960): this should match dialog bg ) } }, track = { sliderState -> TrapezoidTrack( modifier = Modifier Modifier.drawWithContent { // Cut a gap around the thumb. The is pre-rotation and horizontal, // hence we use the left-right gap metrics instead of top-bottom. clipRect( left = size.width * (sliderState.coercedValueAsFraction) - THUMB_CENTER_TO_GAP_OUTSIDE.toPx(), top = 0f, bottom = size.height, right = size.width * (sliderState.coercedValueAsFraction) + THUMB_CENTER_TO_GAP_OUTSIDE.toPx(), clipOp = ClipOp.Difference, ) { this@drawWithContent.drawContent() } } // TODO(440620729): gradient blur from top to bottom. or no bottom blur. .blur( BLUR_X, Loading Loading @@ -343,6 +352,8 @@ private object Specs { val THUMB_MIN_HEIGHT = 48.dp val THUMB_MAX_HEIGHT = 120.dp val THUMB_WIDTH = 4.dp val THUMB_GAP = 2.dp val THUMB_CENTER_TO_GAP_OUTSIDE = THUMB_WIDTH / 2 + THUMB_GAP val BLUR_X = 20.dp // max 60 val BLUR_Y = 5.dp // max 30 val EdgeTreatment = BlurredEdgeTreatment(BeamShape()) Loading
packages/SystemUI/tests/goldens/VerticalFlashlightSlider_trackChanges.json +55 −54 Original line number Diff line number Diff line Loading @@ -52,33 +52,33 @@ 1, 1, 1, 0.99497724, 0.9812278, 0.9620522, 0.93871295, 0.9133147, 0.8860553, 0.85823995, 0.8345371, 0.812059, 0.7888985, 0.7637981, 0.7376584, 0.71011096, 0.6822003, 0.6534556, 0.62476915, 0.60055894, 0.57778704, 0.5544573, 0.5292598, 0.5030645, 0.4754855, 0.4475569, 0.41880202, 0.3901099, 0.36589646, 0.34312266, 0.9924659, 0.9768645, 0.9555721, 0.9313418, 0.90474665, 0.877308, 0.8513069, 0.82960844, 0.8087622, 0.7867776, 0.7624702, 0.73684335, 0.70961833, 0.68190616, 0.65328157, 0.6246671, 0.6004995, 0.5777526, 0.55443746, 0.52924836, 0.5030581, 0.4754818, 0.44755483, 0.4188009, 0.39010924, 0.36589605, 0.34312248, 0.19822222 ] }, Loading @@ -95,33 +95,33 @@ 0, 0, 0, 0.79907274, 2.986481, 6.0371423, 9.750208, 13.79084, 18.127565, 22.552736, 26.323647, 29.899708, 33.584328, 37.57757, 41.736164, 46.118713, 50.55904, 55.132065, 59.695816, 63.54744, 67.17024, 70.8818, 74.89049, 79.057915, 83.44549, 87.88867, 92.46332, 97.02797, 100.88011, 104.50321, 1.1986091, 3.680649, 7.0680733, 10.9228945, 15.153937, 19.519176, 23.655724, 27.10775, 30.424194, 33.921745, 37.788837, 41.86583, 46.197086, 50.60584, 55.159744, 59.71205, 63.5569, 67.17572, 70.88495, 74.8923, 79.058945, 83.446075, 87.889, 92.4635, 97.02808, 100.88017, 104.50324, 127.55556 ] }, Loading Loading @@ -170,3 +170,4 @@ } ] }