Skip to content

Instantly share code, notes, and snippets.

View alexvanyo's full-sized avatar
💛

Alex Vanyo alexvanyo

💛
View GitHub Profile
// Copyright 2026 Google LLC.
// SPDX-License-Identifier: Apache-2.0
val TopSpecialAlignmentLine = HorizontalAlignmentLine(::min)
val BottomSpecialAlignmentLine = HorizontalAlignmentLine(::max)
@Preview
@Composable
fun OverlayExample() {
Layout(
@alexvanyo
alexvanyo / WindowInsetRulersContentPadding.kt
Last active January 14, 2026 21:44
An example of using the WindowInsetRulers to drive content padding for a LazyColumn
// Copyright 2025 Google LLC.
// SPDX-License-Identifier: Apache-2.0
@Preview
@Composable
fun WindowInsetRulersContentPadding() {
val paddingValues = remember {
object : PaddingValues {
var start by mutableStateOf(0.dp)
var end by mutableStateOf(0.dp)
var top by mutableStateOf(0.dp)
@alexvanyo
alexvanyo / NotifyInput.kt
Last active January 5, 2026 08:27
A Modifier to track all touch inputs on a Composable
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
/**
* A [Modifier] that tracks all input, and calls [block] every time input is received.
*/
private fun Modifier.notifyInput(block: () -> Unit): Modifier =
composed {
val currentBlock by rememberUpdatedState(block)
pointerInput(Unit) {
while (currentCoroutineContext().isActive) {
/*
* Copyright 2024 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2024 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2024 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2025 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alexvanyo
alexvanyo / SnapshotStateSet.kt
Last active May 7, 2025 21:58
An implementation of a MutableSet backed by snapshot state
/*
* Copyright 2022 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alexvanyo
alexvanyo / LocalSessionInfo.kt
Created November 18, 2024 19:01
SessionValue utilities
/*
* Copyright 2024 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@alexvanyo
alexvanyo / EdgeToEdgeAlertDialog.kt
Last active September 17, 2024 01:48
EdgeToEdgeDialogs
/*
* Copyright 2024 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software