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
import android.graphics.Bitmap | |
import android.graphics.BitmapShader | |
import android.graphics.RuntimeShader | |
import android.graphics.Shader | |
import android.os.Build | |
import androidx.compose.animation.core.withInfiniteAnimationFrameMillis | |
import androidx.compose.foundation.shape.RoundedCornerShape | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.produceState | |
import androidx.compose.ui.Modifier |
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
import android.graphics.Color | |
import android.graphics.RuntimeShader | |
import android.os.Build | |
import androidx.compose.animation.core.withInfiniteAnimationFrameMillis | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.produceState | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.composed | |
import androidx.compose.ui.draw.drawWithCache | |
import androidx.compose.ui.graphics.Brush |
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
const val SECONDS = 5 | |
class MainViewModel : ViewModel() { | |
private var timerJob: Job? = null | |
private val _uiState = MutableStateFlow(MainUiState()) | |
val uiState = _uiState.asStateFlow() | |
fun makeApiCall() { | |
timerJob?.cancel() | |
timerJob = viewModelScope.launch { |
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
@Composable | |
private fun MainScreen(viewModel: MainViewModel) { | |
val context = LocalContext.current | |
val uiState = viewModel.uiState.collectAsState() | |
Box(modifier = Modifier.fillMaxSize()) { | |
Text( | |
modifier = Modifier | |
.align(Alignment.TopCenter) |
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
val strokeColor = Color(0x80ffffff) | |
val transparent = Color.Transparent | |
drawPath( | |
path = path, | |
color = strokeColor, | |
style = Stroke(1f), | |
blendMode = BlendMode.Luminosity | |
// blendMode = BlendMode.Luminosity | |
) | |
drawPath( |
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
val scrollState = rememberScrollState() | |
val items = listOf(1, 2, 3, 4) | |
Box { | |
Image( | |
bitmap = bg.asImageBitmap(), | |
contentDescription = "", | |
modifier = Modifier.fillMaxWidth() | |
) |
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
... | |
var screenWidthPx: Int | |
var screenWidthDp: Int | |
var cardWidthPx: Int | |
var cardWidthDp: Int | |
var cardHeightPx: Int | |
val cardHeightDp = 150 | |
var cardMarginPx: Int | |
val cardMarginDp = 15 |
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
package dev.jakhongirmadaminov.glassmorphic_sample | |
import android.graphics.Bitmap | |
import android.graphics.BitmapFactory | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.Image | |
import androidx.compose.foundation.background |