From 103827ced2e8c2081ef4ce7b432962564dd10aa0 Mon Sep 17 00:00:00 2001 From: stslex Date: Thu, 8 Aug 2024 22:14:05 +0300 Subject: [PATCH 1/5] update libs --- .gitignore | 1 + app/build.gradle.kts | 1 + .../st/slex/csplashscreen/ui/InitialApp.kt | 10 +- .../st/slex/csplashscreen/ui/MainActivity.kt | 14 ++- .../ui/components/NavigationHost.kt | 9 +- build-logic/dependencies/build.gradle.kts | 4 +- ...droidApplicationComposeConventionPlugin.kt | 12 +- .../AndroidApplicationConventionPlugin.kt | 8 +- .../AndroidLibraryComposeConventionPlugin.kt | 11 +- .../kotlin/AndroidLibraryConventionPlugin.kt | 7 +- .../dependencies/src/main/kotlin/AppExt.kt | 115 +++++++++++++++++- .../kotlin/RoomLibraryConventionPlugin.kt | 12 +- .../st.slex.csplashscreen/ComposeAndroid.kt | 83 +++++++------ .../st.slex.csplashscreen/KotlinAndroid.kt | 66 ++++------ build.gradle.kts | 2 + core/collection/build.gradle.kts | 1 + .../slex/csplashscreen/core/ui/utils/UiExt.kt | 2 + .../favourite/ui/presenter/FavouriteStore.kt | 1 + .../ui/ImageDetailScreen.kt | 5 +- .../ui/components/DetailImageBodyTags.kt | 3 +- .../user/ui/components/pager/UserPager.kt | 9 +- .../user/ui/components/tabs/UserTabsRow.kt | 19 +-- .../feature/user/ui/state/UserPagerState.kt | 6 +- gradle/libs.versions.toml | 54 ++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- 25 files changed, 300 insertions(+), 157 deletions(-) diff --git a/.gitignore b/.gitignore index 6a3af2d9..8378e122 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.iml .gradle .idea +.kotlin /local.properties .DS_Store /build diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0a6cd1d4..d3629490 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(libs.plugins.convention.application) alias(libs.plugins.convention.application.compose) + alias(libs.plugins.composeCompiler) } dependencies { diff --git a/app/src/main/java/st/slex/csplashscreen/ui/InitialApp.kt b/app/src/main/java/st/slex/csplashscreen/ui/InitialApp.kt index 9d6b3a92..28b1d264 100644 --- a/app/src/main/java/st/slex/csplashscreen/ui/InitialApp.kt +++ b/app/src/main/java/st/slex/csplashscreen/ui/InitialApp.kt @@ -13,6 +13,7 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.Stable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -20,18 +21,19 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import androidx.navigation.NavHostController import com.google.accompanist.systemuicontroller.rememberSystemUiController import st.slex.csplashscreen.core.navigation.AppDestination import st.slex.csplashscreen.core.navigation.navigator.NavigationTarget +import st.slex.csplashscreen.ui.components.NavHostControllerHolder import st.slex.csplashscreen.ui.components.NavigationHost import st.slex.csplashscreen.ui.components.bottom_appbar.BottomAppBarResource import st.slex.csplashscreen.ui.components.bottom_appbar.MainBottomAppBar @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable +@Stable fun InitialApp( - navController: NavHostController, + navControllerHolder: NavHostControllerHolder, onBottomAppBarClick: (NavigationTarget.Screen) -> Unit, modifier: Modifier = Modifier, ) { @@ -42,7 +44,7 @@ fun InitialApp( mutableStateOf(AppDestination.HOME) } - navController.addOnDestinationChangedListener { _, destination, _ -> + navControllerHolder.navController.addOnDestinationChangedListener { _, destination, _ -> currentDestination = AppDestination.findByRoute(destination.route) } @@ -76,7 +78,7 @@ fun InitialApp( modifier = Modifier .background(MaterialTheme.colorScheme.background) .systemBarsPadding(), - navController = navController, + holder = navControllerHolder, ) }, ) diff --git a/app/src/main/java/st/slex/csplashscreen/ui/MainActivity.kt b/app/src/main/java/st/slex/csplashscreen/ui/MainActivity.kt index 7e5ebd0c..42ae9b3f 100644 --- a/app/src/main/java/st/slex/csplashscreen/ui/MainActivity.kt +++ b/app/src/main/java/st/slex/csplashscreen/ui/MainActivity.kt @@ -4,14 +4,15 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.runtime.Composable +import androidx.compose.runtime.Stable import androidx.compose.runtime.remember import androidx.core.view.WindowCompat -import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController import org.koin.androidx.compose.getKoin import org.koin.androidx.compose.koinViewModel import st.slex.csplashscreen.core.navigation.di.moduleCoreNavigation import st.slex.csplashscreen.core.ui.theme.AppTheme +import st.slex.csplashscreen.ui.components.NavHostControllerHolder class MainActivity : ComponentActivity() { @@ -21,15 +22,15 @@ class MainActivity : ComponentActivity() { WindowCompat.setDecorFitsSystemWindows(window, false) setContent { AppTheme { - val navHostController = rememberNavController() - SetupComposeDependencies(navHostController) + val navHostControllerHolder = NavHostControllerHolder(rememberNavController()) + SetupComposeDependencies(navHostControllerHolder) val viewModel = koinViewModel() InitialApp( /*TODO AFTER reconfiguration controller in VM don't change it State, so it need to have latest instance. Need Research to find more efficient way */ - navController = navHostController, + navControllerHolder = navHostControllerHolder, onBottomAppBarClick = remember { { viewModel.navigate(it) } } @@ -39,12 +40,13 @@ class MainActivity : ComponentActivity() { } @Composable + @Stable private fun SetupComposeDependencies( - navController: NavHostController + holder: NavHostControllerHolder ) { getKoin().loadModules( listOf( - moduleCoreNavigation(navController), + moduleCoreNavigation(holder.navController), ) ) } diff --git a/app/src/main/java/st/slex/csplashscreen/ui/components/NavigationHost.kt b/app/src/main/java/st/slex/csplashscreen/ui/components/NavigationHost.kt index f0041ab2..8f308b08 100644 --- a/app/src/main/java/st/slex/csplashscreen/ui/components/NavigationHost.kt +++ b/app/src/main/java/st/slex/csplashscreen/ui/components/NavigationHost.kt @@ -1,6 +1,7 @@ package st.slex.csplashscreen.ui.components import androidx.compose.runtime.Composable +import androidx.compose.runtime.Stable import androidx.compose.ui.Modifier import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost @@ -12,14 +13,18 @@ import st.slex.csplashscreen.feature.home.navigation.homeGraph import st.slex.csplashscreen.feature.search.navigation.searchPhotosGraph import st.slex.csplashscreen.feature.user.navigation.userGraph +@Stable +class NavHostControllerHolder(val navController: NavHostController) + @Composable +@Stable fun NavigationHost( - navController: NavHostController, + holder: NavHostControllerHolder, modifier: Modifier = Modifier, startDestination: AppDestination = AppDestination.HOME ) { NavHost( - navController = navController, + navController = holder.navController, startDestination = startDestination.navigationRoute ) { homeGraph(modifier) diff --git a/build-logic/dependencies/build.gradle.kts b/build-logic/dependencies/build.gradle.kts index c6882605..23905c1e 100644 --- a/build-logic/dependencies/build.gradle.kts +++ b/build-logic/dependencies/build.gradle.kts @@ -11,6 +11,8 @@ dependencies { compileOnly(libs.ksp.gradlePlugin) compileOnly(libs.room.gradlePlugin) compileOnly(libs.android.tools.common) + compileOnly(libs.vkompose.gradlePlugin) + compileOnly(libs.composeCompiler.gradlePlugin) } tasks { @@ -38,7 +40,7 @@ gradlePlugin { id = "csplashscreen.android.library" implementationClass = "AndroidLibraryConventionPlugin" } - register("roomLibrary"){ + register("roomLibrary") { id = "csplashscreen.room.library" implementationClass = "RoomLibraryConventionPlugin" } diff --git a/build-logic/dependencies/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt b/build-logic/dependencies/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt index 254ce1c2..e28940ee 100644 --- a/build-logic/dependencies/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt +++ b/build-logic/dependencies/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt @@ -1,3 +1,5 @@ +import AppExt.findPluginId +import AppExt.libs import com.android.build.api.dsl.ApplicationExtension import org.gradle.api.Plugin import org.gradle.api.Project @@ -7,11 +9,15 @@ import st.slex.csplashscreen.configureAndroidCompose class AndroidApplicationComposeConventionPlugin : Plugin { override fun apply(target: Project) { - with(target) { pluginManager.apply("com.android.application") - val extension = extensions.getByType() - configureAndroidCompose(extension) + pluginManager.apply(libs.findPluginId("kotlin")) + pluginManager.apply(libs.findPluginId("composeCompiler")) + pluginManager.apply(libs.findPluginId("vkompose")) + + configureAndroidCompose( + commonExtension = extensions.getByType() + ) } } } \ No newline at end of file diff --git a/build-logic/dependencies/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/build-logic/dependencies/src/main/kotlin/AndroidApplicationConventionPlugin.kt index c5a8ad8b..052afa4e 100644 --- a/build-logic/dependencies/src/main/kotlin/AndroidApplicationConventionPlugin.kt +++ b/build-logic/dependencies/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -1,8 +1,7 @@ -import AppExt.currentLibs import AppExt.findVersionInt import AppExt.findVersionString +import AppExt.libs import com.android.build.api.dsl.ApplicationExtension -import com.google.devtools.ksp.gradle.KspExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.configure @@ -16,7 +15,6 @@ class AndroidApplicationConventionPlugin : Plugin { override fun apply(target: Project) { with(target) { - val libs = currentLibs with(pluginManager) { apply("com.android.application") apply("org.jetbrains.kotlin.android") @@ -36,10 +34,6 @@ class AndroidApplicationConventionPlugin : Plugin { configureSigning(target) } } - - extensions.configure { - arg("KOIN_CONFIG_CHECK", "true") - } } } } diff --git a/build-logic/dependencies/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt b/build-logic/dependencies/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt index 00224999..b660e711 100644 --- a/build-logic/dependencies/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt +++ b/build-logic/dependencies/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt @@ -1,3 +1,5 @@ +import AppExt.findPluginId +import AppExt.libs import com.android.build.gradle.LibraryExtension import org.gradle.api.Plugin import org.gradle.api.Project @@ -9,8 +11,13 @@ class AndroidLibraryComposeConventionPlugin : Plugin { override fun apply(target: Project) { with(target) { pluginManager.apply("com.android.library") - val extension = extensions.getByType() - configureAndroidCompose(extension) + pluginManager.apply(libs.findPluginId("kotlin")) + pluginManager.apply(libs.findPluginId("composeCompiler")) + pluginManager.apply(libs.findPluginId("vkompose")) + + configureAndroidCompose( + commonExtension = extensions.getByType() + ) } } } \ No newline at end of file diff --git a/build-logic/dependencies/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/dependencies/src/main/kotlin/AndroidLibraryConventionPlugin.kt index d811cd82..622e65de 100644 --- a/build-logic/dependencies/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/dependencies/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -1,5 +1,6 @@ +import AppExt.findPluginId +import AppExt.libs import com.android.build.gradle.LibraryExtension -import com.google.devtools.ksp.gradle.KspExtension import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalogsExtension @@ -37,10 +38,6 @@ class AndroidLibraryConventionPlugin : Plugin { } } - extensions.configure { - arg("KOIN_CONFIG_CHECK", "true") - } - val libs = extensions.getByType().named("libs") configurations.configureEach { resolutionStrategy { diff --git a/build-logic/dependencies/src/main/kotlin/AppExt.kt b/build-logic/dependencies/src/main/kotlin/AppExt.kt index ff9c5119..30ba5ed4 100644 --- a/build-logic/dependencies/src/main/kotlin/AppExt.kt +++ b/build-logic/dependencies/src/main/kotlin/AppExt.kt @@ -1,6 +1,7 @@ import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalog import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.getByType object AppExt { @@ -8,7 +9,7 @@ object AppExt { /** * Get the version catalog for the project * */ - val Project.currentLibs: VersionCatalog + val Project.libs: VersionCatalog get() = extensions.getByType().named("libs") /** @@ -20,4 +21,116 @@ object AppExt { * Find the version of the library */ fun VersionCatalog.findVersionString(name: String) = findVersion(name).get().toString() + + /** + * Find the plugin id + */ + fun VersionCatalog.findPluginId(alias: String) = findPlugin(alias).get().get().pluginId + + /** + * Find the library by alias + */ + fun Project.implementation(vararg alias: String) { + dependencies { + alias.forEach { + add("implementation", libs.findLibrary(it).get()) + } + } + } + + fun Project.debugImplementation(vararg alias: String) { + dependencies { + alias.forEach { + add("debugImplementation", libs.findLibrary(it).get()) + } + } + } + + fun Project.implementationPlatform(vararg alias: String) { + dependencies { + alias.forEach { + add( + "debugImplementation", + platform(libs.findLibrary(it).get()) + ) + } + } + } + + /** + * Find the bundle by alias + */ + fun Project.implementationBundle(vararg alias: String) { + dependencies { + alias.forEach { + add("implementation", libs.findBundle(it).get()) + } + } + } + + /** + * Find the library by alias + */ + fun Project.androidTestImplementation(vararg alias: String) { + dependencies { + alias.forEach { + add("androidTestImplementation", libs.findLibrary(it).get()) + } + } + } + + /** + * Find the library by alias + */ + fun Project.androidTestImplementationBundle(vararg alias: String) { + dependencies { + alias.forEach { + add("androidTestImplementation", libs.findBundle(it).get()) + } + } + } + + fun Project.androidTestImplementationPlatform(vararg alias: String) { + dependencies { + alias.forEach { + add( + "androidTestImplementation", + dependencies.platform(libs.findLibrary(it).get()) + ) + } + } + } + + /** + * Find the library by alias + */ + fun Project.testImplementationBundle(vararg alias: String) { + dependencies { + alias.forEach { + add("testImplementation", libs.findBundle(it).get()) + } + } + } + + /** + * Find the library by alias + */ + fun Project.coreLibraryDesugaring(vararg alias: String) { + dependencies { + alias.forEach { + add("coreLibraryDesugaring", libs.findLibrary(it).get()) + } + } + } + + /** + * Find the library by alias + */ + fun Project.ksp(vararg alias: String) { + dependencies { + alias.forEach { + add("ksp", libs.findLibrary(it).get()) + } + } + } } \ No newline at end of file diff --git a/build-logic/dependencies/src/main/kotlin/RoomLibraryConventionPlugin.kt b/build-logic/dependencies/src/main/kotlin/RoomLibraryConventionPlugin.kt index 43f80bc0..5dcbe531 100644 --- a/build-logic/dependencies/src/main/kotlin/RoomLibraryConventionPlugin.kt +++ b/build-logic/dependencies/src/main/kotlin/RoomLibraryConventionPlugin.kt @@ -1,4 +1,4 @@ -import AppExt.currentLibs +import AppExt.libs import androidx.room.gradle.RoomExtension import com.google.devtools.ksp.gradle.KspExtension import org.gradle.api.Plugin @@ -25,11 +25,11 @@ class RoomLibraryConventionPlugin : Plugin { } dependencies { - "implementation"(currentLibs.findBundle("room").get()) - "annotationProcessor"(currentLibs.findLibrary("androidx-room-compiler").get()) - "implementation"(currentLibs.findLibrary("androidx-paging-runtime").get()) - "androidTestApi"(currentLibs.findLibrary("androidx-room-testing").get()) - "ksp"(currentLibs.findLibrary("androidx-room-compiler").get()) + "implementation"(libs.findBundle("room").get()) + "annotationProcessor"(libs.findLibrary("androidx-room-compiler").get()) + "implementation"(libs.findLibrary("androidx-paging-runtime").get()) + "androidTestApi"(libs.findLibrary("androidx-room-testing").get()) + "ksp"(libs.findLibrary("androidx-room-compiler").get()) } } } diff --git a/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/ComposeAndroid.kt b/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/ComposeAndroid.kt index 38a0815f..30e62670 100644 --- a/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/ComposeAndroid.kt +++ b/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/ComposeAndroid.kt @@ -1,12 +1,15 @@ package st.slex.csplashscreen -import AppExt.currentLibs -import AppExt.findVersionString +import AppExt.androidTestImplementation +import AppExt.androidTestImplementationPlatform +import AppExt.debugImplementation +import AppExt.implementation +import AppExt.implementationBundle +import AppExt.implementationPlatform import com.android.build.api.dsl.CommonExtension +import com.vk.gradle.plugin.compose.utils.VkomposeExtension import org.gradle.api.Project -import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.gradle.kotlin.dsl.configure /** * Configure Compose-specific options @@ -14,52 +17,48 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile internal fun Project.configureAndroidCompose( commonExtension: CommonExtension<*, *, *, *, *, *>, ) { - val libs = currentLibs - commonExtension.apply { - buildFeatures.compose = true - composeOptions.kotlinCompilerExtensionVersion = libs.findVersionString("composeCompiler") - - dependencies { - val composeBom = libs.findLibrary("androidx-compose-bom").get() - add("implementation", platform(composeBom)) - add("androidTestImplementation", platform(composeBom)) - - val composeApi = libs.findBundle("compose").get() - add("implementation", composeApi) - -// val composeManifest = libs.findBundle("androidx-compose-manifest").get() -// add("debugImplementation", composeManifest) - - val tooling = libs.findLibrary("androidx-compose-tooling").get() - add("debugImplementation", tooling) - val composeTest = libs.findLibrary("androidx-compose-ui-test-junit4").get() - add("androidTestImplementation", composeTest) - - val accompanist = libs.findBundle("accompanist").get() - add("implementation", accompanist) - - val appcompat = libs.findLibrary("appcompat").get() - add("implementation", appcompat) + androidTestImplementationPlatform("androidx-compose-bom") + implementationPlatform("androidx-compose-bom") + debugImplementation("androidx-compose-tooling") + androidTestImplementation("androidx-compose-ui-test-junit4") + implementationBundle("accompanist", "compose", "lifecycle") + implementation("appcompat", "material", "koin-androidx-compose") + } - val material = libs.findLibrary("material").get() - add("implementation", material) + extensions.configure(action = ::configureVkompose) +} - val lifecycle = libs.findBundle("lifecycle").get() - add("implementation", lifecycle) +private fun Project.configureVkompose( + extension: VkomposeExtension +): Unit = with(extension) { + skippabilityCheck = true + skippabilityCheck { + // For more see + // https://android-review.googlesource.com/c/platform/frameworks/support/+/2668595 + // https://issuetracker.google.com/issues/309765121 + stabilityConfigurationPath = "/path/file.config" + } - val koinCompose = libs.findLibrary("koin-androidx-compose").get() - add("implementation", koinCompose) - } + recompose { + isHighlighterEnabled = true + isLoggerEnabled = true + // or + // logger { + // logModifierChanges = true // true by default since 0.5 + // logFunctionChanges = true // true by default since 0.5. log when function arguments (like lambdas or function references) of composable function are changed + // } } - tasks.withType().configureEach { - kotlinOptions { - freeCompilerArgs = freeCompilerArgs //+ buildComposeMetricsParameters() - } + testTag { + isApplierEnabled = true + isDrawerEnabled = false + isCleanerEnabled = false } + + sourceInformationClean = true } // TODO Check diff --git a/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/KotlinAndroid.kt b/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/KotlinAndroid.kt index c8d8f4df..19941114 100644 --- a/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/KotlinAndroid.kt +++ b/build-logic/dependencies/src/main/kotlin/st.slex.csplashscreen/KotlinAndroid.kt @@ -1,17 +1,24 @@ package st.slex.csplashscreen -import AppExt.currentLibs +import AppExt.androidTestImplementationBundle +import AppExt.coreLibraryDesugaring import AppExt.findVersionInt +import AppExt.implementation +import AppExt.implementationBundle +import AppExt.ksp +import AppExt.libs +import AppExt.testImplementationBundle import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.DefaultConfig import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties +import com.google.devtools.ksp.gradle.KspExtension import org.gradle.api.JavaVersion import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionAware +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.properties.Properties @@ -21,7 +28,7 @@ import org.jetbrains.kotlin.konan.properties.Properties internal fun Project.configureKotlinAndroid( commonExtension: CommonExtension<*, *, *, *, *, *>, ) { - val libs = currentLibs + val libs = libs commonExtension.apply { @@ -42,61 +49,42 @@ internal fun Project.configureKotlinAndroid( compileOptions { // Up to Java 11 APIs are available through desugaring // https://developer.android.com/studio/write/java11-minimal-support-table - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 isCoreLibraryDesugaringEnabled = true } } configureKotlin() - dependencies { - "coreLibraryDesugaring"(libs.findLibrary("android-desugarJdkLibs").get()) - "implementation"(libs.findLibrary("androidx-core-ktx").get()) - "testImplementation"(libs.findBundle("test").get()) - "androidTestImplementation"(libs.findBundle("android-test").get()) - "implementation"(libs.findLibrary("kotlinx-collections-immutable").get()) - "implementation"(libs.findLibrary("coroutines").get()) - "implementation"(libs.findBundle("koin").get()) - "ksp"(libs.findLibrary("koin-ksp").get()) + extensions.configure { + arg("KOIN_CONFIG_CHECK", "true") } -} -private fun CommonExtension<*, *, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { - (this as ExtensionAware).extensions.configure("kotlinOptions", block) + dependencies { + coreLibraryDesugaring("android-desugarJdkLibs") + implementation("androidx-core-ktx", "kotlinx-collections-immutable", "coroutines") + androidTestImplementationBundle("android-test") + implementationBundle("koin") + testImplementationBundle("test") + ksp("koin-ksp") + } } -// TODO check -///** -// * Configure base Kotlin options for JVM (non-Android) -// */ -//internal fun Project.configureKotlinJvm() { -// extensions.configure { -// // Up to Java 11 APIs are available through desugaring -// // https://developer.android.com/studio/write/java11-minimal-support-table -// sourceCompatibility = JavaVersion.VERSION_11 -// targetCompatibility = JavaVersion.VERSION_11 -// } -// -// configureKotlin() -//} - /** * Configure base Kotlin options */ private fun Project.configureKotlin() { // Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947 tasks.withType().configureEach { - kotlinOptions { + compilerOptions { // Set JVM target to 11 - jvmTarget = JavaVersion.VERSION_11.toString() + jvmTarget.set(JvmTarget.JVM_17) // Treat all Kotlin warnings as errors (disabled by default) // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties val warningsAsErrors: String? by project - allWarningsAsErrors = warningsAsErrors.toBoolean() - freeCompilerArgs = freeCompilerArgs + listOf( - "-opt-in=kotlin.RequiresOptIn", - ) + allWarningsAsErrors.set(warningsAsErrors?.toBoolean() ?: false) + freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") } } } diff --git a/build.gradle.kts b/build.gradle.kts index e09de459..c4c90e15 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,8 @@ plugins { alias(libs.plugins.serialization) alias(libs.plugins.ksp) apply false alias(libs.plugins.room) apply false + alias(libs.plugins.vkompose) apply false + alias(libs.plugins.composeCompiler) apply false } buildscript { diff --git a/core/collection/build.gradle.kts b/core/collection/build.gradle.kts index 53ce4b36..8d981ce1 100644 --- a/core/collection/build.gradle.kts +++ b/core/collection/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("csplashscreen.android.library") id("csplashscreen.android.library.compose") + alias(libs.plugins.composeCompiler) } dependencies { diff --git a/core/ui/src/main/java/st/slex/csplashscreen/core/ui/utils/UiExt.kt b/core/ui/src/main/java/st/slex/csplashscreen/core/ui/utils/UiExt.kt index ed468d72..322ead20 100644 --- a/core/ui/src/main/java/st/slex/csplashscreen/core/ui/utils/UiExt.kt +++ b/core/ui/src/main/java/st/slex/csplashscreen/core/ui/utils/UiExt.kt @@ -2,6 +2,7 @@ package st.slex.csplashscreen.core.ui.utils import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.NonRestartableComposable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalLifecycleOwner @@ -38,6 +39,7 @@ object UiExt { } @Composable +@NonRestartableComposable fun SharedFlow.CollectAsEvent( minActionState: Lifecycle.State = Lifecycle.State.STARTED, action: suspend (T) -> Unit, diff --git a/feature/favourite/src/main/java/st/slex/csplashscreen/feature/favourite/ui/presenter/FavouriteStore.kt b/feature/favourite/src/main/java/st/slex/csplashscreen/feature/favourite/ui/presenter/FavouriteStore.kt index 2352fc32..99a13412 100644 --- a/feature/favourite/src/main/java/st/slex/csplashscreen/feature/favourite/ui/presenter/FavouriteStore.kt +++ b/feature/favourite/src/main/java/st/slex/csplashscreen/feature/favourite/ui/presenter/FavouriteStore.kt @@ -30,6 +30,7 @@ class FavouriteStore( } private fun actionInit() { + interactor.photos .map { pagingData -> pagingData diff --git a/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/ImageDetailScreen.kt b/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/ImageDetailScreen.kt index 76b6d631..e292baf3 100644 --- a/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/ImageDetailScreen.kt +++ b/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/ImageDetailScreen.kt @@ -34,13 +34,14 @@ import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.google.accompanist.systemuicontroller.rememberSystemUiController +import kotlinx.collections.immutable.toImmutableList import st.slex.csplashscreen.core.ui.components.ImageComponent import st.slex.csplashscreen.core.ui.components.UserImageHeadWithUserName import st.slex.csplashscreen.core.ui.theme.Dimen import st.slex.csplashscreen.feature.feature_photo_detail.R import st.slex.csplashscreen.feature.feature_photo_detail.domain.model.ImageDetail -import st.slex.csplashscreen.feature.feature_photo_detail.ui.presenter.ImageDetailStoreComponent.State import st.slex.csplashscreen.feature.feature_photo_detail.ui.components.DetailImageBodyTags +import st.slex.csplashscreen.feature.feature_photo_detail.ui.presenter.ImageDetailStoreComponent.State @Composable fun ImageDetailScreen( @@ -114,7 +115,7 @@ private fun ImageDetail( ) if (imageModel?.photo?.tags.orEmpty().isNotEmpty()) { DetailImageBodyTags( - tags = imageModel?.photo?.tags.orEmpty(), + tags = imageModel?.photo?.tags.orEmpty().toImmutableList(), onClick = onTagClick ) Divider( diff --git a/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/components/DetailImageBodyTags.kt b/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/components/DetailImageBodyTags.kt index 600a20c5..fee28b28 100644 --- a/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/components/DetailImageBodyTags.kt +++ b/feature/photo-detail/src/main/java/st/slex/csplashscreen/feature/feature_photo_detail/ui/components/DetailImageBodyTags.kt @@ -13,10 +13,11 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import kotlinx.collections.immutable.ImmutableList @Composable fun DetailImageBodyTags( - tags: List, + tags: ImmutableList, onClick: (tag: String) -> Unit ) { LazyRow( diff --git a/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/pager/UserPager.kt b/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/pager/UserPager.kt index 3ecd25e3..63e27a67 100644 --- a/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/pager/UserPager.kt +++ b/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/pager/UserPager.kt @@ -4,7 +4,9 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Column import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier +import kotlinx.coroutines.launch import st.slex.csplashscreen.core.collection.ui.component.LazyListCollection import st.slex.csplashscreen.core.photos.ui.component.LazyListPhotos import st.slex.csplashscreen.feature.user.ui.components.tabs.UserTab @@ -23,10 +25,15 @@ fun UserPager( Column( modifier = modifier ) { + val coroutineScope = rememberCoroutineScope() UserTabsRow( pagerState = userPagerState.pagerState, userTabs = userPagerState.userTabs, - onClick = userPagerState::scrollToTop + onClick = { + coroutineScope.launch { + userPagerState.scrollToTop(it) + } + } ) HorizontalPager( diff --git a/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/tabs/UserTabsRow.kt b/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/tabs/UserTabsRow.kt index 9f62d282..3836c39b 100644 --- a/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/tabs/UserTabsRow.kt +++ b/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/components/tabs/UserTabsRow.kt @@ -11,19 +11,19 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import st.slex.csplashscreen.core.ui.utils.tabIndicatorOffset -import kotlinx.coroutines.CoroutineScope +import kotlinx.collections.immutable.ImmutableSet import kotlinx.coroutines.launch +import st.slex.csplashscreen.core.ui.utils.tabIndicatorOffset @OptIn(ExperimentalFoundationApi::class) @Composable fun UserTabsRow( pagerState: PagerState, - userTabs: Set, - onClick: suspend (Int) -> Unit, + userTabs: ImmutableSet, + onClick: (Int) -> Unit, modifier: Modifier = Modifier, - scope: CoroutineScope = rememberCoroutineScope(), ) { + val scope = rememberCoroutineScope() TabRow( modifier = modifier, selectedTabIndex = pagerState.currentPage, @@ -50,13 +50,14 @@ fun UserTabsRow( selected = pagerState.currentPage == index, onClick = remember { { - scope.launch { - if (pagerState.currentPage == index) { - onClick(index) - } else { + if (pagerState.currentPage == index) { + onClick(index) + } else { + scope.launch { pagerState.animateScrollToPage(index) } } + } } ) diff --git a/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/state/UserPagerState.kt b/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/state/UserPagerState.kt index d8b5aa20..ddbd6a84 100644 --- a/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/state/UserPagerState.kt +++ b/feature/user/src/main/java/st/slex/csplashscreen/feature/user/ui/state/UserPagerState.kt @@ -9,6 +9,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.Stable import androidx.compose.runtime.remember import androidx.paging.compose.LazyPagingItems +import kotlinx.collections.immutable.ImmutableSet +import kotlinx.collections.immutable.toImmutableSet import st.slex.csplashscreen.core.collection.ui.model.CollectionModel import st.slex.csplashscreen.core.photos.ui.model.PhotoModel import st.slex.csplashscreen.feature.user.ui.components.tabs.UserTab @@ -22,7 +24,7 @@ data class UserPagerState( val photosListState: LazyListState, val collectionsListState: LazyListState, val likesListState: LazyListState, - val userTabs: Set, + val userTabs: ImmutableSet, val pagerState: PagerState, ) { @@ -92,7 +94,7 @@ fun rememberUserPagerState( photos = photos, likes = likes, collections = collections, - userTabs = userTabs, + userTabs = userTabs.toImmutableSet(), pagerState = pagerState, photosListState = photosListState, likesListState = likesListState, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d7e83059..d5c4603a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,8 +1,8 @@ [versions] androidDesugarJdkLibs = "2.0.4" -kotlin = "1.9.23" -androidGradlePlugin = "8.3.2" -androidTools = "31.4.0" +kotlin = "2.0.10" +androidGradlePlugin = "8.5.1" +androidTools = "31.5.1" minSdk = "28" targetSdk = "34" @@ -10,37 +10,41 @@ compileSdk = "34" versionName = "1.72" versionCode = "18" -ktx = "1.13.0" -material = "1.11.0" -appcompat = "1.6.1" +ktx = "1.13.1" +material = "1.12.0" +appcompat = "1.7.0" immutableCollection = "0.3.5" -lifecycle = "2.7.0" -coroutines = "1.7.3" -#suppress UnusedProperty -composeCompiler = "1.5.12" -composeBom = "2024.04.01" +lifecycle = "2.8.4" +coroutines = "1.8.1" + +composeBom = "2024.06.00" +composeGradle = "1.6.11" composeNavigation = "2.7.7" accompanist = "0.30.0" coilCompose = "2.5.0" -composeActivity = "1.9.0" +composeActivity = "1.9.1" koin = "3.5.6" koinKsp = "1.3.1" -ktor = "2.3.6" +ktor = "2.3.12" ktorAndroid = "2.2.4" okhttp3 = "4.12.0" junit = "4.13.2" -androidxJunit = "1.1.5" -espresso = "3.5.1" +androidxJunit = "1.2.1" +espresso = "3.6.1" robolectric = "4.9" -androidxTest = "1.5.0" +androidxTest = "1.6.1" room = "2.6.1" -ksp = "1.9.23-1.0.19" +ksp = "2.0.10-1.0.24" mockito = "2.19.0" - +vkompose = "0.5.5-k2" +serialization = "1.6.3" +paging = "3.3.2" +slf4j = "1.7.9" +coroutineTest = "1.8.1" [libraries] android-desugarJdkLibs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" } android-gradlePlugin = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePlugin" } @@ -49,6 +53,8 @@ kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", v ksp-gradlePlugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } android-tools-common = { group = "com.android.tools", name = "common", version.ref = "androidTools" } room-gradlePlugin = { group = "androidx.room", name = "room-gradle-plugin", version.ref = "room" } +vkompose-gradlePlugin = { group = "com.vk.vkompose", name = "com.vk.vkompose.gradle.plugin", version.ref = "vkompose" } +composeCompiler-gradlePlugin = { group = "org.jetbrains.compose", name = "compose-gradle-plugin", version.ref = "composeGradle" } kotlinx-collections-immutable = { group = "org.jetbrains.kotlinx", name = "kotlinx-collections-immutable", version.ref = "immutableCollection" } @@ -74,10 +80,10 @@ androidx-compose-navigation = { group = "androidx.navigation", name = "navigatio coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilCompose" } -androidx-compose-paging = "androidx.paging:paging-compose:3.2.1" -androidx-paging-runtime = "androidx.paging:paging-runtime-ktx:3.2.1" +androidx-compose-paging = { group = "androidx.paging", name = "paging-compose", version.ref = "paging" } +androidx-paging-runtime = { group = "androidx.paging", name = "paging-runtime-ktx", version.ref = "paging" } -kotlinx-serialization-json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0" +kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "serialization" } accompanist-placeholder = { module = "com.google.accompanist:accompanist-placeholder", version.ref = "accompanist" } accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" } @@ -94,7 +100,7 @@ brotli = { module = "org.brotli:dec", version = "0.1.2" } okhttp3-core = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp3" } okhttp3-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp3" } -slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version = "1.7.9" } +slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" } junit = { group = "junit", name = "junit", version.ref = "junit" } mockito = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" } @@ -119,15 +125,17 @@ koin-test-junit = { module = "io.insert-koin:koin-test-junit4", version.ref = "k koin-ksp = { group = "io.insert-koin", name = "koin-ksp-compiler", version.ref = "koinKsp" } -coroutine-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version = "1.7.3" } +coroutine-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutineTest" } [plugins] kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } application = { id = "com.android.application", version.ref = "androidGradlePlugin" } library = { id = "com.android.library", version.ref = "androidGradlePlugin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } room = { id = "androidx.room", version.ref = "room" } +vkompose = { id = "com.vk.vkompose", version.ref = "vkompose" } convention-application = { id = "csplashscreen.android.application", version = "1.0" } convention-application-compose = { id = "csplashscreen.android.application.compose", version = "1.0" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 04cba79f..92fbb6c9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Feb 15 09:17:21 MSK 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 50f3f1ed6712aa220b02b7d71d1b438f3e60d2b7 Mon Sep 17 00:00:00 2001 From: Ilya Stepanyuk Date: Fri, 9 Aug 2024 00:18:15 +0300 Subject: [PATCH 2/5] Update android_deploy_prod.yml --- .github/workflows/android_deploy_prod.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/android_deploy_prod.yml b/.github/workflows/android_deploy_prod.yml index 4987469f..649223a0 100644 --- a/.github/workflows/android_deploy_prod.yml +++ b/.github/workflows/android_deploy_prod.yml @@ -19,9 +19,7 @@ jobs: - name: Update Version run: bash ./.github/scripts/update_versions.sh - - uses: ruby/setup-ruby@v1.152.0 - with: - ruby-version: '2.7.0' + - uses: ruby/setup-ruby@v1 - name: Cache Ruby - Bundler uses: actions/cache@v2 @@ -94,4 +92,4 @@ jobs: uses: ad-m/github-push-action@master with: github_token: ${{ secrets.PUSH_TOKEN }} - branch: ${{ github.ref }} \ No newline at end of file + branch: ${{ github.ref }} From dceb6bd76a135fe13624f4181f1ccb9ff66c67da Mon Sep 17 00:00:00 2001 From: Ilya Stepanyuk Date: Fri, 9 Aug 2024 00:19:30 +0300 Subject: [PATCH 3/5] Update android_deploy_prod.yml --- .github/workflows/android_deploy_prod.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/android_deploy_prod.yml b/.github/workflows/android_deploy_prod.yml index 649223a0..0a05556b 100644 --- a/.github/workflows/android_deploy_prod.yml +++ b/.github/workflows/android_deploy_prod.yml @@ -20,6 +20,8 @@ jobs: run: bash ./.github/scripts/update_versions.sh - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' - name: Cache Ruby - Bundler uses: actions/cache@v2 From 9e2301cefbf1c58fb06f75b93204e2bde2a26d23 Mon Sep 17 00:00:00 2001 From: stslex Date: Fri, 9 Aug 2024 00:29:33 +0300 Subject: [PATCH 4/5] fix deploy --- .github/workflows/android_deploy_beta.yml | 4 ++-- gradle/libs.versions.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/android_deploy_beta.yml b/.github/workflows/android_deploy_beta.yml index bccec8ef..87a44a24 100644 --- a/.github/workflows/android_deploy_beta.yml +++ b/.github/workflows/android_deploy_beta.yml @@ -21,9 +21,9 @@ jobs: - name: Update Version run: bash ./.github/scripts/update_versions.sh - - uses: ruby/setup-ruby@v1.152.0 + - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7.0' + ruby-version: '3.3' - name: Cache Ruby - Bundler uses: actions/cache@v2 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d5c4603a..508903b1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ minSdk = "28" targetSdk = "34" compileSdk = "34" versionName = "1.72" -versionCode = "18" +versionCode = "19" ktx = "1.13.1" material = "1.12.0" From b083fd24ca1e19982e66962ce4fe20784e775c60 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 21:38:06 +0000 Subject: [PATCH 5/5] update version --- fastlane/report.xml | 6 +++--- gradle/libs.versions.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fastlane/report.xml b/fastlane/report.xml index 18414dbe..4bbd74e2 100644 --- a/fastlane/report.xml +++ b/fastlane/report.xml @@ -5,17 +5,17 @@ - + - + - + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 508903b1..1a1ed1c8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,8 +7,8 @@ androidTools = "31.5.1" minSdk = "28" targetSdk = "34" compileSdk = "34" -versionName = "1.72" -versionCode = "19" +versionName = "1.73" +versionCode = "20" ktx = "1.13.1" material = "1.12.0"