This project is a Kotlin Multiplatform Mobile (KMM/KMP) application that demonstrates a shared user interface and network logic between Android and iOS. The app fetches a list of StackOverflow users via the StackExchange API and supports web content display through a WebView.
- Shared User Interface: Built entirely with Compose for both platforms.
- User List Screen: Displays a list of users retrieved from the StackExchange API.
- WebView Handler: Opens user-related web content when needed.
- Networking: Implemented with Ktor client.
- Serialization: JSON conversion using Kotlinx Serialization.
- Image Loading: Network images loaded via Kamel.
- ViewModel: Shared
UserViewModelto manage UI state and networking.
-
APIService and NetworkClient: Handles API requests via Ktor.
client.get("https://api.stackexchange.com/2.3/users?site=stackoverflow&page=1&pagesize=20").body() -
UserScreen: Compose-based screen displaying the list of users with network-loaded images.
-
WebViewHandler: Cross-platform WebView implementation for showing user pages.
-
UserViewModel: Maintains UI state, handles API requests, and exposes data to UserScreen.
-
Ktor – for network requests
-
Kotlinx Serialization – for JSON parsing
-
Kamel – for loading images from the network
-
Jetpack Compose / Compose Multiplatform – for building UI
-
Kotlinx Coroutines – for asynchronous operations
-
Clone the repository:
git clone https://github.com/michellequibido-virtusize/kmp.git
-
Open the project in Android Studio / IntelliJ IDEA with KMM support.
-
Sync Gradle to fetch dependencies.
-
Run this command to create the xcframework for iOS
./gradlew :shared:assembleXCFramework
-
Add the shared.xcframework to iOSApp -> Frameworks
-
Run the Android or iOS app target. The shared UserScreen and WebViewHandler will work across both platforms.