https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Joey

12/02/2019, 1:38 AM
Can someone give me technique on how to listen for button state (android/iOS) in common code?
s

Sam

12/02/2019, 3:10 AM
Most people here don't share code at that level. At best they share it at the level right below the view using some MVC variant like MVVM or MVP. If you really want to try and wrap the two very different ui toolkits with common code it would be a combination of expect/actual classes. I would suggest just writing the ui layer in platform code and use MPP for sharing logic.
👍 1
j

Joey

12/02/2019, 5:01 AM
Thank you for the helpful info! Will check on how each of them work because im just new in kotlin. Appreciate the help
m

Michal Harakal

12/02/2019, 9:58 AM
With MVP you can have even presenters platform independent, so only view is platform specific
The DroidconKotlin app by touchlabs uses MVVM and they share also quite a lot of code between platforms
j

Joey

12/02/2019, 9:59 AM
Will look into this @Michal Harakal
k

Kris Wong

12/02/2019, 1:30 PM
i have written simple UI in an MPP, so it is possible. but you end up with one implementation per target.
j

Joey

12/03/2019, 12:42 AM
Got it, thanks @Kris Wong
m

Martin Gagnon

12/03/2019, 1:22 AM
A bit late to the party, but we just open sourced this: https://github.com/mirego/trikot.metaviews
It allows reactive bindings between kmp and native apps
Any fields (text, color, etc..) can be bound to a ReactiveStream publisher (a coroutine per example)
j

Joey

12/03/2019, 4:26 AM
Thanks @Martin Gagnon appreciate the help!
2 Views