I know how to launch a new activity in native andr...
# getting-started
h
I know how to launch a new activity in native android. But I want to have a single shared function that launches a new activity in iOS and Android
i
There's no such thing as an "activity" in iOS, there are view controllers. Main purpose of KMP is to share the code than can be shared, not platform specific stuff
👍 1
h
So how would you create a kotlin multiplatform app that can change views?
s
Look into expect / actual functions
h
I understand that (kind of), but what would the function return?
i
I wouldn't - I'd just have a use case in the shared KMP module, and handle the navigation in iosApp/androidApp. For example, imagine having SignInUseCase. I'd simply call e.g.
Copy code
signInUseCase.execute(email: "<mailto:test@test.com|test@test.com>", password: "securemuch")
from view models in iOS/Android. And then in completion block I'd handle the navigation. This way KMP does all the heavy lifting, and navigation is trivial anyway. It's not like you're saving some actual time by forcing that into the shared code. Hope this makes sense!
h
It helps!
👍 1