Skip to content

Instantly share code, notes, and snippets.

View AJIEKCX's full-sized avatar

Alex Panov AJIEKCX

View GitHub Profile
package ru.alexpanov.composepuzzlers
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
@Test
fun sharedFlowSampleTest() = runTest {
val values = mutableListOf<Int>()
val sharedFlow = MutableSharedFlow<Int>()
val job = launch {
sharedFlow.toList(values)
}
advanceUntilIdle()
@AJIEKCX
AJIEKCX / StackView.swift
Created July 18, 2023 17:25
SwiftUI StackView for Decompose integration
import Shared
import SwiftUI
/*
A custom implementation of the stack view wrapper with:
- no indices for `onBack` action
- no `getTitle`
- no `NavigationStack`
- custom UINavigationController
@AJIEKCX
AJIEKCX / DeclarativeModalBottomSheetState.kt
Created October 8, 2023 13:33
Declarative Modal Bottom Sheet State
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
@AJIEKCX
AJIEKCX / RetainedComposeComponent.kt
Created February 6, 2024 08:24
Decompose retained component creation from Composable fun
import android.app.Activity
import android.os.Bundle
import androidx.activity.BackEventCompat
import androidx.activity.OnBackPressedCallback
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner