All Projects → jtouzy → Kompose

jtouzy / Kompose

🔥 Architecture pattern for multiplatform mobile apps with Kotlin Multiplatform (common), SwiftUI (iOS) & Compose (Android).

Programming Languages

swift
15916 projects
kotlin
9241 projects

Projects that are alternatives of or similar to Kompose

Flutter News Reader
News Reader App to fetch Articles from different news channels using Flutter.
Stars: ✭ 80 (-29.2%)
Mutual labels:  mobile-app
Github Native
📱 mobile github client built with react-native
Stars: ✭ 94 (-16.81%)
Mutual labels:  mobile-app
Androidcomposesamples
An Android app which provides examples for Android Jetpack Compose
Stars: ✭ 105 (-7.08%)
Mutual labels:  compose
Docker Series
Docker Series about containerizing ASP.NET Core app with MySQL..
Stars: ✭ 88 (-22.12%)
Mutual labels:  compose
Book Of Spices
An educational app to help you learn about spices, built on top of react-native, react-native-navigation from wix and lottie-react-native for animations.
Stars: ✭ 94 (-16.81%)
Mutual labels:  mobile-app
React Native Qrcode App
DEPRECATED: QRCode Reader and Generator written with React Native
Stars: ✭ 97 (-14.16%)
Mutual labels:  mobile-app
Reactnativemeteorboilerplate
Stars: ✭ 79 (-30.09%)
Mutual labels:  mobile-app
Twittercompose
TwitterCompose is an Android application 📱 for showcasing Jetpack Compose for building declarative UI in Android.
Stars: ✭ 109 (-3.54%)
Mutual labels:  compose
Learn Jetpack Compose By Example
🚀 This project contains various examples that show how you would do things the "Jetpack Compose" way
Stars: ✭ 1,319 (+1067.26%)
Mutual labels:  compose
Boden
Purely native C++ cross-platform GUI framework for Android and iOS development. https://www.boden.io
Stars: ✭ 1,394 (+1133.63%)
Mutual labels:  mobile-app
Flutter Mvvm Provider Demo
Stars: ✭ 89 (-21.24%)
Mutual labels:  mobile-app
Woocommerce Ios
WooCommerce iOS app
Stars: ✭ 93 (-17.7%)
Mutual labels:  mobile-app
Wq.app
💻📱 wq's app library: a JavaScript framework powering offline-first web & native apps for geospatial data collection, mobile surveys, and citizen science. Powered by Redux, React, Material UI and Mapbox GL.
Stars: ✭ 99 (-12.39%)
Mutual labels:  mobile-app
Watf Bank
WaTF Bank - What a Terrible Failure Mobile Banking Application for Android and iOS
Stars: ✭ 87 (-23.01%)
Mutual labels:  mobile-app
To Do
A Kotlin Multiplatform to-do list app with SwiftUI and Compose UI frontends
Stars: ✭ 105 (-7.08%)
Mutual labels:  compose
Cooking App Flutter
Example app build with Flutter
Stars: ✭ 79 (-30.09%)
Mutual labels:  mobile-app
Novum
Novum is a news app built with flutter.
Stars: ✭ 96 (-15.04%)
Mutual labels:  mobile-app
Laqul
A complete starter kit that allows you create amazing apps that look native thanks to the Quasar Framework. Powered by an API developed in Laravel Framework using the easy GraphQL queries language. And ready to use the Google Firebase features.
Stars: ✭ 110 (-2.65%)
Mutual labels:  mobile-app
Mvvm Reddit
A companion project for our blog post on better Android software development using MVVM with RxJava.
Stars: ✭ 106 (-6.19%)
Mutual labels:  mobile-app
Brightid
Reference mobile app for BrightID
Stars: ✭ 101 (-10.62%)
Mutual labels:  mobile-app

Kompose

Reusable architecture pattern for multiplatform mobile projects with Kotlin Multiplatform, SwiftUI & Compose.

overview

Try now ⬇️.

Purpose

