Skip to content

Instantly share code, notes, and snippets.

View Alex009's full-sized avatar
🏔️

Aleksey Mikhailov Alex009

🏔️
View GitHub Profile
@Alex009
Alex009 / sample.md
Created March 31, 2019 16:09
Kotlin/Native generics usage samples

Simple generics usage

class in kotlin - LiveData.kt

/**
 * Created by Aleksey Mikhailov <Aleksey.Mikhailov@icerockdev.com> on 09.07.2018.
 */
expect open class LiveData<T> {
    open val value: T

    fun <OT> map(function: (T) -> OT): LiveData<OT>
@Alex009
Alex009 / sample.h
Created November 29, 2019 14:52
K/N generics
__attribute__((swift_name("WidgetsWidget")))
@interface MPLWidgetsWidget<WS> : KotlinBase
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (MPLWidgetsViewBundle<WS> *)buildViewViewFactoryContext:(UIViewController *)viewFactoryContext __attribute__((swift_name("buildView(viewFactoryContext:)")));
@property (readonly) WS size __attribute__((swift_name("size")));
@end;
@Alex009
Alex009 / LoginScreen.kt
Last active December 2, 2019 08:09
ConstraintWidget api sample
/*
* Copyright 2019 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
package com.icerockdev.library.universal
import dev.icerock.moko.fields.FormField
import dev.icerock.moko.fields.liveBlock
import dev.icerock.moko.mvvm.viewmodel.ViewModel
import dev.icerock.moko.resources.desc.StringDesc
@Alex009
Alex009 / logs
Created December 24, 2019 05:21
GoogleMaps linking
warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/alekseymikhailovwork/.konan/kotlin-native-macos-1.3.61/konan/targets/ios_x64/native/debug.bc with '[2 x i32] [i32 13, i32 2]' from out)
warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/alekseymikhailovwork/.konan/kotlin-native-macos-1.3.61/konan/targets/ios_x64/native/strict.bc with '[2 x i32] [i32 13, i32 2]' from out)
warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/alekseymikhailovwork/.konan/kotlin-native-macos-1.3.61/klib/common/stdlib/targets/ios_x64/native/runtime.bc with '[2 x i32] [i32 13, i32 2]' from out)
warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/alekseymikhailovwork/.konan/kotlin-native-macos-1.3.61/klib/platform/ios_x64/posix/targets/ios_x64/native/cstubs.bc with '[2 x i32] [i32 13, i32
@Alex009
Alex009 / gist:d29ecf9995806cc445d35da9f1ecf969
Created December 26, 2019 06:17
GoogleMaps framework linking
Run tool: konanc with args: -g -ea -target ios_x64 -p framework
-o /Users/alekseymikhailovwork/Documents/development/icerockdev_workspace/moko/moko-maps/sample/mpp-library/build/bin/iosX64/MultiPlatformLibraryDebugFramework/MultiPlatformLibrary.framework
-l /Users/alekseymikhailovwork/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/maps-google-iosx64/0.1.0/b4eb5e91e5acfae3c39c4cd3adcd5941072fa9ec/maps-google.klib
-l /Users/alekseymikhailovwork/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/maps-google-iosx64/0.1.0/f5b69645514f16f2b172e581b035b12b67a0ca8d/maps-google-cinterop-googleMaps.klib
-l /Users/alekseymikhailovwork/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/maps-iosx64/0.1.0/96633f2a7872ce7150952bf721149121b8ebc5c9/maps.klib
-l /Users/alekseymikhailovwork/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/geo-iosx64/0.1.0/a90cf4fec108e45ce31ad6d2430117408aad4dfa/geo.klib
-l /Users/alekseymikhailovwork/.gradle/caches/modules-2/files-2.1/dev.icerock.moko/mvvm-iosx64/0.4.0/722bfc2
package com.icerock.yellowdoor.feature.personalInfo
import dev.icerock.moko.mvvm.dispatcher.EventsDispatcher
import dev.icerock.moko.mvvm.livedata.LiveData
import dev.icerock.moko.mvvm.livedata.MutableLiveData
import dev.icerock.moko.mvvm.livedata.map
import dev.icerock.moko.mvvm.livedata.readOnly
import dev.icerock.moko.resources.ImageResource
import dev.icerock.moko.resources.desc.StringDesc
import dev.icerock.moko.resources.desc.desc
fun report(b: Any?, c: Any) {
val a = b?.calculate().intersect(c) ?: return
if(a.total <= 100) return
val c = a.convert()
reportTotal(c, fullData = a)
}
/*
* Copyright 2019 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Alex009
Alex009 / build.gradle.kts
Created November 22, 2021 15:39
Welcome Feature Gradle Build File
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import dev.icerock.gradle.generator.FatFrameworkWithResourcesTask
plugins {
kotlin(module = "multiplatform")
id("com.android.library")
id("dev.icerock.mobile.multiplatform-resources")