Upgrade to Pro — share decks privately, control downloads, hide ads and more …

kmp-iosmeetup.pdf

 kmp-iosmeetup.pdf

Overview of Kotlin Multiplatform for the iOSoho meetup in NYC

Kevin Galligan

January 14, 2019
Tweet

More Decks by Kevin Galligan

Other Decks in Programming

Transcript

  1. kot·lin mul·ti·plat·form /ˌkätˈlin məltiˈplatfôrm,ˌkätˈlin məltīˈplatfôrm/ noun noun: kotlin multiplatform 1.optional,

    natively-integrated, open-source, code sharing platform, based on the popular, modern language kotlin. facilitates non-ui logic availability on many platforms.
  2. Q3 Q2 Q4 Q1 Q2 2018 2019 0 .6 v0.7

    v0.8 v0.8.2 v0.9.3 IDE tooling! Coroutines?
  3. Q3 Q2 Q4 Q1 Q2 2018 2019 0 .6 v0.7

    v0.8 v0.8.2 v0.9.3 IDE tooling! Coroutines? K/N 1.0, Kotlin 1.3 Gradle 4.10+
  4. Q3 Q2 Q4 Q1 Q2 2018 2019 0 .6 v0.7

    v0.8 v0.8.2 v0.9.3 IDE tooling! Coroutines? K/N 1.0, Kotlin 1.3 Gradle 4.10+ K/N 1.1, Kotlin 1.3.20 Community Libraries Big Co Support
  5. Q3 Q2 Q4 Q1 Q2 2018 2019 0 .6 v0.7

    v0.8 v0.8.2 v0.9.3 IDE tooling! Coroutines? K/N 1.0, Kotlin 1.3 Gradle 4.10+ K/N 1.1, Kotlin 1.3.20 Community Libraries Big Co Support MT Coroutines Improved tooling
  6. Q3 Q2 Q4 Q1 Q2 2018 2019 0 .6 v0.7

    v0.8 v0.8.2 v0.9.3 IDE tooling! Coroutines? K/N 1.0, Kotlin 1.3 Gradle 4.10+ K/N 1.1, Kotlin 1.3.20 Community Libraries Big Co Support MT Coroutines Improved tooling Reactive Library Big Prod Apps “Mainstream”
  7. expect val mainThread:Boolean actual val mainThread: Boolean get() = Looper.myLooper()

    === Looper.getMainLooper() actual val mainThread: Boolean get() = NSThread.isMainThread()
  8. expect val mainThread:Boolean actual val mainThread: Boolean get() = Looper.myLooper()

    === Looper.getMainLooper() actual val mainThread: Boolean get() = NSThread.isMainThread() actual val mainThread: Boolean = true
  9. expect fun currentTimeMillis():Long expect fun <B> backgroundTask(backJob:()-> B, mainJob:(B) ->

    Unit) expect fun backgroundTask(backJob:()->Unit) expect fun networkBackgroundTask(backJob:()->Unit) expect fun initContext():NativeOpenHelperFactory expect fun <T> goFreeze(a:T):T expect fun <T> T.freeze2(): T expect fun simpleGet(url:String):String expect fun logException(t:Throwable) expect fun settingsFactory(): Settings.Factory expect fun createUuid():String
  10. actual class Date(val iosDate:NSDate) { actual fun toLongMillis():Long{ return floor(iosDate.timeIntervalSince1970).toLong()

    * 1000L } } actual class DateFormatHelper actual constructor(format:String){ val formatter:NSDateFormatter init { formatter = NSDateFormatter() formatter.dateFormat = format } actual fun toDate(s:String):Date = Date(formatter.dateFromString(s)!!) actual fun format(d:Date):String = formatter.stringFromDate(d.iosDate) }
  11. fun initPlatformClient( staticFileLoader: (filePrefix: String, fileType: String) -> String?, analyticsCallback:

    (name: String, params: Map<String, Any>) -> Unit, clLogCallback: (s: String) -> Unit) {
  12. fun initPlatformClient( staticFileLoader: (filePrefix: String, fileType: String) -> String?, analyticsCallback:

    (name: String, params: Map<String, Any>) -> Unit, clLogCallback: (s: String) -> Unit) { AppContext.initPlatformClient ({filePrefix, fileType -> loadAsset("${filePrefix}.${fileType}")}, {name: String, params: Map<String, Any> -> val event = CustomEvent(name) //Loop Answers.getInstance().logCustom(event) }, { Log.w("MainApp", it) })
  13. let appContext = AppContext() appContext.doInitPlatformClient(staticFileLoader: loadAsset, analyticsCallback: analyticsCallback, clLogCallback: csLog)

    func loadAsset(filePrefix:String, fileType:String) -> String?{ do{ let bundleFile = Bundle.main.path(forResource: filePrefix, ofType: fileType) return try String(contentsOfFile: bundleFile!) } catch { return nil } }
  14. interface SessionDetailsView : BaseView { fun updateView(isFavorite: Boolean, session: SessionModel)

    fun setupRatingButtons(rating: SessionRating?) fun setRatingClickable(clickable: Boolean) }
  15. interface SessionDetailsView : BaseView { fun updateView(isFavorite: Boolean, session: SessionModel)

    fun setupRatingButtons(rating: SessionRating?) fun setRatingClickable(clickable: Boolean) }
  16. ?