generated from JetBrains/compose-multiplatform-ios-android-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 added a general CardBackgroundSurface to be used across the app to …
…display a blurred card background
- Loading branch information
1 parent
ecfab73
commit 71eacbb
Showing
8 changed files
with
121 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
shared/src/commonMain/kotlin/net/schacher/mcc/shared/design/compose/CardBackgroundSurface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package net.schacher.mcc.shared.design.compose | ||
|
||
import androidx.compose.animation.core.tween | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.BoxScope | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.blur | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.FilterQuality | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.unit.dp | ||
|
||
@Composable | ||
fun CardBackgroundBox( | ||
cardCode: String, | ||
modifier: Modifier = Modifier, | ||
content: @Composable BoxScope.() -> Unit | ||
) { | ||
Box( | ||
modifier = modifier | ||
) { | ||
CardBackgroundImage( | ||
modifier = Modifier.fillMaxWidth(), | ||
background = MaterialTheme.colors.background, | ||
cardCode = cardCode | ||
) | ||
|
||
content() | ||
} | ||
} | ||
|
||
@Composable | ||
fun CardBackgroundImage( | ||
modifier: Modifier = Modifier.fillMaxWidth(), | ||
background: Color = MaterialTheme.colors.background, | ||
cardCode: String | ||
) { | ||
Box(modifier = modifier.height(340.dp)) { | ||
CardImage( | ||
modifier = Modifier.fillMaxSize() | ||
.blur(30.dp) | ||
.background(MaterialTheme.colors.surface), | ||
cardCode = cardCode, | ||
filterQuality = FilterQuality.Low, | ||
contentScale = ContentScale.Crop, | ||
animationSpec = tween( | ||
durationMillis = 500 | ||
), | ||
onLoading = {}, | ||
onFailure = {}) | ||
|
||
Box( | ||
modifier = Modifier.fillMaxSize().background( | ||
Brush.verticalGradient( | ||
colorStops = arrayOf( | ||
0f to background.copy(alpha = 0f), | ||
1f to background.copy(alpha = 1f) | ||
) | ||
) | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters