File tree Expand file tree Collapse file tree
Jetsnack/app/src/main/java/com/example/jetsnack/ui/snackdetail Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ import androidx.compose.runtime.setValue
5757import androidx.compose.ui.Alignment
5858import androidx.compose.ui.Modifier
5959import androidx.compose.ui.draw.blur
60+ import androidx.compose.ui.draw.drawWithCache
6061import androidx.compose.ui.geometry.Offset
6162import androidx.compose.ui.graphics.Brush
6263import androidx.compose.ui.graphics.TileMode
@@ -137,19 +138,23 @@ private fun Header() {
137138 label = " offset"
138139 )
139140
140- val brushSize = 400f
141- val brush = Brush .linearGradient(
142- colors = brushColors,
143- start = Offset (offset, offset),
144- end = Offset (offset + brushSize, offset + brushSize),
145- tileMode = TileMode .Mirror
146- )
147141 Spacer (
148142 modifier = Modifier
149143 .height(280 .dp)
150144 .fillMaxWidth()
151145 .blur(40 .dp)
152- .background(brush)
146+ .drawWithCache {
147+ val brushSize = 400f
148+ val brush = Brush .linearGradient(
149+ colors = brushColors,
150+ start = Offset (offset, offset),
151+ end = Offset (offset + brushSize, offset + brushSize),
152+ tileMode = TileMode .Mirror
153+ )
154+ onDrawBehind {
155+ drawRect(brush)
156+ }
157+ }
153158
154159 )
155160}
You can’t perform that action at this time.
0 commit comments