Skip to content

Instantly share code, notes, and snippets.

View vadiole's full-sized avatar
♥️
stay determined

Dmitriy vadiole

♥️
stay determined
View GitHub Profile
@vadiole
vadiole / ScalePressEffect.kt
Created January 14, 2023 20:51
Scale press effect for your views
package vadiole.presseffect
import android.annotation.SuppressLint
import android.view.MotionEvent
import android.view.View
import android.view.View.OnTouchListener
import android.view.ViewPropertyAnimator
import android.view.animation.AccelerateDecelerateInterpolator
@SuppressLint("ClickableViewAccessibility")
@vadiole
vadiole / HyperlinkText.kt
Created September 19, 2022 13:26
Composable function for displaying text with inline clickable links (touch effect included)
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextLayoutResult
@vadiole
vadiole / FigmaColorsToCompose.js
Last active September 12, 2022 15:19
Converts json colors exported from figma into compose
// Colors from https://www.figma.com/community/plugin/1143682832255826428
const colors = {
colorName: 'rgb(23, 23, 23)',
};
for (var key in colors) {
if (colors.hasOwnProperty(key)) {
console.log('val ' + key + ' = Color(' + RGBAToAHex(colors[key]) + ')');
}
}
@vadiole
vadiole / ViewWallpaperService.kt
Created September 30, 2021 00:12
WallpaperService with View
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.graphics.Canvas
import android.os.PowerManager
import android.service.wallpaper.WallpaperService
import android.util.Log
import android.view.Choreographer
import android.view.SurfaceHolder
@vadiole
vadiole / SquircleDrawable.kt
Last active March 13, 2023 22:22
SquircleDrawable with iOS-like rounded corners
import android.graphics.Canvas
import android.graphics.ColorFilter
import android.graphics.Matrix
import android.graphics.Paint
import android.graphics.Path
import android.graphics.PixelFormat
import android.graphics.Rect
import android.graphics.drawable.Drawable
import kotlin.math.pow
@vadiole
vadiole / ShakeController.kt
Last active September 30, 2021 00:08
IOS-like shaking animation
import android.animation.ValueAnimator
import android.view.View
import java.lang.ref.WeakReference
class ShakeController(v: View) {
val view: WeakReference<View> = WeakReference(v)
private var isShaking = false
// rotate and translate bounds, params for random duration
private val rotate = 1f