Skip to content

Kotlin Multiplatform mobile app with MVVM, for Android and iOS

Notifications You must be signed in to change notification settings

samdanTetteh/Kotlin-MPP-Android-IOS

Repository files navigation

Prerequisites

Android Studio 3.5.x XCode 11.3.x

Structure

The project has three main subfolders:

  • app is the Android app
  • ios is the iOS app
  • shared is the Kotlin Multiplatform library that's accessible to both apps

Setup

You'll need to edit or override local.properties to point to your own Android SDK directory

To build the Koltin Multiplatform library you might want to run ./gradlew sharedcode:packForXCode at least once.

Features

Notes

This app displays an initial data of 200 todos in a recyclerview from Jsonplaceholder and persisted on device, making sure application follows the Single source of truth analogy. Once this is done all other requests for data is done locally.

Each platform has implementations their own view model class due to the different uses with data manipulation in different platforms. A new task is add is persisted locally and added to the bottom of the list in the recycler view. The shared data layer is using the repository pattern to decide which is the source of data. For networking i am using Ktor and for Json serialization Kotlinx serialization.

Both IOS and Android handle their own view representations once data is retrieved from the shared repository to conform to platform specification standards. This is also to enable UI tests to be implemented at the platform level.

MVVM (Model-View-View-Model)

MVVM is my preferred design pattern as it make sure you write quality maintainable code and also helps to follow the SOLID and clean architecture.

Advantages

  • it's a clean separation of the code.
  • Makes it easier to go into one parts and make changes without affecting other key parts of the code.
  • That means you can remain agile with new releases of code quickly.
  • The presentation layer and the logic is loosely coupled.
  • The external and internal dependences are in separate pieces of code from the parts with the core logic beinfg tested are.
  • That makes it a lot easier to write unit tests against a core logic - this is not a feature I was able to run in the current app structure. Please can we discuss how to do this as part of the review/feedback.

Disadvantages

  • Some people think that for simple UIs, MVVM can be an overkill.

Assumptions

Due to the wide growth of the Kotlin language, Kotlin multiplatform applications are becoming quite popular. It gives you the ability to write software for a wide range of platforms sharing one code base(the business logic) not just mobile with a language that is already popular with developers. Koltin syntax is very similar to swift, making it easier to pick up by IOS developers.

Although initially the app architecture can take some getting use to, Kotlin multiplatform is really about pragmatic programming to help meet the growing demand to develop mobile applications on multiple platforms – a clean, clear way to avoid having to write the code twice.

About

Kotlin Multiplatform mobile app with MVVM, for Android and iOS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published