Skip to content

Instantly share code, notes, and snippets.

View Sal7one's full-sized avatar
Probably making my 7th cup of Coffee

Saleh Alanazi Sal7one

Probably making my 7th cup of Coffee
View GitHub Profile
@Sal7one
Sal7one / handlersCompose.kt
Created June 23, 2024 07:58
It's the weekend and I miss handlers :]
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
@Sal7one
Sal7one / README.md
Created May 27, 2024 15:44 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@Sal7one
Sal7one / ComposeWavesSimilarToFlag.kt
Last active May 10, 2024 14:05
Waves in canvas compose
val otherColors = listOf(
// Color(0xffffffff),
Color(0xff125B34),
)
@Composable
fun CubicWaves() {
var angle by remember { mutableFloatStateOf(0f) }
val cols = 50
@Sal7one
Sal7one / HeartShape.kt
Created May 5, 2024 07:00
Animated heart jetpack compose, with gaps
// 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(
@Sal7one
Sal7one / ExpandedButtonCompose.kt
Last active April 21, 2024 16:52
Menu button scale expand something something compose kotlin
// Original idea by https://twitter.com/raffichill/status/1781492309500027206
// Tried to make it vanilla as possible
@Composable
fun EditMenu() {
var isExpanded by remember {
mutableStateOf(false)
}
val scale by animateFloatAsState(
@Sal7one
Sal7one / AssistedInjectionHilt.kt
Last active February 27, 2024 21:23
Assisted Injection with hilt Helper code - I think it's dumb and a bad practice but here's the code anyways :)
// 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
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 "
@Sal7one
Sal7one / loader.kt
Created April 3, 2022 06:16
Loading SVGs from a URL with COIL on Jetpack compose (inline imageLoader)
// 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")
//
//
@Sal7one
Sal7one / hotline-miami-2-vita-custom-bullet-calculator.markdown
Created January 23, 2022 15:15
Hotline Miami 2 Vita. custom bullet calculator