├── shared
├── core
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── core
│ │ │ ├── Error.kt
│ │ │ └── Result.kt
│ ├── proguard-rules.pro
│ └── build.gradle.kts
├── data
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── data
│ │ │ ├── util
│ │ │ ├── Constant.kt
│ │ │ └── KtorLogger.kt
│ │ │ ├── api
│ │ │ ├── ApiService.kt
│ │ │ ├── model
│ │ │ │ └── RepoApiModel.kt
│ │ │ └── ApiServiceImpl.kt
│ │ │ ├── repository
│ │ │ ├── HomeRepository.kt
│ │ │ └── HomeRepositoryImpl.kt
│ │ │ ├── model
│ │ │ └── RepoDataModel.kt
│ │ │ └── di
│ │ │ └── DataModule.kt
│ ├── proguard-rules.pro
│ └── build.gradle.kts
├── di
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── di
│ │ │ └── UtilModules.kt
│ ├── proguard-rules.pro
│ └── build.gradle.kts
├── domain
│ ├── .gitignore
│ ├── consumer-rules.pro
│ ├── src
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── domain
│ │ │ ├── util
│ │ │ └── UseCase.kt
│ │ │ ├── model
│ │ │ └── RepoDomainModel.kt
│ │ │ ├── di
│ │ │ └── DomainModule.kt
│ │ │ └── usecase
│ │ │ └── GetSearchRepoUseCase.kt
│ ├── proguard-rules.pro
│ └── build.gradle.kts
├── src
│ ├── androidMain
│ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── app
│ │ │ ├── Main.android.kt
│ │ │ └── di
│ │ │ └── Util.kt
│ ├── commonTest
│ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── app
│ │ │ └── Test.kt
│ ├── iosMain
│ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── app
│ │ │ ├── main.ios.kt
│ │ │ └── di
│ │ │ └── Util.kt
│ ├── androidUnitTest
│ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── app
│ │ │ └── Test.android.kt
│ ├── iosTest
│ │ └── kotlin
│ │ │ └── com
│ │ │ └── adnan
│ │ │ └── app
│ │ │ └── Test.ios.kt
│ └── commonMain
│ │ └── kotlin
│ │ └── com
│ │ └── adnan
│ │ └── app
│ │ ├── navigation
│ │ └── Navigation.kt
│ │ ├── presentation
│ │ ├── di
│ │ │ └── FeatureModule.kt
│ │ ├── home
│ │ │ ├── widget
│ │ │ │ ├── ShowShimmerMovies.kt
│ │ │ │ ├── CoilImage.kt
│ │ │ │ ├── ShowRepos.kt
│ │ │ │ ├── Snackbar.kt
│ │ │ │ ├── ShimmerRectangle.kt
│ │ │ │ ├── ErrorWidget.kt
│ │ │ │ ├── SearchTopAppBar.kt
│ │ │ │ ├── ShimmerItem.kt
│ │ │ │ ├── EmptyWidget.kt
│ │ │ │ ├── ShimmerLoading.kt
│ │ │ │ └── RepoItem.kt
│ │ │ ├── HomeScreen.kt
│ │ │ └── HomeViewModel.kt
│ │ ├── model
│ │ │ └── RepoUiModel.kt
│ │ └── util
│ │ │ └── Constant.kt
│ │ ├── di
│ │ ├── ProvideModules.kt
│ │ └── Util.kt
│ │ └── App.kt
└── build.gradle.kts
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── iosApp
├── iosApp
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ ├── AccentColor.colorset
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Preview Content
│ │ └── Preview Assets.xcassets
│ │ │ └── Contents.json
│ ├── iOSApp.swift
│ ├── ContentView.swift
│ └── Info.plist
└── iosApp.xcodeproj
│ └── project.pbxproj
├── androidApp
├── src
│ ├── main
│ │ └── res
│ │ │ └── values
│ │ │ └── styles.xml
│ └── androidMain
│ │ ├── kotlin
│ │ └── com
│ │ │ └── adnan
│ │ │ └── app
│ │ │ └── android
│ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
└── build.gradle.kts
├── .gitignore
├── gradle.properties
├── settings.gradle.kts
├── README.md
├── gradlew.bat
└── gradlew
/shared/core/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/shared/data/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/shared/di/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/shared/di/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/shared/core/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/shared/data/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/shared/domain/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/shared/domain/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Adnan9011/github-search/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/androidApp/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea
4 | .DS_Store
5 | build
6 | captures
7 | .externalNativeBuild
8 | .cxx
9 | local.properties
10 | xcuserdata
--------------------------------------------------------------------------------
/iosApp/iosApp/iOSApp.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 |
3 | @main
4 | struct iOSApp: App {
5 | var body: some Scene {
6 | WindowGroup {
7 | ContentView()
8 | }
9 | }
10 | }
--------------------------------------------------------------------------------
/shared/src/androidMain/kotlin/com/adnan/app/Main.android.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app
2 |
3 | import androidx.compose.runtime.Composable
4 |
5 | @Composable
6 | fun MainView() {
7 | App()
8 | }
--------------------------------------------------------------------------------
/shared/domain/src/commonMain/kotlin/com/adnan/domain/util/UseCase.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.domain.util
2 |
3 | interface UseCase {
4 | suspend operator fun invoke(input: Input): Output
5 | }
--------------------------------------------------------------------------------
/shared/src/commonTest/kotlin/com/adnan/app/Test.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app
2 |
3 | import kotlin.test.Test
4 |
5 | class CommonGreetingTest {
6 |
7 | @Test
8 | fun testExample() {
9 | }
10 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/util/Constant.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.util
2 |
3 | const val TIME_OUT = 60_000L
4 |
5 | object Rout {
6 | const val BASE_URL = "https://api.github.com/"
7 | }
--------------------------------------------------------------------------------
/shared/src/iosMain/kotlin/com/adnan/app/main.ios.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app
2 |
3 | import androidx.compose.ui.window.ComposeUIViewController
4 |
5 | fun MainViewController() = ComposeUIViewController { App() }
6 |
--------------------------------------------------------------------------------
/shared/src/androidUnitTest/kotlin/com/adnan/app/Test.android.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app
2 |
3 | import org.junit.Test
4 |
5 | class AndroidGreetingTest {
6 |
7 | @Test
8 | fun testExample() {
9 | }
10 | }
--------------------------------------------------------------------------------
/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/iosTest/kotlin/com/adnan/app/Test.ios.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app
2 |
3 | import kotlin.test.Test
4 | import kotlin.test.assertTrue
5 |
6 | class IosGreetingTest {
7 |
8 | @Test
9 | fun testExample() {
10 |
11 | }
12 | }
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Feb 21 22:06:04 IRST 2024
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/core/src/commonMain/kotlin/com/adnan/core/Error.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.core
2 |
3 | data class Error(val message: String = "", val code: Int = 0, val throwable: Throwable? = null) {
4 | fun isMessage(): Boolean = message.isNotEmpty()
5 | fun isThrowable(): Boolean = throwable != null
6 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/api/ApiService.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.api
2 |
3 | import com.adnan.core.Result
4 | import com.adnan.data.api.model.RepoApiModel
5 | import kotlinx.coroutines.flow.Flow
6 |
7 | interface ApiService {
8 | fun searchRepo(org: String): Flow>>
9 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #Gradle
2 | org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
3 | org.gradle.caching=true
4 | org.gradle.configuration-cache=true
5 |
6 | #Kotlin
7 | kotlin.code.style=official
8 |
9 | #Android
10 | android.useAndroidX=true
11 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/navigation/Navigation.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.navigation
2 |
3 | import com.adnan.app.navigation.Screens.HOME_SCREEN
4 |
5 | private object Screens {
6 | const val HOME_SCREEN = "/home"
7 | }
8 |
9 | object Destinations {
10 | const val HOME_ROUT = HOME_SCREEN
11 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/repository/HomeRepository.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.repository
2 |
3 | import com.adnan.core.Result
4 | import com.adnan.data.model.RepoDataModel
5 | import kotlinx.coroutines.flow.Flow
6 |
7 | interface HomeRepository {
8 | fun searchRepo(org: String): Flow>>
9 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/di/FeatureModule.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.di
2 |
3 | import com.adnan.app.di.viewModelDefinition
4 | import com.adnan.app.presentation.home.HomeViewModel
5 | import org.koin.dsl.module
6 |
7 | val featureModule = module {
8 | viewModelDefinition { HomeViewModel(get()) }
9 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/util/KtorLogger.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.util
2 |
3 | import io.github.aakira.napier.Napier
4 | import io.ktor.client.plugins.logging.Logger
5 |
6 | private const val TAG = "Ktor"
7 |
8 | class KtorLogger() : Logger {
9 | override fun log(message: String) {
10 | Napier.d(message, tag = TAG)
11 | }
12 | }
--------------------------------------------------------------------------------
/shared/di/src/commonMain/kotlin/com/adnan/di/UtilModules.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.di
2 |
3 | import com.adnan.data.di.dataModule
4 | import com.adnan.domain.di.domainModule
5 | import org.koin.dsl.module
6 |
7 | object UtilModules {
8 |
9 | fun getModules() = module {
10 | includes(
11 | dataModule,
12 | domainModule
13 | )
14 | }
15 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/di/ProvideModules.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.di
2 |
3 | import com.adnan.app.presentation.di.featureModule
4 | import com.adnan.di.UtilModules
5 | import org.koin.dsl.module
6 |
7 | object ProvideModules {
8 |
9 | fun getModules() = module {
10 | includes(
11 | featureModule,
12 | UtilModules.getModules()
13 | )
14 | }
15 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/model/RepoDataModel.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.model
2 |
3 | import com.adnan.data.api.model.RepoApiModel
4 |
5 | data class RepoDataModel(
6 | val id: Int,
7 | val name: String,
8 | val forksNumber: Int,
9 | val avatarUrl: String
10 | )
11 |
12 | fun RepoApiModel.toData() = RepoDataModel(
13 | id = id,
14 | name = name,
15 | forksNumber = forksNumber,
16 | avatarUrl = owner.avatarUrl
17 | )
--------------------------------------------------------------------------------
/shared/domain/src/commonMain/kotlin/com/adnan/domain/model/RepoDomainModel.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.domain.model
2 |
3 | import com.adnan.data.model.RepoDataModel
4 |
5 | data class RepoDomainModel(
6 | val id: Int,
7 | val name: String,
8 | val forksNumber: Int,
9 | val avatarUrl: String
10 | )
11 |
12 | fun RepoDataModel.toDomain() = RepoDomainModel(
13 | id = id,
14 | name = name,
15 | forksNumber = forksNumber,
16 | avatarUrl = avatarUrl
17 | )
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/api/model/RepoApiModel.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.api.model
2 |
3 | import kotlinx.serialization.SerialName
4 | import kotlinx.serialization.Serializable
5 |
6 | @Serializable
7 | data class RepoApiModel(
8 | val id: Int,
9 | val name: String,
10 | @SerialName("forks_count") val forksNumber: Int,
11 | val owner: Owner
12 | )
13 |
14 | @Serializable
15 | data class Owner(
16 | @SerialName("avatar_url") val avatarUrl: String = ""
17 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/di/Util.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.di
2 |
3 | import dev.icerock.moko.mvvm.viewmodel.ViewModel
4 | import org.koin.core.definition.Definition
5 | import org.koin.core.definition.KoinDefinition
6 | import org.koin.core.module.Module
7 | import org.koin.core.qualifier.Qualifier
8 |
9 | expect inline fun Module.viewModelDefinition(
10 | qualifier: Qualifier? = null,
11 | noinline definition: Definition
12 | ): KoinDefinition
--------------------------------------------------------------------------------
/androidApp/src/androidMain/kotlin/com/adnan/app/android/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.android
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import com.adnan.app.MainView
7 |
8 | class MainActivity : ComponentActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 |
12 | setContent {
13 | MainView()
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/ShowShimmerMovies.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.lazy.LazyColumn
4 | import androidx.compose.runtime.Composable
5 |
6 | @Composable
7 | fun ShowShimmerRepos(
8 | isEnableShimmer: Boolean,
9 | count: Int
10 | ) {
11 | LazyColumn()
12 | {
13 | items(count = count) {
14 | ShimmerRepoItem(isEnableShimmer = isEnableShimmer)
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/shared/src/iosMain/kotlin/com/adnan/app/di/Util.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.di
2 |
3 | import dev.icerock.moko.mvvm.viewmodel.ViewModel
4 | import org.koin.core.definition.Definition
5 | import org.koin.core.definition.KoinDefinition
6 | import org.koin.core.module.Module
7 | import org.koin.core.qualifier.Qualifier
8 |
9 | actual inline fun Module.viewModelDefinition(
10 | qualifier: Qualifier?,
11 | noinline definition: Definition,
12 | ): KoinDefinition = factory(qualifier = qualifier, definition = definition)
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/CoilImage.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.runtime.Composable
4 | import coil3.compose.LocalPlatformContext
5 | import coil3.compose.rememberAsyncImagePainter
6 | import coil3.request.ImageRequest
7 |
8 | @Composable
9 | fun AsyncImagePainter(
10 | imageUrl: String
11 | ) = rememberAsyncImagePainter(
12 | model = ImageRequest
13 | .Builder(LocalPlatformContext.current)
14 | .data(imageUrl)
15 | .build()
16 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/model/RepoUiModel.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.model
2 |
3 | import com.adnan.domain.model.RepoDomainModel
4 |
5 | data class RepoUiModel(
6 | val id: Int,
7 | val name: String,
8 | val forksNumber: Int,
9 | val avatarUrl: String,
10 | val isLiked: Boolean
11 | )
12 |
13 | fun RepoDomainModel.toUi(isLiked: Boolean) = RepoUiModel(
14 | id = id,
15 | name = name,
16 | forksNumber = forksNumber,
17 | avatarUrl = avatarUrl,
18 | isLiked = isLiked
19 | )
--------------------------------------------------------------------------------
/iosApp/iosApp/ContentView.swift:
--------------------------------------------------------------------------------
1 | import SwiftUI
2 | import shared
3 |
4 | struct ComposeView: UIViewControllerRepresentable {
5 | func makeUIViewController(context: Context) -> UIViewController {
6 | Main_iosKt.MainViewController()
7 | }
8 |
9 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
10 | }
11 |
12 | struct ContentView: View {
13 | var body: some View {
14 | ComposeView()
15 | .ignoresSafeArea(.all, edges: .bottom) // Compose has own keyboard handler
16 | }
17 | }
--------------------------------------------------------------------------------
/shared/domain/src/commonMain/kotlin/com/adnan/domain/di/DomainModule.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.domain.di
2 |
3 | import com.adnan.core.Result
4 | import com.adnan.domain.model.RepoDomainModel
5 | import com.adnan.domain.usecase.GetSearchRepoUseCase
6 | import com.adnan.domain.util.UseCase
7 | import kotlinx.coroutines.flow.Flow
8 | import org.koin.core.module.dsl.bind
9 | import org.koin.core.module.dsl.singleOf
10 | import org.koin.dsl.module
11 |
12 | val domainModule = module {
13 | singleOf(::GetSearchRepoUseCase) { bind>>>>() }
14 | }
--------------------------------------------------------------------------------
/shared/src/androidMain/kotlin/com/adnan/app/di/Util.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.di
2 |
3 | import dev.icerock.moko.mvvm.viewmodel.ViewModel
4 | import org.koin.androidx.viewmodel.dsl.viewModel
5 | import org.koin.core.definition.Definition
6 | import org.koin.core.definition.KoinDefinition
7 | import org.koin.core.module.Module
8 | import org.koin.core.qualifier.Qualifier
9 |
10 | actual inline fun Module.viewModelDefinition(
11 | qualifier: Qualifier?,
12 | noinline definition: Definition,
13 | ): KoinDefinition = viewModel(qualifier = qualifier, definition = definition)
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
2 | pluginManagement {
3 | repositories {
4 | google()
5 | gradlePluginPortal()
6 | mavenCentral()
7 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
8 | }
9 | }
10 |
11 | dependencyResolutionManagement {
12 | repositories {
13 | google()
14 | mavenCentral()
15 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
16 | }
17 | }
18 |
19 | rootProject.name = "Adnan-Bama-Test"
20 | include(":androidApp")
21 | include(":shared")
22 | include(":shared:data")
23 | include(":shared:core")
24 | include(":shared:domain")
25 | include(":shared:di")
26 |
--------------------------------------------------------------------------------
/androidApp/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Project README
2 |
3 |
4 | https://github.com/Adnan9011/github-search/assets/7091803/4960fc5b-6d89-4953-9055-ceba699673d1
5 |
6 |
7 | ## Features
8 |
9 | | Feature | Status |
10 | |---------------------------|------------------|
11 | | KMP | ✔️ Implemented |
12 | | MultiModule | ✔️ Implemented |
13 | | Clean Architecture | ✔️ Implemented |
14 | | Implement fake favorite | ✔️ Implemented |
15 | | Koin | ✔️ Implemented |
16 | | Ktor | ✔️ Implemented |
17 | | Shimmer | ✔️ Implemented |
18 | | Error Handling | ✔️ Implemented |
19 | | Tested on Android and Ios | ✔️ Implemented |
20 | | Test with Kotest | ⚠️ Working on it |
21 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/ShowRepos.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.lazy.LazyColumn
4 | import androidx.compose.foundation.lazy.items
5 | import androidx.compose.runtime.Composable
6 | import com.adnan.app.presentation.model.RepoUiModel
7 | import kotlinx.collections.immutable.PersistentList
8 |
9 | @Composable
10 | fun ShowRepos(
11 | repos: PersistentList,
12 | onRepoClicked: (RepoUiModel) -> Unit
13 | ) {
14 | LazyColumn {
15 | items(
16 | items = repos,
17 | key = { repo -> repo.id }
18 | ) { repo ->
19 | RepoItem(
20 | repo = repo,
21 | onRepoClicked = onRepoClicked
22 | )
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/Snackbar.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.material3.SnackbarDuration
4 | import androidx.compose.material3.SnackbarHostState
5 | import androidx.compose.runtime.Composable
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.launch
8 |
9 | @Composable
10 | fun ShowSnackbar(
11 | snackbarHostState: SnackbarHostState,
12 | scope: CoroutineScope,
13 | message: String,
14 | actionLabel: String? = null,
15 | duration: SnackbarDuration = SnackbarDuration.Long
16 | ) {
17 | scope.launch {
18 | snackbarHostState.showSnackbar(
19 | message = message,
20 | actionLabel = actionLabel,
21 | duration = duration
22 | )
23 | }
24 | }
--------------------------------------------------------------------------------
/shared/core/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/shared/data/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/shared/di/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/shared/domain/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/shared/domain/src/commonMain/kotlin/com/adnan/domain/usecase/GetSearchRepoUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.domain.usecase
2 |
3 | import com.adnan.core.Result
4 | import com.adnan.core.map
5 | import com.adnan.data.repository.HomeRepository
6 | import com.adnan.domain.model.RepoDomainModel
7 | import com.adnan.domain.model.toDomain
8 | import com.adnan.domain.util.UseCase
9 | import kotlinx.coroutines.flow.Flow
10 | import kotlinx.coroutines.flow.map
11 |
12 | class GetSearchRepoUseCase internal constructor(
13 | private val repository: HomeRepository
14 | ) : UseCase>>> {
15 | override suspend fun invoke(repo: String): Flow>> {
16 | return repository.searchRepo(repo).map { result ->
17 | result.map { list ->
18 | list.map { it.toDomain() }
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/shared/core/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform)
3 | alias(libs.plugins.androidLibrary)
4 | }
5 |
6 | kotlin {
7 | androidTarget()
8 | listOf(
9 | iosX64(),
10 | iosArm64(),
11 | iosSimulatorArm64()
12 | ).forEach {
13 | it.binaries.framework {
14 | baseName = "core"
15 | isStatic = true
16 | }
17 | }
18 |
19 | sourceSets {}
20 | }
21 |
22 | android {
23 | namespace = "com.adnan.core"
24 | compileSdk = libs.versions.app.compile.sdk.get().toInt()
25 | defaultConfig {
26 | minSdk = libs.versions.app.min.sdk.get().toInt()
27 | }
28 |
29 | compileOptions {
30 | sourceCompatibility = JavaVersion.VERSION_17
31 | targetCompatibility = JavaVersion.VERSION_17
32 | }
33 | kotlin {
34 | jvmToolchain(libs.versions.java.jdk.get().toInt())
35 | }
36 | }
--------------------------------------------------------------------------------
/shared/core/src/commonMain/kotlin/com/adnan/core/Result.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.core
2 |
3 | sealed class Result {
4 |
5 | object Loading : Result()
6 | data class Success(val value: V) : Result()
7 | data class Failure(val error: Error) : Result()
8 | }
9 |
10 | inline fun Result.fold(
11 | loading: (Unit) -> Unit,
12 | success: (V) -> Unit,
13 | failure: (Error) -> Unit
14 | ) =
15 | when (this) {
16 | is Result.Loading -> loading(Unit)
17 | is Result.Success -> success(value)
18 | is Result.Failure -> failure(error)
19 | }
20 |
21 | inline fun Result.map(transform: (V) -> U): Result {
22 |
23 | return when (this) {
24 | Result.Loading -> Result.Loading
25 | is Result.Success -> Result.Success(transform(value))
26 | is Result.Failure -> Result.Failure(error)
27 | }
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/repository/HomeRepositoryImpl.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.repository
2 |
3 | import com.adnan.core.Error
4 | import com.adnan.core.Result
5 | import com.adnan.core.map
6 | import com.adnan.data.api.ApiService
7 | import com.adnan.data.model.RepoDataModel
8 | import com.adnan.data.model.toData
9 | import kotlinx.coroutines.flow.Flow
10 | import kotlinx.coroutines.flow.catch
11 | import kotlinx.coroutines.flow.map
12 |
13 | class HomeRepositoryImpl(
14 | val api: ApiService
15 | ) : HomeRepository {
16 | override fun searchRepo(org: String): Flow>> =
17 | api.searchRepo(org).map { result ->
18 | result.map { list ->
19 | list.map {
20 | it.toData()
21 | }
22 | }
23 | }.catch { throwable ->
24 | Result.Failure(
25 | Error(
26 | message = throwable.message ?: "",
27 | throwable = throwable
28 | )
29 | )
30 | }
31 | }
--------------------------------------------------------------------------------
/shared/di/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform)
3 | alias(libs.plugins.androidLibrary)
4 | }
5 |
6 | kotlin {
7 | androidTarget()
8 | listOf(
9 | iosX64(),
10 | iosArm64(),
11 | iosSimulatorArm64()
12 | ).forEach {
13 | it.binaries.framework {
14 | baseName = "di"
15 | isStatic = true
16 | }
17 | }
18 |
19 | sourceSets {
20 | commonMain.dependencies {
21 | libs.koin.apply {
22 | implementation(core)
23 | }
24 |
25 | projects.shared.apply {
26 | implementation(domain)
27 | implementation(data)
28 | }
29 | }
30 | }
31 | }
32 |
33 | android {
34 | namespace = "com.adnan.di"
35 | compileSdk = libs.versions.app.compile.sdk.get().toInt()
36 | defaultConfig {
37 | minSdk = libs.versions.app.min.sdk.get().toInt()
38 | }
39 |
40 | compileOptions {
41 | sourceCompatibility = JavaVersion.VERSION_17
42 | targetCompatibility = JavaVersion.VERSION_17
43 | }
44 | kotlin {
45 | jvmToolchain(libs.versions.java.jdk.get().toInt())
46 | }
47 | }
--------------------------------------------------------------------------------
/androidApp/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidApplication)
3 | alias(libs.plugins.kotlinMultiplatform)
4 | alias(libs.plugins.compose)
5 |
6 | }
7 |
8 | android {
9 | namespace = "com.adnan.app.android"
10 | compileSdk = libs.versions.app.compile.sdk.get().toInt()
11 | defaultConfig {
12 | applicationId = "com.adnan.app.android"
13 | minSdk = libs.versions.app.min.sdk.get().toInt()
14 | targetSdk = 34
15 | versionCode = 1
16 | versionName = "1.0"
17 | }
18 | compileOptions {
19 | sourceCompatibility = JavaVersion.VERSION_17
20 | targetCompatibility = JavaVersion.VERSION_17
21 | }
22 | kotlin {
23 | jvmToolchain(libs.versions.java.jdk.get().toInt())
24 | }
25 | }
26 |
27 | kotlin {
28 | androidTarget()
29 | sourceSets {
30 | commonMain {
31 | dependencies {
32 | implementation(compose.runtime)
33 | implementation(projects.shared)
34 | }
35 | }
36 |
37 | androidMain {
38 | dependencies {
39 | implementation(libs.androidx.activity.compose)
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/api/ApiServiceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.api
2 |
3 | import com.adnan.core.Error
4 | import com.adnan.core.Result
5 | import com.adnan.data.api.model.RepoApiModel
6 | import io.ktor.client.HttpClient
7 | import io.ktor.client.call.body
8 | import io.ktor.client.request.get
9 | import kotlinx.coroutines.flow.Flow
10 | import kotlinx.coroutines.flow.flow
11 |
12 | class ApiServiceImpl(val httpClient: HttpClient) : ApiService {
13 |
14 | override fun searchRepo(org: String): Flow>> =
15 | flow {
16 | emit(Result.Loading)
17 |
18 | try {
19 | val url = "orgs/$org/repos?per_page=100"
20 | val responseBody = httpClient.get(url) {}.body>()
21 |
22 | emit(Result.Success(responseBody))
23 |
24 | } catch (exception: Exception) {
25 | emit(
26 | Result.Failure(
27 | Error(
28 | message = exception.message ?: "",
29 | throwable = exception
30 | )
31 | )
32 | )
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/ShimmerRectangle.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.background
4 | import androidx.compose.foundation.layout.Box
5 | import androidx.compose.foundation.layout.height
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.foundation.layout.width
8 | import androidx.compose.foundation.shape.RoundedCornerShape
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.draw.clip
12 | import androidx.compose.ui.graphics.Color
13 | import androidx.compose.ui.unit.Dp
14 |
15 | @Composable
16 | fun ShimmerRectangle(
17 | isEnableShimmer: Boolean,
18 | isLightModeActive: Boolean = false,
19 | width: Dp,
20 | height: Dp,
21 | round: Dp,
22 | padding: Dp
23 | ) {
24 | Box(
25 | modifier = Modifier
26 | .padding(all = padding)
27 | .clip(shape = RoundedCornerShape(round))
28 | .background(color = Color.LightGray)
29 | .width(width)
30 | .height(height)
31 | .shimmerLoadingAnimation(
32 | isEnableShimmer = isEnableShimmer,
33 | isLightModeActive = isLightModeActive,
34 | )
35 | )
36 | }
--------------------------------------------------------------------------------
/shared/domain/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform)
3 | alias(libs.plugins.androidLibrary)
4 | }
5 |
6 | kotlin {
7 | androidTarget()
8 | listOf(
9 | iosX64(),
10 | iosArm64(),
11 | iosSimulatorArm64()
12 | ).forEach {
13 | it.binaries.framework {
14 | baseName = "domain"
15 | isStatic = true
16 | }
17 | }
18 |
19 | sourceSets {
20 | commonMain.dependencies {
21 | projects.shared.apply {
22 | implementation(data)
23 | implementation(core)
24 | }
25 | implementation(libs.coroutine)
26 | implementation(libs.koin.core)
27 | }
28 |
29 | androidMain.dependencies {
30 | implementation(libs.koin.android)
31 | }
32 | }
33 | }
34 |
35 | android {
36 | namespace = "com.adnan.domain"
37 | compileSdk = libs.versions.app.compile.sdk.get().toInt()
38 | defaultConfig {
39 | minSdk = libs.versions.app.min.sdk.get().toInt()
40 | }
41 |
42 | compileOptions {
43 | sourceCompatibility = JavaVersion.VERSION_17
44 | targetCompatibility = JavaVersion.VERSION_17
45 | }
46 | kotlin {
47 | jvmToolchain(libs.versions.java.jdk.get().toInt())
48 | }
49 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/App.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app
2 |
3 | import androidx.compose.runtime.Composable
4 | import coil3.ImageLoader
5 | import coil3.annotation.ExperimentalCoilApi
6 | import coil3.compose.setSingletonImageLoaderFactory
7 | import coil3.fetch.NetworkFetcher
8 | import com.adnan.app.di.ProvideModules
9 | import com.adnan.app.navigation.Destinations
10 | import com.adnan.app.presentation.home.HomeScreen
11 | import moe.tlaster.precompose.PreComposeApp
12 | import moe.tlaster.precompose.navigation.NavHost
13 | import moe.tlaster.precompose.navigation.rememberNavigator
14 | import org.koin.compose.KoinApplication
15 | import org.koin.compose.koinInject
16 |
17 | @OptIn(ExperimentalCoilApi::class)
18 | @Composable
19 | fun App() {
20 | KoinApplication(
21 | application = {
22 | modules(ProvideModules.getModules())
23 | }
24 | ) {
25 | setSingletonImageLoaderFactory { context ->
26 | ImageLoader.Builder(context)
27 | .components {
28 | add(NetworkFetcher.Factory())
29 | }
30 | .build()
31 | }
32 |
33 | PreComposeApp {
34 | val navigator = rememberNavigator()
35 |
36 | NavHost(
37 | navigator = navigator,
38 | initialRoute = Destinations.HOME_ROUT,
39 | ) {
40 | scene(
41 | route = Destinations.HOME_ROUT
42 | ) {
43 | HomeScreen(
44 | viewModel = koinInject()
45 | )
46 | }
47 | }
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/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 | UIApplicationSceneManifest
24 |
25 | UIApplicationSupportsMultipleScenes
26 |
27 |
28 | UIRequiredDeviceCapabilities
29 |
30 | armv7
31 |
32 | UISupportedInterfaceOrientations
33 |
34 | UIInterfaceOrientationPortrait
35 | UIInterfaceOrientationLandscapeLeft
36 | UIInterfaceOrientationLandscapeRight
37 |
38 | UISupportedInterfaceOrientations~ipad
39 |
40 | UIInterfaceOrientationPortrait
41 | UIInterfaceOrientationPortraitUpsideDown
42 | UIInterfaceOrientationLandscapeLeft
43 | UIInterfaceOrientationLandscapeRight
44 |
45 | UILaunchScreen
46 |
47 |
48 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/util/Constant.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.util
2 |
3 | import androidx.compose.ui.graphics.Color
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.text.style.TextAlign
8 | import androidx.compose.ui.unit.dp
9 | import androidx.compose.ui.unit.sp
10 |
11 | const val HOME_TITLE = "Result of your search :"
12 | const val NOT_FOUND = "Repo Not Found"
13 | const val ERROR = "Warning ..."
14 |
15 | const val ShimmerRepoItemCount = 5
16 | val ShimmerRectangleHeight = 30.dp
17 |
18 | val TinyPadding = 4.dp
19 | val SmallPadding = 8.dp
20 | val NormalPadding = 16.dp
21 | val HighPadding = 32.dp
22 |
23 | val SmallElevation = 2.dp
24 |
25 | val ItemWidth = 140.dp
26 | val ItemHeight = 100.dp
27 |
28 | val FavoriteIcon = 48.dp
29 |
30 | val EmptySize = 60.dp
31 |
32 | val ItemRound = 20.dp
33 |
34 | val HomeTextTitleStyle =
35 | TextStyle(
36 | fontSize = 20.sp,
37 | color = Color.Black,
38 | fontFamily = FontFamily.Serif,
39 | fontWeight = FontWeight.Bold
40 | )
41 |
42 | val WARNING_TextStyle =
43 | TextStyle(
44 | fontSize = 16.sp,
45 | color = Color.Black,
46 | fontFamily = FontFamily.Serif,
47 | fontWeight = FontWeight.Medium,
48 | textAlign = TextAlign.Justify,
49 | lineHeight = 20.sp
50 | )
51 |
52 | val DetailItemTextStyle =
53 | TextStyle(
54 | fontSize = 12.sp,
55 | color = Color.Black,
56 | fontFamily = FontFamily.Serif,
57 | textAlign = TextAlign.Start,
58 | fontWeight = FontWeight.Bold
59 | )
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/ErrorWidget.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.foundation.layout.padding
8 | import androidx.compose.foundation.layout.size
9 | import androidx.compose.material.icons.Icons
10 | import androidx.compose.material.icons.filled.Warning
11 | import androidx.compose.material3.Icon
12 | import androidx.compose.material3.Text
13 | import androidx.compose.runtime.Composable
14 | import androidx.compose.ui.Alignment
15 | import androidx.compose.ui.Modifier
16 | import androidx.compose.ui.graphics.Color
17 | import com.adnan.app.presentation.util.ERROR
18 | import com.adnan.app.presentation.util.EmptySize
19 | import com.adnan.app.presentation.util.ItemHeight
20 | import com.adnan.app.presentation.util.NormalPadding
21 | import com.adnan.app.presentation.util.WARNING_TextStyle
22 |
23 | @Composable
24 | fun ErrorWidget() {
25 | Column(
26 | modifier = Modifier
27 | .padding(NormalPadding)
28 | .fillMaxWidth()
29 | .height(ItemHeight),
30 | verticalArrangement = Arrangement.Center,
31 | horizontalAlignment = Alignment.CenterHorizontally
32 | ) {
33 | Icon(
34 | modifier = Modifier
35 | .size(EmptySize),
36 | imageVector = Icons.Filled.Warning,
37 | tint = Color.DarkGray,
38 | contentDescription = null
39 | )
40 | Text(
41 | text = ERROR,
42 | style = WARNING_TextStyle
43 | )
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/shared/data/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform)
3 | alias(libs.plugins.androidLibrary)
4 | alias(libs.plugins.kotlin.serialization)
5 | }
6 |
7 | kotlin {
8 | androidTarget()
9 | listOf(
10 | iosX64(),
11 | iosArm64(),
12 | iosSimulatorArm64()
13 | ).forEach {
14 | it.binaries.framework {
15 | baseName = "data"
16 | isStatic = true
17 | }
18 | }
19 |
20 | sourceSets {
21 | commonMain.dependencies {
22 |
23 | projects.shared.apply {
24 | implementation(core)
25 | }
26 |
27 | implementation(libs.kotlinx.serialization)
28 |
29 | implementation(libs.koin.core)
30 |
31 | libs.ktor.apply {
32 | implementation(core)
33 | implementation(serialization)
34 | implementation(negotiation)
35 | implementation(logging)
36 | }
37 |
38 | implementation(libs.napier)
39 | }
40 |
41 | androidMain.dependencies {
42 | implementation(libs.ktor.okhttp)
43 |
44 | implementation(libs.koin.android)
45 | }
46 | iosMain.dependencies {
47 | implementation(libs.ktor.darwin)
48 | }
49 | }
50 | }
51 |
52 | android {
53 | namespace = "com.adnan.data"
54 | compileSdk = libs.versions.app.compile.sdk.get().toInt()
55 | defaultConfig {
56 | minSdk = libs.versions.app.min.sdk.get().toInt()
57 | }
58 |
59 | compileOptions {
60 | sourceCompatibility = JavaVersion.VERSION_17
61 | targetCompatibility = JavaVersion.VERSION_17
62 | }
63 | kotlin {
64 | jvmToolchain(libs.versions.java.jdk.get().toInt())
65 | }
66 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/SearchTopAppBar.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.material3.ExperimentalMaterial3Api
4 | import androidx.compose.material3.MaterialTheme
5 | import androidx.compose.material3.Text
6 | import androidx.compose.material3.TextField
7 | import androidx.compose.material3.TopAppBar
8 | import androidx.compose.material3.TopAppBarDefaults
9 | import androidx.compose.runtime.Composable
10 | import androidx.compose.runtime.getValue
11 | import androidx.compose.runtime.mutableStateOf
12 | import androidx.compose.runtime.remember
13 | import androidx.compose.runtime.setValue
14 | import androidx.compose.ui.graphics.Color
15 | import androidx.compose.ui.text.TextStyle
16 |
17 | @OptIn(ExperimentalMaterial3Api::class)
18 | @Composable
19 | fun SearchTopAppBar(
20 | onSearchTextChanged: (String) -> Unit
21 | ) {
22 | var searchText by remember { mutableStateOf("") }
23 |
24 | TopAppBar(
25 | title = { Text(text = "Home") },
26 | colors = TopAppBarDefaults.topAppBarColors(
27 | containerColor = MaterialTheme.colorScheme.primary,
28 | titleContentColor = MaterialTheme.colorScheme.onPrimary,
29 | navigationIconContentColor = MaterialTheme.colorScheme.onPrimary,
30 | actionIconContentColor = MaterialTheme.colorScheme.onSecondary
31 | ),
32 | actions = {
33 | TextField(
34 | value = searchText,
35 | onValueChange = { text ->
36 | searchText = text
37 | onSearchTextChanged(text)
38 | },
39 | label = { Text("Search") },
40 | maxLines = 1,
41 | textStyle = TextStyle(color = Color.Black)
42 | )
43 | }
44 | )
45 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/ShimmerItem.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.Row
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.shape.RoundedCornerShape
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Modifier
9 | import androidx.compose.ui.draw.clip
10 | import com.adnan.app.presentation.util.ItemHeight
11 | import com.adnan.app.presentation.util.ItemRound
12 | import com.adnan.app.presentation.util.ItemWidth
13 | import com.adnan.app.presentation.util.ShimmerRectangleHeight
14 | import com.adnan.app.presentation.util.SmallPadding
15 |
16 | @Composable
17 | fun ShimmerRepoItem(
18 | isEnableShimmer: Boolean
19 | ) {
20 | Row(
21 | modifier = Modifier
22 | .fillMaxWidth()
23 | .clip(RoundedCornerShape(size = ItemRound))
24 | ) {
25 | ShimmerRectangle(
26 | isEnableShimmer = isEnableShimmer,
27 | width = ItemWidth,
28 | height = ItemHeight,
29 | round = ItemRound,
30 | padding = SmallPadding
31 | )
32 |
33 | Column {
34 | ShimmerRectangle(
35 | isEnableShimmer = isEnableShimmer,
36 | width = ItemWidth,
37 | height = ShimmerRectangleHeight,
38 | round = ItemRound,
39 | padding = SmallPadding
40 | )
41 |
42 | ShimmerRectangle(
43 | isEnableShimmer = isEnableShimmer,
44 | width = ItemWidth,
45 | height = ShimmerRectangleHeight,
46 | round = ItemRound,
47 | padding = SmallPadding
48 | )
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/EmptyWidget.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.foundation.layout.padding
8 | import androidx.compose.foundation.layout.size
9 | import androidx.compose.material.icons.Icons
10 | import androidx.compose.material.icons.filled.Warning
11 | import androidx.compose.material3.Divider
12 | import androidx.compose.material3.Icon
13 | import androidx.compose.material3.Text
14 | import androidx.compose.runtime.Composable
15 | import androidx.compose.ui.Alignment
16 | import androidx.compose.ui.Modifier
17 | import androidx.compose.ui.graphics.Color
18 | import com.adnan.app.presentation.util.EmptySize
19 | import com.adnan.app.presentation.util.ItemHeight
20 | import com.adnan.app.presentation.util.NOT_FOUND
21 | import com.adnan.app.presentation.util.NormalPadding
22 | import com.adnan.app.presentation.util.WARNING_TextStyle
23 |
24 | @Composable
25 | fun EmptyWidget() {
26 | Column(
27 | modifier = Modifier
28 | .padding(NormalPadding)
29 | .fillMaxWidth()
30 | .height(ItemHeight),
31 | verticalArrangement = Arrangement.Center,
32 | horizontalAlignment = Alignment.CenterHorizontally
33 | ) {
34 | Icon(
35 | modifier = Modifier
36 | .size(EmptySize),
37 | imageVector = Icons.Filled.Warning,
38 | tint = Color.DarkGray,
39 | contentDescription = null
40 | )
41 | Divider(
42 | Modifier
43 | .height(NormalPadding),
44 | color = Color.Transparent
45 | )
46 | Text(
47 | text = NOT_FOUND,
48 | style = WARNING_TextStyle
49 | )
50 | }
51 | }
--------------------------------------------------------------------------------
/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "scale" : "1x",
46 | "size" : "20x20"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "scale" : "2x",
51 | "size" : "20x20"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "scale" : "1x",
56 | "size" : "29x29"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "scale" : "2x",
61 | "size" : "29x29"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "scale" : "1x",
66 | "size" : "40x40"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "scale" : "2x",
71 | "size" : "40x40"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "scale" : "1x",
76 | "size" : "76x76"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "scale" : "2x",
81 | "size" : "76x76"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "scale" : "2x",
86 | "size" : "83.5x83.5"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "scale" : "1x",
91 | "size" : "1024x1024"
92 | }
93 | ],
94 | "info" : {
95 | "author" : "xcode",
96 | "version" : 1
97 | }
98 | }
--------------------------------------------------------------------------------
/shared/data/src/commonMain/kotlin/com/adnan/data/di/DataModule.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.data.di
2 |
3 | import com.adnan.data.api.ApiService
4 | import com.adnan.data.api.ApiServiceImpl
5 | import com.adnan.data.repository.HomeRepository
6 | import com.adnan.data.repository.HomeRepositoryImpl
7 | import com.adnan.data.util.KtorLogger
8 | import com.adnan.data.util.Rout
9 | import com.adnan.data.util.TIME_OUT
10 | import io.github.aakira.napier.DebugAntilog
11 | import io.github.aakira.napier.Napier
12 | import io.ktor.client.HttpClient
13 | import io.ktor.client.plugins.DefaultRequest
14 | import io.ktor.client.plugins.HttpTimeout
15 | import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
16 | import io.ktor.client.plugins.logging.LogLevel
17 | import io.ktor.client.plugins.logging.Logging
18 | import io.ktor.client.request.header
19 | import io.ktor.http.HttpHeaders
20 | import io.ktor.serialization.kotlinx.json.json
21 | import kotlinx.coroutines.Dispatchers
22 | import kotlinx.coroutines.IO
23 | import kotlinx.serialization.ExperimentalSerializationApi
24 | import kotlinx.serialization.json.Json
25 | import org.koin.dsl.module
26 |
27 | @OptIn(ExperimentalSerializationApi::class)
28 | val dataModule = module {
29 | single { HomeRepositoryImpl(api = get()) }
30 |
31 | single {
32 | HttpClient() {
33 | install(Logging) {
34 | logger = KtorLogger()
35 | level = LogLevel.ALL
36 | }
37 | install(DefaultRequest) {
38 | url(Rout.BASE_URL)
39 | header("X-GitHub-Api-Version", "2022-11-28")
40 | header(HttpHeaders.Accept, "application/vnd.github+json")
41 | }
42 | install(ContentNegotiation) {
43 | json(Json {
44 | encodeDefaults = false
45 | explicitNulls = false
46 | ignoreUnknownKeys = true
47 | })
48 | }
49 | install(HttpTimeout) {
50 | requestTimeoutMillis = TIME_OUT
51 | connectTimeoutMillis = TIME_OUT
52 | socketTimeoutMillis = TIME_OUT
53 | }
54 | }.also { Napier.base(DebugAntilog()) }
55 | }
56 |
57 | single { Dispatchers.IO }
58 | single { ApiServiceImpl(httpClient = get()) }
59 | }
--------------------------------------------------------------------------------
/shared/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.kotlinMultiplatform)
3 | alias(libs.plugins.androidLibrary)
4 | alias(libs.plugins.compose)
5 | }
6 |
7 | kotlin {
8 | androidTarget()
9 | listOf(
10 | iosX64(),
11 | iosArm64(),
12 | iosSimulatorArm64()
13 | ).forEach {
14 | it.binaries.framework {
15 | baseName = "shared"
16 | isStatic = true
17 | }
18 | }
19 |
20 | sourceSets {
21 | commonMain.dependencies {
22 | projects.shared.apply {
23 | implementation(domain)
24 | implementation(core)
25 | implementation(di)
26 | }
27 | libs.precompose.apply {
28 | implementation(core)
29 | implementation(viewmodel)
30 | implementation(koin)
31 | }
32 | compose.apply {
33 | implementation(runtime)
34 | implementation(foundation)
35 | implementation(animation)
36 | implementation(material3)
37 | }
38 | libs.coil.apply {
39 | implementation(core)
40 | implementation(compose)
41 | implementation(network)
42 | }
43 | libs.ktor.apply {
44 | implementation(core)
45 | }
46 | implementation(libs.coroutine)
47 | libs.koin.apply {
48 | implementation(core)
49 | implementation(compose)
50 | }
51 | implementation(libs.koin.compose)
52 | libs.mvvm.apply {
53 | implementation(compose)
54 | implementation(compose.flow)
55 | }
56 | implementation(libs.kotlinx.collections.immutable)
57 |
58 | implementation(libs.touchlab)
59 | }
60 | commonTest.dependencies {
61 | implementation(libs.kotlin.test)
62 | }
63 | androidMain.dependencies {
64 | compose.apply {
65 | implementation(preview)
66 | implementation(uiTooling)
67 | }
68 | implementation(libs.koin.android)
69 | }
70 | }
71 | }
72 |
73 | android {
74 | namespace = "com.adnan.app"
75 | compileSdk = libs.versions.app.compile.sdk.get().toInt()
76 | defaultConfig {
77 | minSdk = libs.versions.app.min.sdk.get().toInt()
78 | }
79 |
80 | compileOptions {
81 | sourceCompatibility = JavaVersion.VERSION_17
82 | targetCompatibility = JavaVersion.VERSION_17
83 | }
84 | kotlin {
85 | jvmToolchain(libs.versions.java.jdk.get().toInt())
86 | }
87 |
88 | buildFeatures {
89 | compose = true
90 | }
91 | composeOptions {
92 | kotlinCompilerExtensionVersion = libs.versions.compose.android.compiler.get()
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/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%" == "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%"=="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 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/ShimmerLoading.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.animation.core.LinearEasing
4 | import androidx.compose.animation.core.RepeatMode
5 | import androidx.compose.animation.core.animateFloat
6 | import androidx.compose.animation.core.infiniteRepeatable
7 | import androidx.compose.animation.core.rememberInfiniteTransition
8 | import androidx.compose.animation.core.tween
9 | import androidx.compose.foundation.background
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.composed
12 | import androidx.compose.ui.geometry.Offset
13 | import androidx.compose.ui.graphics.Brush
14 | import androidx.compose.ui.graphics.Color
15 |
16 | const val WIDTH_OF_SHADOW_BRUSH = 500
17 | const val ANGLE_OF_AXIS_Y = 270f
18 | const val DURATION = 1000
19 |
20 | fun Modifier.shimmerLoadingAnimation(
21 | isEnableShimmer: Boolean = true,
22 | isLightModeActive: Boolean = true,
23 | widthOfShadowBrush: Int = WIDTH_OF_SHADOW_BRUSH,
24 | angleOfAxisY: Float = ANGLE_OF_AXIS_Y,
25 | durationMillis: Int = DURATION,
26 | ): Modifier {
27 | if (isEnableShimmer) {
28 | return composed {
29 | val shimmerColors = ShimmerAnimationData(isLightMode = isLightModeActive).getColours()
30 |
31 | val transition = rememberInfiniteTransition(label = "")
32 |
33 | val translateAnimation = transition.animateFloat(
34 | initialValue = 0f,
35 | targetValue = (durationMillis + widthOfShadowBrush).toFloat(),
36 | animationSpec = infiniteRepeatable(
37 | animation = tween(
38 | durationMillis = durationMillis,
39 | easing = LinearEasing,
40 | ),
41 | repeatMode = RepeatMode.Restart,
42 | ),
43 | label = "Shimmer loading animation",
44 | )
45 |
46 | this.background(
47 | brush = Brush.linearGradient(
48 | colors = shimmerColors,
49 | start = Offset(x = translateAnimation.value - widthOfShadowBrush, y = 0.0f),
50 | end = Offset(x = translateAnimation.value, y = angleOfAxisY),
51 | ),
52 | )
53 | }
54 | } else {
55 | return this
56 | }
57 | }
58 |
59 | data class ShimmerAnimationData(
60 | private val isLightMode: Boolean = true
61 | ) {
62 | fun getColours(): List {
63 | return if (isLightMode) {
64 | val color = Color.White
65 |
66 | listOf(
67 | color.copy(alpha = 0.3f),
68 | color.copy(alpha = 0.5f),
69 | color.copy(alpha = 1.0f),
70 | color.copy(alpha = 0.5f),
71 | color.copy(alpha = 0.3f),
72 | )
73 | } else {
74 | val color = Color.Black
75 |
76 | listOf(
77 | color.copy(alpha = 0.0f),
78 | color.copy(alpha = 0.3f),
79 | color.copy(alpha = 0.5f),
80 | color.copy(alpha = 0.3f),
81 | color.copy(alpha = 0.0f),
82 | )
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home
2 |
3 | import androidx.compose.foundation.layout.Column
4 | import androidx.compose.foundation.layout.fillMaxWidth
5 | import androidx.compose.foundation.layout.padding
6 | import androidx.compose.foundation.layout.wrapContentHeight
7 | import androidx.compose.material3.Scaffold
8 | import androidx.compose.material3.SnackbarHost
9 | import androidx.compose.material3.SnackbarHostState
10 | import androidx.compose.material3.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.collectAsState
13 | import androidx.compose.runtime.getValue
14 | import androidx.compose.runtime.mutableStateOf
15 | import androidx.compose.runtime.remember
16 | import androidx.compose.runtime.rememberCoroutineScope
17 | import androidx.compose.runtime.setValue
18 | import androidx.compose.ui.Modifier
19 | import com.adnan.app.presentation.home.widget.EmptyWidget
20 | import com.adnan.app.presentation.home.widget.SearchTopAppBar
21 | import com.adnan.app.presentation.home.widget.ShowRepos
22 | import com.adnan.app.presentation.home.widget.ShowShimmerRepos
23 | import com.adnan.app.presentation.home.widget.ShowSnackbar
24 | import com.adnan.app.presentation.model.RepoUiModel
25 | import com.adnan.app.presentation.util.HOME_TITLE
26 | import com.adnan.app.presentation.util.HighPadding
27 | import com.adnan.app.presentation.util.HomeTextTitleStyle
28 | import com.adnan.app.presentation.util.NormalPadding
29 | import com.adnan.app.presentation.util.ShimmerRepoItemCount
30 | import com.adnan.core.Result
31 | import kotlinx.collections.immutable.PersistentList
32 |
33 | @Composable
34 | fun HomeScreen(
35 | modifier: Modifier = Modifier,
36 | viewModel: HomeViewModel
37 | ) {
38 |
39 | val snackbarHostState = remember { SnackbarHostState() }
40 |
41 | Scaffold(
42 | topBar = {
43 | SearchTopAppBar(
44 | onSearchTextChanged = { org ->
45 | viewModel.onSearchTextChanged(org)
46 | }
47 | )
48 | },
49 | snackbarHost = { SnackbarHost(snackbarHostState) },
50 | ) { paddingValues ->
51 |
52 | val uiRepos by viewModel.uiRepos.collectAsState()
53 | var isEnableShimmer by remember { mutableStateOf(false) }
54 |
55 | Column(
56 | modifier = modifier.padding(paddingValues)
57 | .fillMaxWidth()
58 | .wrapContentHeight()
59 | ) {
60 | Text(
61 | text = HOME_TITLE,
62 | style = HomeTextTitleStyle,
63 | modifier = Modifier.padding(
64 | top = NormalPadding,
65 | start = HighPadding,
66 | bottom = NormalPadding
67 | )
68 | )
69 |
70 | when (uiRepos) {
71 | Result.Loading -> {
72 | isEnableShimmer = true
73 | ShowShimmerRepos(
74 | isEnableShimmer = true,
75 | count = ShimmerRepoItemCount
76 | )
77 | }
78 |
79 | is Result.Failure -> {
80 | EmptyWidget()
81 | ShowSnackbar(
82 | snackbarHostState = snackbarHostState,
83 | scope = rememberCoroutineScope(),
84 | message = (uiRepos as Result.Failure).error.message
85 | )
86 | }
87 |
88 | is Result.Success -> {
89 | isEnableShimmer = false
90 | val repos = (uiRepos as Result.Success>).value
91 | if (repos.isEmpty()) {
92 | EmptyWidget()
93 | } else {
94 | ShowRepos(
95 | repos = repos,
96 | onRepoClicked = { repo ->
97 | viewModel.updateFakeFavorite(repo)
98 | }
99 | )
100 | }
101 | }
102 |
103 | else -> {}
104 | }
105 | }
106 |
107 | }
108 | }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/HomeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home
2 |
3 | import com.adnan.app.presentation.model.RepoUiModel
4 | import com.adnan.app.presentation.model.toUi
5 | import com.adnan.core.Error
6 | import com.adnan.core.Result
7 | import com.adnan.core.map
8 | import com.adnan.domain.usecase.GetSearchRepoUseCase
9 | import dev.icerock.moko.mvvm.viewmodel.ViewModel
10 | import kotlinx.collections.immutable.PersistentList
11 | import kotlinx.collections.immutable.toPersistentList
12 | import kotlinx.coroutines.Dispatchers
13 | import kotlinx.coroutines.FlowPreview
14 | import kotlinx.coroutines.IO
15 | import kotlinx.coroutines.Job
16 | import kotlinx.coroutines.flow.MutableStateFlow
17 | import kotlinx.coroutines.flow.asStateFlow
18 | import kotlinx.coroutines.flow.catch
19 | import kotlinx.coroutines.flow.collectLatest
20 | import kotlinx.coroutines.flow.debounce
21 | import kotlinx.coroutines.flow.flowOn
22 | import kotlinx.coroutines.flow.update
23 | import kotlinx.coroutines.launch
24 |
25 | @OptIn(FlowPreview::class)
26 | class HomeViewModel(
27 | private val getSearchRepoUseCase: GetSearchRepoUseCase
28 | ) : ViewModel() {
29 |
30 | init {
31 | setSearchQuery()
32 | }
33 |
34 | private var job = Job()
35 | get() {
36 | if (field.isCancelled) field = Job()
37 | return field
38 | }
39 |
40 | private val _uiRepos =
41 | MutableStateFlow>?>(null)
42 | val uiRepos = _uiRepos.asStateFlow()
43 |
44 | private val searchQuery = MutableStateFlow("")
45 |
46 | fun onSearchTextChanged(org: String) {
47 | searchQuery.value = org
48 | }
49 |
50 | @FlowPreview
51 | private fun setSearchQuery() {
52 | viewModelScope.launch {
53 | searchQuery
54 | .debounce(500)
55 | .collectLatest { query ->
56 | if (query.isNotBlank())
57 | searchRepository()
58 | }
59 |
60 | }
61 | }
62 |
63 | private fun searchRepository() {
64 | cancelJobs()
65 | viewModelScope.launch(job) {
66 | getSearchRepoUseCase(repo = searchQuery.value)
67 | .flowOn(Dispatchers.IO)
68 | .catch { throwable ->
69 | _uiRepos.value = Result.Failure(
70 | Error(
71 | message = throwable.message ?: "",
72 | throwable = throwable
73 | )
74 | )
75 | }
76 | .collect { result ->
77 | _uiRepos.value =
78 | result.map { list ->
79 | list.map {
80 | it.toUi(
81 | checkFakeFavorite(it.id)
82 | )
83 | }.toPersistentList()
84 | }
85 | }
86 | }
87 | }
88 |
89 | private fun checkFakeFavorite(repoId: Int) =
90 | fakeStoreFavoriteRepoId.contains(repoId)
91 |
92 | private fun cancelJobs() {
93 | job.cancel()
94 | }
95 |
96 | /*
97 | * Fake Store Favorite Repos
98 | */
99 |
100 | private val fakeStoreFavoriteRepoId: ArrayList = arrayListOf()
101 |
102 | fun updateFakeFavorite(repoUiModel: RepoUiModel) {
103 | if (repoUiModel.isLiked) addFakeFavorite(repoUiModel.id)
104 | else removeFakeFavorite(repoUiModel.id)
105 | }
106 |
107 | private fun addFakeFavorite(id: Int) {
108 | fakeStoreFavoriteRepoId.add(id)
109 | updateRepo(id)
110 | }
111 |
112 | private fun removeFakeFavorite(id: Int) {
113 | fakeStoreFavoriteRepoId.remove(id)
114 | updateRepo(id)
115 | }
116 |
117 | private fun updateRepo(id: Int) {
118 | _uiRepos.update { result ->
119 | result?.map { persistentList ->
120 | persistentList.map { repoUi ->
121 | if (repoUi.id == id) {
122 | repoUi.copy(isLiked = checkFakeFavorite(id))
123 | } else {
124 | repoUi
125 | }
126 | }.toPersistentList()
127 | }
128 | }
129 | }
130 | }
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.2.2"
3 | org-jetbrains-kotlin-android = "1.9.21"
4 |
5 | compose = "1.5.11"
6 | activity-compose = "1.8.2"
7 | coil = "3.0.0-alpha01"
8 |
9 | kotlinx-immutable-collection = "0.3.5"
10 | kotlinx-serialization = "1.6.2"
11 |
12 | ktor = "2.3.7"
13 | koin = "3.5.3"
14 | koin-compose = "1.1.2"
15 |
16 | androidx-core-ktx = "1.12.0"
17 | junit-junit = "4.13.2"
18 | androidx-test-ext-junit115 = "1.1.5"
19 | androidx-test-espresso-espresso-core = "3.5.1"
20 | androidx-appcompat-appcompat = "1.6.1"
21 | com-google-android-material-material = "1.11.0"
22 | napier = "2.7.1"
23 | coroutine = "1.8.0-RC2"
24 |
25 | mvvm-compose = "0.16.1"
26 |
27 | precompose = "1.5.10"
28 |
29 | java-jdk = "17"
30 | app-compile-sdk = "34"
31 | app-min-sdk = "24"
32 | compose-android-compiler = "1.5.7"
33 | touchlab = "2.0.5"
34 |
35 | [libraries]
36 | kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "org-jetbrains-kotlin-android" }
37 | androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activity-compose" }
38 |
39 | kotlinx-collections-immutable = { group = "org.jetbrains.kotlinx", name = "kotlinx-collections-immutable", version.ref = "kotlinx-immutable-collection" }
40 | kotlinx-serialization = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
41 |
42 | ktor-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktor" }
43 | ktor-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor" }
44 | ktor-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor" }
45 | ktor-negotiation = { group = "io.ktor", name = "ktor-client-content-negotiation", version.ref = "ktor" }
46 | ktor-serialization = { group = "io.ktor", name = "ktor-serialization-kotlinx-json", version.ref = "ktor" }
47 | ktor-logging = { group = "io.ktor", name = "ktor-client-logging", version.ref = "ktor" }
48 |
49 | koin-core = { group = "io.insert-koin", name = "koin-core", version.ref = "koin" }
50 | koin-compose = { group = "io.insert-koin", name = "koin-compose", version.ref = "koin-compose" }
51 | koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
52 | touchlab = { group = "co.touchlab", name = "stately-common", version.ref = "touchlab" }
53 |
54 | core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidx-core-ktx" }
55 | junit = { group = "junit", name = "junit", version.ref = "junit-junit" }
56 | androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit115" }
57 | espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidx-test-espresso-espresso-core" }
58 | appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat-appcompat" }
59 | material = { group = "com.google.android.material", name = "material", version.ref = "com-google-android-material-material" }
60 | coil-core = { group = "io.coil-kt.coil3", name = "coil-core", version.ref = "coil" }
61 | coil-compose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coil" }
62 | coil-network = { group = "io.coil-kt.coil3", name = "coil-network", version.ref = "coil" }
63 |
64 | napier = { group = "io.github.aakira", name = "napier", version.ref = "napier" }
65 |
66 | coroutine = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutine" }
67 |
68 | mvvm-compose = { group = "dev.icerock.moko", name = "mvvm-compose", version.ref = "mvvm-compose" }
69 | mvvm-compose-flow = { group = "dev.icerock.moko", name = "mvvm-flow-compose", version.ref = "mvvm-compose" }
70 |
71 | precompose-core = { module = "moe.tlaster:precompose", version.ref = "precompose" }
72 | precompose-viewmodel = { module = "moe.tlaster:precompose-viewmodel", version.ref = "precompose" }
73 | precompose-koin = { module = "moe.tlaster:precompose-koin", version.ref = "precompose" }
74 |
75 | [plugins]
76 | androidApplication = { id = "com.android.application", version.ref = "agp" }
77 | androidLibrary = { id = "com.android.library", version.ref = "agp" }
78 | kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "org-jetbrains-kotlin-android" }
79 | kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "org-jetbrains-kotlin-android" }
80 |
81 | kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "org-jetbrains-kotlin-android" }
82 |
83 | compose = { id = "org.jetbrains.compose", version.ref = "compose" }
--------------------------------------------------------------------------------
/shared/src/commonMain/kotlin/com/adnan/app/presentation/home/widget/RepoItem.kt:
--------------------------------------------------------------------------------
1 | package com.adnan.app.presentation.home.widget
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.clickable
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.fillMaxWidth
10 | import androidx.compose.foundation.layout.height
11 | import androidx.compose.foundation.layout.padding
12 | import androidx.compose.foundation.layout.size
13 | import androidx.compose.foundation.shape.RoundedCornerShape
14 | import androidx.compose.material.icons.Icons
15 | import androidx.compose.material.icons.rounded.Star
16 | import androidx.compose.material.icons.twotone.Star
17 | import androidx.compose.material3.Icon
18 | import androidx.compose.material3.Surface
19 | import androidx.compose.material3.Text
20 | import androidx.compose.runtime.Composable
21 | import androidx.compose.runtime.getValue
22 | import androidx.compose.runtime.mutableStateOf
23 | import androidx.compose.runtime.remember
24 | import androidx.compose.runtime.setValue
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.draw.clip
27 | import androidx.compose.ui.graphics.Color
28 | import androidx.compose.ui.layout.ContentScale
29 | import androidx.compose.ui.text.style.TextOverflow
30 | import com.adnan.app.presentation.model.RepoUiModel
31 | import com.adnan.app.presentation.util.DetailItemTextStyle
32 | import com.adnan.app.presentation.util.FavoriteIcon
33 | import com.adnan.app.presentation.util.ItemHeight
34 | import com.adnan.app.presentation.util.ItemRound
35 | import com.adnan.app.presentation.util.ItemWidth
36 | import com.adnan.app.presentation.util.NormalPadding
37 | import com.adnan.app.presentation.util.SmallElevation
38 | import com.adnan.app.presentation.util.SmallPadding
39 |
40 | @Composable
41 | fun RepoItem(
42 | repo: RepoUiModel,
43 | onRepoClicked: (RepoUiModel) -> Unit
44 | ) {
45 | var isLiked by remember { mutableStateOf(repo.isLiked) }
46 |
47 | Surface(
48 | modifier = Modifier
49 | .background(Color.White)
50 | .padding(all = SmallPadding)
51 | .fillMaxWidth()
52 | .clickable {
53 | isLiked = !isLiked
54 | onRepoClicked(repo.copy(isLiked = isLiked))
55 | }
56 | .clip(RoundedCornerShape(size = ItemRound)),
57 | shadowElevation = SmallElevation,
58 | tonalElevation = SmallElevation
59 | ) {
60 | Row(
61 | modifier = Modifier
62 | .fillMaxWidth()
63 | .height(ItemHeight)
64 | ) {
65 |
66 | Image(
67 | modifier = Modifier
68 | .size(width = ItemWidth, height = ItemHeight),
69 | painter = AsyncImagePainter(repo.avatarUrl),
70 | contentScale = ContentScale.Crop,
71 | contentDescription = null
72 | )
73 |
74 | Column(
75 | modifier = Modifier
76 | .fillMaxWidth(0.8f)
77 | .fillMaxHeight()
78 | ) {
79 |
80 | Text(
81 | text = repo.name,
82 | style = DetailItemTextStyle,
83 | modifier = Modifier
84 | .fillMaxWidth()
85 | .padding(
86 | top = SmallPadding,
87 | bottom = SmallPadding,
88 | start = NormalPadding,
89 | end = NormalPadding
90 | ),
91 | overflow = TextOverflow.Ellipsis,
92 | maxLines = 1
93 | )
94 |
95 | Text(
96 | modifier = Modifier
97 | .padding(
98 | top = SmallPadding,
99 | bottom = SmallPadding,
100 | start = NormalPadding,
101 | end = NormalPadding
102 | ),
103 | text = "Number of Forks: ${repo.forksNumber}",
104 | overflow = TextOverflow.Ellipsis,
105 | maxLines = 1,
106 | style = DetailItemTextStyle,
107 | )
108 | }
109 | Icon(
110 | imageVector = if (isLiked) Icons.Rounded.Star else Icons.TwoTone.Star,
111 | tint = Color.Red,
112 | modifier = Modifier
113 | .padding(
114 | end = SmallPadding
115 | )
116 | .size(FavoriteIcon),
117 | contentDescription = null
118 | )
119 |
120 | }
121 | }
122 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or 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 UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/iosApp/iosApp.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
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 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXCopyFilesBuildPhase section */
17 | 7555FFB4242A642300829871 /* Embed Frameworks */ = {
18 | isa = PBXCopyFilesBuildPhase;
19 | buildActionMask = 2147483647;
20 | dstPath = "";
21 | dstSubfolderSpec = 10;
22 | files = (
23 | );
24 | name = "Embed Frameworks";
25 | runOnlyForDeploymentPostprocessing = 0;
26 | };
27 | /* End PBXCopyFilesBuildPhase section */
28 |
29 | /* Begin PBXFileReference section */
30 | 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
31 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; };
32 | 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; };
33 | 7555FF7B242A565900829871 /* iosApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iosApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; };
35 | 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
36 | /* End PBXFileReference section */
37 |
38 | /* Begin PBXFrameworksBuildPhase section */
39 | 7555FF78242A565900829871 /* Frameworks */ = {
40 | isa = PBXFrameworksBuildPhase;
41 | buildActionMask = 2147483647;
42 | files = (
43 | );
44 | runOnlyForDeploymentPostprocessing = 0;
45 | };
46 | /* End PBXFrameworksBuildPhase section */
47 |
48 | /* Begin PBXGroup section */
49 | 058557D7273AAEEB004C7B11 /* Preview Content */ = {
50 | isa = PBXGroup;
51 | children = (
52 | 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */,
53 | );
54 | path = "Preview Content";
55 | sourceTree = "";
56 | };
57 | 7555FF72242A565900829871 = {
58 | isa = PBXGroup;
59 | children = (
60 | 7555FF7D242A565900829871 /* iosApp */,
61 | 7555FF7C242A565900829871 /* Products */,
62 | 7555FFB0242A642200829871 /* Frameworks */,
63 | );
64 | sourceTree = "";
65 | };
66 | 7555FF7C242A565900829871 /* Products */ = {
67 | isa = PBXGroup;
68 | children = (
69 | 7555FF7B242A565900829871 /* iosApp.app */,
70 | );
71 | name = Products;
72 | sourceTree = "";
73 | };
74 | 7555FF7D242A565900829871 /* iosApp */ = {
75 | isa = PBXGroup;
76 | children = (
77 | 058557BA273AAA24004C7B11 /* Assets.xcassets */,
78 | 7555FF82242A565900829871 /* ContentView.swift */,
79 | 7555FF8C242A565B00829871 /* Info.plist */,
80 | 2152FB032600AC8F00CF470E /* iOSApp.swift */,
81 | 058557D7273AAEEB004C7B11 /* Preview Content */,
82 | );
83 | path = iosApp;
84 | sourceTree = "";
85 | };
86 | 7555FFB0242A642200829871 /* Frameworks */ = {
87 | isa = PBXGroup;
88 | children = (
89 | );
90 | name = Frameworks;
91 | sourceTree = "";
92 | };
93 | /* End PBXGroup section */
94 |
95 | /* Begin PBXNativeTarget section */
96 | 7555FF7A242A565900829871 /* iosApp */ = {
97 | isa = PBXNativeTarget;
98 | buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */;
99 | buildPhases = (
100 | 7555FFB5242A651A00829871 /* ShellScript */,
101 | 7555FF77242A565900829871 /* Sources */,
102 | 7555FF78242A565900829871 /* Frameworks */,
103 | 7555FF79242A565900829871 /* Resources */,
104 | 7555FFB4242A642300829871 /* Embed Frameworks */,
105 | );
106 | buildRules = (
107 | );
108 | dependencies = (
109 | );
110 | name = iosApp;
111 | productName = iosApp;
112 | productReference = 7555FF7B242A565900829871 /* iosApp.app */;
113 | productType = "com.apple.product-type.application";
114 | };
115 | /* End PBXNativeTarget section */
116 |
117 | /* Begin PBXProject section */
118 | 7555FF73242A565900829871 /* Project object */ = {
119 | isa = PBXProject;
120 | attributes = {
121 | LastSwiftUpdateCheck = 1130;
122 | LastUpgradeCheck = 1130;
123 | ORGANIZATIONNAME = orgName;
124 | TargetAttributes = {
125 | 7555FF7A242A565900829871 = {
126 | CreatedOnToolsVersion = 11.3.1;
127 | };
128 | };
129 | };
130 | buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */;
131 | compatibilityVersion = "Xcode 9.3";
132 | developmentRegion = en;
133 | hasScannedForEncodings = 0;
134 | knownRegions = (
135 | en,
136 | Base,
137 | );
138 | mainGroup = 7555FF72242A565900829871;
139 | productRefGroup = 7555FF7C242A565900829871 /* Products */;
140 | projectDirPath = "";
141 | projectRoot = "";
142 | targets = (
143 | 7555FF7A242A565900829871 /* iosApp */,
144 | );
145 | };
146 | /* End PBXProject section */
147 |
148 | /* Begin PBXResourcesBuildPhase section */
149 | 7555FF79242A565900829871 /* Resources */ = {
150 | isa = PBXResourcesBuildPhase;
151 | buildActionMask = 2147483647;
152 | files = (
153 | 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */,
154 | 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */,
155 | );
156 | runOnlyForDeploymentPostprocessing = 0;
157 | };
158 | /* End PBXResourcesBuildPhase section */
159 |
160 | /* Begin PBXShellScriptBuildPhase section */
161 | 7555FFB5242A651A00829871 /* ShellScript */ = {
162 | isa = PBXShellScriptBuildPhase;
163 | buildActionMask = 2147483647;
164 | files = (
165 | );
166 | inputFileListPaths = (
167 | );
168 | inputPaths = (
169 | );
170 | outputFileListPaths = (
171 | );
172 | outputPaths = (
173 | );
174 | runOnlyForDeploymentPostprocessing = 0;
175 | shellPath = /bin/sh;
176 | shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n";
177 | };
178 | /* End PBXShellScriptBuildPhase section */
179 |
180 | /* Begin PBXSourcesBuildPhase section */
181 | 7555FF77242A565900829871 /* Sources */ = {
182 | isa = PBXSourcesBuildPhase;
183 | buildActionMask = 2147483647;
184 | files = (
185 | 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */,
186 | 7555FF83242A565900829871 /* ContentView.swift in Sources */,
187 | );
188 | runOnlyForDeploymentPostprocessing = 0;
189 | };
190 | /* End PBXSourcesBuildPhase section */
191 |
192 | /* Begin XCBuildConfiguration section */
193 | 7555FFA3242A565B00829871 /* Debug */ = {
194 | isa = XCBuildConfiguration;
195 | buildSettings = {
196 | ALWAYS_SEARCH_USER_PATHS = NO;
197 | CLANG_ANALYZER_NONNULL = YES;
198 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
199 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
200 | CLANG_CXX_LIBRARY = "libc++";
201 | CLANG_ENABLE_MODULES = YES;
202 | CLANG_ENABLE_OBJC_ARC = YES;
203 | CLANG_ENABLE_OBJC_WEAK = YES;
204 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
205 | CLANG_WARN_BOOL_CONVERSION = YES;
206 | CLANG_WARN_COMMA = YES;
207 | CLANG_WARN_CONSTANT_CONVERSION = YES;
208 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
209 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
210 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
211 | CLANG_WARN_EMPTY_BODY = YES;
212 | CLANG_WARN_ENUM_CONVERSION = YES;
213 | CLANG_WARN_INFINITE_RECURSION = YES;
214 | CLANG_WARN_INT_CONVERSION = YES;
215 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
216 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
217 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
218 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
219 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
220 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
221 | CLANG_WARN_STRICT_PROTOTYPES = YES;
222 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
223 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
224 | CLANG_WARN_UNREACHABLE_CODE = YES;
225 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
226 | COPY_PHASE_STRIP = NO;
227 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
228 | ENABLE_STRICT_OBJC_MSGSEND = YES;
229 | ENABLE_TESTABILITY = YES;
230 | GCC_C_LANGUAGE_STANDARD = gnu11;
231 | GCC_DYNAMIC_NO_PIC = NO;
232 | GCC_NO_COMMON_BLOCKS = YES;
233 | GCC_OPTIMIZATION_LEVEL = 0;
234 | GCC_PREPROCESSOR_DEFINITIONS = (
235 | "DEBUG=1",
236 | "$(inherited)",
237 | );
238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
240 | GCC_WARN_UNDECLARED_SELECTOR = YES;
241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
242 | GCC_WARN_UNUSED_FUNCTION = YES;
243 | GCC_WARN_UNUSED_VARIABLE = YES;
244 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
245 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
246 | MTL_FAST_MATH = YES;
247 | ONLY_ACTIVE_ARCH = YES;
248 | SDKROOT = iphoneos;
249 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
250 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
251 | };
252 | name = Debug;
253 | };
254 | 7555FFA4242A565B00829871 /* Release */ = {
255 | isa = XCBuildConfiguration;
256 | buildSettings = {
257 | ALWAYS_SEARCH_USER_PATHS = NO;
258 | CLANG_ANALYZER_NONNULL = YES;
259 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
261 | CLANG_CXX_LIBRARY = "libc++";
262 | CLANG_ENABLE_MODULES = YES;
263 | CLANG_ENABLE_OBJC_ARC = YES;
264 | CLANG_ENABLE_OBJC_WEAK = YES;
265 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
266 | CLANG_WARN_BOOL_CONVERSION = YES;
267 | CLANG_WARN_COMMA = YES;
268 | CLANG_WARN_CONSTANT_CONVERSION = YES;
269 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
270 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
271 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
272 | CLANG_WARN_EMPTY_BODY = YES;
273 | CLANG_WARN_ENUM_CONVERSION = YES;
274 | CLANG_WARN_INFINITE_RECURSION = YES;
275 | CLANG_WARN_INT_CONVERSION = YES;
276 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
277 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
278 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
280 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
281 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
282 | CLANG_WARN_STRICT_PROTOTYPES = YES;
283 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
284 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
285 | CLANG_WARN_UNREACHABLE_CODE = YES;
286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
287 | COPY_PHASE_STRIP = NO;
288 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
289 | ENABLE_NS_ASSERTIONS = NO;
290 | ENABLE_STRICT_OBJC_MSGSEND = YES;
291 | GCC_C_LANGUAGE_STANDARD = gnu11;
292 | GCC_NO_COMMON_BLOCKS = YES;
293 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
294 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
295 | GCC_WARN_UNDECLARED_SELECTOR = YES;
296 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
297 | GCC_WARN_UNUSED_FUNCTION = YES;
298 | GCC_WARN_UNUSED_VARIABLE = YES;
299 | IPHONEOS_DEPLOYMENT_TARGET = 14.1;
300 | MTL_ENABLE_DEBUG_INFO = NO;
301 | MTL_FAST_MATH = YES;
302 | SDKROOT = iphoneos;
303 | SWIFT_COMPILATION_MODE = wholemodule;
304 | SWIFT_OPTIMIZATION_LEVEL = "-O";
305 | VALIDATE_PRODUCT = YES;
306 | };
307 | name = Release;
308 | };
309 | 7555FFA6242A565B00829871 /* Debug */ = {
310 | isa = XCBuildConfiguration;
311 | buildSettings = {
312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
313 | CODE_SIGN_STYLE = Automatic;
314 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
315 | ENABLE_PREVIEWS = YES;
316 | FRAMEWORK_SEARCH_PATHS = (
317 | "$(inherited)",
318 | "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"
319 | );
320 | INFOPLIST_FILE = iosApp/Info.plist;
321 | IPHONEOS_DEPLOYMENT_TARGET = 16.0;
322 | LD_RUNPATH_SEARCH_PATHS = (
323 | "$(inherited)",
324 | "@executable_path/Frameworks",
325 | );
326 | OTHER_LDFLAGS = (
327 | "$(inherited)",
328 | "-framework",
329 | shared,
330 | );
331 | PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp;
332 | PRODUCT_NAME = "$(TARGET_NAME)";
333 | SWIFT_VERSION = 5.0;
334 | TARGETED_DEVICE_FAMILY = "1,2";
335 | };
336 | name = Debug;
337 | };
338 | 7555FFA7242A565B00829871 /* Release */ = {
339 | isa = XCBuildConfiguration;
340 | buildSettings = {
341 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
342 | CODE_SIGN_STYLE = Automatic;
343 | DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
344 | ENABLE_PREVIEWS = YES;
345 | FRAMEWORK_SEARCH_PATHS = (
346 | "$(inherited)",
347 | "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"
348 | );
349 | INFOPLIST_FILE = iosApp/Info.plist;
350 | IPHONEOS_DEPLOYMENT_TARGET = 16.0;
351 | LD_RUNPATH_SEARCH_PATHS = (
352 | "$(inherited)",
353 | "@executable_path/Frameworks",
354 | );
355 | OTHER_LDFLAGS = (
356 | "$(inherited)",
357 | "-framework",
358 | shared,
359 | );
360 | PRODUCT_BUNDLE_IDENTIFIER = orgIdentifier.iosApp;
361 | PRODUCT_NAME = "$(TARGET_NAME)";
362 | SWIFT_VERSION = 5.0;
363 | TARGETED_DEVICE_FAMILY = "1,2";
364 | };
365 | name = Release;
366 | };
367 | /* End XCBuildConfiguration section */
368 |
369 | /* Begin XCConfigurationList section */
370 | 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = {
371 | isa = XCConfigurationList;
372 | buildConfigurations = (
373 | 7555FFA3242A565B00829871 /* Debug */,
374 | 7555FFA4242A565B00829871 /* Release */,
375 | );
376 | defaultConfigurationIsVisible = 0;
377 | defaultConfigurationName = Release;
378 | };
379 | 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = {
380 | isa = XCConfigurationList;
381 | buildConfigurations = (
382 | 7555FFA6242A565B00829871 /* Debug */,
383 | 7555FFA7242A565B00829871 /* Release */,
384 | );
385 | defaultConfigurationIsVisible = 0;
386 | defaultConfigurationName = Release;
387 | };
388 | /* End XCConfigurationList section */
389 | };
390 | rootObject = 7555FF73242A565900829871 /* Project object */;
391 | }
--------------------------------------------------------------------------------