Skip to content

Instantly share code, notes, and snippets.

View Alex009's full-sized avatar
🏔️

Aleksey Mikhailov Alex009

🏔️
View GitHub Profile
@Alex009
Alex009 / QrScannerScreen.android.kt
Created May 10, 2023 08:09 — forked from oianmol/QrScannerScreen.android.kt
QR Code Scanner with Jetbrains Jetpack compose multiplatform!
import android.Manifest
import android.content.pm.PackageManager
import android.util.Log
import android.view.ViewGroup
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageAnalysis
import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
@Alex009
Alex009 / README.md
Last active April 4, 2024 05:38
Как устроена интеграция Kotlin/Native в iOS приложение

Как Kotlin работает в iOS

Код написанный на Kotlin компилируется компилятором Kotlin/Native в бинарный файл. Конкретно для iOS этот бинарник заворачивается в .framework - это созданный Apple формат библиотек.

Данный .framework для iOS (а точнее для Xcode) выглядит как обычная нативная библиотека, также как условный Alamofire, SwiftUI и любые другие библиотеки в Apple мире. У этой библиотеки доступен Objective-C header - заголовочный файл, описывающий в синтаксисе Objective-C какие классы и методы есть в этой библиотеке.

.framework должен быть подключен к Xcode проекту.

@Alex009
Alex009 / build.gradle.kts
Last active October 27, 2023 11:06
valid config of moko-resources with kotlin 1.9.10, compose 1.5.3
/*
* Copyright 2023 LLC Campus.
*/
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
kotlin("multiplatform").apply(false)
kotlin("plugin.serialization").apply(false)
id("com.android.application").apply(false)
@Alex009
Alex009 / branches.sh
Created April 18, 2024 06:44
Checkout all git branches
git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /remotes/p;" | xargs -L1 git checkout -t
@Alex009
Alex009 / FlowBinding.swift
Created February 28, 2025 05:29
SwiftUI Binding for MutableStateFlow
// code from Chris Hatton - https://kotlinlang.slack.com/archives/C9JM6Q2UX/p1740462546873469?thread_ts=1740462525.562349&cid=C9JM6Q2UX
struct FlowBinding<FlowValue: Equatable, BoundValue: Equatable, Content>: View where Content: View {
private let mutableStateFlow: SkieSwiftMutableStateFlow<FlowValue>
private let content: (Binding<BoundValue>) -> Content
private let transformOut: (FlowValue) -> BoundValue
private let transformIn: (BoundValue) -> FlowValue
// Track the source of truth internally
@State private var currentValue: BoundValue