Skip to content

Instantly share code, notes, and snippets.

View burnoo's full-sized avatar

Bruno Wieczorek burnoo

  • Kotlin Multiplatform / Android Developer
  • Wrocław, Poland
  • 13:24 (UTC +01:00)
View GitHub Profile
@burnoo
burnoo / Google Maps Compose for Wear OS.md
Created October 17, 2022 18:58
Google Maps Compose for Wear OS

Currently Google Maps Compose does not support Wear OS officially. The main problem is a lack of support for swipe to dissmiss gesture. I came up with a workaround to add swipe to dissmiss on edges (which currently have to be black):

@Composable
fun ComposeMap() {
    val cameraPositionState = rememberCameraPositionState()
    val focusRequester = remember { FocusRequester() }

    Box(
@burnoo
burnoo / Jetpack Compose two-way data binding.kt
Last active October 13, 2022 07:08
Jetpack Compose two-way data binding
private class MutableStateAdapter<T>(
private val state: State<T>,
private val mutate: (T) -> Unit
) : MutableState<T> {
override var value: T
get() = state.value
set(value) {
mutate(value)
}
@burnoo
burnoo / viewModelStoreOwner usage.kt
Last active October 21, 2021 13:58
Cokoin Medium 7
@Composable
fun Screen1(navController: NavController) {
val rootViewModel = getViewModel<RootViewModel>(
viewModelStoreOwner = navController.getBackStackEntry("root")
)
}
@burnoo
burnoo / Cokoin ViewModel.kt
Created October 21, 2021 13:48
Cokoin medium 6
val module = module {
viewModel { AppViewModel() }
}
Koin(appDeclaration = { modules(module) }) {
val viewModel = getViewModel<AppViewModel>()
Text(viewModel.text)
}
@burnoo
burnoo / KoinContext.kt
Created October 13, 2021 12:25
Cokoin medium 5
@Composable
fun App() {
val globalData = get<AppData>() // uses Global KoinContext
Koin(koinApplication) {
val localData = get<AppData>() // uses Local KoinContext (koinApplication)
}
}
@burnoo
burnoo / HarmonyOSAndroidCheatSheet.MD
Last active October 7, 2021 12:39
Java HarmonyOS API for Android developers - cheatsheet

Basic Applications Elements

Android HarmonyOS Notes / Usage
Application AbilityPackage
@burnoo
burnoo / Koin Scopes.kt
Last active October 4, 2021 19:54
Cokoin Medium 4
data class A(val value: String)
val scopedModule = module {
scope<ScopeTypeA> {
scoped { A("scopeA") }
}
scope<ScopeTypeB> {
scoped { A("scopeB") }
}
}
@burnoo
burnoo / Preview Koin.kt
Created September 21, 2021 09:46
Medium Cokoin 3
@Composable
fun Hello() {
val hello = get<Hello>()
Text(hello.text)
}
val previewModule = module {
factory { Hello(text = "preview hello text") }
}
@burnoo
burnoo / Wrapping Configuration.kt
Last active October 13, 2021 12:17
Cokoin Medium 2
val appModule = module {
single { AppData() }
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Koin(appDeclaration = { modules(appModule) }) {
val appData = get<AppData>()
@burnoo
burnoo / build.gradle
Last active December 5, 2021 16:57
Medium Cokoin 1
dependencies {
implementation "dev.burnoo:cokoin:0.3.2"
// REMOVE "org.koin:koin-androidx-compose:X.Y.Z" if you were using it
}