Skip to content

Instantly share code, notes, and snippets.

View mhrohani1385's full-sized avatar
✍️
Will release a big project as open source soon. working on it ... !

M.H.Rohani mhrohani1385

✍️
Will release a big project as open source soon. working on it ... !
  • Iran
  • 10:53 (UTC +03:30)
View GitHub Profile
@mhrohani1385
mhrohani1385 / RememberPreference.kt
Last active July 26, 2023 10:19
rememberSavable alternative wiht a useful feature for saving in Shared Preferences from a Composable scope. Eesy to use (like usage.kt) !
class ShardPreferencesHandler<T>(
private val `class`: Class<T>,
context: Context,
private val initValue : T?,
private val key: String? = null,
private val addNameToKey: Boolean = false
) {
enum class Type(val theClass: KClass<*>) {
Float(kotlin.Float::class),
@mhrohani1385
mhrohani1385 / how.md
Last active June 17, 2023 09:24
How to convert svg to vector drawable with Adobe illustrator and Vector asset studio
  1. Open SVG file with illustrator and convert all to compound path with (Ctrl + 8)
  2. Save new SVG file
  3. Use saved file in Android Studio's Vector Asset Studio without any error
@mhrohani1385
mhrohani1385 / placeholder.kt
Last active December 20, 2022 17:51
A placeholder with animation for android compose
fun Modifier.gradientProcessingBackground() : Modifier = composed {
val infiniteYTransition = rememberInfiniteTransition()
val state = infiniteYTransition.animateFloat(
initialValue = 0f,
targetValue = 0.7f,
animationSpec = infiniteRepeatable(
animation = tween(500, easing = EaseInOutExpo),
repeatMode = RepeatMode.Restart
)
)
@mhrohani1385
mhrohani1385 / compose-to-bitmap-tools.kt
Created December 19, 2022 12:21
Convert Composable To Bitmap Without Displaying It
@Composable
fun BitmapComposable(
onBitmapped: (bitmap: Bitmap) -> Unit = { _ -> },
backgroundColor: Color = Color.Transparent,
dpSize : DpSize,
readyToDraw : State<Boolean> = mutableStateOf(true),
composable: @Composable () -> Unit
) {
var lastBitmap : Bitmap? = remember {
null