Share
Embed
Fast Prototypes using Kotlin_Native (and Flutter)
Presented at Informal get-together of Kotlin developers in Berlin
https://www.meetup.com/kotlin-berlin/events/tvhffpyzcbwb/
JB Lorenzo
January 17, 2019
Transcript
70 slides
-
Agenda • Who are we • Our story: what problem
do I want to solve • Tools we used • The code! • Recap • Q&A -
We fuel local economies by making it super easy for
anyone to buy or sell almost anything through our platforms -
We operate a network of market-leading trading platforms in over
40 countries that are used by more than 350 million people every month -
Mana ger Mobi Mobi Mobi Ayelen Chavez Rem Cruz Cristiano
Madeira JB Lorenzo -
Once upon a time… This is a story about how
we made the OLX Group Product & Tech Conference app in record time. -
• We were only 4 engineers (or 3 and a
half) • We had our ambitious priorities for the quarter • We didn't have much spare time • The VP of Engineer asked us to help with a new app -
• We were only 4 engineers (or 3 and a
half) • We had our ambitious priorities for the quarter • We didn't have much spare time • The VP of Engineer asked us to help with a new app -
• We were only 4 engineers (or 3 and a
half) • We had our ambitious priorities for the quarter • We didn't have much spare time • The VP of Engineer asked us to help with a new app -
• We were only 4 engineers (or 3 and a
half) • We had our ambitious priorities for the quarter • We didn't have much spare time • The VP of Engineer asked us to help with a new app -
We needed a UI/UX Super hero Karen Banzon Material Theme
Editor in Sketch -
// GetSchedulesUseCase.kt class GetSchedulesUseCase(val repository: ConferenceRepository): UseCase<T, Input> { private
val noFavoriteKeywords = listOf("coffee break", "lunch") override var disposeBag: Disposal = emptyArray<CancellableType>().toMutableList() override fun buildUseCaseObservable(params: Input): Observable<T> { return create { o -> FetchConferenceUseCase(repository).execute(Observer(onNext = { var schedules = emptyList<Map<String, String>>().toMutableList() it.talks.forEach { schedules.add(mapOf(...)) } o.onNext(schedules) }, onError = { o.onError(it) }), Unit) -
// GetSchedulesUseCase.kt class GetSchedulesUseCase(val repository: ConferenceRepository): UseCase<T, Input> { private
val noFavoriteKeywords = listOf("coffee break", "lunch") override var disposeBag: Disposal = emptyArray<CancellableType>().toMutableList() override fun buildUseCaseObservable(params: Input): Observable<T> { return create { o -> FetchConferenceUseCase(repository).execute(Observer(onNext = { var schedules = emptyList<Map<String, String>>().toMutableList() it.talks.forEach { schedules.add(mapOf(...)) } o.onNext(schedules) }, onError = { o.onError(it) }), Unit) -
// GetSchedulesUseCase.kt class GetSchedulesUseCase(val repository: ConferenceRepository): UseCase<T, Input> { private
val noFavoriteKeywords = listOf("coffee break", "lunch") override var disposeBag: Disposal = emptyArray<CancellableType>().toMutableList() override fun buildUseCaseObservable(params: Input): Observable<T> { return create { o -> FetchConferenceUseCase(repository).execute(Observer(onNext = { var schedules = emptyList<Map<String, String>>().toMutableList() it.talks.forEach { schedules.add(mapOf(...)) } o.onNext(schedules) }, onError = { o.onError(it) }), Unit) -
// GetSchedulesUseCase.kt class GetSchedulesUseCase(val repository: ConferenceRepository): UseCase<T, Input> { private
val noFavoriteKeywords = listOf("coffee break", "lunch") override var disposeBag: Disposal = emptyArray<CancellableType>().toMutableList() override fun buildUseCaseObservable(params: Input): Observable<T> { return create { o -> FetchConferenceUseCase(repository).execute(Observer(onNext = { var schedules = emptyList<Map<String, String>>().toMutableList() it.talks.forEach { schedules.add(mapOf(...)) } o.onNext(schedules) }, onError = { o.onError(it) }), Unit) -
// MainActivity.kt import com.olxgroup.olxconf.domain.GetSchedulesUseCase val schedulesUseCase = GetSchedulesUseCase(repository) MethodChannel(flutterView, CHANNEL).setMethodCallHandler
{ call, result -> when (call.method) { "getSchedules" -> getSchedules(result) "getSpeakers" -> getSpeakers(result) "getInfo" -> getInfo(result) "launchMap" -> launchMap(result, call) } } -
// MainActivity.kt import com.olxgroup.olxconf.domain.GetSchedulesUseCase val schedulesUseCase = GetSchedulesUseCase(repository) MethodChannel(flutterView, CHANNEL).setMethodCallHandler
{ call, result -> when (call.method) { "getSchedules" -> getSchedules(result) "getSpeakers" -> getSpeakers(result) "getInfo" -> getInfo(result) "launchMap" -> launchMap(result, call) } } -
// MainActivity.kt import com.olxgroup.olxconf.domain.GetSchedulesUseCase val schedulesUseCase = GetSchedulesUseCase(repository) MethodChannel(flutterView, CHANNEL).setMethodCallHandler
{ call, result -> when (call.method) { "getSchedules" -> getSchedules(result) "getSpeakers" -> getSpeakers(result) "getInfo" -> getInfo(result) "launchMap" -> launchMap(result, call) } } -
// MainActivity.kt import com.olxgroup.olxconf.domain.GetSchedulesUseCase val schedulesUseCase = GetSchedulesUseCase(repository) MethodChannel(flutterView, CHANNEL).setMethodCallHandler
{ call, result -> when (call.method) { "getSchedules" -> getSchedules(result) "getSpeakers" -> getSpeakers(result) "getInfo" -> getInfo(result) "launchMap" -> launchMap(result, call) } } -
// AppDelegate.swift import OLXConfFramework let channel = FlutterMethodChannel.init(name: "/api", binaryMessenger:
controller) channel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in if call.method == "getSchedules" { self.getSchedules(result) } else if call.method == "getSpeakers" { self.getSpeakers(result) } else if call.method == "getInfo" { self.getInfo(result) } else if call.method == "launchMap" { self.launchMap(call, result) } }); -
// AppDelegate.swift import OLXConfFramework let channel = FlutterMethodChannel.init(name: "/api", binaryMessenger:
controller) channel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in if call.method == "getSchedules" { self.getSchedules(result) } else if call.method == "getSpeakers" { self.getSpeakers(result) } else if call.method == "getInfo" { self.getInfo(result) } else if call.method == "launchMap" { self.launchMap(call, result) } }); -
// AppDelegate.swift import OLXConfFramework let channel = FlutterMethodChannel.init(name: "/api", binaryMessenger:
controller) channel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in if call.method == "getSchedules" { self.getSchedules(result) } else if call.method == "getSpeakers" { self.getSpeakers(result) } else if call.method == "getInfo" { self.getInfo(result) } else if call.method == "launchMap" { self.launchMap(call, result) } }); -
// AppDelegate.swift import OLXConfFramework let channel = FlutterMethodChannel.init(name: "/api", binaryMessenger:
controller) channel.setMethodCallHandler({ (call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in if call.method == "getSchedules" { self.getSchedules(result) } else if call.method == "getSpeakers" { self.getSpeakers(result) } else if call.method == "getInfo" { self.getInfo(result) } else if call.method == "launchMap" { self.launchMap(call, result) } }); -
// data_schedule.dart static const platform = const MethodChannel('/api'); final List<dynamic>
result = await platform.invokeMethod('getSchedules'); -
// data_schedule.dart static const platform = const MethodChannel('/api'); final List<dynamic>
result = await platform.invokeMethod('getSchedules'); -
// data_schedule.dart static const platform = const MethodChannel('/api'); final List<dynamic>
result = await platform.invokeMethod('getSchedules'); -
• Packing and Unpacking • Companion in Swift • arm32
• JVM libraries -
• Packing and Unpacking • Companion in Swift • arm32
• JVM libraries -
• Packing and Unpacking • Companion in Swift • arm32
• JVM libraries -
• Packing and Unpacking • Companion in Swift • arm32
• JVM libraries -
• Flutter is awesome for fast prototypes • Flutter and
Kotlin/Native are still in beta but is usable already though with some limitations • Kotlin/Native works well to reduce the amount of platform specific code • Some glue code needs to be written to pass around/serialize objects • Don’t be afraid to try out new technologies (but …) -
• Flutter is awesome for fast prototypes • Flutter and
Kotlin/Native are still in beta but is usable already though with some limitations • Kotlin/Native works well to reduce the amount of platform specific code • Some glue code needs to be written to pass around/serialize objects • Don’t be afraid to try out new technologies (but …) -
• Flutter is awesome for fast prototypes • Flutter and
Kotlin/Native are still in beta but is usable already though with some limitations • Kotlin/Native works well to reduce the amount of platform specific code • Some glue code needs to be written to pass around/serialize objects • Don’t be afraid to try out new technologies (but …) -
• Flutter is awesome for fast prototypes • Flutter and
Kotlin/Native are still in beta but is usable already though with some limitations • Kotlin/Native works well to reduce the amount of platform specific code • Some glue code needs to be written to pass around/serialize objects • Don’t be afraid to try out new technologies (but …) -
• Flutter is awesome for fast prototypes • Flutter and
Kotlin/Native are still in beta but is usable already though with some limitations • Kotlin/Native works well to reduce the amount of platform specific code • Some glue code needs to be written to pass around/serialize objects • Don’t be afraid to try out new technologies (but …) -
Questions Email: [email protected] and [email protected] We are hiring: joinolx.com Medium
post: http://bit.ly/kotlin_flutter