├── shared
├── src
│ ├── androidMain
│ │ ├── AndroidManifest.xml
│ │ └── kotlin
│ │ │ └── me
│ │ │ └── inassar
│ │ │ ├── main.android.kt
│ │ │ └── platform
│ │ │ └── Platform.kt
│ ├── desktopMain
│ │ └── kotlin
│ │ │ └── me
│ │ │ └── inassar
│ │ │ ├── main.desktop.kt
│ │ │ └── platform
│ │ │ └── Platform.kt
│ ├── iosMain
│ │ └── kotlin
│ │ │ └── me
│ │ │ └── inassar
│ │ │ ├── main.ios.kt
│ │ │ ├── utils
│ │ │ └── DeviceOrientationUtils.kt
│ │ │ └── platform
│ │ │ └── Platform.kt
│ └── commonMain
│ │ └── kotlin
│ │ └── me
│ │ └── inassar
│ │ ├── common
│ │ ├── config
│ │ │ ├── Constants.kt
│ │ │ ├── Defaults.kt
│ │ │ └── Enums.kt
│ │ ├── locale
│ │ │ ├── SupportedLanguages.kt
│ │ │ ├── GeneralStrings.kt
│ │ │ └── Localize.kt
│ │ ├── composable
│ │ │ ├── RenderLoading.kt
│ │ │ ├── RenderError.kt
│ │ │ ├── RatingBar.kt
│ │ │ ├── ImageLoader.kt
│ │ │ └── TopAppBar.kt
│ │ └── network
│ │ │ ├── ResponseResource.kt
│ │ │ ├── RemoteError.kt
│ │ │ └── KtorClient.kt
│ │ ├── di
│ │ ├── CacheModule.kt
│ │ ├── RemoteModule.kt
│ │ ├── RepositoryModule.kt
│ │ ├── ViewModelModule.kt
│ │ ├── AppModule.kt
│ │ └── Koin.kt
│ │ ├── features
│ │ └── feature
│ │ │ ├── presentation
│ │ │ ├── manipulator
│ │ │ │ ├── FeatureEvents.kt
│ │ │ │ ├── FeatureState.kt
│ │ │ │ └── FeatureViewModel.kt
│ │ │ ├── data
│ │ │ │ ├── UiProducts.kt
│ │ │ │ └── FeatureStrings.kt
│ │ │ ├── mapper
│ │ │ │ └── UiProductsMapper.kt
│ │ │ └── ui
│ │ │ │ ├── products
│ │ │ │ ├── FeatureScreen.kt
│ │ │ │ └── ProductItem.kt
│ │ │ │ └── details
│ │ │ │ └── ProductDetails.kt
│ │ │ ├── data
│ │ │ ├── remote
│ │ │ │ ├── FeatureRemoteApi.kt
│ │ │ │ ├── source
│ │ │ │ │ └── FeatureRemoteApiImpl.kt
│ │ │ │ └── dto
│ │ │ │ │ └── getProducts
│ │ │ │ │ └── response
│ │ │ │ │ └── GetProductsResponseDto.kt
│ │ │ └── repository
│ │ │ │ └── FeatureRepositoryImpl.kt
│ │ │ └── domain
│ │ │ ├── repository
│ │ │ └── FeatureRepository.kt
│ │ │ ├── model
│ │ │ └── DomainProducts.kt
│ │ │ └── mapper
│ │ │ └── DomainProductsMapper.kt
│ │ ├── platform
│ │ └── Platform.kt
│ │ └── App.kt
└── build.gradle.kts
├── iosApp
├── Configuration
│ └── Config.xcconfig
├── iosApp
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ ├── app-icon-1024.png
│ │ │ └── Contents.json
│ │ └── AccentColor.colorset
│ │ │ └── Contents.json
│ ├── Preview Content
│ │ └── Preview Assets.xcassets
│ │ │ └── Contents.json
│ ├── iOSApp.swift
│ ├── ContentView.swift
│ └── Info.plist
├── Podfile
└── iosApp.xcodeproj
│ └── project.pbxproj
├── androidApp
├── src
│ └── androidMain
│ │ ├── res
│ │ ├── values
│ │ │ └── strings.xml
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ └── drawable
│ │ │ └── ic_launcher_background.xml
│ │ ├── kotlin
│ │ └── me
│ │ │ └── inassar
│ │ │ ├── MainActivity.kt
│ │ │ └── MyApp.kt
│ │ └── AndroidManifest.xml
└── build.gradle.kts
├── readme_images
├── target_device.png
├── edit_run_config.png
├── run_on_android.png
├── run_on_desktop.png
└── open_project_view.png
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── desktopApp
├── src
│ └── jvmMain
│ │ └── kotlin
│ │ └── me
│ │ └── inassar
│ │ ├── MyApp.kt
│ │ └── main.kt
└── build.gradle.kts
├── cleanup.sh
├── .gitignore
├── gradle.properties
├── settings.gradle.kts
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── .run
└── desktopApp.run.xml
├── gradlew.bat
├── gradlew
├── docs
└── project_setup.md
├── README.md
└── LICENSE.txt
/shared/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/iosApp/Configuration/Config.xcconfig:
--------------------------------------------------------------------------------
1 | TEAM_ID=
2 | BUNDLE_ID=me.inassar
3 | APP_NAME=KMM Template
4 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | KMM Template
3 |
--------------------------------------------------------------------------------
/iosApp/Podfile:
--------------------------------------------------------------------------------
1 | target 'iosApp' do
2 | use_frameworks!
3 | platform :ios, '14.1'
4 | pod 'shared', :path => '../shared'
5 | end
--------------------------------------------------------------------------------
/readme_images/target_device.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/readme_images/target_device.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/readme_images/edit_run_config.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/readme_images/edit_run_config.png
--------------------------------------------------------------------------------
/readme_images/run_on_android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/readme_images/run_on_android.png
--------------------------------------------------------------------------------
/readme_images/run_on_desktop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/readme_images/run_on_desktop.png
--------------------------------------------------------------------------------
/readme_images/open_project_view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/readme_images/open_project_view.png
--------------------------------------------------------------------------------
/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/shared/src/desktopMain/kotlin/me/inassar/main.desktop.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import androidx.compose.runtime.Composable
4 |
5 | @Composable
6 | fun MainView() = App()
--------------------------------------------------------------------------------
/shared/src/androidMain/kotlin/me/inassar/main.android.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import androidx.compose.runtime.Composable
4 |
5 | @Composable
6 | fun MainView() = App()
7 |
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/app-icon-1024.png
--------------------------------------------------------------------------------
/shared/src/iosMain/kotlin/me/inassar/main.ios.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import androidx.compose.ui.window.ComposeUIViewController
4 |
5 |
6 | fun MainViewController() = ComposeUIViewController { App() }
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ranger163/kotlin-multiplatform-template/HEAD/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/desktopApp/src/jvmMain/kotlin/me/inassar/MyApp.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import me.inassar.di.initKoin
4 |
5 |
6 | /**
7 | * Created by Ahmed Nassar on 5/27/23.
8 | */
9 | val koin = initKoin(enableNetworkLogs = true).koin
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/config/Constants.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.config
2 |
3 | /**
4 | * Created by Ahmed Nassar on 5/27/23.
5 | */
6 | const val ARABIC_LANGUAGE = "ar"
7 | const val ENGLISH_LANGUAGE = "en"
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/locale/SupportedLanguages.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.locale
2 |
3 | /**
4 | * Created by Ahmed Nassar on 8/3/23.
5 | */
6 | class SupportedLanguages(
7 | val en: String,
8 | val ar: String
9 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/di/CacheModule.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.di
2 |
3 | import org.koin.dsl.module
4 |
5 | /**
6 | * Created by Ahmed Nassar on 5/27/23.
7 | */
8 | val cacheModule = module {
9 | // single { Impl() }
10 | }
--------------------------------------------------------------------------------
/cleanup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | rm -rf .idea
3 | ./gradlew clean
4 | rm -rf .gradle
5 | rm -rf build
6 | rm -rf */build
7 | rm -rf iosApp/iosApp.xcworkspace
8 | rm -rf iosApp/Pods
9 | rm -rf iosApp/iosApp.xcodeproj/project.xcworkspace
10 | rm -rf iosApp/iosApp.xcodeproj/xcuserdata
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Dec 26 11:35:19 AST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/manipulator/FeatureEvents.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.manipulator
2 |
3 | /**
4 | * Created by Ahmed Nassar on 5/27/23.
5 | */
6 | sealed class FeatureEvents {
7 | object GetProducts : FeatureEvents()
8 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/config/Defaults.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.config
2 |
3 | /**
4 | * Created by Ahmed Nassar on 5/27/23.
5 | */
6 |
7 | const val DEFAULT_INT = Int.MIN_VALUE
8 | const val DEFAULT_DOUBLE = Double.MIN_VALUE
9 | const val DEFAULT_FLOAT = Float.MIN_VALUE
10 | const val DEFAULT_STRING = ""
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/config/Enums.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.config
2 |
3 | /**
4 | * Created by Ahmed Nassar on 5/27/23.
5 | */
6 | enum class Platform {
7 | IOS, ANDROID, DESKTOP
8 | }
9 |
10 | enum class Locales(val value: String) {
11 | ARABIC(ARABIC_LANGUAGE), ENGLISH(ENGLISH_LANGUAGE)
12 | }
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "app-icon-1024.png",
5 | "idiom" : "universal",
6 | "platform" : "ios",
7 | "size" : "1024x1024"
8 | }
9 | ],
10 | "info" : {
11 | "author" : "xcode",
12 | "version" : 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/iosApp/iosApp/iOSApp.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 | import shared
3 |
4 | @main
5 | struct iosApp: App {
6 |
7 | init(){
8 | KoinKt.doInitKoin(enableNetworkLogs: true) // Pass true/false depending on debug/release config
9 | }
10 |
11 | var body: some Scene {
12 | WindowGroup {
13 | ContentView()
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/desktopApp/src/jvmMain/kotlin/me/inassar/main.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import androidx.compose.ui.window.Window
4 | import androidx.compose.ui.window.application
5 |
6 | fun main() = application {
7 | init()
8 |
9 | Window(onCloseRequest = ::exitApplication) {
10 | MainView()
11 | }
12 | }
13 |
14 | private fun init() {
15 | koin
16 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/composable/RenderLoading.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.composable
2 |
3 | import androidx.compose.runtime.Composable
4 | import com.mohamedrejeb.calf.ui.progress.AdaptiveCircularProgressIndicator
5 |
6 | /**
7 | * Created by Ahmed Nassar on 5/27/23.
8 | */
9 | @Composable
10 | fun RenderLoading() = AdaptiveCircularProgressIndicator()
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/composable/RenderError.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.composable
2 |
3 | import androidx.compose.material3.Text
4 | import androidx.compose.runtime.Composable
5 | import androidx.compose.ui.graphics.Color
6 |
7 | /**
8 | * Created by Ahmed Nassar on 5/27/23.
9 | */
10 | @Composable
11 | fun RenderError(message: String) {
12 | Text(text = message, color = Color.Black)
13 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/di/RemoteModule.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.di
2 |
3 | import me.inassar.features.feature.data.remote.FeatureRemoteApi
4 | import me.inassar.features.feature.data.remote.source.FeatureRemoteApiImpl
5 | import org.koin.dsl.module
6 |
7 | /**
8 | * Created by Ahmed Nassar on 5/27/23.
9 | */
10 | val remoteModule = module {
11 | single { FeatureRemoteApiImpl(get()) }
12 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/data/UiProducts.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.data
2 |
3 |
4 | data class UiProducts(
5 | val products: List
6 | )
7 |
8 |
9 | data class UiProduct(
10 | val description: String,
11 | val id: Int,
12 | val price: Int,
13 | val rating: Double,
14 | val thumbnail: String,
15 | val title: String
16 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/di/RepositoryModule.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.di
2 |
3 | import me.inassar.features.feature.data.repository.FeatureRepositoryImpl
4 | import me.inassar.features.feature.domain.repository.FeatureRepository
5 | import org.koin.dsl.module
6 |
7 | /**
8 | * Created by Ahmed Nassar on 5/27/23.
9 | */
10 | val repositoryModule = module {
11 | single { FeatureRepositoryImpl() }
12 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | build/
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 | androidApp/build
11 | buildSrc/.gradle
12 | buildSrc/build
13 | shared/build
14 | desktopApp/.gradle
15 | desktopApp/build
16 | iosApp/Podfile.lock
17 | iosApp/Pods/*
18 | iosApp/iosApp.xcworkspace/*
19 | iosApp/iosApp.xcodeproj/*
20 | !iosApp/iosApp.xcodeproj/project.pbxproj
21 | shared/shared.podspec
22 |
--------------------------------------------------------------------------------
/androidApp/src/androidMain/kotlin/me/inassar/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 |
7 | class MainActivity : ComponentActivity() {
8 | override fun onCreate(savedInstanceState: Bundle?) {
9 | super.onCreate(savedInstanceState)
10 |
11 | setContent {
12 | MainView()
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/data/remote/FeatureRemoteApi.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.data.remote
2 |
3 | import me.inassar.common.network.ResponseResource
4 | import me.inassar.features.feature.data.remote.dto.getProducts.response.GetProductsResponseDto
5 |
6 | /**
7 | * Created by Ahmed Nassar on 5/27/23.
8 | */
9 | interface FeatureRemoteApi {
10 | suspend fun getProductsList(): ResponseResource
11 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/di/ViewModelModule.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.di
2 |
3 | import org.koin.dsl.module
4 |
5 | /**
6 | * Created by Ahmed Nassar on 5/27/23.
7 | */
8 | @Deprecated(
9 | message = "There is no use for the in this template as I've " +
10 | "initialized viewModel using moko, but I'll leave it " +
11 | "here to act as a guid for you"
12 | )
13 | val viewModelModule = module {
14 | // singleOf(::FeatureViewModel)
15 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/platform/Platform.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.platform
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.ui.graphics.Color
5 | import me.inassar.common.config.Platform
6 | import org.koin.core.module.Module
7 |
8 | expect val currentDeviceLanguage: String
9 | expect val currentPlatform: Platform
10 | expect val platformNetworkEngineModule: Module
11 | @Composable
12 | expect fun ChangeStatusBarColors(statusBarColor: Color)
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/domain/repository/FeatureRepository.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.domain.repository
2 |
3 | import kotlinx.coroutines.flow.Flow
4 | import me.inassar.common.network.ResponseResource
5 | import me.inassar.features.feature.domain.model.DomainProducts
6 |
7 | /**
8 | * Created by Ahmed Nassar on 5/27/23.
9 | */
10 | interface FeatureRepository {
11 | suspend fun getProducts(): Flow>
12 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/manipulator/FeatureState.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.manipulator
2 |
3 | import me.inassar.features.feature.presentation.data.UiProducts
4 |
5 | /**
6 | * Created by Ahmed Nassar on 5/27/23.
7 | */
8 | sealed interface FeatureState {
9 | object Loading : FeatureState
10 | data class Error(val errorMessage: String) : FeatureState
11 | data class Success(val uiProducts: UiProducts) : FeatureState
12 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/network/ResponseResource.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.network
2 |
3 | /**
4 | * Created by Ahmed Nassar on 5/27/23.
5 | */
6 | sealed class ResponseResource {
7 | data class Success(val data: T) : ResponseResource()
8 | data class Error(val error: Throwable) : ResponseResource()
9 |
10 | companion object {
11 | fun success(data: T) = Success(data)
12 | fun error(error: Throwable) = Error(error)
13 | }
14 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/data/FeatureStrings.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.data
2 |
3 | import me.inassar.common.locale.Localize
4 | import me.inassar.common.locale.SupportedLanguages
5 |
6 | /**
7 | * Created by Ahmed Nassar on 8/5/23.
8 | */
9 | enum class FeatureStrings(override val supportedLanguages: SupportedLanguages) : Localize {
10 | PRODUCT_LIST_SCREEN_TITLE(SupportedLanguages(en = "Product List", ar = "قائمة المنتجات")),
11 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #Gradle
2 | org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
3 | #Kotlin
4 | kotlin.code.style=official
5 | #MPP
6 | kotlin.mpp.stability.nowarn=true
7 | kotlin.mpp.enableCInteropCommonization=true
8 | kotlin.mpp.androidSourceSetLayoutVersion=2
9 | #Compose
10 | org.jetbrains.compose.experimental.uikit.enabled=true
11 | #Android
12 | android.useAndroidX=true
13 | android.defaults.buildfeatures.buildconfig=true
14 | android.nonTransitiveRClass=true
15 | android.nonFinalResIds=true
16 | #BuildKonfig (DEV, QA, STG, PROD)
17 | buildFlavor=DEV
--------------------------------------------------------------------------------
/iosApp/iosApp/ContentView.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import SwiftUI
3 | import shared
4 |
5 | struct ComposeView: UIViewControllerRepresentable {
6 | func makeUIViewController(context: Context) -> UIViewController {
7 | Main_iosKt.MainViewController()
8 | }
9 |
10 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
11 | }
12 |
13 | struct ContentView: View {
14 | var body: some View {
15 | ComposeView()
16 | .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
17 | }
18 | }
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "KmmTemplate"
2 |
3 | include(":androidApp")
4 | include(":shared")
5 | include(":desktopApp")
6 |
7 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
8 |
9 | pluginManagement {
10 | repositories {
11 | gradlePluginPortal()
12 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
13 | google()
14 | }
15 | }
16 |
17 | dependencyResolutionManagement {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/domain/model/DomainProducts.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.domain.model
2 |
3 |
4 | data class DomainProducts(
5 | val limit: Int,
6 | val products: List,
7 | val skip: Int,
8 | val total: Int
9 | )
10 |
11 |
12 | data class DomainProduct(
13 | val brand: String,
14 | val category: String,
15 | val description: String,
16 | val discountPercentage: Double,
17 | val id: Int,
18 | val images: List,
19 | val price: Int,
20 | val rating: Double,
21 | val stock: Int,
22 | val thumbnail: String,
23 | val title: String
24 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.di
2 |
3 | import io.github.aakira.napier.DebugAntilog
4 | import io.github.aakira.napier.Napier
5 | import kotlinx.coroutines.CoroutineScope
6 | import kotlinx.coroutines.Dispatchers
7 | import kotlinx.coroutines.SupervisorJob
8 | import me.inassar.common.network.ktorHttpClient
9 | import org.koin.dsl.module
10 |
11 | /**
12 | * Created by Ahmed Nassar on 5/27/23.
13 | */
14 |
15 | fun appModule(enableNetworkLogs: Boolean) = module {
16 | Napier.base(DebugAntilog())
17 | single { ktorHttpClient(get(), enableNetworkLogs = enableNetworkLogs) }
18 | single { CoroutineScope(Dispatchers.Default + SupervisorJob()) }
19 | }
--------------------------------------------------------------------------------
/androidApp/src/androidMain/kotlin/me/inassar/MyApp.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import android.app.Application
4 | import me.inassar.di.initKoinForAndroid
5 | import org.koin.android.ext.koin.androidContext
6 | import org.koin.android.ext.koin.androidLogger
7 |
8 | /**
9 | * Created by Ahmed Nassar on 5/27/23.
10 | */
11 | class MyApp : Application() {
12 | override fun onCreate() {
13 | super.onCreate()
14 | initKoin()
15 | }
16 |
17 | private fun initKoin() = initKoinForAndroid(
18 | enableNetworkLogs = true, // Pass true/false depending on debug/release config
19 | appDeclaration = {
20 | androidLogger()
21 | androidContext(this@MyApp)
22 | }
23 | )
24 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: 'Your short but descriptive bug title'
5 | labels: '[feature],[enhancement]'
6 | assignees: 'ranger163'
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/shared/src/desktopMain/kotlin/me/inassar/platform/Platform.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.platform
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.ui.graphics.Color
5 | import io.ktor.client.engine.cio.CIO
6 | import me.inassar.common.config.Platform
7 | import org.koin.core.module.Module
8 | import org.koin.dsl.module
9 | import java.util.Locale
10 |
11 | /**
12 | * Created by Ahmed Nassar on 7/31/23.
13 | */
14 |
15 | actual val currentDeviceLanguage: String
16 | get() = Locale.getDefault().language
17 |
18 | actual val currentPlatform: Platform
19 | get() = Platform.DESKTOP
20 |
21 | actual val platformNetworkEngineModule: Module
22 | get() = module { single { CIO.create() } }
23 |
24 | @Composable
25 | actual fun ChangeStatusBarColors(statusBarColor: Color) = Unit
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/mapper/UiProductsMapper.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.mapper
2 |
3 | import me.inassar.features.feature.domain.model.DomainProducts
4 | import me.inassar.features.feature.presentation.data.UiProduct
5 | import me.inassar.features.feature.presentation.data.UiProducts
6 |
7 | /**
8 | * Created by Ahmed Nassar on 5/27/23.
9 | */
10 | fun DomainProducts.toUiProducts() = UiProducts(
11 | products = this.products.map { domainProduct ->
12 | UiProduct(
13 | description = domainProduct.description,
14 | id = domainProduct.id,
15 | price = domainProduct.price,
16 | rating = domainProduct.rating,
17 | thumbnail = domainProduct.thumbnail,
18 | title = domainProduct.title,
19 | )
20 | }
21 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/di/Koin.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.di
2 |
3 | import org.koin.core.context.startKoin
4 | import org.koin.dsl.KoinAppDeclaration
5 | import me.inassar.platform.platformNetworkEngineModule
6 |
7 | /**
8 | * Created by Ahmed Nassar on 5/27/23.
9 | */
10 | fun initKoinForAndroid(enableNetworkLogs: Boolean, appDeclaration: KoinAppDeclaration = {}) =
11 | startKoin {
12 | appDeclaration()
13 | modules(
14 | appModule(enableNetworkLogs = enableNetworkLogs),
15 | platformNetworkEngineModule,
16 | remoteModule,
17 | cacheModule,
18 | repositoryModule,
19 | viewModelModule
20 | )
21 | }
22 |
23 | // called by iOS, desktop...etc
24 | fun initKoin(enableNetworkLogs: Boolean) =
25 | initKoinForAndroid(enableNetworkLogs = enableNetworkLogs) {}
--------------------------------------------------------------------------------
/desktopApp/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2 |
3 | @Suppress("DSL_SCOPE_VIOLATION")
4 | plugins {
5 | alias(libs.plugins.multiplatform)
6 | alias(libs.plugins.jetbrains.compose)
7 | }
8 |
9 | kotlin {
10 | jvm()
11 | sourceSets {
12 | val jvmMain by getting {
13 | dependencies {
14 | implementation(compose.desktop.currentOs)
15 | implementation(rootProject.projects.shared)
16 | }
17 | }
18 | }
19 | }
20 |
21 | compose.desktop {
22 | application {
23 | mainClass = "me.inassar.MainKt"
24 |
25 | nativeDistributions {
26 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
27 | packageName = "KotlinMultiplatformComposeDesktopApplication"
28 | packageVersion = "1.0.0"
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: 'Your short but descriptive bug title'
5 | labels: '[bug]'
6 | assignees: 'ranger163'
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Version [e.g. 22]
29 |
30 | **Mobile(IOS/Android) (please complete the following information):**
31 | - Device: [e.g. iPhone6]
32 | - OS: [e.g. iOS8.1]
33 | - Version [e.g. 22]
34 |
35 | **Additional context**
36 | Add any other context about the problem here.
37 |
--------------------------------------------------------------------------------
/androidApp/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.run/desktopApp.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/data/remote/source/FeatureRemoteApiImpl.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.data.remote.source
2 |
3 | import io.ktor.client.HttpClient
4 | import io.ktor.client.call.body
5 | import io.ktor.client.request.get
6 | import me.inassar.common.network.ResponseResource
7 | import me.inassar.common.network.performCall
8 | import me.inassar.features.feature.data.remote.FeatureRemoteApi
9 | import me.inassar.features.feature.data.remote.dto.getProducts.response.GetProductsResponseDto
10 | import org.koin.core.component.KoinComponent
11 |
12 | class FeatureRemoteApiImpl(private val client: HttpClient) : FeatureRemoteApi, KoinComponent {
13 | override suspend fun getProductsList(): ResponseResource = runCatching {
14 | val response =
15 | client.get { performCall(endpoint = "products") }.body()
16 | ResponseResource.success(response)
17 | }.getOrElse { error ->
18 | ResponseResource.error(error)
19 | }
20 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/locale/GeneralStrings.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.locale
2 |
3 | /**
4 | * Created by Ahmed Nassar on 8/2/23.
5 | * This class is used to get general translated string resources when required.
6 | * @sample GeneralStrings.Network.NETWORK_UNKNOWN_ERROR.localize()
7 | */
8 | enum class GeneralStrings {
9 | ;
10 |
11 | enum class Network(
12 | override val supportedLanguages: SupportedLanguages
13 | ) : Localize {
14 | NETWORK_UNKNOWN_ERROR(
15 | SupportedLanguages(
16 | en = "Unknown error has occurred.",
17 | ar = "حدث خطأ غير مُتوقع"
18 | )
19 | )
20 | }
21 |
22 | enum class UI(
23 | override val supportedLanguages: SupportedLanguages
24 | ) : Localize {
25 | IMAGE_CONTENT_DESC_WITH_ERROR(
26 | SupportedLanguages(
27 | en = "Default image placeholder with error",
28 | ar = "صوره إفتراضية تظهر خطأ"
29 | )
30 | )
31 | }
32 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/network/RemoteError.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.network
2 |
3 | import io.ktor.client.plugins.ClientRequestException
4 | import io.ktor.client.plugins.RedirectResponseException
5 | import io.ktor.client.plugins.ServerResponseException
6 | import me.inassar.common.locale.GeneralStrings
7 |
8 | /**
9 | * Created by Ahmed Nassar on 5/27/23.
10 | */
11 | fun Throwable.toUserErrorMessage() = runCatching {
12 | when (this) {
13 | is RedirectResponseException -> {
14 | // 3xx - responses
15 | Throwable(message)
16 | }
17 |
18 | is ClientRequestException -> {
19 | // 4xx - responses
20 | Throwable(message)
21 | }
22 |
23 | is ServerResponseException -> {
24 | // 5xx - responses
25 | Throwable(message)
26 | }
27 |
28 | else -> {
29 | Throwable(GeneralStrings.Network.NETWORK_UNKNOWN_ERROR.localize())
30 | }
31 | }
32 | }.getOrDefault(Throwable(GeneralStrings.Network.NETWORK_UNKNOWN_ERROR.localize()))
--------------------------------------------------------------------------------
/shared/src/iosMain/kotlin/me/inassar/utils/DeviceOrientationUtils.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.utils
2 |
3 | import platform.UIKit.UIDevice
4 | import platform.UIKit.UIDeviceOrientation
5 |
6 |
7 | fun getDeviceOrientation(): DeviceOrientation {
8 | return when (UIDevice.currentDevice.orientation) {
9 | UIDeviceOrientation.UIDeviceOrientationLandscapeRight -> DeviceOrientation(
10 | portrait = false,
11 | landscape = true
12 | )
13 |
14 | UIDeviceOrientation.UIDeviceOrientationPortraitUpsideDown -> DeviceOrientation(
15 | portrait = true,
16 | landscape = false
17 | )
18 |
19 | UIDeviceOrientation.UIDeviceOrientationPortrait -> DeviceOrientation(
20 | portrait = true,
21 | landscape = false
22 | )
23 |
24 | UIDeviceOrientation.UIDeviceOrientationLandscapeLeft -> DeviceOrientation(
25 | portrait = false,
26 | landscape = true
27 | )
28 |
29 | else -> DeviceOrientation(portrait = true, landscape = false)
30 | }
31 | }
32 |
33 | data class DeviceOrientation(val portrait: Boolean, val landscape: Boolean)
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/data/repository/FeatureRepositoryImpl.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.data.repository
2 |
3 | import kotlinx.coroutines.flow.Flow
4 | import kotlinx.coroutines.flow.flow
5 | import me.inassar.common.network.ResponseResource
6 | import me.inassar.common.network.toUserErrorMessage
7 | import me.inassar.features.feature.data.remote.FeatureRemoteApi
8 | import me.inassar.features.feature.domain.mapper.toDomainProducts
9 | import me.inassar.features.feature.domain.model.DomainProducts
10 | import me.inassar.features.feature.domain.repository.FeatureRepository
11 | import org.koin.core.component.KoinComponent
12 | import org.koin.core.component.inject
13 |
14 | class FeatureRepositoryImpl : FeatureRepository, KoinComponent {
15 | private val remote: FeatureRemoteApi by inject()
16 |
17 | override suspend fun getProducts(): Flow> = flow {
18 | when (val result = remote.getProductsList()) {
19 | is ResponseResource.Error -> emit(ResponseResource.error(result.error.toUserErrorMessage()))
20 | is ResponseResource.Success -> emit(ResponseResource.success(result.data.toDomainProducts()))
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/shared/src/androidMain/kotlin/me/inassar/platform/Platform.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.platform
2 |
3 | import android.app.Activity
4 | import androidx.compose.runtime.Composable
5 | import androidx.compose.runtime.SideEffect
6 | import androidx.compose.ui.graphics.Color
7 | import androidx.compose.ui.graphics.toArgb
8 | import androidx.compose.ui.platform.LocalView
9 | import androidx.core.view.WindowCompat
10 | import io.ktor.client.engine.android.Android
11 | import me.inassar.common.config.Platform
12 | import org.koin.core.module.Module
13 | import org.koin.dsl.module
14 | import java.util.Locale
15 |
16 | /**
17 | * Created by Ahmed Nassar on 7/31/23.
18 | */
19 |
20 | actual val currentDeviceLanguage: String
21 | get() = Locale.getDefault().language
22 |
23 | actual val currentPlatform: Platform
24 | get() = Platform.ANDROID
25 |
26 | actual val platformNetworkEngineModule: Module
27 | get() = module { single { Android.create() } }
28 |
29 | @Composable
30 | actual fun ChangeStatusBarColors(statusBarColor: Color) {
31 | val view = LocalView.current
32 | SideEffect {
33 | val window = (view.context as Activity).window
34 | window.statusBarColor = statusBarColor.toArgb()
35 | WindowCompat.getInsetsController(window, view)
36 | }
37 | }
--------------------------------------------------------------------------------
/androidApp/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @Suppress("DSL_SCOPE_VIOLATION")
2 | plugins {
3 | alias(libs.plugins.multiplatform)
4 | alias(libs.plugins.android.application)
5 | alias(libs.plugins.jetbrains.compose)
6 | }
7 |
8 | kotlin {
9 | androidTarget()
10 | sourceSets {
11 | val androidMain by getting {
12 | dependencies {
13 | implementation(rootProject.projects.shared)
14 | }
15 | }
16 | }
17 | }
18 |
19 | android {
20 | compileSdk = libs.versions.compileSdk.get().toInt()
21 | namespace = libs.versions.applicationId.get()
22 |
23 | sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
24 |
25 | defaultConfig {
26 | applicationId = libs.versions.applicationId.get()
27 | minSdk = libs.versions.minSdk.get().toInt()
28 | targetSdk = libs.versions.targetSdk.get().toInt()
29 | versionCode = libs.versions.versionCode.get().toInt()
30 | versionName = libs.versions.versionName.get()
31 | }
32 | compileOptions {
33 | sourceCompatibility = JavaVersion.VERSION_17
34 | targetCompatibility = JavaVersion.VERSION_17
35 | }
36 | buildFeatures {
37 | compose = true
38 | }
39 | composeOptions {
40 | kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
41 | }
42 | kotlin {
43 | jvmToolchain(17)
44 | }
45 | }
46 |
47 | dependencies {
48 | implementation(libs.koinCore)
49 | implementation(libs.koinAndroid)
50 | implementation(libs.koinCompose)
51 | }
52 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/data/remote/dto/getProducts/response/GetProductsResponseDto.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.data.remote.dto.getProducts.response
2 |
3 |
4 | import kotlinx.serialization.SerialName
5 | import kotlinx.serialization.Serializable
6 |
7 | @Serializable
8 | data class GetProductsResponseDto(
9 | @SerialName("limit")
10 | val limit: Int? = null, // 30
11 | @SerialName("products")
12 | val products: List? = null,
13 | @SerialName("skip")
14 | val skip: Int? = null, // 0
15 | @SerialName("total")
16 | val total: Int? = null // 100
17 | )
18 |
19 | @Serializable
20 | data class ProductDto(
21 | @SerialName("brand")
22 | val brand: String? = null, // Apple
23 | @SerialName("category")
24 | val category: String? = null, // smartphones
25 | @SerialName("description")
26 | val description: String? = null, // An apple mobile which is nothing like apple
27 | @SerialName("discountPercentage")
28 | val discountPercentage: Double? = null, // 12.96
29 | @SerialName("id")
30 | val id: Int? = null, // 1
31 | @SerialName("images")
32 | val images: List? = null,
33 | @SerialName("price")
34 | val price: Int? = null, // 549
35 | @SerialName("rating")
36 | val rating: Double? = null, // 4.69
37 | @SerialName("stock")
38 | val stock: Int? = null, // 94
39 | @SerialName("thumbnail")
40 | val thumbnail: String? = null, // https://i.dummyjson.com/data/products/1/thumbnail.jpg
41 | @SerialName("title")
42 | val title: String? = null // iPhone 9
43 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/domain/mapper/DomainProductsMapper.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.domain.mapper
2 |
3 | import me.inassar.common.config.DEFAULT_DOUBLE
4 | import me.inassar.common.config.DEFAULT_INT
5 | import me.inassar.common.config.DEFAULT_STRING
6 | import me.inassar.features.feature.data.remote.dto.getProducts.response.GetProductsResponseDto
7 | import me.inassar.features.feature.domain.model.DomainProduct
8 | import me.inassar.features.feature.domain.model.DomainProducts
9 |
10 | /**
11 | * Created by Ahmed Nassar on 5/27/23.
12 | */
13 | fun GetProductsResponseDto.toDomainProducts() = DomainProducts(
14 | limit = this.limit ?: DEFAULT_INT,
15 | products = this.products?.map { productDto ->
16 | DomainProduct(
17 | brand = productDto?.brand ?: DEFAULT_STRING,
18 | category = productDto?.category ?: DEFAULT_STRING,
19 | description = productDto?.description ?: DEFAULT_STRING,
20 | discountPercentage = productDto?.discountPercentage ?: DEFAULT_DOUBLE,
21 | id = productDto?.id ?: DEFAULT_INT,
22 | images = productDto?.images?.map { it ?: DEFAULT_STRING }.orEmpty(),
23 | price = productDto?.price ?: DEFAULT_INT,
24 | rating = productDto?.rating ?: DEFAULT_DOUBLE,
25 | stock = productDto?.stock ?: DEFAULT_INT,
26 | thumbnail = productDto?.thumbnail ?: DEFAULT_STRING,
27 | title = productDto?.title ?: DEFAULT_STRING,
28 | )
29 | }.orEmpty(),
30 | skip = this.skip ?: DEFAULT_INT,
31 | total = this.total ?: DEFAULT_INT,
32 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/locale/Localize.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.locale
2 |
3 | import me.inassar.common.config.Locales
4 | import me.inassar.platform.currentDeviceLanguage
5 |
6 | /**
7 | * Created by Ahmed Nassar on 8/2/23.
8 | * Used to get translated string resources when required.
9 | * It currently has AR and EN languages but you ca always add more languages as you need. But don't
10 | * forget to update Local.kt enum class with your needed languages.
11 | * Also you can pass args to append it to your localized string.
12 | */
13 | interface Localize {
14 | val supportedLanguages: SupportedLanguages
15 |
16 | /**
17 | * This is where the translation is happening depending on passed localization.
18 | * @param args: is used to pass arguments to be added to the localized string resource.
19 | */
20 | fun localize(vararg args: Any): String {
21 | val builder = StringBuilder().also { stringBuilder ->
22 | args.forEach { arg ->
23 | stringBuilder.append("$arg ")
24 | }
25 | }
26 |
27 | // TODO: later get language from app's setting instead of device language.
28 | return when (currentDeviceLanguage) {
29 | Locales.ARABIC.value -> if (builder.isEmpty()) supportedLanguages.ar
30 | else "${supportedLanguages.ar} $builder"
31 |
32 | Locales.ENGLISH.value -> if (builder.isEmpty()) supportedLanguages.en
33 | else "${supportedLanguages.en} $builder"
34 |
35 | else -> if (builder.isEmpty()) supportedLanguages.en
36 | else "${supportedLanguages.en} $builder"
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/composable/RatingBar.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.composable
2 |
3 | import androidx.compose.foundation.layout.Row
4 | import androidx.compose.material.icons.Icons
5 | import androidx.compose.material.icons.outlined.Star
6 | import androidx.compose.material.icons.outlined.StarHalf
7 | import androidx.compose.material.icons.outlined.StarOutline
8 | import androidx.compose.material3.Icon
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.graphics.Color
12 | import kotlin.math.ceil
13 | import kotlin.math.floor
14 |
15 | /**
16 | * Created by Ahmed Nassar on 8/6/23.
17 | */
18 |
19 | @Composable
20 | fun RatingBar(
21 | modifier: Modifier = Modifier,
22 | rating: Double = 0.0,
23 | stars: Int = 5,
24 | starsColor: Color = Color(0xFFFFE234),
25 | ) {
26 | val filledStars = floor(rating).toInt()
27 | val unfilledStars = (stars - ceil(rating)).toInt()
28 | val halfStar = !(rating.rem(1).equals(0.0))
29 |
30 | Row(modifier = modifier) {
31 | repeat(filledStars) {
32 | Icon(
33 | imageVector = Icons.Outlined.Star,
34 | contentDescription = null,
35 | tint = starsColor
36 | )
37 | }
38 | if (halfStar) {
39 | Icon(
40 | imageVector = Icons.Outlined.StarHalf,
41 | contentDescription = null,
42 | tint = starsColor
43 | )
44 | }
45 | repeat(unfilledStars) {
46 | Icon(
47 | imageVector = Icons.Outlined.StarOutline,
48 | contentDescription = null,
49 | tint = starsColor
50 | )
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/iosApp/iosApp/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | CADisableMinimumFrameDurationOnPhone
24 |
25 | UIApplicationSceneManifest
26 |
27 | UIApplicationSupportsMultipleScenes
28 |
29 |
30 | UILaunchScreen
31 |
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/manipulator/FeatureViewModel.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.manipulator
2 |
3 | import cafe.adriel.voyager.core.model.StateScreenModel
4 | import cafe.adriel.voyager.core.model.screenModelScope
5 | import kotlinx.coroutines.Dispatchers
6 | import kotlinx.coroutines.coroutineScope
7 | import kotlinx.coroutines.flow.update
8 | import kotlinx.coroutines.launch
9 | import me.inassar.common.network.ResponseResource
10 | import me.inassar.features.feature.domain.repository.FeatureRepository
11 | import me.inassar.features.feature.presentation.mapper.toUiProducts
12 | import org.koin.core.component.KoinComponent
13 | import org.koin.core.component.inject
14 |
15 | /**
16 | * Created by Ahmed Nassar on 5/27/23.
17 | */
18 | class FeatureModel : StateScreenModel(initialState = FeatureState.Loading),
19 | KoinComponent {
20 | private val repository: FeatureRepository by inject()
21 |
22 | fun onEvent(events: FeatureEvents) {
23 | when (events) {
24 | FeatureEvents.GetProducts -> getFeatures()
25 | }
26 | }
27 |
28 | private fun getFeatures() {
29 | // We should specify dispatchers to be on default always, as this is the only dispatcher that supports desktop
30 | screenModelScope.launch(Dispatchers.Default) {
31 | repository.getProducts().collect { result ->
32 | when (result) {
33 | is ResponseResource.Error ->
34 | mutableState.update {
35 | FeatureState.Error(result.error.message.orEmpty())
36 | }
37 |
38 | is ResponseResource.Success -> mutableState.update {
39 | FeatureState.Success(result.data.toUiProducts())
40 | }
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/App.kt:
--------------------------------------------------------------------------------
1 | package me.inassar
2 |
3 | import androidx.compose.foundation.layout.padding
4 | import androidx.compose.material3.MaterialTheme
5 | import androidx.compose.material3.Scaffold
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.ui.Modifier
8 | import androidx.compose.ui.graphics.Color
9 | import cafe.adriel.voyager.navigator.Navigator
10 | import cafe.adriel.voyager.transitions.FadeTransition
11 | import cafe.adriel.voyager.transitions.ScaleTransition
12 | import cafe.adriel.voyager.transitions.SlideTransition
13 | import me.inassar.common.composable.TopBar
14 | import me.inassar.common.config.Platform
15 | import me.inassar.features.feature.presentation.ui.products.ProductsScreen
16 | import me.inassar.platform.currentPlatform
17 |
18 | @Composable
19 | fun App() {
20 | MaterialTheme {
21 | Navigator(
22 | screen = ProductsScreen
23 | ) { navigator ->
24 | Scaffold(
25 | topBar = {
26 | TopBar(
27 | title = navigator.lastItem.key,
28 | canPop = navigator.canPop,
29 | appBarColor = Color.Red,
30 | statusBarColor = Color.Red,
31 | onNavigationBackClick = { navigator.pop() })
32 | }
33 | ) { paddingValues ->
34 | when (currentPlatform) {
35 | Platform.IOS -> SlideTransition(
36 | navigator = navigator,
37 | modifier = Modifier.padding(paddingValues)
38 | )
39 |
40 | Platform.ANDROID -> FadeTransition(
41 | navigator = navigator,
42 | modifier = Modifier.padding(paddingValues)
43 | )
44 |
45 | Platform.DESKTOP -> ScaleTransition(
46 | navigator = navigator,
47 | modifier = Modifier.padding(paddingValues)
48 | )
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/composable/ImageLoader.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.composable
2 |
3 | import androidx.compose.animation.core.tween
4 | import androidx.compose.foundation.Image
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.fillMaxWidth
7 | import androidx.compose.foundation.layout.height
8 | import androidx.compose.foundation.layout.size
9 | import androidx.compose.material.icons.Icons
10 | import androidx.compose.material.icons.filled.BrokenImage
11 | import androidx.compose.material3.LinearProgressIndicator
12 | import androidx.compose.runtime.Composable
13 | import androidx.compose.ui.Alignment
14 | import androidx.compose.ui.Modifier
15 | import androidx.compose.ui.layout.ContentScale
16 | import androidx.compose.ui.unit.dp
17 | import io.kamel.image.KamelImage
18 | import io.kamel.image.asyncPainterResource
19 | import me.inassar.common.locale.GeneralStrings
20 |
21 | /**
22 | * Created by Ahmed Nassar on 7/28/23.
23 | */
24 |
25 | @Composable
26 | fun LoadImage(
27 | modifier: Modifier = Modifier,
28 | contentScale: ContentScale = ContentScale.Fit,
29 | imagePath: String,
30 | contentDescription: String?
31 | ) {
32 | KamelImage(
33 | modifier = modifier,
34 | contentScale = contentScale,
35 | resource = asyncPainterResource(imagePath),
36 | contentDescription = contentDescription,
37 | animationSpec = tween(),
38 | onLoading = { loadingProgress ->
39 | Box(
40 | modifier = modifier,
41 | contentAlignment = Alignment.BottomCenter
42 | ) {
43 | LinearProgressIndicator(
44 | modifier = Modifier.fillMaxWidth().height(1.dp),
45 | progress = loadingProgress
46 | )
47 | }
48 | },
49 | onFailure = { exception ->
50 | Box(
51 | modifier = modifier,
52 | contentAlignment = Alignment.Center
53 | ) {
54 | Image(
55 | modifier = Modifier.size(48.dp),
56 | imageVector = Icons.Default.BrokenImage,
57 | contentDescription =
58 | GeneralStrings.UI.IMAGE_CONTENT_DESC_WITH_ERROR.localize(exception),
59 | alpha = 0.3f
60 | )
61 | }
62 | }
63 | )
64 | }
--------------------------------------------------------------------------------
/shared/src/iosMain/kotlin/me/inassar/platform/Platform.kt:
--------------------------------------------------------------------------------
1 | @file:OptIn(ExperimentalForeignApi::class)
2 |
3 | package me.inassar.platform
4 |
5 | import androidx.compose.runtime.Composable
6 | import androidx.compose.runtime.SideEffect
7 | import androidx.compose.runtime.mutableStateOf
8 | import androidx.compose.runtime.remember
9 | import androidx.compose.ui.graphics.Color
10 | import com.mohamedrejeb.calf.ui.utils.toUIColor
11 | import io.ktor.client.engine.darwin.Darwin
12 | import kotlinx.cinterop.ExperimentalForeignApi
13 | import kotlinx.cinterop.copy
14 | import me.inassar.common.config.Platform
15 | import me.inassar.utils.getDeviceOrientation
16 | import org.koin.core.module.Module
17 | import org.koin.dsl.module
18 | import platform.CoreGraphics.CGRectMake
19 | import platform.Foundation.NSLocale
20 | import platform.Foundation.preferredLanguages
21 | import platform.UIKit.UIApplication
22 | import platform.UIKit.UIView
23 | import platform.UIKit.UIWindow
24 |
25 | /**
26 | * Created by Ahmed Nassar on 7/31/23.
27 | */
28 |
29 | actual val currentDeviceLanguage: String
30 | get() = NSLocale.preferredLanguages.first().toString().substring(0..1)
31 |
32 | actual val currentPlatform: Platform
33 | get() = Platform.IOS
34 |
35 | actual val platformNetworkEngineModule: Module
36 | get() = module { single { Darwin.create() } }
37 |
38 | /**
39 | * This solution is a hack, as in devices that has dynamic island "14 pro/pro max, 15 series"
40 | * it has this weired horizontal line which doesn't belong to status bar or navigation bar.
41 | * check the forums here: https://developer.apple.com/forums/thread/715417
42 | * Also check this blog to know more about this issue explaining: https://useyourloaf.com/blog/iphone-14-screen-sizes/
43 | */
44 | @OptIn(ExperimentalForeignApi::class)
45 | @Composable
46 | actual fun ChangeStatusBarColors(statusBarColor: Color) {
47 | val safeFrameSize = remember { mutableStateOf(0.0) }
48 |
49 | val window =
50 | (UIApplication.sharedApplication.windows.first() as UIWindow)
51 | // Getting safe area size
52 | window.safeAreaLayoutGuide.layoutFrame.copy {
53 | // Getting safe area size in case of landscape and portrait
54 | if (getDeviceOrientation().portrait) {
55 | safeFrameSize.value = origin.y
56 | } else {
57 | safeFrameSize.value = origin.x
58 | }
59 | }
60 |
61 | val statusBar = UIView(
62 | frame = CGRectMake(
63 | x = 0.0,
64 | y = 0.0,
65 | width = Double.MAX_VALUE,
66 | height = safeFrameSize.value
67 | )
68 | )
69 |
70 | statusBar.backgroundColor = statusBarColor.toUIColor()
71 | SideEffect {
72 | UIApplication.sharedApplication.keyWindow?.addSubview(statusBar)
73 | }
74 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if %ERRORLEVEL% equ 0 goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if %ERRORLEVEL% equ 0 goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/network/KtorClient.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.network
2 |
3 | import io.github.aakira.napier.Napier
4 | import io.ktor.client.HttpClient
5 | import io.ktor.client.engine.HttpClientEngine
6 | import io.ktor.client.plugins.DefaultRequest
7 | import io.ktor.client.plugins.HttpTimeout
8 | import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
9 | import io.ktor.client.plugins.logging.LogLevel
10 | import io.ktor.client.plugins.logging.Logger
11 | import io.ktor.client.plugins.logging.Logging
12 | import io.ktor.client.plugins.observer.ResponseObserver
13 | import io.ktor.client.request.HttpRequestBuilder
14 | import io.ktor.client.request.header
15 | import io.ktor.client.request.headers
16 | import io.ktor.http.ContentType
17 | import io.ktor.http.HttpHeaders
18 | import io.ktor.http.encodedPath
19 | import io.ktor.http.takeFrom
20 | import io.ktor.serialization.kotlinx.json.json
21 | import kotlinx.serialization.json.Json
22 | import me.inassar.TemplateConfig
23 |
24 | /**
25 | * Created by Ahmed Nassar on 5/27/23.
26 | */
27 |
28 | private const val TIMEOUT = 60_000L
29 |
30 | fun ktorHttpClient(
31 | httpClientEngine: HttpClientEngine,
32 | enableNetworkLogs: Boolean
33 | ) = HttpClient(httpClientEngine) {
34 | expectSuccess = true
35 |
36 | if (enableNetworkLogs) {
37 | install(Logging) {
38 | level = LogLevel.ALL
39 | logger = object : Logger {
40 | override fun log(message: String) {
41 | Napier.log(
42 | priority = io.github.aakira.napier.LogLevel.INFO,
43 | tag = "Network Logger",
44 | message = message
45 | )
46 | }
47 | }
48 | }
49 | }
50 |
51 | install(HttpTimeout) {
52 | connectTimeoutMillis = TIMEOUT
53 | requestTimeoutMillis = TIMEOUT
54 | socketTimeoutMillis = TIMEOUT
55 | }
56 |
57 | install(ContentNegotiation) {
58 | json(Json {
59 | isLenient = true
60 | prettyPrint = true
61 | ignoreUnknownKeys = true
62 | })
63 | }
64 |
65 | install(ResponseObserver) {
66 | onResponse { response ->
67 | if (enableNetworkLogs)
68 | Napier.log(
69 | priority = io.github.aakira.napier.LogLevel.INFO,
70 | tag = "Http status",
71 | message = response.status.value.toString()
72 | )
73 | }
74 | }
75 |
76 | install(DefaultRequest) {
77 | header(HttpHeaders.ContentType, ContentType.Application.Any)
78 | }
79 | }
80 |
81 | /**
82 | * @param baseUrl: passing a new baseUrl will override the default one, so you can
83 | * use multiple baseUrls using same client.
84 | * @param endpoint: pass your endpoint here to be able to perform your request.
85 | */
86 | fun HttpRequestBuilder.performCall(endpoint: String, baseUrl: String = TemplateConfig.BASE_URL) = url {
87 | takeFrom(baseUrl)
88 | encodedPath = endpoint
89 | headers {
90 | append(
91 | HttpHeaders.Authorization, "tokenFromSession"
92 | )
93 | }
94 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/ui/products/FeatureScreen.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.ui.products
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.PaddingValues
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.lazy.grid.GridCells
8 | import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
9 | import androidx.compose.foundation.lazy.grid.items
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.runtime.collectAsState
12 | import androidx.compose.runtime.getValue
13 | import androidx.compose.ui.Alignment
14 | import androidx.compose.ui.Modifier
15 | import androidx.compose.ui.unit.dp
16 | import cafe.adriel.voyager.core.lifecycle.LifecycleEffect
17 | import cafe.adriel.voyager.core.model.rememberScreenModel
18 | import cafe.adriel.voyager.core.screen.Screen
19 | import cafe.adriel.voyager.core.screen.ScreenKey
20 | import cafe.adriel.voyager.navigator.LocalNavigator
21 | import cafe.adriel.voyager.navigator.currentOrThrow
22 | import me.inassar.common.composable.RenderError
23 | import me.inassar.common.composable.RenderLoading
24 | import me.inassar.features.feature.presentation.data.FeatureStrings
25 | import me.inassar.features.feature.presentation.data.UiProducts
26 | import me.inassar.features.feature.presentation.manipulator.FeatureEvents
27 | import me.inassar.features.feature.presentation.manipulator.FeatureModel
28 | import me.inassar.features.feature.presentation.manipulator.FeatureState
29 | import me.inassar.features.feature.presentation.ui.details.ProductDetails
30 | import org.koin.core.component.KoinComponent
31 |
32 | /**
33 | * Created by Ahmed Nassar on 5/27/23.
34 | */
35 | object ProductsScreen : Screen, KoinComponent {
36 |
37 | override val key: ScreenKey = FeatureStrings.PRODUCT_LIST_SCREEN_TITLE.localize()
38 |
39 | @Composable
40 | override fun Content() {
41 |
42 | val featureModel = rememberScreenModel { FeatureModel() }
43 | val productsState by featureModel.state.collectAsState()
44 |
45 | LifecycleEffect(onStarted = { featureModel.onEvent(FeatureEvents.GetProducts) })
46 |
47 | ProductsList(productsState)
48 | }
49 |
50 | @Composable
51 | fun ProductsList(state: FeatureState) {
52 | Column(
53 | modifier = Modifier.fillMaxSize(),
54 | verticalArrangement = Arrangement.Center,
55 | horizontalAlignment = Alignment.CenterHorizontally
56 | ) {
57 | when (state) {
58 | is FeatureState.Loading -> RenderLoading()
59 | is FeatureState.Error -> RenderError(message = state.errorMessage)
60 | is FeatureState.Success -> RenderData(state.uiProducts)
61 | }
62 | }
63 | }
64 |
65 | @Composable
66 | fun RenderData(data: UiProducts) {
67 | val navigator = LocalNavigator.currentOrThrow
68 |
69 | LazyVerticalGrid(
70 | columns = GridCells.Adaptive(200.dp),
71 | verticalArrangement = Arrangement.spacedBy(16.dp),
72 | horizontalArrangement = Arrangement.spacedBy(16.dp),
73 | contentPadding = PaddingValues(16.dp),
74 | modifier = Modifier.fillMaxSize(),
75 | ) {
76 | items(items = data.products, key = { it.hashCode() }) { product ->
77 | ProductItem(product = product, onItemClicked = {
78 | navigator.push(ProductDetails(product))
79 | })
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/common/composable/TopAppBar.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.common.composable
2 |
3 | import androidx.compose.foundation.layout.RowScope
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.foundation.layout.size
7 | import androidx.compose.material3.Surface
8 | import androidx.compose.material.icons.Icons
9 | import androidx.compose.material.icons.filled.ArrowBack
10 | import androidx.compose.material.icons.filled.ArrowBackIosNew
11 | import androidx.compose.material3.ExperimentalMaterial3Api
12 | import androidx.compose.material3.Icon
13 | import androidx.compose.material3.IconButton
14 | import androidx.compose.material3.Text
15 | import androidx.compose.material3.TopAppBar
16 | import androidx.compose.material3.TopAppBarDefaults
17 | import androidx.compose.runtime.Composable
18 | import androidx.compose.ui.Modifier
19 | import androidx.compose.ui.graphics.Color
20 | import androidx.compose.ui.text.font.FontWeight
21 | import androidx.compose.ui.text.style.TextAlign
22 | import androidx.compose.ui.text.style.TextOverflow
23 | import androidx.compose.ui.unit.dp
24 | import androidx.compose.ui.unit.sp
25 | import me.inassar.common.config.Platform
26 | import me.inassar.platform.ChangeStatusBarColors
27 | import me.inassar.platform.currentPlatform
28 |
29 | /**
30 | * Created by Ahmed Nassar on 8/6/23.
31 | */
32 |
33 | @OptIn(ExperimentalMaterial3Api::class)
34 | @Composable
35 | fun TopBar(
36 | title: String,
37 | appBarColor: Color = Color.White,
38 | statusBarColor: Color = Color.White,
39 | contentColor: Color = Color.White,
40 | canPop: Boolean = false,
41 | onNavigationBackClick: () -> Unit = {},
42 | appBarActions: @Composable RowScope.() -> Unit = {}
43 | ) {
44 | val isAndroid = when (currentPlatform) {
45 | Platform.IOS -> false
46 | Platform.ANDROID -> true
47 | Platform.DESKTOP -> false
48 | }
49 |
50 | ChangeStatusBarColors(statusBarColor = statusBarColor)
51 |
52 | Surface(shadowElevation = 3.dp) {
53 |
54 | TopAppBar(
55 | title = {
56 | Text(
57 | modifier = Modifier.fillMaxWidth(),
58 | text = title,
59 | fontSize = 20.sp,
60 | maxLines = 1,
61 | overflow = TextOverflow.Ellipsis,
62 | fontWeight = FontWeight.Bold,
63 | textAlign = if (isAndroid) TextAlign.Start else TextAlign.Center
64 | )
65 | },
66 | colors = TopAppBarDefaults.topAppBarColors(
67 | containerColor = appBarColor,
68 | actionIconContentColor = contentColor,
69 | navigationIconContentColor = contentColor,
70 | titleContentColor = contentColor
71 | ),
72 | navigationIcon = {
73 | if (canPop) {
74 | IconButton(
75 | modifier = Modifier
76 | .padding(start = 5.dp)
77 | .size(width = 30.dp, height = 40.dp),
78 | onClick = { onNavigationBackClick() }
79 | ) {
80 | Icon(
81 | imageVector = if (isAndroid)
82 | Icons.Filled.ArrowBack
83 | else
84 | Icons.Filled.ArrowBackIosNew,
85 | contentDescription = null
86 | )
87 | }
88 | }
89 | },
90 | actions = appBarActions
91 | )
92 | }
93 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/ui/details/ProductDetails.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.ui.details
2 |
3 | import androidx.compose.foundation.background
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.Column
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.foundation.layout.fillMaxHeight
9 | import androidx.compose.foundation.layout.fillMaxSize
10 | import androidx.compose.foundation.layout.fillMaxWidth
11 | import androidx.compose.foundation.layout.padding
12 | import androidx.compose.foundation.shape.CornerSize
13 | import androidx.compose.material3.Divider
14 | import androidx.compose.material3.MaterialTheme
15 | import androidx.compose.material3.Text
16 | import androidx.compose.runtime.Composable
17 | import androidx.compose.ui.Alignment
18 | import androidx.compose.ui.Modifier
19 | import androidx.compose.ui.graphics.Color
20 | import androidx.compose.ui.layout.ContentScale
21 | import androidx.compose.ui.text.style.TextOverflow
22 | import androidx.compose.ui.unit.dp
23 | import cafe.adriel.voyager.core.screen.Screen
24 | import cafe.adriel.voyager.core.screen.ScreenKey
25 | import me.inassar.common.composable.LoadImage
26 | import me.inassar.common.composable.RatingBar
27 | import me.inassar.features.feature.presentation.data.UiProduct
28 |
29 | /**
30 | * Created by Ahmed Nassar on 8/5/23.
31 | */
32 | class ProductDetails(private val product: UiProduct) : Screen {
33 |
34 | override val key: ScreenKey = product.title
35 |
36 | @Composable
37 | override fun Content() {
38 | Column(
39 | modifier = Modifier
40 | .fillMaxWidth()
41 | .background(MaterialTheme.colorScheme.surface)
42 | ) {
43 | Box(
44 | modifier = Modifier
45 | .fillMaxHeight(0.5f)
46 | .fillMaxWidth()
47 | ) {
48 | LoadImage(
49 | modifier = Modifier.fillMaxSize(),
50 | imagePath = product.thumbnail,
51 | contentDescription = product.title,
52 | contentScale = ContentScale.FillBounds
53 | )
54 | RatingBar(
55 | rating = product.rating,
56 | modifier = Modifier.background(
57 | color = Color.Gray.copy(alpha = 0.5f),
58 | shape = MaterialTheme.shapes.medium.copy(
59 | topEnd = CornerSize(0.dp),
60 | topStart = CornerSize(8.dp),
61 | bottomEnd = CornerSize(0.dp),
62 | bottomStart = CornerSize(0.dp)
63 | )
64 | ).align(Alignment.BottomEnd).padding(4.dp)
65 | )
66 | }
67 |
68 | Column(modifier = Modifier.fillMaxSize().padding(8.dp)) {
69 | Row(
70 | modifier = Modifier.fillMaxWidth(),
71 | horizontalArrangement = Arrangement.SpaceBetween,
72 | verticalAlignment = Alignment.CenterVertically
73 | ) {
74 | Text(
75 | modifier = Modifier.weight(0.9f),
76 | maxLines = 1,
77 | text = product.title,
78 | color = MaterialTheme.colorScheme.onSurface,
79 | style = MaterialTheme.typography.titleLarge,
80 | overflow = TextOverflow.Ellipsis
81 | )
82 |
83 | Text(
84 | maxLines = 1,
85 | text = "${product.price} $",
86 | color = MaterialTheme.colorScheme.onSurface,
87 | style = MaterialTheme.typography.bodyLarge
88 | )
89 | }
90 |
91 | Divider(
92 | Modifier.padding(vertical = 8.dp),
93 | thickness = 0.5.dp,
94 | color = Color.Gray.copy(alpha = 0.3f)
95 | )
96 |
97 | Text(
98 | modifier = Modifier.padding(vertical = 8.dp),
99 | text = product.description,
100 | color = MaterialTheme.colorScheme.onSurface,
101 | style = MaterialTheme.typography.bodyLarge
102 | )
103 | }
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/me/inassar/features/feature/presentation/ui/products/ProductItem.kt:
--------------------------------------------------------------------------------
1 | package me.inassar.features.feature.presentation.ui.products
2 |
3 | import androidx.compose.animation.animateContentSize
4 | import androidx.compose.animation.core.Spring
5 | import androidx.compose.animation.core.spring
6 | import androidx.compose.foundation.background
7 | import androidx.compose.foundation.clickable
8 | import androidx.compose.foundation.interaction.MutableInteractionSource
9 | import androidx.compose.foundation.layout.Arrangement
10 | import androidx.compose.foundation.layout.Column
11 | import androidx.compose.foundation.layout.Row
12 | import androidx.compose.foundation.layout.Spacer
13 | import androidx.compose.foundation.layout.fillMaxSize
14 | import androidx.compose.foundation.layout.fillMaxWidth
15 | import androidx.compose.foundation.layout.height
16 | import androidx.compose.foundation.layout.padding
17 | import androidx.compose.material3.Card
18 | import androidx.compose.material3.Divider
19 | import androidx.compose.material3.MaterialTheme
20 | import androidx.compose.material3.Text
21 | import androidx.compose.runtime.Composable
22 | import androidx.compose.runtime.getValue
23 | import androidx.compose.runtime.mutableStateOf
24 | import androidx.compose.runtime.remember
25 | import androidx.compose.runtime.setValue
26 | import androidx.compose.ui.Alignment
27 | import androidx.compose.ui.Modifier
28 | import androidx.compose.ui.graphics.Color
29 | import androidx.compose.ui.layout.ContentScale
30 | import androidx.compose.ui.text.style.TextOverflow
31 | import androidx.compose.ui.unit.dp
32 | import me.inassar.common.composable.LoadImage
33 | import me.inassar.features.feature.presentation.data.UiProduct
34 |
35 | /**
36 | * Created by Ahmed Nassar on 5/27/23.
37 | */
38 |
39 | @Composable
40 | fun ProductItem(
41 | modifier: Modifier = Modifier,
42 | product: UiProduct,
43 | onItemClicked: () -> Unit
44 | ) {
45 | var isCardExpanded by remember { mutableStateOf(false) }
46 |
47 | Card(
48 | modifier = modifier.fillMaxWidth()
49 | .background(MaterialTheme.colorScheme.surface)
50 | .clickable { onItemClicked() })
51 | {
52 | Column(modifier = modifier.fillMaxWidth()) {
53 | LoadImage(
54 | modifier = modifier.height(150.dp).fillMaxWidth(),
55 | imagePath = product.thumbnail,
56 | contentDescription = product.title,
57 | contentScale = ContentScale.FillBounds
58 | )
59 |
60 | Column(modifier = modifier.fillMaxSize().padding(8.dp)) {
61 | Row(
62 | modifier = modifier.fillMaxWidth(),
63 | horizontalArrangement = Arrangement.SpaceBetween,
64 | verticalAlignment = Alignment.CenterVertically
65 | ) {
66 | Text(
67 | maxLines = 1,
68 | text = product.title,
69 | color = MaterialTheme.colorScheme.onSurface,
70 | style = MaterialTheme.typography.titleMedium,
71 | overflow = TextOverflow.Ellipsis
72 | )
73 | Text(
74 | maxLines = 1,
75 | text = "${product.price} $",
76 | color = MaterialTheme.colorScheme.onSurface,
77 | style = MaterialTheme.typography.bodyMedium
78 | )
79 | }
80 |
81 | Divider(
82 | modifier.padding(vertical = 4.dp),
83 | thickness = 0.5.dp,
84 | color = Color.Gray.copy(alpha = 0.3f)
85 | )
86 |
87 | Text(
88 | modifier = modifier.animateContentSize(
89 | animationSpec = spring(
90 | dampingRatio = Spring.DampingRatioMediumBouncy,
91 | stiffness = Spring.StiffnessMedium
92 | )
93 | ).clickable(
94 | interactionSource = remember { MutableInteractionSource() },
95 | indication = null
96 | ) {
97 | isCardExpanded = isCardExpanded.not()
98 | }.padding(vertical = 8.dp),
99 | text = product.description,
100 | color = MaterialTheme.colorScheme.onSurface,
101 | style = MaterialTheme.typography.bodyMedium,
102 | maxLines = if (isCardExpanded.not()) 2 else 10,
103 | overflow = TextOverflow.Ellipsis
104 | )
105 | }
106 | }
107 | }
108 | Spacer(modifier = modifier.height(16.dp))
109 | }
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | # Define the dependency versions
2 | [versions]
3 |
4 | #Plugins
5 | agpVersionPlugin = "8.2.0"
6 |
7 | #Global
8 | kotlinVersion = "1.9.21"
9 | applicationId = "me.inassar"
10 |
11 | #Android
12 | compileSdk = "34"
13 | targetSdk = "34"
14 | minSdk = "24"
15 | versionCode = "1"
16 | versionName = "1.0.0"
17 | composeCompiler = "1.5.4"
18 | activityCompose = "1.8.2"
19 | appcompat = "1.6.1"
20 | coreKtx = "1.12.0"
21 |
22 | #Third Party
23 | kamelImageLoaderVersion = "0.9.1"
24 | voyagerVersion = "1.0.0"
25 | calfAdaptiveUiVersion = "0.3.0"
26 | napierVersion = "2.6.1"
27 | buildKonfigVersion = "0.14.0"
28 |
29 | #Multiplatform
30 | composeMultiplatformVersion = "1.5.11"
31 | ktorVersion = "2.3.7"
32 | kotlinxCoroutines = "1.7.3"
33 | kotlinxDateTime = "0.4.0"
34 | koinVersion = "3.5.3"
35 |
36 | # Define the libraries
37 | [libraries]
38 |
39 | #Multiplatform
40 | ktorCore = { module = "io.ktor:ktor-client-core", version.ref = "ktorVersion" }
41 | contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktorVersion" }
42 | ktorLogging = { module = "io.ktor:ktor-client-logging", version.ref = "ktorVersion" }
43 | ktorSerializationJson = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktorVersion" }
44 | ktorClientCio = { module = "io.ktor:ktor-client-cio", version.ref = "ktorVersion" }
45 | ktorClientAndroid = { module = "io.ktor:ktor-client-android", version.ref = "ktorVersion" }
46 | ktorClientDarwin = { module = "io.ktor:ktor-client-darwin", version.ref = "ktorVersion" }
47 |
48 | coroutinesCore = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
49 | kotlinDateTime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDateTime" }
50 |
51 | classpath_buildKonfig = { module = "com.codingfeline.buildkonfig:buildkonfig-gradle-plugin", version.ref = "buildKonfigVersion" }
52 |
53 | #Android
54 | coreKtx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
55 | appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
56 | composeActivity = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
57 | runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "composeMultiplatformVersion" }
58 |
59 | composeUI = { module = "androidx.compose.ui:ui", version.ref = "composeCompiler" }
60 | composeUtil = { module = "androidx.compose.ui:ui-util", version.ref = "composeCompiler" }
61 | composeTooling = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "composeCompiler" }
62 | composeMaterialIcons = { module = "androidx.compose.material:material-icons-extended", version.ref = "composeCompiler" }
63 |
64 | #ThirdParty
65 | koinCore = { module = "io.insert-koin:koin-core", version.ref = "koinVersion" }
66 | koinTest = { module = "io.insert-koin:koin-test", version.ref = "koinVersion" }
67 | koinTestJUnit4 = { module = "io.insert-koin:koin-test-junit4", version.ref = "koinVersion" }
68 | koinAndroid = { module = "io.insert-koin:koin-android", version.ref = "koinVersion" }
69 | koinCompose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koinVersion" }
70 | kamelImageLoader = { module = "media.kamel:kamel-image", version.ref = "kamelImageLoaderVersion" }
71 | voyagerNavigator = { module = "cafe.adriel.voyager:voyager-navigator", version.ref = "voyagerVersion" }
72 | voyagerScreenModel = { module = "cafe.adriel.voyager:voyager-screenmodel", version.ref = "voyagerVersion" }
73 | voyagerTransitions = { module = "cafe.adriel.voyager:voyager-transitions", version.ref = "voyagerVersion" }
74 | calfAdaptiveUi = { module = "com.mohamedrejeb.calf:calf-ui", version.ref = "calfAdaptiveUiVersion" }
75 | napier = { module = "io.github.aakira:napier", version.ref = "napierVersion" }
76 |
77 | # Define bundles/groups of libraries
78 | [bundles]
79 | multiplatformLibs = [
80 | "ktorCore",
81 | "contentNegotiation",
82 | "ktorLogging",
83 | "ktorSerializationJson",
84 | "coroutinesCore",
85 | "kotlinDateTime",
86 | "koinCore",
87 | "kamelImageLoader",
88 | "voyagerNavigator",
89 | "voyagerScreenModel",
90 | "voyagerTransitions",
91 | "calfAdaptiveUi",
92 | "napier"
93 | ]
94 | androidLibs = [
95 | "composeActivity",
96 | "appcompat",
97 | "coreKtx",
98 | "composeMaterialIcons",
99 | "runtime",
100 | "composeUI",
101 | "composeUtil",
102 | "composeTooling"
103 | ]
104 |
105 | [plugins]
106 | android_application = { id = "com.android.application", version.ref = "agpVersionPlugin" }
107 | android_library = { id = "com.android.library", version.ref = "agpVersionPlugin" }
108 | jetbrains_compose = { id = "org.jetbrains.compose", version.ref = "composeMultiplatformVersion" }
109 | jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlinVersion" }
110 | multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlinVersion" }
111 | android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
112 | native_cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlinVersion" }
113 | plugin_serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlinVersion" }
114 | plugin_buildKonfig = { id = "com.codingfeline.buildkonfig", version.ref = "buildKonfigVersion" }
--------------------------------------------------------------------------------
/shared/build.gradle.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("DSL_SCOPE_VIOLATION")
2 |
3 | import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
4 |
5 |
6 | plugins {
7 | alias(libs.plugins.multiplatform)
8 | id(libs.plugins.native.cocoapods.get().pluginId)
9 | alias(libs.plugins.android.library)
10 | alias(libs.plugins.jetbrains.compose)
11 | alias(libs.plugins.plugin.serialization)
12 | id(libs.plugins.plugin.buildKonfig.get().pluginId)
13 | }
14 |
15 | kotlin {
16 | androidTarget()
17 |
18 | jvm("desktop")
19 |
20 | iosX64()
21 | iosArm64()
22 | iosSimulatorArm64()
23 |
24 | cocoapods {
25 | version = "1.0.0"
26 | summary = "Some description for the Shared Module"
27 | homepage = "Link to the Shared Module homepage"
28 | ios.deploymentTarget = "14.1"
29 | podfile = project.file("../iosApp/Podfile")
30 | framework {
31 | baseName = "shared"
32 | isStatic = true
33 | export(libs.calfAdaptiveUi)
34 | }
35 | }
36 |
37 | sourceSets {
38 | val commonMain by getting {
39 | dependencies {
40 | implementation(compose.runtime)
41 | implementation(compose.foundation)
42 | implementation(compose.material3)
43 | implementation(compose.animation)
44 | implementation(compose.materialIconsExtended)
45 |
46 | api(libs.bundles.multiplatformLibs)
47 | }
48 | }
49 | val androidMain by getting {
50 | dependencies {
51 | api(libs.bundles.androidLibs)
52 | implementation(libs.ktorClientAndroid)
53 | }
54 | }
55 | val iosX64Main by getting
56 | val iosArm64Main by getting
57 | val iosSimulatorArm64Main by getting
58 | val iosMain by creating {
59 | dependsOn(commonMain)
60 | iosX64Main.dependsOn(this)
61 | iosArm64Main.dependsOn(this)
62 | iosSimulatorArm64Main.dependsOn(this)
63 | dependencies {
64 | implementation(libs.ktorClientDarwin)
65 | }
66 | }
67 | val desktopMain by getting {
68 | dependencies {
69 | implementation(compose.desktop.common)
70 | implementation(libs.ktorClientCio)
71 | }
72 | }
73 | }
74 | }
75 |
76 | android {
77 | compileSdk = libs.versions.compileSdk.get().toInt()
78 | namespace = "me.inassar.common"
79 |
80 | sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
81 | sourceSets["main"].res.srcDirs("src/androidMain/res")
82 | sourceSets["main"].resources.srcDirs("src/commonMain/resources")
83 |
84 | defaultConfig {
85 | minSdk = libs.versions.minSdk.get().toInt()
86 | }
87 | compileOptions {
88 | sourceCompatibility = JavaVersion.VERSION_17
89 | targetCompatibility = JavaVersion.VERSION_17
90 | }
91 | buildFeatures {
92 | compose = true
93 | }
94 | composeOptions {
95 | kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
96 | }
97 | kotlin {
98 | jvmToolchain(17)
99 | }
100 | }
101 |
102 |
103 | buildkonfig {
104 | packageName = libs.versions.applicationId.get()
105 | objectName = "TemplateConfig" // You can name the config file what you want
106 | val baseUrl = "BASE_URL"
107 | val flavor = "FLAVOR"
108 |
109 | defaultConfigs {
110 | when (project.findProperty("buildFlavor")) {
111 | BuildFlavors.DEV.name -> {
112 | buildConfigField(
113 | type = STRING,
114 | name = flavor,
115 | value = BuildFlavors.DEV.name,
116 | const = true
117 | )
118 | buildConfigField(
119 | type = STRING,
120 | name = baseUrl,
121 | value = "https://dummyjson.com/",
122 | const = true
123 | )
124 | }
125 |
126 | BuildFlavors.QA.name -> {
127 | buildConfigField(
128 | type = STRING,
129 | name = flavor,
130 | value = BuildFlavors.QA.name,
131 | const = true
132 | )
133 | buildConfigField(
134 | type = STRING,
135 | name = baseUrl,
136 | value = "https://dummyjson.com/",
137 | const = true
138 | )
139 | }
140 |
141 | BuildFlavors.STG.name -> {
142 | buildConfigField(
143 | type = STRING,
144 | name = flavor,
145 | value = BuildFlavors.STG.name,
146 | const = true
147 | )
148 | buildConfigField(
149 | type = STRING,
150 | name = baseUrl,
151 | value = "https://dummyjson.com/",
152 | const = true
153 | )
154 | }
155 |
156 | BuildFlavors.PROD.name -> {
157 | buildConfigField(
158 | type = STRING,
159 | name = flavor,
160 | value = BuildFlavors.PROD.name,
161 | const = true
162 | )
163 | buildConfigField(
164 | type = STRING,
165 | name = baseUrl,
166 | value = "https://dummyjson.com/",
167 | const = true
168 | )
169 | }
170 | }
171 | }
172 | }
--------------------------------------------------------------------------------
/androidApp/src/androidMain/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Stop when "xargs" is not available.
209 | if ! command -v xargs >/dev/null 2>&1
210 | then
211 | die "xargs is not available"
212 | fi
213 |
214 | # Use "xargs" to parse quoted args.
215 | #
216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
217 | #
218 | # In Bash we could simply go:
219 | #
220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
221 | # set -- "${ARGS[@]}" "$@"
222 | #
223 | # but POSIX shell has neither arrays nor command substitution, so instead we
224 | # post-process each arg (as a line of input to sed) to backslash-escape any
225 | # character that might be a shell metacharacter, then use eval to reverse
226 | # that process (while maintaining the separation between arguments), and wrap
227 | # the whole thing up as a single "set" statement.
228 | #
229 | # This will of course break if any of these variables contains a newline or
230 | # an unmatched quote.
231 | #
232 |
233 | eval "set -- $(
234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
235 | xargs -n1 |
236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
237 | tr '\n' ' '
238 | )" '"$@"'
239 |
240 | exec "$JAVACMD" "$@"
241 |
--------------------------------------------------------------------------------
/docs/project_setup.md:
--------------------------------------------------------------------------------
1 | # Set up the environment
2 |
3 | > **Note**
4 | > The iOS part of Compose Multiplatform is in Beta. It may change incompatibly and require manual migration in the
5 | > future.
6 | > If you have any issues, please report them on [GitHub](https://github.com/JetBrains/compose-multiplatform/issues).
7 |
8 | > **Warning**
9 | > You need a Mac with macOS to write and run iOS-specific code on simulated or real devices.
10 | > This is an Apple requirement.
11 |
12 | To work with this project, you need the following:
13 |
14 | * A machine running a recent version of macOS
15 | * JDK 17
16 | * [Xcode](https://apps.apple.com/us/app/xcode/id497799835)
17 | * [Android Studio](https://developer.android.com/studio)
18 | * The [Kotlin Multiplatform Mobile plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile)
19 | * The [CocoaPods dependency manager](https://kotlinlang.org/docs/native-cocoapods.html)
20 |
21 | ### Check your environment
22 |
23 | Before you start, use the [KDoctor](https://github.com/Kotlin/kdoctor) tool to ensure that your development environment
24 | is configured correctly:
25 |
26 | 1. Install KDoctor with [Homebrew](https://brew.sh/):
27 |
28 | ```text
29 | brew install kdoctor
30 | ```
31 |
32 | 2. Run KDoctor in your terminal:
33 |
34 | ```text
35 | kdoctor
36 | ```
37 |
38 | If everything is set up correctly, you'll see valid output:
39 |
40 | ```text
41 | Environment diagnose (to see all details, use -v option):
42 | [✓] Operation System
43 | [✓] Java
44 | [✓] Android Studio
45 | [✓] Xcode
46 | [✓] Cocoapods
47 |
48 | Conclusion:
49 | ✓ Your system is ready for Kotlin Multiplatform Mobile development!
50 | ```
51 |
52 | Otherwise, KDoctor will highlight which parts of your setup still need to be configured and will suggest a way to fix
53 | them.
54 |
55 | ## Examine the project structure
56 |
57 | Open the project in Android Studio and switch the view from **Android** to **Project** to see all the files and targets
58 | belonging to the project:
59 |
60 |
61 |
62 | Your Compose Multiplatform project includes 4 modules:
63 |
64 | ### `shared`
65 |
66 | This is a Kotlin module that contains the logic common for desktop, Android, and iOS applications, that is, the code you
67 | share between platforms.
68 |
69 | This `shared` module is also where you'll write your Compose Multiplatform code.
70 | In `shared/src/commonMain/kotlin/App.kt`, you can find the shared root `@Composable` function for your app.
71 |
72 | It uses Gradle as the build system. You can add dependencies and change settings in `shared/build.gradle.kts`.
73 | The `shared` module builds into a Java library, an Android library, and an iOS framework.
74 |
75 | ### `desktopApp`
76 |
77 | This is a Kotlin module that builds into a desktop application. It uses Gradle as the build system. The `desktopApp`
78 | module depends on and uses the `shared` module as a regular library.
79 |
80 | ### `androidApp`
81 |
82 | This is a Kotlin module that builds into an Android application. It uses Gradle as the build system.
83 | The `androidApp` module depends on and uses the `shared` module as a regular Android library.
84 |
85 | ### `iosApp`
86 |
87 | This is an Xcode project that builds into an iOS application.
88 | It depends on and uses the `shared` module as a CocoaPods dependency.
89 |
90 | ## Run your application
91 |
92 | ### On desktop
93 |
94 | To run your desktop application in Android Studio, select `desktopApp` in the list of run configurations and click **Run**:
95 |
96 | 
97 |
98 | You can also run Gradle tasks in the terminal:
99 |
100 | * `./gradlew run` to run application
101 | * `./gradlew package` to store native distribution into `build/compose/binaries`
102 |
103 | ### On Android
104 |
105 | To run your application on an Android emulator:
106 |
107 | 1. Ensure you have an Android virtual device available.
108 | Otherwise, [create one](https://developer.android.com/studio/run/managing-avds#createavd).
109 | 2. In the list of run configurations, select `androidApp`.
110 | 3. Choose your virtual device and click **Run**:
111 |
112 | 
113 |
114 |
115 | Alternatively, use Gradle
116 |
117 | To install an Android application on a real Android device or an emulator, run `./gradlew installDebug` in the terminal.
118 |
119 |
120 |
121 | ### On iOS
122 |
123 | #### Running on a simulator
124 |
125 | To run your application on an iOS simulator in Android Studio, modify the `iosApp` run configuration:
126 |
127 | 1. In the list of run configurations, select **Edit Configurations**:
128 |
129 |
130 |
131 | 2. Navigate to **iOS Application** | **iosApp**.
132 | 3. In the **Execution target** list, select your target device. Click **OK**:
133 |
134 |
135 |
136 | 4. The `iosApp` run configuration is now available. Click **Run** next to your virtual device:
137 |
138 | #### Running on a real iOS device
139 |
140 | You can run your Compose Multiplatform application on a real iOS device for free.
141 | To do so, you'll need the following:
142 |
143 | * The `TEAM_ID` associated with your [Apple ID](https://support.apple.com/en-us/HT204316)
144 | * The iOS device registered in Xcode
145 |
146 | > **Note**
147 | > Before you continue, we suggest creating a simple "Hello, world!" project in Xcode to ensure you can successfully run
148 | > apps on your device.
149 | > You can follow the instructions below or watch
150 | > this [Stanford CS193P lecture recording](https://youtu.be/bqu6BquVi2M?start=716&end=1399).
151 |
152 |
153 | How to create and run a simple project in Xcode
154 |
155 | 1. On the Xcode welcome screen, select **Create a new project in Xcode**.
156 | 2. On the **iOS** tab, choose the **App** template. Click **Next**.
157 | 3. Specify the product name and keep other settings default. Click **Next**.
158 | 4. Select where to store the project on your computer and click **Create**. You'll see an app that displays "Hello,
159 | world!" on the device screen.
160 | 5. At the top of your Xcode screen, click on the device name near the **Run** button.
161 | 6. Plug your device into the computer. You'll see this device in the list of run options.
162 | 7. Choose your device and click **Run**.
163 |
164 |
165 |
166 | ##### Finding your Team ID
167 |
168 | In the terminal, run `kdoctor --team-ids` to find your Team ID.
169 | KDoctor will list all Team IDs currently configured on your system, for example:
170 |
171 | ```text
172 | 3ABC246XYZ (Max Sample)
173 | ZABCW6SXYZ (SampleTech Inc.)
174 | ```
175 |
176 |
177 | Alternative way to find your Team ID
178 |
179 | If KDoctor doesn't work for you, try this alternative method:
180 |
181 | 1. In Android Studio, run the `iosApp` configuration with the selected real device. The build should fail.
182 | 2. Go to Xcode and select **Open a project or file**.
183 | 3. Navigate to the `iosApp/iosApp.xcworkspace` file of your project.
184 | 4. In the left-hand menu, select `iosApp`.
185 | 5. Navigate to **Signing & Capabilities**.
186 | 6. In the **Team** list, select your team.
187 |
188 | If you haven't set up your team yet, use the **Add account** option and follow the steps.
189 |
190 |
191 |
192 | To run the application, set the `TEAM_ID`:
193 |
194 | 1. In the template, navigate to the `iosApp/Configuration/Config.xcconfig` file.
195 | 2. Set your `TEAM_ID`.
196 | 3. Re-open the project in Android Studio. It should show the registered iOS device in the `iosApp` run configuration.
197 |
198 | ## How to configure the iOS application
199 |
200 | To get a better understanding of this project's setup and learn how to configure the basic properties of your iOS app without Xcode,
201 | open the `iosApp/Configuration/Config.xcconfig` file in Android Studio. The configuration file contains:
202 |
203 | * `APP_NAME`, a target executable and an application bundle name.
204 | * `BUNDLE_ID`,
205 | which [uniquely identifies the app throughout the system](https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier#discussion).
206 | * `TEAM_ID`, [a unique identifier generated by Apple that's assigned to your team](https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/#:~:text=A%20Team%20ID%20is%20a,developer%20in%20App%20Store%20Connect).
207 |
208 | To configure the `APP_NAME` option, open `Config.xcconfig` in any text editor *before opening* the project in Android
209 | Studio, and then set the desired name.
210 |
211 | If you need to change this option after you open the project in Android Studio, do the following:
212 |
213 | 1. Close the project in Android Studio.
214 | 2. Run `./cleanup.sh` in your terminal.
215 | 3. Change the setting.
216 | 4. Open the project in Android Studio again.
217 |
218 | To configure advanced settings, use Xcode. After opening the project in Android Studio,
219 | open the `iosApp/iosApp.xcworkspace` file in Xcode and make changes there.
220 |
221 | ## Hooray :partying_face:
222 |
223 | Now you are ready to fly :airplane:, this project was configured, built and made with :heart: by [Ahmed Nassar](https://github.com/ranger163), for any questions, enhancements, new feature enquiries or bug fixes please head to [Issues Section](https://github.com/ranger163/kotlin-multiplatform-template/issues/new/choose) and don't hesitate to share with me your thoughts :eyes:.
224 |
225 | Happy coding :computer:.
226 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # This is a [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform) application.
2 |
3 | > **Note**
4 | > The iOS part of Compose Multiplatform is in Alpha. It may change incompatibly and require manual migration in the
5 | > future.
6 | > If you have any issues, please report them on [GitHub](https://github.com/JetBrains/compose-multiplatform/issues).
7 |
8 | > **PS**
9 | > This template is a fork from [Jetbrains' compose multiplatform template](https://github.com/JetBrains/compose-multiplatform-template#readme)
10 |
11 | ## Set up the environment
12 |
13 | > **Warning**
14 | > You need a Mac with macOS to write and run iOS-specific code on simulated or real devices.
15 | > This is an Apple requirement.
16 |
17 | To work with this project, you need the following:
18 |
19 | * A machine running a recent version of macOS
20 | * JDK 17
21 | * [Xcode](https://apps.apple.com/us/app/xcode/id497799835)
22 | * [Android Studio](https://developer.android.com/studio)
23 | * The [Kotlin Multiplatform Mobile plugin](https://plugins.jetbrains.com/plugin/14936-kotlin-multiplatform-mobile)
24 | * The [CocoaPods dependency manager](https://kotlinlang.org/docs/native-cocoapods.html)
25 |
26 | ### Check your environment
27 |
28 | Before you start, use the [KDoctor](https://github.com/Kotlin/kdoctor) tool to ensure that your development environment
29 | is configured correctly:
30 |
31 | 1. Install KDoctor with [Homebrew](https://brew.sh/):
32 |
33 | ```text
34 | brew install kdoctor
35 | ```
36 |
37 | 2. Run KDoctor in your terminal:
38 |
39 | ```text
40 | kdoctor
41 | ```
42 |
43 | If everything is set up correctly, you'll see valid output:
44 |
45 | ```text
46 | Environment diagnose (to see all details, use -v option):
47 | [✓] Operation System
48 | [✓] Java
49 | [✓] Android Studio
50 | [✓] Xcode
51 | [✓] Cocoapods
52 |
53 | Conclusion:
54 | ✓ Your system is ready for Kotlin Multiplatform Mobile development!
55 | ```
56 |
57 | Otherwise, KDoctor will highlight which parts of your setup still need to be configured and will suggest a way to fix
58 | them.
59 |
60 | ## Examine the project structure
61 |
62 | Open the project in Android Studio and switch the view from **Android** to **Project** to see all the files and targets
63 | belonging to the project:
64 |
65 |
66 |
67 | Your Compose Multiplatform project includes 4 modules:
68 |
69 | ### `shared`
70 |
71 | This is a Kotlin module that contains the logic common for desktop, Android, and iOS applications, that is, the code you
72 | share between platforms.
73 |
74 | This `shared` module is also where you'll write your Compose Multiplatform code.
75 | In `shared/src/commonMain/kotlin/App.kt`, you can find the shared root `@Composable` function for your app.
76 |
77 | It uses Gradle as the build system. You can add dependencies and change settings in `shared/build.gradle.kts`.
78 | The `shared` module builds into a Java library, an Android library, and an iOS framework.
79 |
80 | ### `desktopApp`
81 |
82 | This is a Kotlin module that builds into a desktop application. It uses Gradle as the build system. The `desktopApp`
83 | module depends on and uses the `shared` module as a regular library.
84 |
85 | ### `androidApp`
86 |
87 | This is a Kotlin module that builds into an Android application. It uses Gradle as the build system.
88 | The `androidApp` module depends on and uses the `shared` module as a regular Android library.
89 |
90 | ### `iosApp`
91 |
92 | This is an Xcode project that builds into an iOS application.
93 | It depends on and uses the `shared` module as a CocoaPods dependency.
94 |
95 | ## Run your application
96 |
97 | ### On desktop
98 |
99 | To run your desktop application in Android Studio, select `desktopApp` in the list of run configurations and click **Run**:
100 |
101 | 
102 |
103 | You can also run Gradle tasks in the terminal:
104 |
105 | * `./gradlew run` to run application
106 | * `./gradlew package` to store native distribution into `build/compose/binaries`
107 |
108 | ### On Android
109 |
110 | To run your application on an Android emulator:
111 |
112 | 1. Ensure you have an Android virtual device available.
113 | Otherwise, [create one](https://developer.android.com/studio/run/managing-avds#createavd).
114 | 2. In the list of run configurations, select `androidApp`.
115 | 3. Choose your virtual device and click **Run**:
116 |
117 | 
118 |
119 |
120 | Alternatively, use Gradle
121 |
122 | To install an Android application on a real Android device or an emulator, run `./gradlew installDebug` in the terminal.
123 |
124 |
125 |
126 | ### On iOS
127 |
128 | #### Running on a simulator
129 |
130 | To run your application on an iOS simulator in Android Studio, modify the `iosApp` run configuration:
131 |
132 | 1. In the list of run configurations, select **Edit Configurations**:
133 |
134 |
135 |
136 | 2. Navigate to **iOS Application** | **iosApp**.
137 | 3. In the **Execution target** list, select your target device. Click **OK**:
138 |
139 |
140 |
141 | 4. The `iosApp` run configuration is now available. Click **Run** next to your virtual device:
142 |
143 | #### Running on a real iOS device
144 |
145 | You can run your Compose Multiplatform application on a real iOS device for free.
146 | To do so, you'll need the following:
147 |
148 | * The `TEAM_ID` associated with your [Apple ID](https://support.apple.com/en-us/HT204316)
149 | * The iOS device registered in Xcode
150 |
151 | > **Note**
152 | > Before you continue, we suggest creating a simple "Hello, world!" project in Xcode to ensure you can successfully run
153 | > apps on your device.
154 | > You can follow the instructions below or watch
155 | > this [Stanford CS193P lecture recording](https://youtu.be/bqu6BquVi2M?start=716&end=1399).
156 |
157 |
158 | How to create and run a simple project in Xcode
159 |
160 | 1. On the Xcode welcome screen, select **Create a new project in Xcode**.
161 | 2. On the **iOS** tab, choose the **App** template. Click **Next**.
162 | 3. Specify the product name and keep other settings default. Click **Next**.
163 | 4. Select where to store the project on your computer and click **Create**. You'll see an app that displays "Hello,
164 | world!" on the device screen.
165 | 5. At the top of your Xcode screen, click on the device name near the **Run** button.
166 | 6. Plug your device into the computer. You'll see this device in the list of run options.
167 | 7. Choose your device and click **Run**.
168 |
169 |
170 |
171 | ##### Finding your Team ID
172 |
173 | In the terminal, run `kdoctor --team-ids` to find your Team ID.
174 | KDoctor will list all Team IDs currently configured on your system, for example:
175 |
176 | ```text
177 | 3ABC246XYZ (Max Sample)
178 | ZABCW6SXYZ (SampleTech Inc.)
179 | ```
180 |
181 |
182 | Alternative way to find your Team ID
183 |
184 | If KDoctor doesn't work for you, try this alternative method:
185 |
186 | 1. In Android Studio, run the `iosApp` configuration with the selected real device. The build should fail.
187 | 2. Go to Xcode and select **Open a project or file**.
188 | 3. Navigate to the `iosApp/iosApp.xcworkspace` file of your project.
189 | 4. In the left-hand menu, select `iosApp`.
190 | 5. Navigate to **Signing & Capabilities**.
191 | 6. In the **Team** list, select your team.
192 |
193 | If you haven't set up your team yet, use the **Add account** option and follow the steps.
194 |
195 |
196 |
197 | To run the application, set the `TEAM_ID`:
198 |
199 | 1. In the template, navigate to the `iosApp/Configuration/Config.xcconfig` file.
200 | 2. Set your `TEAM_ID`.
201 | 3. Re-open the project in Android Studio. It should show the registered iOS device in the `iosApp` run configuration.
202 |
203 | ## How to configure the iOS application
204 |
205 | To get a better understanding of this project's setup and learn how to configure the basic properties of your iOS app without Xcode,
206 | open the `iosApp/Configuration/Config.xcconfig` file in Android Studio. The configuration file contains:
207 |
208 | * `APP_NAME`, a target executable and an application bundle name.
209 | * `BUNDLE_ID`,
210 | which [uniquely identifies the app throughout the system](https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier#discussion).
211 | * `TEAM_ID`, [a unique identifier generated by Apple that's assigned to your team](https://developer.apple.com/help/account/manage-your-team/locate-your-team-id/#:~:text=A%20Team%20ID%20is%20a,developer%20in%20App%20Store%20Connect).
212 |
213 | To configure the `APP_NAME` option, open `Config.xcconfig` in any text editor *before opening* the project in Android
214 | Studio, and then set the desired name.
215 |
216 | If you need to change this option after you open the project in Android Studio, do the following:
217 |
218 | 1. Close the project in Android Studio.
219 | 2. Run `./cleanup.sh` in your terminal.
220 | 3. Change the setting.
221 | 4. Open the project in Android Studio again.
222 |
223 | To configure advanced settings, use Xcode. After opening the project in Android Studio,
224 | open the `iosApp/iosApp.xcworkspace` file in Xcode and make changes there.
225 |
226 | ## Hooray :partying_face:
227 |
228 | Now you are ready to fly :airplane:, this project was configured, built and made with :heart: by [Ahmed Nassar](https://github.com/ranger163), for any questions, enhancements, new feature enquiries or bug fixes please head to [Issues Section](https://github.com/ranger163/kotlin-multiplatform-template/issues/new/choose) and don't hesitate to share with me your thoughts :eyes:.
229 |
230 | Happy coding :computer:.
231 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2020-2021 JetBrains s.r.o. and and respective authors and developers.
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 51;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; };
11 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; };
12 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
13 | 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
14 | CBB20C58ABD876AC4E21323F /* Pods_iosApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44EF6984C6D7D05AF8A2A6FD /* Pods_iosApp.framework */; };
15 | /* End PBXBuildFile section */
16 |
17 | /* Begin PBXFileReference section */
18 | 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
19 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
20 | 083426813C8BCC00CC83B9E0 /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = ""; };
21 | 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; };
22 | 44EF6984C6D7D05AF8A2A6FD /* Pods_iosApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iosApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
23 | 7555FF7B242A565900829871 /* KMM Template.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "KMM Template.app"; sourceTree = BUILT_PRODUCTS_DIR; };
24 | 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
25 | 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
26 | AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; };
27 | DA8E2A739DA349DAF84D4A72 /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = ""; };
28 | /* End PBXFileReference section */
29 |
30 | /* Begin PBXFrameworksBuildPhase section */
31 | F85CB1118929364A9C6EFABC /* Frameworks */ = {
32 | isa = PBXFrameworksBuildPhase;
33 | buildActionMask = 2147483647;
34 | files = (
35 | CBB20C58ABD876AC4E21323F /* Pods_iosApp.framework in Frameworks */,
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | 058557D7273AAEEB004C7B11 /* Preview Content */ = {
43 | isa = PBXGroup;
44 | children = (
45 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */,
46 | );
47 | path = "Preview Content";
48 | sourceTree = "";
49 | };
50 | 7555FF72242A565900829871 = {
51 | isa = PBXGroup;
52 | children = (
53 | AB1DB47929225F7C00F7AF9C /* Configuration */,
54 | 7555FF7D242A565900829871 /* iosApp */,
55 | 7555FF7C242A565900829871 /* Products */,
56 | FEFF387C0A8D172AA4D59CAE /* Pods */,
57 | D9F64CE637735F7BEF32D970 /* Frameworks */,
58 | );
59 | sourceTree = "";
60 | };
61 | 7555FF7C242A565900829871 /* Products */ = {
62 | isa = PBXGroup;
63 | children = (
64 | 7555FF7B242A565900829871 /* KMM Template.app */,
65 | );
66 | name = Products;
67 | sourceTree = "";
68 | };
69 | 7555FF7D242A565900829871 /* iosApp */ = {
70 | isa = PBXGroup;
71 | children = (
72 | 058557BA273AAA24004C7B11 /* Assets.xcassets */,
73 | 7555FF82242A565900829871 /* ContentView.swift */,
74 | 7555FF8C242A565B00829871 /* Info.plist */,
75 | 2152FB032600AC8F00CF470E /* iOSApp.swift */,
76 | 058557D7273AAEEB004C7B11 /* Preview Content */,
77 | );
78 | path = iosApp;
79 | sourceTree = "";
80 | };
81 | AB1DB47929225F7C00F7AF9C /* Configuration */ = {
82 | isa = PBXGroup;
83 | children = (
84 | AB3632DC29227652001CCB65 /* Config.xcconfig */,
85 | );
86 | path = Configuration;
87 | sourceTree = "";
88 | };
89 | D9F64CE637735F7BEF32D970 /* Frameworks */ = {
90 | isa = PBXGroup;
91 | children = (
92 | 44EF6984C6D7D05AF8A2A6FD /* Pods_iosApp.framework */,
93 | );
94 | name = Frameworks;
95 | sourceTree = "";
96 | };
97 | FEFF387C0A8D172AA4D59CAE /* Pods */ = {
98 | isa = PBXGroup;
99 | children = (
100 | DA8E2A739DA349DAF84D4A72 /* Pods-iosApp.debug.xcconfig */,
101 | 083426813C8BCC00CC83B9E0 /* Pods-iosApp.release.xcconfig */,
102 | );
103 | path = Pods;
104 | sourceTree = "";
105 | };
106 | /* End PBXGroup section */
107 |
108 | /* Begin PBXNativeTarget section */
109 | 7555FF7A242A565900829871 /* iosApp */ = {
110 | isa = PBXNativeTarget;
111 | buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
112 | buildPhases = (
113 | 3A7F3434CCE7B64C0F4DBCC5 /* [CP] Check Pods Manifest.lock */,
114 | 7555FF77242A565900829871 /* Sources */,
115 | 7555FF79242A565900829871 /* Resources */,
116 | F85CB1118929364A9C6EFABC /* Frameworks */,
117 | 41CE4A26791665555A4AF65E /* [CP] Copy Pods Resources */,
118 | );
119 | buildRules = (
120 | );
121 | dependencies = (
122 | );
123 | name = iosApp;
124 | productName = iosApp;
125 | productReference = 7555FF7B242A565900829871 /* KMM Template.app */;
126 | productType = "com.apple.product-type.application";
127 | };
128 | /* End PBXNativeTarget section */
129 |
130 | /* Begin PBXProject section */
131 | 7555FF73242A565900829871 /* Project object */ = {
132 | isa = PBXProject;
133 | attributes = {
134 | LastSwiftUpdateCheck = 1130;
135 | LastUpgradeCheck = 1130;
136 | ORGANIZATIONNAME = orgName;
137 | TargetAttributes = {
138 | 7555FF7A242A565900829871 = {
139 | CreatedOnToolsVersion = 11.3.1;
140 | };
141 | };
142 | };
143 | buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;
144 | compatibilityVersion = "Xcode 9.3";
145 | developmentRegion = en;
146 | hasScannedForEncodings = 0;
147 | knownRegions = (
148 | en,
149 | Base,
150 | );
151 | mainGroup = 7555FF72242A565900829871;
152 | productRefGroup = 7555FF7C242A565900829871 /* Products */;
153 | projectDirPath = "";
154 | projectRoot = "";
155 | targets = (
156 | 7555FF7A242A565900829871 /* iosApp */,
157 | );
158 | };
159 | /* End PBXProject section */
160 |
161 | /* Begin PBXResourcesBuildPhase section */
162 | 7555FF79242A565900829871 /* Resources */ = {
163 | isa = PBXResourcesBuildPhase;
164 | buildActionMask = 2147483647;
165 | files = (
166 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */,
167 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */,
168 | );
169 | runOnlyForDeploymentPostprocessing = 0;
170 | };
171 | /* End PBXResourcesBuildPhase section */
172 |
173 | /* Begin PBXShellScriptBuildPhase section */
174 | 3A7F3434CCE7B64C0F4DBCC5 /* [CP] Check Pods Manifest.lock */ = {
175 | isa = PBXShellScriptBuildPhase;
176 | buildActionMask = 2147483647;
177 | files = (
178 | );
179 | inputFileListPaths = (
180 | );
181 | inputPaths = (
182 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
183 | "${PODS_ROOT}/Manifest.lock",
184 | );
185 | name = "[CP] Check Pods Manifest.lock";
186 | outputFileListPaths = (
187 | );
188 | outputPaths = (
189 | "$(DERIVED_FILE_DIR)/Pods-iosApp-checkManifestLockResult.txt",
190 | );
191 | runOnlyForDeploymentPostprocessing = 0;
192 | shellPath = /bin/sh;
193 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
194 | showEnvVarsInLog = 0;
195 | };
196 | 41CE4A26791665555A4AF65E /* [CP] Copy Pods Resources */ = {
197 | isa = PBXShellScriptBuildPhase;
198 | buildActionMask = 2147483647;
199 | files = (
200 | );
201 | inputFileListPaths = (
202 | "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-input-files.xcfilelist",
203 | );
204 | name = "[CP] Copy Pods Resources";
205 | outputFileListPaths = (
206 | "${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-output-files.xcfilelist",
207 | );
208 | runOnlyForDeploymentPostprocessing = 0;
209 | shellPath = /bin/sh;
210 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources.sh\"\n";
211 | showEnvVarsInLog = 0;
212 | };
213 | /* End PBXShellScriptBuildPhase section */
214 |
215 | /* Begin PBXSourcesBuildPhase section */
216 | 7555FF77242A565900829871 /* Sources */ = {
217 | isa = PBXSourcesBuildPhase;
218 | buildActionMask = 2147483647;
219 | files = (
220 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
221 | 7555FF83242A565900829871 /* ContentView.swift in Sources */,
222 | );
223 | runOnlyForDeploymentPostprocessing = 0;
224 | };
225 | /* End PBXSourcesBuildPhase section */
226 |
227 | /* Begin XCBuildConfiguration section */
228 | 7555FFA3242A565B00829871 /* Debug */ = {
229 | isa = XCBuildConfiguration;
230 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
231 | buildSettings = {
232 | ALWAYS_SEARCH_USER_PATHS = NO;
233 | CLANG_ANALYZER_NONNULL = YES;
234 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
236 | CLANG_CXX_LIBRARY = "libc++";
237 | CLANG_ENABLE_MODULES = YES;
238 | CLANG_ENABLE_OBJC_ARC = YES;
239 | CLANG_ENABLE_OBJC_WEAK = YES;
240 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
241 | CLANG_WARN_BOOL_CONVERSION = YES;
242 | CLANG_WARN_COMMA = YES;
243 | CLANG_WARN_CONSTANT_CONVERSION = YES;
244 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
245 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
246 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
247 | CLANG_WARN_EMPTY_BODY = YES;
248 | CLANG_WARN_ENUM_CONVERSION = YES;
249 | CLANG_WARN_INFINITE_RECURSION = YES;
250 | CLANG_WARN_INT_CONVERSION = YES;
251 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
252 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
253 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
254 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
255 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
256 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
257 | CLANG_WARN_STRICT_PROTOTYPES = YES;
258 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
259 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
260 | CLANG_WARN_UNREACHABLE_CODE = YES;
261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
262 | COPY_PHASE_STRIP = NO;
263 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
264 | ENABLE_STRICT_OBJC_MSGSEND = YES;
265 | ENABLE_TESTABILITY = YES;
266 | GCC_C_LANGUAGE_STANDARD = gnu11;
267 | GCC_DYNAMIC_NO_PIC = NO;
268 | GCC_NO_COMMON_BLOCKS = YES;
269 | GCC_OPTIMIZATION_LEVEL = 0;
270 | GCC_PREPROCESSOR_DEFINITIONS = (
271 | "DEBUG=1",
272 | "$(inherited)",
273 | );
274 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
275 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
276 | GCC_WARN_UNDECLARED_SELECTOR = YES;
277 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
278 | GCC_WARN_UNUSED_FUNCTION = YES;
279 | GCC_WARN_UNUSED_VARIABLE = YES;
280 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
281 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
282 | MTL_FAST_MATH = YES;
283 | ONLY_ACTIVE_ARCH = YES;
284 | SDKROOT = iphoneos;
285 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
286 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
287 | };
288 | name = Debug;
289 | };
290 | 7555FFA4242A565B00829871 /* Release */ = {
291 | isa = XCBuildConfiguration;
292 | baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */;
293 | buildSettings = {
294 | ALWAYS_SEARCH_USER_PATHS = NO;
295 | CLANG_ANALYZER_NONNULL = YES;
296 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
297 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
298 | CLANG_CXX_LIBRARY = "libc++";
299 | CLANG_ENABLE_MODULES = YES;
300 | CLANG_ENABLE_OBJC_ARC = YES;
301 | CLANG_ENABLE_OBJC_WEAK = YES;
302 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
303 | CLANG_WARN_BOOL_CONVERSION = YES;
304 | CLANG_WARN_COMMA = YES;
305 | CLANG_WARN_CONSTANT_CONVERSION = YES;
306 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
307 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
308 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
309 | CLANG_WARN_EMPTY_BODY = YES;
310 | CLANG_WARN_ENUM_CONVERSION = YES;
311 | CLANG_WARN_INFINITE_RECURSION = YES;
312 | CLANG_WARN_INT_CONVERSION = YES;
313 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
314 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
315 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
316 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
317 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
318 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
319 | CLANG_WARN_STRICT_PROTOTYPES = YES;
320 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
321 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
322 | CLANG_WARN_UNREACHABLE_CODE = YES;
323 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
324 | COPY_PHASE_STRIP = NO;
325 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
326 | ENABLE_NS_ASSERTIONS = NO;
327 | ENABLE_STRICT_OBJC_MSGSEND = YES;
328 | GCC_C_LANGUAGE_STANDARD = gnu11;
329 | GCC_NO_COMMON_BLOCKS = YES;
330 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
331 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
332 | GCC_WARN_UNDECLARED_SELECTOR = YES;
333 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
334 | GCC_WARN_UNUSED_FUNCTION = YES;
335 | GCC_WARN_UNUSED_VARIABLE = YES;
336 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
337 | MTL_ENABLE_DEBUG_INFO = NO;
338 | MTL_FAST_MATH = YES;
339 | SDKROOT = iphoneos;
340 | SWIFT_COMPILATION_MODE = wholemodule;
341 | SWIFT_OPTIMIZATION_LEVEL = "-O";
342 | VALIDATE_PRODUCT = YES;
343 | };
344 | name = Release;
345 | };
346 | 7555FFA6242A565B00829871 /* Debug */ = {
347 | isa = XCBuildConfiguration;
348 | baseConfigurationReference = DA8E2A739DA349DAF84D4A72 /* Pods-iosApp.debug.xcconfig */;
349 | buildSettings = {
350 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
351 | CODE_SIGN_IDENTITY = "Apple Development";
352 | CODE_SIGN_STYLE = Automatic;
353 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
354 | DEVELOPMENT_TEAM = "${TEAM_ID}";
355 | ENABLE_PREVIEWS = YES;
356 | INFOPLIST_FILE = iosApp/Info.plist;
357 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
358 | LD_RUNPATH_SEARCH_PATHS = (
359 | "$(inherited)",
360 | "@executable_path/Frameworks",
361 | );
362 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
363 | PRODUCT_NAME = "${APP_NAME}";
364 | PROVISIONING_PROFILE_SPECIFIER = "";
365 | SWIFT_VERSION = 5.0;
366 | TARGETED_DEVICE_FAMILY = "1,2";
367 | };
368 | name = Debug;
369 | };
370 | 7555FFA7242A565B00829871 /* Release */ = {
371 | isa = XCBuildConfiguration;
372 | baseConfigurationReference = 083426813C8BCC00CC83B9E0 /* Pods-iosApp.release.xcconfig */;
373 | buildSettings = {
374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
375 | CODE_SIGN_IDENTITY = "Apple Development";
376 | CODE_SIGN_STYLE = Automatic;
377 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
378 | DEVELOPMENT_TEAM = "${TEAM_ID}";
379 | ENABLE_PREVIEWS = YES;
380 | INFOPLIST_FILE = iosApp/Info.plist;
381 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
382 | LD_RUNPATH_SEARCH_PATHS = (
383 | "$(inherited)",
384 | "@executable_path/Frameworks",
385 | );
386 | PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}";
387 | PRODUCT_NAME = "${APP_NAME}";
388 | PROVISIONING_PROFILE_SPECIFIER = "";
389 | SWIFT_VERSION = 5.0;
390 | TARGETED_DEVICE_FAMILY = "1,2";
391 | };
392 | name = Release;
393 | };
394 | /* End XCBuildConfiguration section */
395 |
396 | /* Begin XCConfigurationList section */
397 | 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = {
398 | isa = XCConfigurationList;
399 | buildConfigurations = (
400 | 7555FFA3242A565B00829871 /* Debug */,
401 | 7555FFA4242A565B00829871 /* Release */,
402 | );
403 | defaultConfigurationIsVisible = 0;
404 | defaultConfigurationName = Release;
405 | };
406 | 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = {
407 | isa = XCConfigurationList;
408 | buildConfigurations = (
409 | 7555FFA6242A565B00829871 /* Debug */,
410 | 7555FFA7242A565B00829871 /* Release */,
411 | );
412 | defaultConfigurationIsVisible = 0;
413 | defaultConfigurationName = Release;
414 | };
415 | /* End XCConfigurationList section */
416 | };
417 | rootObject = 7555FF73242A565900829871 /* Project object */;
418 | }
419 |
--------------------------------------------------------------------------------