This repository describes an architecture pattern & best practises for a mobile application project. Main advantages below :

  • Based on a redux-like pattern / Fully reactive (states)
  • Maximum reuse common code between platforms (view logic & controls with presenters, network layers, ...)
  • And so, avoid duplicate work between Android devs and iOS devs for common code and common unit tests
  • Use native languages & frameworks for drawing views (SwiftUI -or Storyboards- for iOS, Compose -or XML- for Android) for maximum design capabilities

Kotlin Multiplatform Overview (for mobile)

This architecture is entirely based on the powerful Kotlin Multiplatform system. The main principle is described below :

overview

With one common Kotlin code, you can generate Cocoa frameworks for iOS development, and also use the same code for an Android app. Kotlin Multiplatform can also be used to generate javascript dependencies or more, but we will not describe it here.

You can discover more about the Kotlin Native features here.

Example app

The best demo is a working app. You can find the Breaking Bad Quotes demo app source code here.

In this app, the specs are simple :

  • List all Breaking Bad characters.
  • Show all Breaking Bad quotes for a selected character.

We will use the Breaking Bad API for this demo app, to demonstrate how powerful the common code can be with network requests & serialization.

Characters screen as an example

Overview

For having an overview of all pieces we need to build the first screen, let's see this diagram below.

overview

As you can see, all the common code is built on a common Kotlin layer, and only the view/reactive stuff, specific to the platforms, are implemented in iOS/Android.

Let's see all the pieces in details.

Some details

  • ViewState : A view state is a temporal state of your View. The state is retained by the Store.

  • Store : A store retains a ViewState. The Presenter will send to the Store a new view state, and the View will react to this and redraw.

This layer is here to customize how the view will react to a view state update. In this example, for iOS, SwiftUI binding is used to react to the state change with ObservableStore. But you can also implements another version of the Store, that will handle a Delegate or an Rx Subject to handle state changes, if you can't use SwiftUI yet.

  • Assembler (iOS) : An assembler is here to merge it all together. The assembler will create the whole module, initializing the presenter, the view, and the store, then linking it together.

Speed up your multiplatform development

🚀 [iOS] Automatically generate a new framework with the last Kotlin classes in each build ?

You can add a Run Script to the Build phases of your project, which will just launch a gradle packForXcode command. You can find an example of the build_ios_frameworks.sh script in the demo app.

🚀 [iOS] Debug Kotlin classes from an imported framework in Xcode ?

Two steps :

The configuration is set in the demo app.

🚀 Use a single locale file for iOS and Android ?

You can use Twine to have a single file reference for all your application locales. Twine is a command line tool that will generate you a Localizable.strings file for iOS and a strings.xml file for Android, based on a single .twine file.

Again, for iOS, with a simple Run Script in your Build Phases, you can generate your strings in each build.

You can find an example in the demo app.

Try it yourself

You want to try it ? But doesn't want to loose time with configuration ? We just provide an utility tool for you to generate the structure of the project, so you can start clean.

For now, it's a bit trivial, until we've published the tool on brew. Clone the repo, execute the main.py file, then give your informations, like below :

JTO @ tmp $ git clone https://github.com/jtouzy/Kompose

Cloning into 'Kompose'...
remote: Enumerating objects: 810, done.
remote: Counting objects: 100% (810/810), done.
remote: Compressing objects: 100% (355/355), done.
remote: Total 1505 (delta 249), reused 759 (delta 211), pack-reused 695
Receiving objects: 100% (1505/1505), 962.43 KiB | 2.47 MiB/s, done.
Resolving deltas: 100% (448/448), done.

JTO @ tmp $ ./Kompose/KomposeCli/main.py

>> Creating a new multi-platform project with Kompose

[1] Your project identifier (example: DemoApp): MyApp  
[2] Your project package (example: com.jtouzy): com.myname
[2] Your project absolute path ('Enter' for this location): 

Creating project directory... /private/tmp/MyApp
Generating files...

>> Your project is ready. Cd here: /private/tmp/MyApp

Issues, ideas

If you have any recommandations, ideas, or issues, please feel free to open a new issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].