Skip to content

Instantly share code, notes, and snippets.

View AJIEKCX's full-sized avatar

Alex Panov AJIEKCX

View GitHub Profile
@AJIEKCX
AJIEKCX / ComposeInReactNative.kt
Created August 10, 2025 10:16
This is an example of how to embed a Jetpack Compose screen into React Native with proper lifecycle handling in navigation.
import android.content.Context
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import android.view.View
@AJIEKCX
AJIEKCX / EncryptedSettings.kt
Created July 15, 2025 17:21
A secure implementation of SharedPreferences for the MultiplatformSettings library
import android.content.SharedPreferences
import com.google.crypto.tink.Aead
import com.google.crypto.tink.KeysetHandle
import com.google.crypto.tink.RegistryConfiguration
import com.google.crypto.tink.TinkProtoKeysetFormat
import com.google.crypto.tink.aead.AeadConfig
import com.google.crypto.tink.aead.PredefinedAeadParameters
import com.google.crypto.tink.integration.android.AndroidKeystore
import com.google.crypto.tink.subtle.Base64
import com.google.crypto.tink.subtle.Hex
@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
@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 / 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
@Test
fun sharedFlowSampleTest() = runTest {
val values = mutableListOf<Int>()
val sharedFlow = MutableSharedFlow<Int>()
val job = launch {
sharedFlow.toList(values)
}
advanceUntilIdle()
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