A Pen by Saleh Alanazi on CodePen.
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
// By Sal7one - 3/4/2022 | |
// Inline ImageLoader if you have a diffrenet need than your ImageLoader Singlton | |
// | |
// Since LocalImageLoader is deprecated | |
// | |
// Coil Version | |
// implementation("io.coil-kt:coil-compose:2.0.0-rc02") | |
// implementation("io.coil-kt:coil-svg:2.0.0-rc02") | |
// | |
// |
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
class MainActivity : AppCompatActivity() { | |
private val secretUserNum = Random().nextInt(100) + 1 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
findViewById<TextView>(R.id.actualPass).text = "Actual pass $secretUserNum " |
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
// Raw hilt viewmodel | |
@HiltViewModel | |
class SomeViewModel @Inject constructor( | |
private val repository: Repo // Injected from hilt | |
) : ViewModel() { | |
} | |
// Let's pass any var we want for example an int that we pass when we create the viewmodel |
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
// infinite with gap of 1 | |
@Composable | |
fun AnimatedHeartShapeRaw( | |
brush: Brush = Brush.verticalGradient(colors = listOf(Color.Magenta, Color.Magenta)), // Default gradient from Magenta to Blue | |
) { | |
val animationPercentage = remember { Animatable(0f) } // Animation state from 0 to 1 | |
LaunchedEffect(Unit) { | |
animationPercentage.animateTo( |
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 otherColors = listOf( | |
// Color(0xffffffff), | |
Color(0xff125B34), | |
) | |
@Composable | |
fun CubicWaves() { | |
var angle by remember { mutableFloatStateOf(0f) } | |
val cols = 50 |
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 com.sal7one.handler | |
import android.os.Bundle | |
import android.os.Handler | |
import android.os.Looper | |
import android.os.Message | |
import android.util.Log | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.activity.enableEdgeToEdge |
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 com.example.salscomposecomponents | |
inline fun <R : Any> R.applyWhen( | |
condition: Boolean, | |
block: R.() -> R, | |
): R = applyChoice(condition = condition, trueBlock = block, falseBlock = { this }) | |
inline fun <R : Any> R.applyChoice( | |
condition: Boolean, | |
trueBlock: R.() -> R, |
OlderNewer