From e6d75ebe75d4b004f42f08d8fc12ac97a114630a Mon Sep 17 00:00:00 2001 From: Louis FARIN Date: Sun, 27 Oct 2024 23:05:02 +0100 Subject: [PATCH] Bump dependencies --- .github/workflows/build.yml | 12 ++-- .github/workflows/release.yml | 12 ++-- build-logic/src/main/kotlin/Plugins.kt | 1 + .../kotlin/plugin/AndroidApplicationPlugin.kt | 1 - .../kotlin/plugin/AndroidComposePlugin.kt | 11 ++-- .../kotlin/plugin/AndroidFeaturePlugin.kt | 1 - .../plugin/JacocoMergeAllReportsPlugin.kt | 2 +- .../src/main/kotlin/plugin/JacocoPlugin.kt | 2 +- .../src/main/kotlin/plugin/util/Android.kt | 6 +- .../src/main/kotlin/plugin/util/Extension.kt | 6 +- .../src/main/kotlin/plugin/util/Jacoco.kt | 7 +-- .../main/kotlin/plugin/util/KotlinOptions.kt | 44 +++++++------ build.gradle.kts | 1 + .../home/container/HomeBottomSheetItem.kt | 9 ++- .../feature/home/container/HomeDestination.kt | 4 +- .../feature/home/discover/DiscoverScreen.kt | 5 +- .../feature/home/watchlist/WatchListScreen.kt | 5 +- .../somovie/feature/login/LogInLayout.kt | 2 +- feature/moviedetails/build.gradle.kts | 1 - .../moviedetails/MovieDetailsContent.kt | 32 ++++++++-- .../moviedetails/MovieDetailsHeader.kt | 4 +- .../moviedetails/MovieDetailsNavigation.kt | 4 +- .../moviedetails/MovieDetailsScreen.kt | 4 +- .../feature/movielist/MovieListNavigation.kt | 4 +- gradle/libs.versions.toml | 62 +++++++++---------- gradle/wrapper/gradle-wrapper.properties | 2 +- .../somovie/ui/common/extension/StateFlow.kt | 2 +- .../louisfn/somovie/ui/component/TopAppBar.kt | 11 +++- .../ui/component/swipe/SwipeContainer.kt | 14 ++--- .../ui/component/swipe/SwipeController.kt | 20 ++---- 30 files changed, 149 insertions(+), 142 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af7a457..2af59b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,11 +22,11 @@ jobs: - name: Checkout repositoryy uses: actions/checkout@v4 - - name: Setup java 17 + - name: Setup java 21 uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup gradle uses: ./.github/workflows/gradle-cache @@ -47,11 +47,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup java 17 + - name: Setup java 21 uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup gradle uses: ./.github/workflows/gradle-cache @@ -78,11 +78,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup java 17 + - name: Setup java 21 uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup gradle uses: ./.github/workflows/gradle-cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ecec513..3ea817f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,11 +18,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup java 17 + - name: Setup java 21 uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup gradle uses: ./.github/workflows/gradle-cache @@ -61,11 +61,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup java 17 + - name: Setup java 21 uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup gradle uses: ./.github/workflows/gradle-cache @@ -127,11 +127,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Setup java 17 + - name: Setup java 21 uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: 17 + java-version: 21 - name: Setup gradle uses: ./.github/workflows/gradle-cache diff --git a/build-logic/src/main/kotlin/Plugins.kt b/build-logic/src/main/kotlin/Plugins.kt index 2303054..4a75dc6 100644 --- a/build-logic/src/main/kotlin/Plugins.kt +++ b/build-logic/src/main/kotlin/Plugins.kt @@ -10,6 +10,7 @@ object Plugins { const val KSP = "com.google.devtools.ksp" const val HILT = "dagger.hilt.android.plugin" const val JACOCO = "org.gradle.jacoco" + const val COMPOSE_COMPILER = "org.jetbrains.kotlin.plugin.compose" const val SOMOVIE_ANDROID_APPLICATION = "somovie.android.application" const val SOMOVIE_ANDROID_LIBRARY = "somovie.android.library" diff --git a/build-logic/src/main/kotlin/plugin/AndroidApplicationPlugin.kt b/build-logic/src/main/kotlin/plugin/AndroidApplicationPlugin.kt index b109c6f..5be28bc 100644 --- a/build-logic/src/main/kotlin/plugin/AndroidApplicationPlugin.kt +++ b/build-logic/src/main/kotlin/plugin/AndroidApplicationPlugin.kt @@ -11,7 +11,6 @@ import plugin.util.configureAndroid import plugin.util.configureKotlinOptions import java.util.Properties -@Suppress("UnstableApiUsage") class AndroidApplicationPlugin : Plugin { override fun apply(target: Project) { with(target) { diff --git a/build-logic/src/main/kotlin/plugin/AndroidComposePlugin.kt b/build-logic/src/main/kotlin/plugin/AndroidComposePlugin.kt index cd4b8ec..5504c61 100644 --- a/build-logic/src/main/kotlin/plugin/AndroidComposePlugin.kt +++ b/build-logic/src/main/kotlin/plugin/AndroidComposePlugin.kt @@ -2,6 +2,7 @@ package plugin +import Plugins import debugImplementation import getLibsVersionCatalog import implementation @@ -13,6 +14,11 @@ import plugin.util.getCommonExtension class AndroidComposePlugin : Plugin { override fun apply(target: Project) { with(target) { + with(pluginManager) { + apply(Plugins.JACOCO) + apply(Plugins.COMPOSE_COMPILER) + } + val libs = getLibsVersionCatalog() val commonExtension = getCommonExtension() @@ -20,11 +26,6 @@ class AndroidComposePlugin : Plugin { buildFeatures { compose = true } - - composeOptions { - kotlinCompilerExtensionVersion = - libs.findVersion("androidxComposeCompiler").get().toString() - } } dependencies { diff --git a/build-logic/src/main/kotlin/plugin/AndroidFeaturePlugin.kt b/build-logic/src/main/kotlin/plugin/AndroidFeaturePlugin.kt index 8822210..6208718 100644 --- a/build-logic/src/main/kotlin/plugin/AndroidFeaturePlugin.kt +++ b/build-logic/src/main/kotlin/plugin/AndroidFeaturePlugin.kt @@ -36,7 +36,6 @@ class AndroidFeaturePlugin : Plugin { implementation(project(":ui:common")) implementation(project(":ui:component")) implementation(project(":ui:theme")) - implementation(libs.findLibrary("accompanist.navigationAnimation").get()) implementation(libs.findLibrary("androidx.constraintlayout.compose").get()) implementation(libs.findLibrary("androidx.lifecycle.runtime").get()) implementation(libs.findLibrary("androidx.lifecycle.viewmodel").get()) diff --git a/build-logic/src/main/kotlin/plugin/JacocoMergeAllReportsPlugin.kt b/build-logic/src/main/kotlin/plugin/JacocoMergeAllReportsPlugin.kt index b586680..e5cc4bd 100644 --- a/build-logic/src/main/kotlin/plugin/JacocoMergeAllReportsPlugin.kt +++ b/build-logic/src/main/kotlin/plugin/JacocoMergeAllReportsPlugin.kt @@ -5,12 +5,12 @@ import com.android.build.api.variant.ApplicationAndroidComponentsExtension import getLibsVersionCatalog import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.configurationcache.extensions.capitalized import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.create import org.gradle.kotlin.dsl.getByType import org.gradle.testing.jacoco.plugins.JacocoPluginExtension import org.gradle.testing.jacoco.tasks.JacocoReport +import plugin.util.capitalized import plugin.util.configureJacoco class JacocoMergeAllReportsPlugin : Plugin { diff --git a/build-logic/src/main/kotlin/plugin/JacocoPlugin.kt b/build-logic/src/main/kotlin/plugin/JacocoPlugin.kt index 7cb8184..c9ac301 100644 --- a/build-logic/src/main/kotlin/plugin/JacocoPlugin.kt +++ b/build-logic/src/main/kotlin/plugin/JacocoPlugin.kt @@ -3,9 +3,9 @@ package plugin import Plugins import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.configurationcache.extensions.capitalized import org.gradle.kotlin.dsl.register import org.gradle.testing.jacoco.tasks.JacocoReport +import plugin.util.capitalized import plugin.util.configureJacoco import plugin.util.getAndroidComponentsExtension diff --git a/build-logic/src/main/kotlin/plugin/util/Android.kt b/build-logic/src/main/kotlin/plugin/util/Android.kt index bf5d3d7..b666092 100644 --- a/build-logic/src/main/kotlin/plugin/util/Android.kt +++ b/build-logic/src/main/kotlin/plugin/util/Android.kt @@ -9,7 +9,7 @@ import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies internal fun Project.configureAndroid( - commonExtension: CommonExtension<*, *, *, *, *>, + commonExtension: CommonExtension<*, *, *, *, *, *>, ) { commonExtension.apply { compileSdk = AppConfig.COMPILE_SDK_VERSION @@ -24,8 +24,8 @@ internal fun Project.configureAndroid( } compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } buildTypes { diff --git a/build-logic/src/main/kotlin/plugin/util/Extension.kt b/build-logic/src/main/kotlin/plugin/util/Extension.kt index 2034d43..a18a02c 100644 --- a/build-logic/src/main/kotlin/plugin/util/Extension.kt +++ b/build-logic/src/main/kotlin/plugin/util/Extension.kt @@ -9,14 +9,16 @@ import com.android.build.gradle.LibraryExtension import org.gradle.api.Project import org.gradle.kotlin.dsl.findByType -internal fun Project.getCommonExtension(): CommonExtension<*, *, *, *, *> = +internal fun Project.getCommonExtension(): CommonExtension<*, *, *, *, *, *> = ( extensions.findByType() ?: extensions.findByType() - ) as CommonExtension<*, *, *, *, *> + ) as CommonExtension<*, *, *, *, *, *> internal fun Project.getAndroidComponentsExtension(): AndroidComponentsExtension<*, *, *> = ( extensions.findByType() ?: extensions.findByType() ) as AndroidComponentsExtension<*, *, *> + +internal fun String.capitalized() = this.replaceFirstChar { it.uppercase() } diff --git a/build-logic/src/main/kotlin/plugin/util/Jacoco.kt b/build-logic/src/main/kotlin/plugin/util/Jacoco.kt index e91970d..fe079da 100644 --- a/build-logic/src/main/kotlin/plugin/util/Jacoco.kt +++ b/build-logic/src/main/kotlin/plugin/util/Jacoco.kt @@ -1,7 +1,6 @@ package plugin.util import org.gradle.api.Project -import org.gradle.configurationcache.extensions.capitalized import org.gradle.testing.jacoco.tasks.JacocoReport internal fun JacocoReport.configureJacoco(project: Project, variantName: String) { @@ -14,12 +13,12 @@ internal fun JacocoReport.configureJacoco(project: Project, variantName: String) val javaClasses = projects .map { proj -> - project.fileTree("${proj.buildDir}/intermediates/javac/$variantName/classes/com") + project.fileTree("${proj.layout.buildDirectory.asFile}/intermediates/javac/$variantName/classes/com") } .onEach { it.exclude(coverageExclusions) } val kotlinClasses = projects .map { proj -> - project.fileTree("${proj.buildDir}/tmp/kotlin-classes/$variantName") + project.fileTree("${proj.layout.buildDirectory.asFile}/tmp/kotlin-classes/$variantName") } .onEach { it.exclude(coverageExclusions) } @@ -36,7 +35,7 @@ internal fun JacocoReport.configureJacoco(project: Project, variantName: String) val executions = projects .map { proj -> - proj.fileTree(proj.buildDir).apply { + proj.fileTree(proj.layout.buildDirectory.asFile).apply { include( "/outputs/code_coverage/${variantName}AndroidTest/connected/**/coverage.ec", "/outputs/unit_test_code_coverage/${variantName}UnitTest/test${variantName.capitalized()}UnitTest.exec", diff --git a/build-logic/src/main/kotlin/plugin/util/KotlinOptions.kt b/build-logic/src/main/kotlin/plugin/util/KotlinOptions.kt index f5b60d5..6d28952 100644 --- a/build-logic/src/main/kotlin/plugin/util/KotlinOptions.kt +++ b/build-logic/src/main/kotlin/plugin/util/KotlinOptions.kt @@ -1,35 +1,41 @@ package plugin.util -import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile internal fun Project.configureKotlinOptions() { tasks.withType().configureEach { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17.toString() + compilerOptions { + jvmTarget.set(JvmTarget.JVM_21) + + freeCompilerArgs.add( + "-opt-in=" + + "kotlin.Experimental," + + "kotlinx.coroutines.ExperimentalCoroutinesApi," + + "kotlinx.coroutines.FlowPreview," + + "androidx.paging.ExperimentalPagingApi," + + "androidx.compose.foundation.layout.ExperimentalLayoutApi," + + "androidx.compose.material.ExperimentalMaterialApi", + ) - freeCompilerArgs = - freeCompilerArgs + ( - "-opt-in=" + - "kotlin.Experimental," + - "kotlinx.coroutines.ExperimentalCoroutinesApi," + - "kotlinx.coroutines.FlowPreview," + - "androidx.paging.ExperimentalPagingApi" - ) if (project.findProperty("composeCompilerReports") == "true") { - freeCompilerArgs = freeCompilerArgs + listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + - project.buildDir.absolutePath + "/compose_compiler", + freeCompilerArgs.addAll( + listOf( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + + project.layout.buildDirectory.asFile.get().absolutePath + "/compose_compiler", + ), ) } if (project.findProperty("composeCompilerMetrics") == "true") { - freeCompilerArgs = freeCompilerArgs + listOf( - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + - project.buildDir.absolutePath + "/compose_compiler", + freeCompilerArgs.addAll( + listOf( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + + project.layout.buildDirectory.asFile.get().absolutePath + "/compose_compiler", + ), ) } } diff --git a/build.gradle.kts b/build.gradle.kts index 3233641..261cfe4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.ksp) apply false alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.hilt) apply false + alias(libs.plugins.compose.compiler) apply false alias(libs.plugins.spotless) alias(libs.plugins.detekt) alias(libs.plugins.gradleversions) diff --git a/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeBottomSheetItem.kt b/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeBottomSheetItem.kt index 8b29c07..2a909bf 100644 --- a/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeBottomSheetItem.kt +++ b/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeBottomSheetItem.kt @@ -2,13 +2,16 @@ package com.louisfn.somovie.feature.home.container import androidx.annotation.StringRes import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.List +import androidx.compose.material.icons.automirrored.filled.List import androidx.compose.material.icons.filled.Movie import androidx.compose.material.icons.filled.Settings import androidx.compose.material.icons.filled.Swipe import androidx.compose.ui.graphics.vector.ImageVector import com.louisfn.somovie.feature.home.account.AccountNavigation -import com.louisfn.somovie.feature.home.container.HomeBottomSheetItem.* +import com.louisfn.somovie.feature.home.container.HomeBottomSheetItem.Account +import com.louisfn.somovie.feature.home.container.HomeBottomSheetItem.Discover +import com.louisfn.somovie.feature.home.container.HomeBottomSheetItem.Explore +import com.louisfn.somovie.feature.home.container.HomeBottomSheetItem.WatchList import com.louisfn.somovie.feature.home.discover.DiscoverNavigation import com.louisfn.somovie.feature.home.explore.ExploreNavigation import com.louisfn.somovie.feature.home.watchlist.WatchlistDestination @@ -21,7 +24,7 @@ sealed class HomeBottomSheetItem( val icon: ImageVector, ) { object Explore : HomeBottomSheetItem(ExploreNavigation, R.string.home_explore, Icons.Default.Movie) - object WatchList : HomeBottomSheetItem(WatchlistDestination, R.string.home_watchlist, Icons.Default.List) + object WatchList : HomeBottomSheetItem(WatchlistDestination, R.string.home_watchlist, Icons.AutoMirrored.Filled.List) object Discover : HomeBottomSheetItem(DiscoverNavigation, R.string.home_discover, Icons.Default.Swipe) object Account : HomeBottomSheetItem(AccountNavigation, R.string.home_account, Icons.Default.Settings) } diff --git a/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeDestination.kt b/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeDestination.kt index 5204399..7c519bc 100644 --- a/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeDestination.kt +++ b/feature/home/container/src/main/kotlin/com/louisfn/somovie/feature/home/container/HomeDestination.kt @@ -1,8 +1,7 @@ package com.louisfn.somovie.feature.home.container -import androidx.compose.animation.ExperimentalAnimationApi import androidx.navigation.NavGraphBuilder -import com.google.accompanist.navigation.animation.composable +import androidx.navigation.compose.composable import com.louisfn.somovie.domain.model.ExploreCategory import com.louisfn.somovie.domain.model.Movie import com.louisfn.somovie.ui.common.navigation.NavigationDestination @@ -11,7 +10,6 @@ object HomeDestination : NavigationDestination { override val route: String = "home" } -@OptIn(ExperimentalAnimationApi::class) fun NavGraphBuilder.homeGraph( showDetails: (Movie) -> Unit, showMore: (ExploreCategory) -> Unit, diff --git a/feature/home/discover/src/main/kotlin/com/louisfn/somovie/feature/home/discover/DiscoverScreen.kt b/feature/home/discover/src/main/kotlin/com/louisfn/somovie/feature/home/discover/DiscoverScreen.kt index 4d796d8..fa48716 100644 --- a/feature/home/discover/src/main/kotlin/com/louisfn/somovie/feature/home/discover/DiscoverScreen.kt +++ b/feature/home/discover/src/main/kotlin/com/louisfn/somovie/feature/home/discover/DiscoverScreen.kt @@ -10,8 +10,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.FractionalThreshold import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons @@ -126,7 +124,6 @@ private fun BoxScope.DiscoverContent( } } -@OptIn(ExperimentalMaterialApi::class) @Composable private fun BoxScope.DiscoverSwipeContainer( items: ImmutableList, @@ -138,7 +135,7 @@ private fun BoxScope.DiscoverSwipeContainer( SwipeContainer( items = ImmutableList(items.take(MaxMovieItemToPreload)), itemKey = MovieItem::id, - thresholdConfig = FractionalThreshold(SwipeFractionalThreshold), + fractionalThreshold = SwipeFractionalThreshold, onDragging = { _, direction, ratio -> draggingState = DraggingState(direction, ratio) }, diff --git a/feature/home/watchlist/src/main/kotlin/com/louisfn/somovie/feature/home/watchlist/WatchListScreen.kt b/feature/home/watchlist/src/main/kotlin/com/louisfn/somovie/feature/home/watchlist/WatchListScreen.kt index 8361477..678f461 100644 --- a/feature/home/watchlist/src/main/kotlin/com/louisfn/somovie/feature/home/watchlist/WatchListScreen.kt +++ b/feature/home/watchlist/src/main/kotlin/com/louisfn/somovie/feature/home/watchlist/WatchListScreen.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalMaterialApi::class) - package com.louisfn.somovie.feature.home.watchlist import android.content.res.Resources @@ -28,7 +26,6 @@ import androidx.compose.material.DismissDirection import androidx.compose.material.DismissState import androidx.compose.material.DismissValue import androidx.compose.material.Divider -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.Scaffold @@ -208,7 +205,7 @@ private fun LogInContent(logInManager: LogInManager, modifier: Modifier = Modifi .align(Alignment.TopCenter) .padding(16.dp), ) - Button(modifier = Modifier.align(Alignment.Center)) + Button(Modifier.align(Alignment.Center)) } }, ) diff --git a/feature/login/src/main/kotlin/com/louisfn/somovie/feature/login/LogInLayout.kt b/feature/login/src/main/kotlin/com/louisfn/somovie/feature/login/LogInLayout.kt index 88b2e0a..85b6b2d 100644 --- a/feature/login/src/main/kotlin/com/louisfn/somovie/feature/login/LogInLayout.kt +++ b/feature/login/src/main/kotlin/com/louisfn/somovie/feature/login/LogInLayout.kt @@ -18,7 +18,7 @@ fun LogInLayout( logInManager: LogInManager, modifier: Modifier = Modifier, content: @Composable BoxScope.(button: @Composable (modifier: Modifier) -> Unit) -> Unit = - { it(modifier = Modifier.align(Alignment.Center)) }, + { it(Modifier.align(Alignment.Center)) }, ) { val uiState by logInManager.state.collectAsStateLifecycleAware() diff --git a/feature/moviedetails/build.gradle.kts b/feature/moviedetails/build.gradle.kts index 5403a35..d039fc6 100644 --- a/feature/moviedetails/build.gradle.kts +++ b/feature/moviedetails/build.gradle.kts @@ -7,6 +7,5 @@ android { } dependencies { - implementation(libs.accompanist.flowlayout) implementation(libs.accompanist.pager.indicators) } diff --git a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsContent.kt b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsContent.kt index a637342..e96f77d 100644 --- a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsContent.kt +++ b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsContent.kt @@ -2,16 +2,40 @@ package com.louisfn.somovie.feature.moviedetails import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.FlowRow +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.requiredWidth +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* +import androidx.compose.material.ButtonDefaults +import androidx.compose.material.LocalMinimumInteractiveComponentEnforcement +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.sharp.AccountCircle -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -22,7 +46,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import com.google.accompanist.flowlayout.FlowRow import com.louisfn.somovie.domain.model.Actor import com.louisfn.somovie.domain.model.MovieGenre import com.louisfn.somovie.domain.model.YoutubeVideo @@ -74,7 +97,6 @@ private fun SectionText(text: String) { ) } -@OptIn(ExperimentalMaterialApi::class) @Composable private fun ColumnScope.OverviewSection(overview: String) { var isExpanded by remember { mutableStateOf(false) } diff --git a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsHeader.kt b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsHeader.kt index 072ea8a..74660b4 100644 --- a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsHeader.kt +++ b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsHeader.kt @@ -23,7 +23,7 @@ import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.People import androidx.compose.material.icons.filled.Share import androidx.compose.runtime.Composable @@ -98,7 +98,7 @@ private fun MovieDetailsTopBar(share: () -> Unit, navigateUp: () -> Unit) { navigationIcon = { MovieDetailsIconButton(onClick = navigateUp) { Icon( - imageVector = Icons.Filled.ArrowBack, + imageVector = Icons.AutoMirrored.Filled.ArrowBack, tint = MaterialTheme.colors.onPrimary, contentDescription = "", ) diff --git a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsNavigation.kt b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsNavigation.kt index 0a5e9ce..7a2ed18 100644 --- a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsNavigation.kt +++ b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsNavigation.kt @@ -1,10 +1,9 @@ package com.louisfn.somovie.feature.moviedetails -import androidx.compose.animation.ExperimentalAnimationApi import androidx.navigation.NavGraphBuilder import androidx.navigation.NavType +import androidx.navigation.compose.composable import androidx.navigation.navArgument -import com.google.accompanist.navigation.animation.composable import com.louisfn.somovie.ui.common.navigation.NavigationDestination object MovieDetailsNavigation : NavigationDestination { @@ -15,7 +14,6 @@ object MovieDetailsNavigation : NavigationDestination { fun createRoute(movieId: Long) = "movie/$movieId" } -@OptIn(ExperimentalAnimationApi::class) fun NavGraphBuilder.movieDetailsGraph(navigateUp: () -> Unit) { composable( route = MovieDetailsNavigation.route, diff --git a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsScreen.kt b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsScreen.kt index b86de56..18d4978 100644 --- a/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsScreen.kt +++ b/feature/moviedetails/src/main/kotlin/com/louisfn/somovie/feature/moviedetails/MovieDetailsScreen.kt @@ -11,7 +11,7 @@ import androidx.compose.material.ButtonDefaults import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.PlaylistAdd +import androidx.compose.material.icons.automirrored.filled.PlaylistAdd import androidx.compose.material.icons.filled.PlaylistRemove import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -143,7 +143,7 @@ private fun AddToWatchlistSmallFab( ) { Icon( imageVector = when (watchlistFabState.state) { - WatchlistState.ADD_TO_WATCHLIST -> Icons.Filled.PlaylistAdd + WatchlistState.ADD_TO_WATCHLIST -> Icons.AutoMirrored.Filled.PlaylistAdd WatchlistState.REMOVE_FROM_WATCHLIST -> Icons.Filled.PlaylistRemove }, tint = MaterialTheme.colors.onPrimary, diff --git a/feature/movielist/src/main/kotlin/com/louisfn/somovie/feature/movielist/MovieListNavigation.kt b/feature/movielist/src/main/kotlin/com/louisfn/somovie/feature/movielist/MovieListNavigation.kt index ebf4752..4cfe626 100644 --- a/feature/movielist/src/main/kotlin/com/louisfn/somovie/feature/movielist/MovieListNavigation.kt +++ b/feature/movielist/src/main/kotlin/com/louisfn/somovie/feature/movielist/MovieListNavigation.kt @@ -1,10 +1,9 @@ package com.louisfn.somovie.feature.movielist -import androidx.compose.animation.ExperimentalAnimationApi import androidx.navigation.NavGraphBuilder import androidx.navigation.NavType +import androidx.navigation.compose.composable import androidx.navigation.navArgument -import com.google.accompanist.navigation.animation.composable import com.louisfn.somovie.domain.model.ExploreCategory import com.louisfn.somovie.domain.model.Movie import com.louisfn.somovie.ui.common.navigation.NavigationDestination @@ -17,7 +16,6 @@ object MovieListNavigation : NavigationDestination { fun createRoute(category: ExploreCategory) = "movies/${ExploreCategory.valueOf(category.name)}" } -@OptIn(ExperimentalAnimationApi::class) fun NavGraphBuilder.movieListGraph( showDetail: (Movie) -> Unit, navigateUp: () -> Unit, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 607d36b..7b54b11 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,51 +1,48 @@ [versions] accompanist = "0.32.0" -androidGradlePlugin = "8.1.4" -androidxActivityCompose = "1.8.1" -androidxAnnotation = "1.7.0" -androidxCompose = "1.5.4" -androidxComposeCompiler = "1.5.4" -androidxComposeMaterial = "1.5.4" +androidGradlePlugin = "8.7.1" +androidxActivityCompose = "1.9.3" +androidxAnnotation = "1.9.0" +androidxCompose = "1.7.4" +androidxComposeMaterial = "1.7.4" androidxConstraintlayout = "1.0.1" -androidxCoreKtx = "1.12.0" -androidxDatastore = "1.0.0" -androidxLifecycle = "2.6.2" -androidxNavigation = "2.7.5" -androidxPaging = "3.2.1" -androidxPagingCompose = "3.2.1" -androidxRoom = "2.6.0" -androidxTest = "1.5.2" -androidxTestCore = "1.5.0" -androidxTestExt = "1.1.5" -androidxWebkit = "1.8.0" +androidxCoreKtx = "1.13.1" +androidxDatastore = "1.1.1" +androidxLifecycle = "2.8.6" +androidxNavigation = "2.8.3" +androidxPaging = "3.3.2" +androidxPagingCompose = "3.3.2" +androidxRoom = "2.6.1" +androidxTest = "1.6.2" +androidxTestCore = "1.6.1" +androidxTestExt = "1.2.1" +androidxWebkit = "1.12.1" coil = "2.5.0" -coroutines = "1.7.1" -detekt = "1.23.3" +coroutines = "1.8.1" +detekt = "1.23.6" detektCompose = "0.3.3" -faker = "1.15.0" -flipper = "0.238.0" -gradleversions = "0.50.0" -hilt = "2.48.1" +faker = "1.16.0" +flipper = "0.250.0" +gradleversions = "0.51.0" +hilt = "2.51.1" hiltAndroidX = "1.0.0" -hiltCompose = "1.1.0" +hiltCompose = "1.2.0" jacoco = "0.8.7" junit = "4.13.2" jvm = "1.7.20" kotest = "5.8.0" -kotlin = "1.9.20" -ksp = "1.9.20-1.0.14" +kotlin = "2.0.20" +ksp = "2.0.20-1.0.25" ktlint = "1.0.1" -leakcanary = "2.12" -moshi = "1.15.0" +leakcanary = "2.14" +moshi = "1.15.1" okHttpLoggingInterceptor = "4.12.0" -retrofit = "2.9.0" -soloader = "0.10.5" +retrofit = "2.11.0" +soloader = "0.11.0" spotless = "6.22.0" timber = "5.0.1" [libraries] -accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanist" } -accompanist-navigationAnimation = { group = "com.google.accompanist", name = "accompanist-navigation-animation", version.ref = "accompanist" } accompanist-pager-indicators = { group = "com.google.accompanist", name = "accompanist-pager-indicators", version.ref = "accompanist" } accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist" } accompanist-webview = { group = "com.google.accompanist", name = "accompanist-webview", version.ref = "accompanist" } @@ -122,5 +119,6 @@ hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 744c64d..707e499 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/ui/common/src/main/kotlin/com/louisfn/somovie/ui/common/extension/StateFlow.kt b/ui/common/src/main/kotlin/com/louisfn/somovie/ui/common/extension/StateFlow.kt index a4569f0..14f95c3 100644 --- a/ui/common/src/main/kotlin/com/louisfn/somovie/ui/common/extension/StateFlow.kt +++ b/ui/common/src/main/kotlin/com/louisfn/somovie/ui/common/extension/StateFlow.kt @@ -5,8 +5,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.State import androidx.compose.runtime.collectAsState import androidx.compose.runtime.remember -import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.lifecycle.Lifecycle +import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.flowWithLifecycle import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow diff --git a/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/TopAppBar.kt b/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/TopAppBar.kt index 27738d8..6fcdd23 100644 --- a/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/TopAppBar.kt +++ b/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/TopAppBar.kt @@ -1,9 +1,14 @@ package com.louisfn.somovie.ui.component import androidx.compose.foundation.layout.RowScope -import androidx.compose.material.* +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.primarySurface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -15,7 +20,7 @@ fun DefaultTopAppBar( modifier: Modifier = Modifier, text: String? = null, backgroundColor: Color = MaterialTheme.colors.primarySurface, - backIcon: ImageVector = Icons.Filled.ArrowBack, + backIcon: ImageVector = Icons.AutoMirrored.Filled.ArrowBack, actions: @Composable RowScope.() -> Unit = {}, navigateUp: (() -> Unit)? = null, ) { diff --git a/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeContainer.kt b/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeContainer.kt index b40e96b..3781562 100644 --- a/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeContainer.kt +++ b/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeContainer.kt @@ -1,5 +1,3 @@ -@file:OptIn(ExperimentalMaterialApi::class) - package com.louisfn.somovie.ui.component.swipe import androidx.compose.animation.core.AnimationSpec @@ -8,9 +6,6 @@ import androidx.compose.animation.core.spring import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.offset -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.FractionalThreshold -import androidx.compose.material.ThresholdConfig import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.key @@ -40,7 +35,7 @@ fun SwipeContainer( itemKey: (T) -> Any, modifier: Modifier = Modifier, maxRotationInDegrees: Float = DefaultMaxRotationInDegrees, - thresholdConfig: ThresholdConfig = FractionalThreshold(DefaultFractionalThreshold), + fractionalThreshold: Float = DefaultFractionalThreshold, velocityThreshold: Dp = DefaultVelocityThreshold, swipeAnimationSpec: AnimationSpec = DefaultSwipeAnimationSpec, cancelAnimationSpec: AnimationSpec = DefaultRewindAnimationSpec, @@ -58,7 +53,7 @@ fun SwipeContainer( SwipeableItem( item = item, maxRotationInDegrees = maxRotationInDegrees, - thresholdConfig = thresholdConfig, + fractionalThreshold = fractionalThreshold, velocityThreshold = velocityThreshold, swipeAnimationSpec = swipeAnimationSpec, cancelAnimationSpec = cancelAnimationSpec, @@ -73,12 +68,11 @@ fun SwipeContainer( } } -@OptIn(ExperimentalMaterialApi::class) @Composable private fun SwipeableItem( item: T, maxRotationInDegrees: Float, - thresholdConfig: ThresholdConfig, + fractionalThreshold: Float, velocityThreshold: Dp, swipeAnimationSpec: AnimationSpec, cancelAnimationSpec: AnimationSpec, @@ -94,7 +88,7 @@ private fun SwipeableItem( val swipeController = rememberSwipeController( size = itemSize, maxRotationInDegrees = maxRotationInDegrees, - thresholdConfig = thresholdConfig, + fractionalThreshold = fractionalThreshold, velocityThreshold = velocityThreshold, swipeAnimationSpec = swipeAnimationSpec, cancelAnimationSpec = cancelAnimationSpec, diff --git a/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeController.kt b/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeController.kt index 3c159b3..198ea59 100644 --- a/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeController.kt +++ b/ui/component/src/main/kotlin/com/louisfn/somovie/ui/component/swipe/SwipeController.kt @@ -1,12 +1,8 @@ -@file:OptIn(ExperimentalMaterialApi::class) - package com.louisfn.somovie.ui.component.swipe import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.AnimationSpec import androidx.compose.animation.core.VectorConverter -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.ThresholdConfig import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.derivedStateOf @@ -20,8 +16,6 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.pointer.PointerInputChange import androidx.compose.ui.input.pointer.util.VelocityTracker import androidx.compose.ui.input.pointer.util.addPointerInputChange -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.center @@ -36,13 +30,12 @@ import kotlin.math.withSign @Stable class SwipeController( - thresholdConfig: ThresholdConfig, + fractionalThreshold: Float, private val velocityThreshold: Float, private val size: IntSize, private val maxRotationInDegrees: Float, private val swipeAnimationSpec: AnimationSpec, private val cancelAnimationSpec: AnimationSpec, - private val density: Density, private val scope: CoroutineScope, private val onDragging: (SwipeDirection, ratio: Float) -> Unit, private val onSwiped: (SwipeDirection) -> Unit, @@ -51,8 +44,7 @@ class SwipeController( ) { private val velocityTracker = VelocityTracker() - private val threshold = - with(thresholdConfig) { density.computeThreshold(0f, size.width.toFloat()) } + private val threshold = size.width.toFloat() * fractionalThreshold private val maxItemWidthWhenRotate = size.height * sin(maxRotationInDegrees).absoluteValue + size.width * cos(maxRotationInDegrees).absoluteValue @@ -112,7 +104,7 @@ class SwipeController( internal fun rememberSwipeController( size: IntSize, maxRotationInDegrees: Float, - thresholdConfig: ThresholdConfig, + fractionalThreshold: Float, velocityThreshold: Dp, swipeAnimationSpec: AnimationSpec, cancelAnimationSpec: AnimationSpec, @@ -124,25 +116,23 @@ internal fun rememberSwipeController( val currentOnDragging by rememberUpdatedState(onDragging) val currentOnSwipe by rememberUpdatedState(onSwiped) - val density = LocalDensity.current val scope = rememberCoroutineScope() val velocityThresholdInPx = velocityThreshold.toPx() return remember( size, maxRotationInDegrees, - thresholdConfig, + fractionalThreshold, swipeAnimationSpec, cancelAnimationSpec, ) { SwipeController( + fractionalThreshold = fractionalThreshold, size = size, maxRotationInDegrees = maxRotationInDegrees, - thresholdConfig = thresholdConfig, velocityThreshold = velocityThresholdInPx, swipeAnimationSpec = swipeAnimationSpec, cancelAnimationSpec = cancelAnimationSpec, - density = density, scope = scope, onDragging = currentOnDragging, onSwiped = currentOnSwipe,