Skip to content

Instantly share code, notes, and snippets.

View TheMelody's full-sized avatar
🤪

被风吹过的夏天 TheMelody

🤪
View GitHub Profile
@fabriciovergara
fabriciovergara / CollapsibleTopAppBar.kt
Last active June 9, 2024 12:16
Collapsible TopAppBar in Jetpack Compose
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.BoxWithConstraintsScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
@StylianosGakis
StylianosGakis / Bouncy ropes demo
Last active July 19, 2023 08:55
Jetpack Compose demo for an animated bouncy rope draggable with your mouse
import androidx.compose.animation.core.animateOffsetAsState
import androidx.compose.animation.core.spring
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
@c5inco
c5inco / HeartRate.kt
Last active June 1, 2024 10:44
Jetpack Compose implementation of inspiration: https://twitter.com/amos_gyamfi/status/1494053914945236999
package des.c5inco.material3
import android.graphics.Matrix
import android.graphics.Path
import androidx.compose.animation.core.*
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
@TheMelody
TheMelody / Compose - MultiFloatingActionButton.kt
Last active November 20, 2021 06:43
Jetpack Compose - FloatingActionButton 展开/折叠 的多级悬浮菜单
/**
* 折叠/展开多个FloatingActionButton菜单
*/
@Composable
fun MultiFloatingActionButton(
modifier: Modifier = Modifier,
srcIcon: ImageVector,
srcIconColor: Color = Color.White,
fabBackgroundColor: Color = Color.Unspecified,
showLabels: Boolean = true,
@iamutkarshtiwari
iamutkarshtiwari / Jetpack Compose Right and Left ModalDrawer
Last active July 29, 2023 10:12
Custom Jetpack Compose ModalDrawer to support Left and Right alignments
package com.iamutkarshtiwari.ds.component.drawer
import androidx.annotation.FloatRange
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
@DavidIbrahim
DavidIbrahim / DashedBorder.kt
Last active May 14, 2024 15:13
dashedBorder modifier for android compose
import androidx.compose.foundation.BorderStroke
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@vganin
vganin / ComposeNumberPicker.kt
Last active January 14, 2024 11:53
Jetpack Compose simple number picker
@Composable
fun NumberPicker(
state: MutableState<Int>,
modifier: Modifier = Modifier,
range: IntRange? = null,
textStyle: TextStyle = LocalTextStyle.current,
onStateChanged: (Int) -> Unit = {},
) {
val coroutineScope = rememberCoroutineScope()
val numbersColumnHeight = 36.dp
companion object {
/** The magnitude of rotation while the list is scrolled. */
private const val SCROLL_ROTATION_MAGNITUDE = 0.25f
/** The magnitude of rotation while the list is over-scrolled. */
private const val OVERSCROLL_ROTATION_MAGNITUDE = -10
/** The magnitude of translation distance while the list is over-scrolled. */
private const val OVERSCROLL_TRANSLATION_MAGNITUDE = 0.2f