Skip to content

Instantly share code, notes, and snippets.

View amal's full-sized avatar
👨‍💻

Art Shendrik amal

👨‍💻
View GitHub Profile
@Nek-12
Nek-12 / DynamicBottomSheetScaffold.kt
Last active March 20, 2024 20:34
Dynamic non-modal bottom sheet for Compose that fixes existing issues with material3 implementation
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
@Nek-12
Nek-12 / StackNavigator.kt
Last active March 12, 2024 16:20
Decompose - Global navigation events with channel
internal class StackComponent(context: ComponentContext): Component {
private val results = Channel<NavResult<*>>(Channel.CONFLATED)
inline fun <reified R> sendResult(result: R) {
val config = stack.active.configuration
// or popWhile - bring desired page to the front
navigation.pop {
results.trySend(NavResult(config, result))
@blessedbyjobs
blessedbyjobs / CMakeLists.txt
Last active March 25, 2024 16:27
Код, используемый для проверки, что устройство имеет root права
// этот файл поместить в корень проекта
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
// адаптировать под структуру вашего проекта
set(SOURCES src/main/cpp/NativeRootChecker.cpp)
add_library(root_checker_jni SHARED ${SOURCES})
@file:OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
package de.kuno.listsections
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateRectAsState
import androidx.compose.foundation.ExperimentalFoundationApi
@halilozercan
halilozercan / DrawGlyphs.kt
Created October 1, 2023 20:30
A Set of helper functions and classes to draw each individual glyph separately
import androidx.compose.ui.draw.drawWithCache
import androidx.compose.ui.geometry.CornerRadius
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ImageBitmap
@KlassenKonstantin
KlassenKonstantin / ClippedForeground.kt
Last active May 7, 2024 10:35
evervault.com inspired animation
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.nativeCanvas
@Composable
@cies
cies / gradle_snippet.kt
Created May 31, 2023 10:02
Make Gradle print its task plan
// This prints the dependencies of each task in the current execution graph
gradle.taskGraph.whenReady(
closureOf<TaskExecutionGraph> {
println("About to run ${allTasks.size} tasks: (use `-i` to see why tasks are skipped, use `--rerun-tasks` to prevent UP-TO-DATE checks)")
allTasks.forEachIndexed { i, task ->
val dependenciesString =
if (task.dependsOn.isEmpty()) {
""
} else {
task.dependsOn.joinToString(", ", " (depends on ", ")") { dependency ->
@zhgchgli0718
zhgchgli0718 / Fastfile
Created April 20, 2023 04:29
A simply extend the Fastlane Action to enable downloading the uploaded Universal APK from the Google Play Console.
lane :test do | options |
apk_downloader(json_key: "./xxx@xxx.iam.gserviceaccount.com.json", package_name: "m.zhgchg.li", version_code:1000, export_file_path: "./zhgchgli.apk")
end
@yorickhenning
yorickhenning / gist:3275ea38e1619a5c8aa0efac9370484d
Last active March 19, 2023 21:16
Reentrance checking coroutine Mutex
suspend fun <ReturnT> Mutex.checkedWithLock(
block: suspend () -> ReturnT
): ReturnT {
val element = LockedMutexesElement(this).key
check (currentCoroutineContext()[element] == null) {
"Reentered Mutex"
}
return withContext(element) { withLock { block() } }
}