diff --git a/.editorconfig b/.editorconfig index 78d7e9abf..75cf3832d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,6 @@ -[*.{kt,kts}] -disabled_rules = import-ordering, experimental:argument-list-wrapping, indent -insert_final_newline = true -# ij_kotlin_allow_trailing_comma = false -# ij_kotlin_allow_trailing_comma_on_call_site = false -# indent_size = unset \ No newline at end of file +root = true + +[*] +ktlint_standard_final-newline = disabled +ktlint_standard_no-consecutive-comments = disabled +ktlint_function_naming_ignore_when_annotated_with = Composable \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3e8aacf4..89baac435 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Build & Test on: workflow_dispatch: @@ -7,7 +7,7 @@ on: jobs: build: - name: ๐Ÿ”จ Build + name: ๐Ÿ”จ Build & Test runs-on: ubuntu-latest steps: @@ -15,33 +15,16 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: '17' - - name: Make gradle executable - run: chmod +x ./gradlew + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Build with gradle - run: ./gradlew build --stacktrace - -# unit-tests: -# name: ๐Ÿงช Run Tests -# runs-on: ubuntu-latest -# steps: -# -# - name: Checkout code -# uses: actions/checkout@v2 -# -# - name: Make gradle executable -# run: chmod +x ./gradlew -# -# - name: Execute unit tests -# run: ./gradlew test --stacktrace -# -# - name: Generate test report -# uses: actions/upload-artifact@v2 -# with: -# name: unit_tests_report.html -# path: androidApp/build/reports/tests/testDebugUnitTest/ \ No newline at end of file + run: ./gradlew :shared:clean :shared:build --stacktrace + + - name: Execute unit tests + run: ./gradlew :shared:allTests --stacktrace \ No newline at end of file diff --git a/.github/workflows/deployAndroidDebug.yml b/.github/workflows/deployAndroidDebug.yml index 2477f4888..698d06946 100644 --- a/.github/workflows/deployAndroidDebug.yml +++ b/.github/workflows/deployAndroidDebug.yml @@ -1,4 +1,4 @@ -name: Deploy Android Debug +name: Build & Deploy Android Debug on: workflow_dispatch: inputs: @@ -16,42 +16,23 @@ env: jobs: build: - name: ๐Ÿ”จ Build + name: ๐Ÿ”จ Build & Deploy runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: adopt java-version: "17" - - name: Make gradle executable - run: chmod +x ./gradlew + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 - name: Build with Gradle - run: ./gradlew build --stacktrace - - deploy: - name: ๐Ÿš€ Deploy to Firebase App Distribution - needs: - - build - runs-on: ubuntu-latest - steps: - - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: adopt - java-version: "17" - - - name: Make gradle executable - run: chmod +x ./gradlew + run: ./gradlew :shared:clean :shared:build --stacktrace - name: Get local.properties from secrets run: echo "${{secrets.LOCAL_PROPERTIES }}" > $GITHUB_WORKSPACE/local.properties diff --git a/appAndroid/build.gradle.kts b/appAndroid/build.gradle.kts index 5b8148fd1..32298375e 100644 --- a/appAndroid/build.gradle.kts +++ b/appAndroid/build.gradle.kts @@ -15,16 +15,18 @@ android { minSdk = 24 targetSdk = compileSdk - versionCode = if (System.getenv("VERSION_CODE").isNullOrEmpty()) { - 1 - } else { - System.getenv("VERSION_CODE").toInt() - } - versionName = if (System.getenv("VERSION_NAME").isNullOrEmpty()) { - "1.0.0" - } else { - System.getenv("VERSION_NAME")?.toString() - } + versionCode = + if (System.getenv("VERSION_CODE").isNullOrEmpty()) { + 1 + } else { + System.getenv("VERSION_CODE").toInt() + } + versionName = + if (System.getenv("VERSION_NAME").isNullOrEmpty()) { + "1.0.0" + } else { + System.getenv("VERSION_NAME")?.toString() + } testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } @@ -34,7 +36,7 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } @@ -78,14 +80,4 @@ dependencies { implementation(libs.firebase.analytics) implementation(libs.firebase.crashlytics) implementation(libs.firebase.performance) - - testImplementation(libs.jUnitKtx) - testImplementation(libs.kotlinX.coroutines.test) - testImplementation(libs.mockk) - testImplementation(libs.kotlin.test) - testImplementation(libs.archTestCore) - testImplementation(libs.robolectric) - - androidTestImplementation(libs.test.rules) - androidTestImplementation(libs.test.runner) } diff --git a/appAndroid/src/main/java/com/vickbt/notflix/NotflixApplication.kt b/appAndroid/src/main/java/com/vickbt/notflix/NotflixApplication.kt index a7f2ec277..36fd44c4a 100644 --- a/appAndroid/src/main/java/com/vickbt/notflix/NotflixApplication.kt +++ b/appAndroid/src/main/java/com/vickbt/notflix/NotflixApplication.kt @@ -8,7 +8,6 @@ import org.koin.android.ext.koin.androidLogger import org.koin.core.logger.Level class NotflixApplication : Application() { - override fun onCreate() { super.onCreate() diff --git a/appAndroid/src/main/java/com/vickbt/notflix/ui/activity/MainActivity.kt b/appAndroid/src/main/java/com/vickbt/notflix/ui/activity/MainActivity.kt index f11c17007..3e0067ca3 100644 --- a/appAndroid/src/main/java/com/vickbt/notflix/ui/activity/MainActivity.kt +++ b/appAndroid/src/main/java/com/vickbt/notflix/ui/activity/MainActivity.kt @@ -8,7 +8,6 @@ import com.vickbt.shared.ui.screens.main.MainScreen @ExperimentalAnimationApi class MainActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/appDesktop/src/main/kotlin/com/vickbt/notflix/ui/windows/MainWindow.kt b/appDesktop/src/main/kotlin/com/vickbt/notflix/ui/windows/MainWindow.kt index d898212c7..f10472cf2 100644 --- a/appDesktop/src/main/kotlin/com/vickbt/notflix/ui/windows/MainWindow.kt +++ b/appDesktop/src/main/kotlin/com/vickbt/notflix/ui/windows/MainWindow.kt @@ -14,11 +14,12 @@ fun MainWindow(applicationScope: ApplicationScope) { Window( onCloseRequest = { applicationScope.exitApplication() }, title = "Notflix", - state = rememberWindowState( - position = WindowPosition.Aligned(Alignment.Center), - width = 1080.dp, - height = 800.dp, - ) + state = + rememberWindowState( + position = WindowPosition.Aligned(Alignment.Center), + width = 1080.dp, + height = 800.dp, + ), ) { MainScreen() } diff --git a/build.gradle.kts b/build.gradle.kts index 92aaafecc..7289d1215 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,6 @@ plugins { alias(libs.plugins.ktLint) alias(libs.plugins.detekt) - alias(libs.plugins.gradleVersionUpdates) } allprojects { @@ -45,16 +44,6 @@ subprojects { apply(plugin = "io.gitlab.arturbosch.detekt") detekt { parallel = true - config = files("${project.rootDir}/config/detekt/detekt.yml") + config.setFrom(files("${project.rootDir}/config/detekt/detekt.yml")) } - - tasks.withType { - checkForGradleUpdate = true - outputDir = "build/dependencyUpdates" - reportfileName = "report" - } -} - -tasks.register("clean").configure { - delete("build") // dependencyUpdates task, for example, writes here } diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 5fa9e9d13..e8ac76deb 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -85,7 +85,7 @@ complexity: threshold: 10 includeStaticDeclarations: false includePrivateDeclarations: false - ComplexMethod: + CyclomaticComplexMethod: active: true threshold: 30 ignoreSingleWhenExpression: false @@ -266,141 +266,6 @@ exceptions: - 'RuntimeException' - 'Throwable' -formatting: - active: true - android: false - autoCorrect: true - AnnotationOnSeparateLine: - active: false - autoCorrect: true - AnnotationSpacing: - active: false - autoCorrect: true - ArgumentListWrapping: - active: false - autoCorrect: true - indentSize: 4 - maxLineLength: 120 - ChainWrapping: - active: true - autoCorrect: true - CommentSpacing: - active: true - autoCorrect: true - EnumEntryNameCase: - active: false - autoCorrect: true - Filename: - active: true - FinalNewline: - active: true - autoCorrect: true - insertFinalNewLine: true - ImportOrdering: - active: false - autoCorrect: true - layout: '*,java.**,javax.**,kotlin.**,^' - Indentation: - active: false - autoCorrect: true - indentSize: 4 - continuationIndentSize: 4 - MaximumLineLength: - active: true - maxLineLength: 120 - ignoreBackTickedIdentifier: false - ModifierOrdering: - active: true - autoCorrect: true - MultiLineIfElse: - active: true - autoCorrect: true - NoBlankLineBeforeRbrace: - active: true - autoCorrect: true - NoConsecutiveBlankLines: - active: true - autoCorrect: true - NoEmptyClassBody: - active: true - autoCorrect: true - NoEmptyFirstLineInMethodBlock: - active: false - autoCorrect: true - NoLineBreakAfterElse: - active: true - autoCorrect: true - NoLineBreakBeforeAssignment: - active: true - autoCorrect: true - NoMultipleSpaces: - active: true - autoCorrect: true - NoSemicolons: - active: true - autoCorrect: true - NoTrailingSpaces: - active: true - autoCorrect: true - NoUnitReturn: - active: true - autoCorrect: true - NoUnusedImports: - active: true - autoCorrect: true - NoWildcardImports: - active: false - PackageName: - active: true - autoCorrect: true - ParameterListWrapping: - active: true - autoCorrect: true - indentSize: 4 - maxLineLength: 120 - SpacingAroundAngleBrackets: - active: false - autoCorrect: true - SpacingAroundColon: - active: true - autoCorrect: true - SpacingAroundComma: - active: true - autoCorrect: true - SpacingAroundCurly: - active: true - autoCorrect: true - SpacingAroundDot: - active: true - autoCorrect: true - SpacingAroundDoubleColon: - active: false - autoCorrect: true - SpacingAroundKeyword: - active: true - autoCorrect: true - SpacingAroundOperators: - active: true - autoCorrect: true - SpacingAroundParens: - active: true - autoCorrect: true - SpacingAroundRangeOperator: - active: true - autoCorrect: true - SpacingAroundUnaryOperator: - active: false - autoCorrect: true - SpacingBetweenDeclarationsWithAnnotations: - active: false - autoCorrect: true - SpacingBetweenDeclarationsWithComments: - active: false - autoCorrect: true - StringTemplate: - active: true - autoCorrect: true - naming: active: true BooleanPropertyNaming: @@ -417,7 +282,6 @@ naming: parameterPattern: '[a-z][A-Za-z0-9]*' privateParameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' - ignoreOverridden: true EnumNaming: active: true excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] @@ -439,7 +303,6 @@ naming: excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' excludeClassPattern: '$^' - ignoreOverridden: true ignoreAnnotated: - 'Composable' FunctionParameterNaming: @@ -447,7 +310,6 @@ naming: excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**' ] parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' - ignoreOverridden: true InvalidPackageDeclaration: active: false excludes: [ '**/*.kts' ] @@ -493,7 +355,6 @@ naming: variablePattern: '[a-z][A-Za-z0-9]*' privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' - ignoreOverridden: true performance: active: true @@ -522,8 +383,6 @@ potential-bugs: active: false DoubleMutabilityForCollection: active: false - DuplicateCaseInWhenExpression: - active: true EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -536,7 +395,7 @@ potential-bugs: active: false IgnoredReturnValue: active: false - restrictToAnnotatedMethods: true + restrictToConfig: true returnValueAnnotations: - '*.CheckResult' - '*.CheckReturnValue' @@ -560,13 +419,8 @@ potential-bugs: ignoreOnClassesPattern: '' MapGetWithNotNullAssertionOperator: active: false - MissingWhenCase: - active: true - allowElseExpression: true NullableToStringCall: active: false - RedundantElseInWhen: - active: true UnconditionalJumpStatementInLoop: active: false UnnecessaryNotNullOperator: @@ -596,7 +450,7 @@ style: active: false DataClassContainsFunctions: active: false - conversionFunctionPrefix: 'to' + conversionFunctionPrefix: [to] DataClassShouldBeImmutable: active: false DestructuringDeclarationWithTooManyEntries: @@ -615,7 +469,7 @@ style: includeLineWrapping: false ForbiddenComment: active: true - values: + comments: - 'FIXME:' - 'STOPSHIP:' ## - 'TODO:' @@ -629,29 +483,16 @@ style: methods: - 'kotlin.io.print' - 'kotlin.io.println' - ForbiddenPublicDataClass: - active: true - excludes: [ '**' ] - ignorePackages: - - '*.internal' - - '*.internal.*' ForbiddenVoid: active: false - ignoreOverridden: false ignoreUsageInGenerics: false FunctionOnlyReturningConstant: active: true ignoreOverridableFunction: true ignoreActualFunction: true - excludedFunctions: '' + excludedFunctions: [] ignoreAnnotated: - 'dagger.Provides' - LibraryCodeMustSpecifyReturnType: - active: true - excludes: [ '**' ] - LibraryEntitiesShouldNotBePublic: - active: true - excludes: [ '**' ] LoopWithTooManyJumpStatements: active: true maxJumpCount: 1 @@ -673,8 +514,6 @@ style: ignoreEnums: false ignoreRanges: false ignoreExtensionFunctions: true - MandatoryBracesIfStatements: - active: false MandatoryBracesLoops: active: false MaxLineLength: @@ -701,7 +540,7 @@ style: active: true OptionalUnit: active: false - OptionalWhenBraces: + BracesOnWhenStatements: active: false PreferToOverPairSyntax: active: false @@ -716,7 +555,7 @@ style: ReturnCount: active: true max: 5 - excludedFunctions: 'equals' + excludedFunctions: [equals] excludeLabeled: false excludeReturnFromLambda: true excludeGuardClauses: false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 72eee98b2..1d85a887f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,21 +1,20 @@ [versions] kotlin = "1.9.21" gradle = "8.1.0" -ktLint = "11.6.0" -detekt = "1.19.0" -gradleVersionUpdate = "0.50.0" -googleServices = "4.4.0" -firebaseAppDistribution = "4.0.1" -firebaseCrashlytics = "2.9.9" +ktLint = "12.1.1" +detekt = "1.23.6" +googleServices = "4.4.2" +firebaseAppDistribution = "5.0.0" +firebaseCrashlytics = "3.0.2" firebasePerformance = "1.4.2" nativeCocoapod = "1.9.0" # Kotlin Multiplatform Version -kotlinxCoroutines = "1.7.3" -koinCore = "3.5.3" +kotlinxCoroutines = "1.8.1" +koinCore = "3.5.6" koinCompose = "1.1.5" -koinComposeViewModel = "1.2.0-Beta4" -koinAndroid = "3.5.3" +koinComposeViewModel = "1.2.0-Beta5" +koinAndroid = "3.5.6" koinAndroidxCompose = "3.5.3" composeMultiplatform = "1.5.11" kotlinxSerializationJson = "1.6.2" @@ -33,9 +32,6 @@ datastore = "1.1.1" #Android Versions androidxActivity = "1.8.2" -#Desktop Versions -kamel = "0.4.0" - androidxCore = "1.12.0" material = "1.11.0" coroutines = "1.5.2" @@ -55,8 +51,6 @@ turbine = "0.12.3" [plugins] ktLint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktLint" } detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" } -gradleVersionUpdates = { id = "com.github.ben-manes.versions", version.ref = "gradleVersionUpdate" } -#kotlinX-testResources = { id = "com.goncalossilva.resources", version.ref = "kotlinxTestResources" } multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } nativeCocoapod = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" } android-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } @@ -85,7 +79,6 @@ ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-contentNegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" } ktor-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" } ktor-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" } -ktor-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } ktor-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } ktor-android = { module = "io.ktor:ktor-client-android", version.ref = "ktor" } ktor-java = { module = "io.ktor:ktor-client-java", version.ref = "ktor" } @@ -120,19 +113,9 @@ firebase-performance = { module = "com.google.firebase:firebase-perf" } #Tests Lib Dependencies mockk = { module = "io.mockk:mockk", version.ref = "mockk" } -# kotlinX-testResources = { module = "com.goncalossilva:resources", version.ref = "kotlinxTestResources" } kotlinX-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinxCoroutines" } - -jUnit = { module = "junit:junit" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -googleTruth = { module = "com.google.truth:truth", version.ref = "truth" } robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } -jUnitKtx = { module = "androidx.test.ext:junit-ktx", version.ref = "jUnitKtx" } -espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" } -test-core = { module = "androidx.test:core-ktx", version.ref = "test" } -archTestCore = { module = "androidx.arch.core:core-testing", version.ref = "archTestCore" } -test-rules = { module = "androidx.test:rules", version.ref = "test" } -test-runner = { module = "androidx.test:runner", version.ref = "test" } turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" } [bundles] diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index b1cf759c3..9e34a8c1e 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -131,7 +131,7 @@ buildkonfig { buildConfigField( STRING, "API_KEY", - gradleLocalProperties(rootDir).getProperty("api_key") ?: "" + gradleLocalProperties(rootDir).getProperty("api_key") ?: "", ) } } diff --git a/shared/src/androidMain/kotlin/com/vickbt/shared/di/Module.kt b/shared/src/androidMain/kotlin/com/vickbt/shared/di/Module.kt index ff1fbba66..dedaafa16 100644 --- a/shared/src/androidMain/kotlin/com/vickbt/shared/di/Module.kt +++ b/shared/src/androidMain/kotlin/com/vickbt/shared/di/Module.kt @@ -5,7 +5,8 @@ import com.vickbt.shared.utils.DatastoreFactory import org.koin.core.module.Module import org.koin.dsl.module -actual fun platformModule(): Module = module { - single { DatabaseDriverFactory(context = get()) } - single { DatastoreFactory(context = get()).createDatastore() } -} +actual fun platformModule(): Module = + module { + single { DatabaseDriverFactory(context = get()) } + single { DatastoreFactory(context = get()).createDatastore() } + } diff --git a/shared/src/androidMain/kotlin/com/vickbt/shared/utils/ContextUtils.kt b/shared/src/androidMain/kotlin/com/vickbt/shared/utils/ContextUtils.kt index c785b3074..0e2fbd4f0 100644 --- a/shared/src/androidMain/kotlin/com/vickbt/shared/utils/ContextUtils.kt +++ b/shared/src/androidMain/kotlin/com/vickbt/shared/utils/ContextUtils.kt @@ -3,12 +3,12 @@ package com.vickbt.shared.utils import android.content.Context object ContextUtils { - private var kmpApplicationContext: Context? = null val context - get() = kmpApplicationContext - ?: error("Android context has not been set. Please call setContext in your Application's onCreate.") + get() = + kmpApplicationContext + ?: error("Android context has not been set. Please call setContext in your Application's onCreate.") fun setContext(context: Context) { kmpApplicationContext = context.applicationContext diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/cache/sqldelight/daos/FavoriteMovieDao.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/cache/sqldelight/daos/FavoriteMovieDao.kt index 2424c8d16..1d10b8922 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/cache/sqldelight/daos/FavoriteMovieDao.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/cache/sqldelight/daos/FavoriteMovieDao.kt @@ -12,7 +12,6 @@ import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime class FavoriteMovieDao(private val databaseDriverFactory: DatabaseDriverFactory) { - val appDatabase = AppDatabase(driver = databaseDriverFactory.createDriver()) val dbQuery = appDatabase.appDatabaseQueries @@ -35,8 +34,9 @@ class FavoriteMovieDao(private val databaseDriverFactory: DatabaseDriverFactory) title = movie.title, voteAverage = movie.voteAverage, voteCount = movie.voteCount?.toLong(), - createdAt = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) - .toString() + createdAt = + Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) + .toString(), ) } } @@ -45,8 +45,7 @@ class FavoriteMovieDao(private val databaseDriverFactory: DatabaseDriverFactory) fun getAllFavoriteMovies() = dbQuery.getAllFavoriteMovies().asFlow().mapToList(Dispatchers.IO) /**Get single movies from FavoriteMovie table based on its ID*/ - fun getFavoriteMovie(movieId: Int) = - dbQuery.getFavoriteMovie(id = movieId.toLong()).executeAsOne() + fun getFavoriteMovie(movieId: Int) = dbQuery.getFavoriteMovie(id = movieId.toLong()).executeAsOne() /**Delete favorite movie details based on its ID*/ fun deleteFavouriteMovie(movieId: Int) = dbQuery.deleteFavoriteMovie(id = movieId.toLong()) @@ -55,6 +54,5 @@ class FavoriteMovieDao(private val databaseDriverFactory: DatabaseDriverFactory) fun deleteAllFavouriteMovies() = dbQuery.deleteAllFavoriteMovies() /**Return value depending on whether movie details is in FavoriteMovie table*/ - fun isMovieFavorite(movieId: Int) = - dbQuery.isMovieFavorite(id = movieId.toLong()).executeAsOneOrNull() + fun isMovieFavorite(movieId: Int) = dbQuery.isMovieFavorite(id = movieId.toLong()).executeAsOneOrNull() } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/FavoritesRepositoryImpl.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/FavoritesRepositoryImpl.kt index 602cfb86a..2b1748a4b 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/FavoritesRepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/FavoritesRepositoryImpl.kt @@ -9,7 +9,6 @@ import kotlinx.coroutines.flow.map class FavoritesRepositoryImpl(private val favoriteMovieDao: FavoriteMovieDao) : FavoritesRepository { - override suspend fun getFavouriteMovies(): Flow> { return favoriteMovieDao.getAllFavoriteMovies() .map { it.map { movieDetail -> movieDetail.toDomain() } } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MovieDetailsRepositoryImpl.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MovieDetailsRepositoryImpl.kt index a356f257a..9b02c6d40 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MovieDetailsRepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MovieDetailsRepositoryImpl.kt @@ -21,9 +21,8 @@ import kotlinx.coroutines.flow.flowOf class MovieDetailsRepositoryImpl( private val httpClient: HttpClient, - private val favoriteMovieDao: FavoriteMovieDao + private val favoriteMovieDao: FavoriteMovieDao, ) : MovieDetailsRepository { - override suspend fun fetchMovieDetails(movieId: Int): Flow> { val isMovieCached = isMovieFavorite(movieId = movieId) @@ -40,7 +39,7 @@ class MovieDetailsRepositoryImpl( val response = httpClient.get(urlString = "movie/$movieId").body() response.toDomain() - } + }, ) } } @@ -51,22 +50,23 @@ class MovieDetailsRepositoryImpl( val response = httpClient.get(urlString = "movie/$movieId/credits").body() response.toDomain() - } + }, ) } override suspend fun fetchSimilarMovies( movieId: Int, - page: Int + page: Int, ): Flow?>> { return flowOf( safeApiCall { - val response = httpClient.get(urlString = "movie/$movieId/similar") { - parameter("page", page) - }.body() + val response = + httpClient.get(urlString = "movie/$movieId/similar") { + parameter("page", page) + }.body() response.movies?.map { it.toDomain() } - } + }, ) } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MoviesRepositoryImpl.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MoviesRepositoryImpl.kt index 6f8d2f8e9..3d9f5bb61 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MoviesRepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/MoviesRepositoryImpl.kt @@ -14,58 +14,61 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf class MoviesRepositoryImpl constructor( - private val httpClient: HttpClient + private val httpClient: HttpClient, ) : MoviesRepository { - override suspend fun fetchNowPlayingMovies(page: Int): Flow?>> { return flowOf( safeApiCall { - val response = httpClient.get(urlString = "movie/now_playing") { - parameter("page", page) - }.body() + val response = + httpClient.get(urlString = "movie/now_playing") { + parameter("page", page) + }.body() response.movies?.map { it.toDomain() } - } + }, ) } override suspend fun fetchTrendingMovies( mediaType: String, timeWindow: String, - page: Int + page: Int, ): Flow?>> { return flowOf( safeApiCall { - val response = httpClient.get(urlString = "trending/$mediaType/$timeWindow") { - parameter("page", page) - }.body() + val response = + httpClient.get(urlString = "trending/$mediaType/$timeWindow") { + parameter("page", page) + }.body() response.movies?.map { it.toDomain() } - } + }, ) } override suspend fun fetchPopularMovies(page: Int): Flow?>> { return flowOf( safeApiCall { - val response = httpClient.get(urlString = "movie/popular") { - parameter("page", page) - }.body() + val response = + httpClient.get(urlString = "movie/popular") { + parameter("page", page) + }.body() response.movies?.map { it.toDomain() } - } + }, ) } override suspend fun fetchUpcomingMovies(page: Int): Flow?>> { return flowOf( safeApiCall { - val response = httpClient.get(urlString = "movie/upcoming") { - parameter("page", page) - }.body() + val response = + httpClient.get(urlString = "movie/upcoming") { + parameter("page", page) + }.body() response.movies?.map { it.toDomain() } - } + }, ) } @@ -81,17 +84,18 @@ class MoviesRepositoryImpl constructor( override suspend fun searchMovie( movieName: String, - page: Int + page: Int, ): Flow?>> { return flowOf( safeApiCall { - val response = httpClient.get(urlString = "search/movie") { - parameter("query", movieName) - parameter("page", page) - }.body() + val response = + httpClient.get(urlString = "search/movie") { + parameter("query", movieName) + parameter("page", page) + }.body() response.movies?.map { it.toDomain() } - } + }, ) } } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/SettingsRepositoryImpl.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/SettingsRepositoryImpl.kt index ee9afc0bf..c678d68a9 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/SettingsRepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/datasources/SettingsRepositoryImpl.kt @@ -11,10 +11,12 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map class SettingsRepositoryImpl( - private val dataStore: DataStore + private val dataStore: DataStore, ) : SettingsRepository { - - override suspend fun savePreferenceSelection(key: String, selection: Int) { + override suspend fun savePreferenceSelection( + key: String, + selection: Int, + ) { dataStore.edit { preferences -> preferences[intPreferencesKey(key)] = selection } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/DtoToDomain.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/DtoToDomain.kt index 020952366..87ac7a856 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/DtoToDomain.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/DtoToDomain.kt @@ -28,7 +28,7 @@ fun MovieDto.toDomain(): Movie { video = this.video, voteAverage = this.voteAverage, voteCount = this.voteCount, - mediaType = this.mediaType + mediaType = this.mediaType, ) } @@ -51,7 +51,7 @@ fun MovieDetailsDto.toDomain(): MovieDetails { title = this.title, video = this.video, voteAverage = this.voteAverage, - voteCount = this.voteCount + voteCount = this.voteCount, ) } @@ -63,14 +63,14 @@ fun ActorDto.toDomain(): Actor { id = this.id, name = this.name, originalName = this.originalName, - profilePath = this.profilePath + profilePath = this.profilePath, ) } fun CastDto.toDomain(): Cast { return Cast( actor = this.actor?.map { it.toDomain() }, - id = this.id + id = this.id, ) } @@ -85,7 +85,7 @@ fun VideoDto.toDomain(): Video { publishedAt = this.publishedAt, site = this.site, size = this.size, - type = this.type + type = this.type, ) } @@ -100,6 +100,6 @@ fun ErrorResponseDto.toDomain(): ErrorResponse { return ErrorResponse( success = this.success, statusCode = this.statusCode, - statusMessage = this.statusMessage + statusMessage = this.statusMessage, ) } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/EntityToDomain.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/EntityToDomain.kt index f1774f55a..f7a99337e 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/EntityToDomain.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/mappers/EntityToDomain.kt @@ -22,6 +22,6 @@ fun FavoriteMovieEntity.toDomain(): MovieDetails { title = this.title, video = null, voteAverage = this.voteAverage, - voteCount = this.voteCount?.toInt() + voteCount = this.voteCount?.toInt(), ) } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ActorDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ActorDto.kt index 436efbed7..2998f96a7 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ActorDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ActorDto.kt @@ -5,25 +5,18 @@ import kotlinx.serialization.Serializable @Serializable data class ActorDto( - @SerialName("cast_id") val castId: Int? = null, - @SerialName("character") val character: String? = null, - @SerialName("credit_id") val creditId: String? = null, - @SerialName("id") val id: Int, - @SerialName("name") val name: String? = null, - @SerialName("original_name") val originalName: String? = null, - @SerialName("profile_path") - val profilePath: String? = null + val profilePath: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ApiError.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ApiError.kt index 86512362a..146d54463 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ApiError.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ApiError.kt @@ -5,13 +5,10 @@ import kotlinx.serialization.Serializable @Serializable data class ApiError( - @SerialName("status_code") val statusCode: Int?, - @SerialName("status_message") val statusMessage: String?, - @SerialName("success") - val success: Boolean? + val success: Boolean?, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/CastDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/CastDto.kt index a6192fe8f..7dfacf1dd 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/CastDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/CastDto.kt @@ -5,10 +5,8 @@ import kotlinx.serialization.Serializable @Serializable data class CastDto( - @SerialName("cast") val actor: List? = null, - @SerialName("id") - val id: Int + val id: Int, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/DatesDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/DatesDto.kt index 12df74db2..e0c11ae5b 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/DatesDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/DatesDto.kt @@ -7,7 +7,6 @@ import kotlinx.serialization.Serializable data class DatesDto( @SerialName("maximum") val maximum: String? = null, - @SerialName("minimum") - val minimum: String? = null + val minimum: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ErrorResponseDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ErrorResponseDto.kt index db5713c7c..cb7066740 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ErrorResponseDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/ErrorResponseDto.kt @@ -7,10 +7,8 @@ import kotlinx.serialization.Serializable data class ErrorResponseDto( @SerialName("success") val success: Boolean, - @SerialName("status_code") val statusCode: Int, - @SerialName("status_message") - val statusMessage: String + val statusMessage: String, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/GenreDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/GenreDto.kt index 28fde62a1..a138e28b2 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/GenreDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/GenreDto.kt @@ -5,10 +5,8 @@ import kotlinx.serialization.Serializable @Serializable data class GenreDto( - @SerialName("id") val id: Int? = null, - @SerialName("name") - val name: String? = null + val name: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDetailsDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDetailsDto.kt index 30763330e..b2605d59a 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDetailsDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDetailsDto.kt @@ -5,64 +5,44 @@ import kotlinx.serialization.Serializable @Serializable data class MovieDetailsDto( - @SerialName("adult") val adult: Boolean? = null, - @SerialName("backdrop_path") val backdropPath: String? = null, - @SerialName("genres") val genres: List? = null, - @SerialName("homepage") val homepage: String? = null, - @SerialName("id") val id: Int, - @SerialName("imdb_id") val imdbId: String? = null, - @SerialName("original_language") val originalLanguage: String? = null, - @SerialName("original_title") val originalTitle: String? = null, - @SerialName("overview") val overview: String? = null, - @SerialName("popularity") val popularity: Double? = null, - @SerialName("poster_path") val posterPath: String? = null, - @SerialName("release_date") val releaseDate: String? = null, - @SerialName("runtime") val runtime: Int? = null, - @SerialName("spoken_languages") val spokenLanguages: List? = null, - @SerialName("status") val status: String? = null, - @SerialName("tagline") val tagline: String? = null, - @SerialName("title") val title: String? = null, - @SerialName("video") val video: Boolean? = null, - @SerialName("vote_average") val voteAverage: Double? = null, - @SerialName("vote_count") - val voteCount: Int? = null + val voteCount: Int? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDto.kt index c828f465c..53871ff09 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieDto.kt @@ -7,47 +7,32 @@ import kotlinx.serialization.Serializable data class MovieDto( @SerialName("adult") val adult: Boolean? = null, - @SerialName("backdrop_path") val backdropPath: String? = null, - @SerialName("genre_ids") val genreIds: List? = null, - @SerialName("id") val id: Int, - @SerialName("original_language") val originalLanguage: String? = null, - @SerialName("original_title") val originalTitle: String? = null, - @SerialName("overview") val overview: String? = null, - @SerialName("popularity") val popularity: Double? = null, - @SerialName("poster_path") val posterPath: String? = null, - @SerialName("release_date") val releaseDate: String? = null, - @SerialName("title") val title: String? = null, - @SerialName("video") val video: Boolean? = null, - @SerialName("vote_average") val voteAverage: Double? = null, - @SerialName("vote_count") val voteCount: Int? = null, - @SerialName("media_type") - val mediaType: String? = null - + val mediaType: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieResultsDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieResultsDto.kt index f6fed87a4..e214b77f1 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieResultsDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieResultsDto.kt @@ -7,13 +7,10 @@ import kotlinx.serialization.Serializable data class MovieResultsDto( @SerialName("page") val page: Int? = null, - @SerialName("results") val movies: List? = null, - @SerialName("total_pages") val totalPages: Int? = null, - @SerialName("total_results") - val totalResults: Int? = null + val totalResults: Int? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieVideoDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieVideoDto.kt index 908655f88..0edaac757 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieVideoDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/MovieVideoDto.kt @@ -5,10 +5,8 @@ import kotlinx.serialization.Serializable @Serializable data class MovieVideoDto( - @SerialName("id") val id: Int? = null, - @SerialName("results") - val videos: List? = null + val videos: List? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/SpokenLanguageDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/SpokenLanguageDto.kt index 220460627..5831975fa 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/SpokenLanguageDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/SpokenLanguageDto.kt @@ -5,13 +5,10 @@ import kotlinx.serialization.Serializable @Serializable data class SpokenLanguageDto( - @SerialName("english_name") val englishName: String? = null, - @SerialName("iso_639_1") val iso6391: String? = null, - @SerialName("name") - val name: String? = null + val name: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/VideoDto.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/VideoDto.kt index 4e6a12130..d7c6d6c53 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/VideoDto.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/models/VideoDto.kt @@ -5,34 +5,24 @@ import kotlinx.serialization.Serializable @Serializable data class VideoDto( - @SerialName("id") val id: String? = null, - @SerialName("iso_3166_1") val iso31661: String? = null, - @SerialName("iso_639_1") val iso6391: String? = null, - @SerialName("key") val key: String? = null, - @SerialName("name") val name: String? = null, - @SerialName("official") val official: Boolean? = null, - @SerialName("published_at") val publishedAt: String? = null, - @SerialName("site") val site: String? = null, - @SerialName("size") val size: Int? = null, - @SerialName("type") - val type: String? = null + val type: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/utils/SafeApiCall.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/utils/SafeApiCall.kt index 819c727fe..a369899df 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/utils/SafeApiCall.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/data/network/utils/SafeApiCall.kt @@ -40,11 +40,11 @@ suspend fun safeApiCall(apiCall: suspend () -> T): ResultState { * */ internal suspend fun parseNetworkError( errorResponse: HttpResponse? = null, - exception: Exception? = null + exception: Exception? = null, ): Exception { throw errorResponse?.body()?.toDomain() ?: ErrorResponse( success = false, statusCode = 0, - statusMessage = exception?.message ?: "Error" + statusMessage = exception?.message ?: "Error", ) } diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/di/CommonModule.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/di/CommonModule.kt index bf07b2918..4f76ced41 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/di/CommonModule.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/di/CommonModule.kt @@ -34,63 +34,65 @@ import org.koin.compose.viewmodel.dsl.viewModelOf import org.koin.core.module.Module import org.koin.dsl.module -fun commonModule(enableNetworkLogs: Boolean) = module { - /** - * Creates a http client for Ktor that is provided to the - * API client via constructor injection - */ - single { - HttpClient { - expectSuccess = true - addDefaultResponseValidation() +fun commonModule(enableNetworkLogs: Boolean) = + module { + /** + * Creates a http client for Ktor that is provided to the + * API client via constructor injection + */ + single { + HttpClient { + expectSuccess = true + addDefaultResponseValidation() - defaultRequest { - url { - protocol = URLProtocol.HTTPS - host = BASE_URL - path(URL_PATH) - parameters.append("api_key", BuildKonfig.API_KEY) + defaultRequest { + url { + protocol = URLProtocol.HTTPS + host = BASE_URL + path(URL_PATH) + parameters.append("api_key", BuildKonfig.API_KEY) + } } - } - if (enableNetworkLogs) { - install(Logging) { - level = LogLevel.HEADERS - logger = object : Logger { - override fun log(message: String) { - Napier.i(tag = "Http Client", message = message) - } + if (enableNetworkLogs) { + install(Logging) { + level = LogLevel.HEADERS + logger = + object : Logger { + override fun log(message: String) { + Napier.i(tag = "Http Client", message = message) + } + } + }.also { + Napier.base(DebugAntilog()) } - }.also { - Napier.base(DebugAntilog()) } - } - install(ContentNegotiation) { - json( - Json { - ignoreUnknownKeys = true - isLenient = true - } - ) + install(ContentNegotiation) { + json( + Json { + ignoreUnknownKeys = true + isLenient = true + }, + ) + } } } - } - single { FavoriteMovieDao(databaseDriverFactory = get()) } + single { FavoriteMovieDao(databaseDriverFactory = get()) } - single { MoviesRepositoryImpl(httpClient = get()) } - single { - MovieDetailsRepositoryImpl(httpClient = get(), favoriteMovieDao = get()) - } - single { FavoritesRepositoryImpl(favoriteMovieDao = get()) } - single { SettingsRepositoryImpl(dataStore = get()) } + single { MoviesRepositoryImpl(httpClient = get()) } + single { + MovieDetailsRepositoryImpl(httpClient = get(), favoriteMovieDao = get()) + } + single { FavoritesRepositoryImpl(favoriteMovieDao = get()) } + single { SettingsRepositoryImpl(dataStore = get()) } - viewModelOf(::MainViewModel) - viewModelOf(::HomeViewModel) - viewModelOf(::DetailsViewModel) - viewModelOf(::SettingsViewModel) - viewModelOf(::FavoritesViewModel) -} + viewModelOf(::MainViewModel) + viewModelOf(::HomeViewModel) + viewModelOf(::DetailsViewModel) + viewModelOf(::SettingsViewModel) + viewModelOf(::FavoritesViewModel) + } expect fun platformModule(): Module diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/di/Koin.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/di/Koin.kt index b1224854c..674ad0a9d 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/di/Koin.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/di/Koin.kt @@ -4,11 +4,13 @@ import org.koin.core.KoinApplication import org.koin.core.context.startKoin import org.koin.dsl.KoinAppDeclaration -fun initKoin(enableNetworkLogs: Boolean = true, appDeclaration: KoinAppDeclaration = {}) = - startKoin { - appDeclaration() - modules(platformModule(), commonModule(enableNetworkLogs = enableNetworkLogs)) - } +fun initKoin( + enableNetworkLogs: Boolean = true, + appDeclaration: KoinAppDeclaration = {}, +) = startKoin { + appDeclaration() + modules(platformModule(), commonModule(enableNetworkLogs = enableNetworkLogs)) +} // called by iOS etc // fun initKoin() = initKoin(enableNetworkLogs = false) {} diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Actor.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Actor.kt index 8cec87ee7..552870916 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Actor.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Actor.kt @@ -1,18 +1,11 @@ package com.vickbt.shared.domain.models data class Actor( - val castId: Int?, - val character: String?, - val creditId: String?, - val id: Int, - val name: String?, - val originalName: String?, - - val profilePath: String? + val profilePath: String?, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Cast.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Cast.kt index 2920bf53a..97d4d163c 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Cast.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Cast.kt @@ -1,8 +1,6 @@ package com.vickbt.shared.domain.models data class Cast( - val actor: List? = null, - - val id: Int + val id: Int, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Dates.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Dates.kt index 816b54c43..6513858d5 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Dates.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Dates.kt @@ -2,6 +2,5 @@ package com.vickbt.shared.domain.models data class Dates( val maximum: String?, - - val minimum: String? + val minimum: String?, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/ErrorResponse.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/ErrorResponse.kt index dbf02b63c..a67a676f4 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/ErrorResponse.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/ErrorResponse.kt @@ -3,5 +3,5 @@ package com.vickbt.shared.domain.models data class ErrorResponse( val success: Boolean, val statusCode: Int, - val statusMessage: String + val statusMessage: String, ) : Exception() diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Genre.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Genre.kt index 5b4bbbc8f..05cbc8dcf 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Genre.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Genre.kt @@ -1,8 +1,6 @@ package com.vickbt.shared.domain.models data class Genre( - val id: Int? = null, - - val name: String? = null + val name: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Movie.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Movie.kt index f25be479b..ee69beecd 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Movie.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/Movie.kt @@ -2,36 +2,20 @@ package com.vickbt.shared.domain.models data class Movie( val adult: Boolean? = null, - val backdropPath: String? = null, - val id: Int? = null, - val originalLanguage: String? = null, - val originalTitle: String? = null, - val overview: String? = null, - val popularity: Double? = null, - val posterPath: String? = null, - val releaseDate: String? = null, - val title: String? = null, - val video: Boolean? = null, - val voteAverage: Double? = null, - val voteCount: Int? = null, - val category: String? = null, - val isFavorite: Boolean? = null, - val cacheId: Int? = 0, - - val mediaType: String? = null + val mediaType: String? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieDetails.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieDetails.kt index f410d5f02..5742c18e7 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieDetails.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieDetails.kt @@ -1,40 +1,22 @@ package com.vickbt.shared.domain.models data class MovieDetails( - val adult: Boolean? = null, - val backdropPath: String? = null, - val homepage: String? = null, - val id: Int, - val imdbId: String? = null, - val originalLanguage: String? = null, - val originalTitle: String? = null, - val overview: String? = null, - val popularity: Double? = null, - val posterPath: String? = null, - val releaseDate: String? = null, - val runtime: Int? = null, - val status: String? = null, - val tagline: String? = null, - val title: String? = null, - val video: Boolean? = null, - val voteAverage: Double? = null, - - val voteCount: Int? = null + val voteCount: Int? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieResults.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieResults.kt index ea2cbdf42..9a65f36bb 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieResults.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieResults.kt @@ -1,12 +1,8 @@ package com.vickbt.shared.domain.models data class MovieResults( - val page: Int? = null, - val movies: List? = null, - val totalPages: Int? = null, - - val totalResults: Int? = null + val totalResults: Int? = null, ) diff --git a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieVideo.kt b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieVideo.kt index 04bbd8cbf..27167400d 100644 --- a/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieVideo.kt +++ b/shared/src/commonMain/kotlin/com/vickbt/shared/domain/models/MovieVideo.kt @@ -2,6 +2,5 @@ package com.vickbt.shared.domain.models data class MovieVideo( val id: Int? = null, - - val videos: List