Kotlin Multiplatform sample with SwiftUI and Compose (Desktop and Android) clients. Heavily inspired by Wordle game.

Overview

WordMasterKMP

Kotlin Multiplatform sample heavily inspired by Wordle game and also Word Master and wordle-solver samples. The main game logic/state is included in shared KMP code with basic UI then in following clients

  • iOS (SwiftUI)
  • Android (Jetpack Compose)
  • Desktop (Compose for Desktop)

Shared KMP game logic/state

The shared WordMasterService class includes following StateFlows representing the current set of guesses and updated status info for each letter.

val boardGuesses = MutableStateFlow<ArrayList<ArrayList<String>>>(arrayListOf())
val boardStatus = MutableStateFlow<ArrayList<ArrayList<LetterStatus>>>(arrayListOf())

The various clients call WordService.setGuess() when a user enters a letter and then WordService.checkGuess() after row of letters are entered...UI then reflects any resulting updates to above StateFlow's. The Compose clients for example do that using following (with any updates to those StateFlow's triggering recomposition)

val boardGuesses by wordMasterService.boardGuesses.collectAsState()
val boardStatus by wordMasterService.boardStatus.collectAsState()

On iOS we're using [KMP-NativeCoroutines](https://github.com/rickclephas/KMP-NativeCoroutines) library to map the `StateFlow`s to Swift `AsyncStream`s. So, for example, our Swift view model includes
@Published public var boardStatus: [[LetterStatus]] = []
@Published public var boardGuesses: [[String]] = []

which are then updated using for example

let stream = asyncStream(for: wordMasterService.boardStatusNative)
for try await data in stream {
  self.boardStatus = data as! [[LetterStatus]]
}

let stream = asyncStream(for: wordMasterService.boardGuessesNative)
for try await data in stream {
    self.boardGuesses = data as! [[String]]
}

Any updates to boardStatus or boardGuesses will trigger our SwiftUI UI to be recomposed again.

Remaining work includes

  • check if overall word is valid and show indication in UI if not (ideally with animations!)
  • better keyboard navigation
  • share Compose code between Android and Desktop
  • indicator in UI that correct guess entered (other than all letters being green)

Screenshots

Screenshot 2022-01-08 at 22 40 36

Simulator Screen Shot - iPhone 13 Pro - 2022-01-08 at 22 38 11

Screenshot_1641682073

You might also like...
Joplin - an open source note taking and to-do application with synchronization capabilities for Windows, macOS, Linux, Android and iOS. Forum: https://discourse.joplinapp.org/
Joplin - an open source note taking and to-do application with synchronization capabilities for Windows, macOS, Linux, Android and iOS. Forum: https://discourse.joplinapp.org/

Joplin® is a free, open source note taking and to-do application, which can handle a large number of notes organised into notebooks. The notes are sea

Blazing⚡️Fast BTC and ETH Wallet Generator library for React Native, Android and iOS

Blazing ⚡️ Fast BTC and ETH Wallet Generator library for React Native, Android and iOS.

Fridax enables you to read variables and intercept/hook functions in Xamarin/Mono JIT and AOT compiled iOS/Android applications.

Fridax is a Node package for dealing with Xamarin applications while using the Frida API. Goal • Installation • Usage • Examples • Issues • License Bu

iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android).
iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android).

FinanceReactNative iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android). Data is pulled from Yahoo Finance

🏀 iOS and Android NBA app created with React Native
🏀 iOS and Android NBA app created with React Native

Swish An iOS and Android NBA app created with React Native. If you would like to request a feature, find a bug, have a question, or would like to leav

The Outline Client is a cross-platform VPN or proxy client for Windows, macOS, iOS, Android, and ChromeOS

Outline Client The Outline Client is a cross-platform VPN or proxy client for Windows, macOS, iOS, Android, and ChromeOS. The Outline Client is design

The Bitwarden mobile application is written in C# with Xamarin Android, Xamarin iOS, and Xamarin Forms.
The Bitwarden mobile application is written in C# with Xamarin Android, Xamarin iOS, and Xamarin Forms.

Bitwarden Mobile Application The Bitwarden mobile application is written in C# with Xamarin Android, Xamarin iOS, and Xamarin Forms. Build/Run Require

Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects
Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects

Introduction Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import the latest

Allows you to emulate an Android native library, and an experimental  iOS emulation
Allows you to emulate an Android native library, and an experimental iOS emulation

unidbg Allows you to emulate an Android native library, and an experimental iOS emulation. This is an educational project to learn more about the ELF/

Owner
John O'Reilly
Android Software Engineer
John O'Reilly
Kotlin Multiplatform project that gets network data from Food2Fork.ca

Food2Fork Recipe App This is the codebase for a Kotlin Multiplatform Mobile course. Watch the course List to Detail screen Searching Architecture Shar

Mitch Tabian 309 Nov 24, 2022
A Kotlin multiplatform library for building dynamic server-driven UI

Component Box · A Kotlin multiplatform library for building dynamic server-driven UI. Material Component-Based Interoperable Dynamic What You See Is W

Dropbox 210 Nov 17, 2022
Sonic language: Heavily inspired by Swift, but compiles to C so you can use it anywhere.

Sonic Sonic programming language: Heavily inspired by Swift, but compiles to C so you can use it anywhere. Brought to you by Chris Hulbert and Andres

Sonic Language 27 Apr 8, 2022
Kotlin Multiplatfom app for Droidcon Events

Sessionize/Droidcon Mobile Clients General Info This project has a pair of native mobile applications backed by the Sessionize data api for use in eve

Touchlab 804 Nov 17, 2022
A macOS application for accessing the output of the SimpleAnalytics package on the desktop.

The SimpleAnalytics package allows you to collect data user interaction analytic data in iOS and macOS applications. This SimpleAnalytics Reader app project allows you to more easily make sense of that collected data by displaying it on your Mac.

Dennis Birch 10 Mar 13, 2022
A VM launcher for Parallels Desktop

PDrunner 适用于Parallels Desktop的虚拟机启动器 A VM launcher for Parallels Desktop 使用 Usage PDrunner是一个菜单栏APP, 启动后会在菜单栏显示一个图标. 点击菜单栏图标可列出当前Mac上安装的所有客户机, 然后点击客户机

null 3.2k Jan 16, 2022
Podman-desktop: a graphical menu bar application for managing Podman machines

podman-desktop podman-desktop is a graphical menu bar application for managing P

Containers 1.7k Nov 16, 2022
Desktop Pets for macOS!

Desktop Pets This is the source code of my macOS app Desktop Pets!. As you can guess, it brings Desktop Pets to macOS ?? What's a Desktop Pet? It's ju

Federico Curzel 65 Nov 16, 2022
Ported scrcpy for mobile platforms, to remotely control Android devices on your iPhone or Android phone.

scrcpy-mobile Ported scrcpy for mobile platforms, to remotely control Android devices on your iPhone or Android phone. Currently only supports control

Ethan 116 Nov 13, 2022
React Native utility library around image and video files for getting metadata like MIME type, timestamp, duration, and dimensions. Works on iOS and Android using Java and Obj-C, instead of Node 🚀.

Qeepsake React Native File Utils Extracts information from image and video files including MIME type, duration (video), dimensions, and timestamp. The

Qeepsake 12 Oct 19, 2022