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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"v":"4.12.0","fr":30,"ip":0,"op":90,"w":400,"h":400,"nm":"c","assets":[{"id":"comp_27","layers":[{"ind":1,"ty":0,"nm":"p","refId":"comp_28","sr":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":300},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":240,"st":0},{"ind":2,"ty":0,"nm":"p","refId":"comp_28","sr":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":240},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":240,"st":0},{"ind":3,"ty":0,"nm":"p","refId":"comp_28","sr":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":180},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":240,"st":0},{"ind":4,"ty":0,"nm":"p","refId":"comp_28","sr":1,"ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":120},"p":{"a":0,"k":[50,50,0]},"a":{"a":0,"k":[50,50,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"w":100,"h":100,"ip":0,"op":240,"st":0},{"ind":5,"ty":0,"nm":"
@Sal7one
Sal7one / tabbedRow.kt
Last active July 24, 2024 06:21
TabbedRow
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,
@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 "