From 32aa4b04bd04a65908407ddbdc2c83e671f3e5ec Mon Sep 17 00:00:00 2001 From: Adam Kobus Date: Fri, 12 Aug 2022 20:31:48 +0200 Subject: [PATCH] Updated dependencies. 1.0.2 release --- CHANGELOG.md | 6 + README.md | 8 +- build.gradle | 10 +- .../src/main/java/com/adamkobus/vm/Libs.kt | 26 +- demo/build.gradle | 2 +- .../android/vm/demo/app/DemoApplication.kt | 13 +- .../adamkobus/android/vm/demo/di/DemoBinds.kt | 18 -- .../android/vm/demo/di/NavigationModule.kt | 36 +++ .../adamkobus/android/vm/demo/nav/Actions.kt | 24 +- .../demo/nav/ComposeNavigationConfigurator.kt | 23 ++ .../android/vm/demo/nav/DemoGraph.kt | 21 +- .../vm/demo/nav/DemoNavActionVerifier.kt | 15 +- .../android/vm/demo/nav/DemoNavHost.kt | 15 +- .../android/vm/demo/ui/dialog/DemoDialogVM.kt | 6 +- .../android/vm/demo/ui/home/HomeScreenVM.kt | 11 +- .../android/vm/demo/ui/logs/LogsScreenVM.kt | 8 +- detekt/config/custom.yml | 15 +- detekt/config/default.yml | 273 ++++++------------ gradle/publishing-root.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 20 files changed, 247 insertions(+), 287 deletions(-) delete mode 100644 demo/src/main/java/com/adamkobus/android/vm/demo/di/DemoBinds.kt create mode 100644 demo/src/main/java/com/adamkobus/android/vm/demo/di/NavigationModule.kt create mode 100644 demo/src/main/java/com/adamkobus/android/vm/demo/nav/ComposeNavigationConfigurator.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc7d8d..d60d3d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ### Changes +# 1.0.2 + +### Changes + +- Updated AGP to 7.2.2 + # 1.0.1 ### Fixes diff --git a/README.md b/README.md index 8581f68..5ea6b5f 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ repositories { dependencies { // LifecycleObserverKtx - implementation "com.adamkobus:lifecycle-observer-ktx:1.0.1" + implementation "com.adamkobus:lifecycle-observer-ktx:1.0.2" // LifecycleObserverKtx + LifecycleAwareViewModel + ViewParam - implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.1" + implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.2" } ``` @@ -39,10 +39,10 @@ repositories { dependencies { // LifecycleObserverKtx - implementation "com.adamkobus:lifecycle-observer-ktx:1.0.1-SNAPSHOT" + implementation "com.adamkobus:lifecycle-observer-ktx:1.0.2-SNAPSHOT" // LifecycleObserverKtx + LifecycleAwareViewModel + ViewParam - implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.1-SNAPSHOT" + implementation "com.adamkobus:lifecycle-observer-viewmodel-ktx:1.0.2-SNAPSHOT" } ``` diff --git a/build.gradle b/build.gradle index bbaae5b..d970669 100644 --- a/build.gradle +++ b/build.gradle @@ -6,22 +6,22 @@ apply plugin: "com.github.ben-manes.versions" buildscript { ext { // https://github.com/JLLeitschuh/ktlint-gradle/releases - ktlintPluginVersion = "10.2.1" + ktlintPluginVersion = "10.3.0" // https://github.com/detekt/detekt/releases - detektPluginVersion = "1.19.0" + detektPluginVersion = "1.21.0" // https://github.com/ben-manes/gradle-versions-plugin/releases - versionsPluginVersion = "0.41.0" + versionsPluginVersion = "0.42.0" // https://github.com/gradle-nexus/publish-plugin/releases publishPluginVersion = "1.1.0" // https://developer.android.com/studio/releases/gradle-plugin - androidGradlePluginVersion = "7.1.0" + androidGradlePluginVersion = "7.2.2" // https://kotlinlang.org/docs/releases.html#release-details - kotlinVersion = "1.6.0" + kotlinVersion = "1.7.10" } repositories { diff --git a/buildSrc/src/main/java/com/adamkobus/vm/Libs.kt b/buildSrc/src/main/java/com/adamkobus/vm/Libs.kt index c078022..7d24a27 100644 --- a/buildSrc/src/main/java/com/adamkobus/vm/Libs.kt +++ b/buildSrc/src/main/java/com/adamkobus/vm/Libs.kt @@ -9,37 +9,39 @@ object Libs { /** * [Kotlint Coroutines Releases](https://github.com/Kotlin/kotlinx.coroutines/releases) */ - const val KOTLIN_COROUTINES_VERSION = "1.6.0" + const val KOTLIN_COROUTINES_VERSION = "1.6.4" /** * [Jetpack Compose Releases](https://developer.android.com/jetpack/androidx/versions/all-channel) */ - const val COMPOSE_VERSION = "1.1.0-rc01" + const val COMPOSE_VERSION = "1.2.1" + + const val COMPOSE_COMPILER_VERSION = "1.3.0" /** * [Accompanist Version](https://github.com/google/accompanist/releases) */ - const val ACCOMPANIST_VERSION = "0.22.0-rc" + const val ACCOMPANIST_VERSION = "0.25.1" /** * [Ktlint Releases](https://github.com/pinterest/ktlint/releases) */ - const val KTLINT_VERSION = "0.43.2" + const val KTLINT_VERSION = "0.42.1" /** * [AndroidX Lifecycle Releases](https://developer.android.com/jetpack/androidx/releases/lifecycle) */ - const val ANDROIDX_LIFECYCLE_VERSION = "2.4.0" + const val ANDROIDX_LIFECYCLE_VERSION = "2.5.1" /** * [AndroidX Appcompat Releases](https://developer.android.com/jetpack/androidx/releases/appcompat) */ - const val ANDROIDX_APPCOMPAT_VERSION = "1.4.1" + const val ANDROIDX_APPCOMPAT_VERSION = "1.5.0" /** * [Hilt Releases](https://github.com/google/dagger/releases) */ - const val HILT_VERSION = "2.40.5" + const val HILT_VERSION = "2.43.2" object Kotlin { const val Coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$KOTLIN_COROUTINES_VERSION" @@ -49,7 +51,7 @@ object Libs { /** * [Compose Activity Releases](https://androidx.tech/artifacts/activity/activity-compose/) */ - const val Activity = "androidx.activity:activity-compose:1.4.0" + const val Activity = "androidx.activity:activity-compose:1.5.1" const val Ui = "androidx.compose.ui:ui:$COMPOSE_VERSION" const val Material = "androidx.compose.material:material:$COMPOSE_VERSION" const val ToolingPreview = "androidx.compose.ui:ui-tooling-preview:$COMPOSE_VERSION" @@ -72,7 +74,7 @@ object Libs { /** * [Material Releases](https://github.com/material-components/material-components-android/releases) */ - const val Material = "com.google.android.material:material:1.5.0" + const val Material = "com.google.android.material:material:1.6.1" const val Hilt = "com.google.dagger:hilt-android:$HILT_VERSION" const val HiltCompiler = "com.google.dagger:hilt-android-compiler:$HILT_VERSION" @@ -86,7 +88,7 @@ object Libs { /** * [Compose Navigation Releases](https://github.com/AdamKobus/compose-navigation/releases) */ - const val Navigation = "com.adamkobus:compose-navigation:0.1.0" + const val Navigation = "com.adamkobus:compose-navigation:0.3.0" } object Test { @@ -98,8 +100,8 @@ object Libs { /** * [Mockk Releases](https://github.com/mockk/mockk/releases) */ - const val Mockk = "io.mockk:mockk:1.12.2" + const val Mockk = "io.mockk:mockk:1.12.5" - const val CoroutinesTest = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$KOTLIN_VERSION" + const val CoroutinesTest = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$KOTLIN_COROUTINES_VERSION" } } diff --git a/demo/build.gradle b/demo/build.gradle index 25760fe..de70494 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -20,7 +20,7 @@ android { } composeOptions { - kotlinCompilerExtensionVersion Libs.COMPOSE_VERSION + kotlinCompilerExtensionVersion Libs.COMPOSE_COMPILER_VERSION } } diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/app/DemoApplication.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/app/DemoApplication.kt index f59fcc8..8a75342 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/app/DemoApplication.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/app/DemoApplication.kt @@ -1,7 +1,18 @@ package com.adamkobus.android.vm.demo.app import android.app.Application +import com.adamkobus.android.vm.demo.nav.ComposeNavigationConfigurator import dagger.hilt.android.HiltAndroidApp +import javax.inject.Inject @HiltAndroidApp -class DemoApplication : Application() +class DemoApplication : Application() { + + @Inject + lateinit var composeNavigationConfigStep: ComposeNavigationConfigurator + + override fun onCreate() { + super.onCreate() + composeNavigationConfigStep.configure() + } +} diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/di/DemoBinds.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/di/DemoBinds.kt deleted file mode 100644 index 4c33920..0000000 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/di/DemoBinds.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.adamkobus.android.vm.demo.di - -import com.adamkobus.android.vm.demo.nav.DemoNavActionVerifier -import com.adamkobus.compose.navigation.NavActionVerifier -import dagger.Binds -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import dagger.multibindings.IntoSet - -@InstallIn(SingletonComponent::class) -@Module -interface DemoBinds { - - @Binds - @IntoSet - fun bindsDemoNavActionVerifier(impl: DemoNavActionVerifier): NavActionVerifier -} diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/di/NavigationModule.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/di/NavigationModule.kt new file mode 100644 index 0000000..17d3c05 --- /dev/null +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/di/NavigationModule.kt @@ -0,0 +1,36 @@ +package com.adamkobus.android.vm.demo.di + +import com.adamkobus.android.vm.demo.nav.DemoNavActionVerifier +import com.adamkobus.compose.navigation.ComposeNavigation +import com.adamkobus.compose.navigation.NavActionVerifier +import com.adamkobus.compose.navigation.NavigationConsumer +import com.adamkobus.compose.navigation.NavigationStateSource +import dagger.Binds +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import dagger.multibindings.IntoSet + +@Module(includes = [NavigationModuleBinds::class]) +@InstallIn(SingletonComponent::class) +object NavigationModule { + + @Provides + fun providesNavigationConsumer(): NavigationConsumer { + return ComposeNavigation.getNavigationConsumer() + } + + @Provides + fun provideNavigationStateSource(): NavigationStateSource = + ComposeNavigation.getNavigationStateSource() +} + +@InstallIn(SingletonComponent::class) +@Module +internal interface NavigationModuleBinds { + + @Binds + @IntoSet + fun bindDefaultNavActionVerifier(impl: DemoNavActionVerifier): NavActionVerifier +} diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/Actions.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/Actions.kt index faaed50..60c2eb2 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/Actions.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/Actions.kt @@ -1,24 +1,18 @@ package com.adamkobus.android.vm.demo.nav -import com.adamkobus.compose.navigation.data.NavAction -import com.adamkobus.compose.navigation.data.PopBackStackDestination +import com.adamkobus.compose.navigation.action.NavAction +import com.adamkobus.compose.navigation.action.NavActionWrapper -sealed class FromHome(navAction: NavAction) : NavAction(navAction) { +sealed class FromHome(navAction: NavAction) : NavActionWrapper(navAction) { - object ToLogsList : FromHome(DemoGraph.Home to DemoGraph.LogsList) + object ToLogsList : FromHome(DemoGraph.Home goTo DemoGraph.LogsList) } -sealed class FromDemoDialog(navAction: NavAction) : NavAction(navAction) { - object Dismiss : FromDemoDialog( - NavAction( - DemoGraph.DemoDialog, - PopBackStackDestination, - navigateWithController = { it.popBackStack() } - ) - ) +sealed class FromDemoDialog(navAction: NavAction) : NavActionWrapper(navAction) { + object Dismiss : FromDemoDialog(DemoGraph.DemoDialog.pop()) } -sealed class FromLogs(navAction: NavAction) : NavAction(navAction) { - class ToDemoDialog(logId: Int) : NavAction(DemoGraph.LogsList to DemoGraph.DemoDialog arg logId) - object Back : NavAction(DemoGraph.LogsList, PopBackStackDestination, navigateWithController = { it.popBackStack() }) +sealed class FromLogs(navAction: NavAction) : NavActionWrapper(navAction) { + class ToDemoDialog(logId: Int) : FromLogs(DemoGraph.LogsList goTo DemoGraph.DemoDialog arg logId) + object Back : FromLogs(DemoGraph.LogsList.pop()) } diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/ComposeNavigationConfigurator.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/ComposeNavigationConfigurator.kt new file mode 100644 index 0000000..324fa66 --- /dev/null +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/ComposeNavigationConfigurator.kt @@ -0,0 +1,23 @@ +package com.adamkobus.android.vm.demo.nav + +import android.util.Log +import com.adamkobus.compose.navigation.BuildConfig +import com.adamkobus.compose.navigation.ComposeNavigation +import com.adamkobus.compose.navigation.NavActionVerifier +import javax.inject.Inject + +class ComposeNavigationConfigurator @Inject constructor( + private val navVerifiers: Set<@JvmSuppressWildcards NavActionVerifier>, +) { + + fun configure() { + val logLevel = if (BuildConfig.DEBUG) { + Log.VERBOSE + } else { + Log.WARN + } + ComposeNavigation + .addNavActionVerifiers(navVerifiers) + .setLogLevel(logLevel) + } +} diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoGraph.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoGraph.kt index 3011a26..e9b1a3a 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoGraph.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoGraph.kt @@ -1,37 +1,36 @@ package com.adamkobus.android.vm.demo.nav import androidx.compose.animation.ExperimentalAnimationApi -import androidx.navigation.NavBackStackEntry import androidx.navigation.NavGraphBuilder import com.adamkobus.android.vm.demo.ui.dialog.DemoDialog import com.adamkobus.android.vm.demo.ui.home.HomeScreen import com.adamkobus.android.vm.demo.ui.logs.LogsScreen -import com.adamkobus.compose.navigation.data.NavGraph +import com.adamkobus.compose.navigation.destination.NavGraph +import com.adamkobus.compose.navigation.destination.NavStackEntry import com.adamkobus.compose.navigation.ext.composableDestination import com.adamkobus.compose.navigation.ext.composableDialog import com.adamkobus.compose.navigation.ext.composableNavigation -import com.adamkobus.compose.navigation.ext.getInt -object DemoGraph : NavGraph { - override val name: String = "demoGraph" +object DemoGraph : NavGraph("demoGraph") { const val PARAM_LOG_ID = "logId" - val Home = navDestination("home") - val LogsList = navDestination("logs") + val Home = screenDestination("home") + val LogsList = screenDestination("logs") - val DemoDialog = navDestination("demoDialog") { + val DemoDialog = dialogDestination("demoDialog") { param(PARAM_LOG_ID) } + + override fun startDestination() = Home } -fun NavBackStackEntry.logId(): Int = getInt(DemoGraph.PARAM_LOG_ID) +fun NavStackEntry.logId(): Int = getInt(DemoGraph.PARAM_LOG_ID) @OptIn(ExperimentalAnimationApi::class) fun NavGraphBuilder.demoGraph() { composableNavigation( - graph = DemoGraph, - startDestination = DemoGraph.Home + graph = DemoGraph ) { composableDestination(DemoGraph.Home) { HomeScreen() diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavActionVerifier.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavActionVerifier.kt index 89b5cd3..124ab5f 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavActionVerifier.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavActionVerifier.kt @@ -1,13 +1,20 @@ package com.adamkobus.android.vm.demo.nav import com.adamkobus.compose.navigation.NavActionVerifier -import com.adamkobus.compose.navigation.data.INavDestination -import com.adamkobus.compose.navigation.data.NavAction +import com.adamkobus.compose.navigation.VerifyResult +import com.adamkobus.compose.navigation.action.NavAction +import com.adamkobus.compose.navigation.destination.GlobalGraph +import com.adamkobus.compose.navigation.destination.NavState import javax.inject.Inject class DemoNavActionVerifier @Inject constructor() : NavActionVerifier { - override fun isNavActionAllowed(currentDestination: INavDestination, action: NavAction): Boolean { - return action.fromDestination == currentDestination + override fun isNavActionAllowed(navState: NavState, action: NavAction): VerifyResult { + if (action.fromDestination.graph == GlobalGraph) return VerifyResult.Allow + return if (navState.isCurrent(action.fromDestination)) { + VerifyResult.Allow + } else { + VerifyResult.Discard + } } } diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavHost.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavHost.kt index d42ca38..f283472 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavHost.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/nav/DemoNavHost.kt @@ -1,10 +1,11 @@ package com.adamkobus.android.vm.demo.nav import androidx.compose.animation.ExperimentalAnimationApi +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.adamkobus.compose.navigation.ui.NavComposable -import com.google.accompanist.navigation.animation.AnimatedNavHost +import com.adamkobus.compose.navigation.ComposeNavHost +import com.adamkobus.compose.navigation.NavigationId import com.google.accompanist.navigation.animation.rememberAnimatedNavController @OptIn(ExperimentalAnimationApi::class) @@ -13,11 +14,11 @@ fun DemoNavHost( modifier: Modifier = Modifier ) { val navHostController = rememberAnimatedNavController() - NavComposable(navController = navHostController) - AnimatedNavHost( - navController = navHostController, - startDestination = DemoGraph.name, - modifier = modifier + ComposeNavHost( + startGraph = DemoGraph, + controller = navHostController, + navigationId = NavigationId.DEFAULT, + modifier = Modifier.fillMaxSize() ) { demoGraph() } diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/ui/dialog/DemoDialogVM.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/ui/dialog/DemoDialogVM.kt index 802c44a..7de0d98 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/ui/dialog/DemoDialogVM.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/ui/dialog/DemoDialogVM.kt @@ -6,13 +6,13 @@ import com.adamkobus.android.vm.ViewParam import com.adamkobus.android.vm.collectParam import com.adamkobus.android.vm.demo.model.logs.DemoLogsStore import com.adamkobus.android.vm.demo.nav.FromDemoDialog -import com.adamkobus.compose.navigation.NavActionConsumer +import com.adamkobus.compose.navigation.NavigationConsumer import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class DemoDialogVM @Inject constructor( - private val navActionConsumer: NavActionConsumer, + private val navigationConsumer: NavigationConsumer, private val logsStore: DemoLogsStore ) : LifecycleAwareViewModel() { @@ -25,7 +25,7 @@ class DemoDialogVM @Inject constructor( val interactions = DemoDialogInteractions( onDismissClicked = { runOnMain { - navActionConsumer.offer(FromDemoDialog.Dismiss) + navigationConsumer.offer(FromDemoDialog.Dismiss) } } ) diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/ui/home/HomeScreenVM.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/ui/home/HomeScreenVM.kt index 662c686..e81ca26 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/ui/home/HomeScreenVM.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/ui/home/HomeScreenVM.kt @@ -2,24 +2,21 @@ package com.adamkobus.android.vm.demo.ui.home import androidx.lifecycle.viewModelScope import com.adamkobus.android.vm.LifecycleAwareViewModel -import com.adamkobus.android.vm.demo.di.DispatcherMain import com.adamkobus.android.vm.demo.nav.FromHome -import com.adamkobus.compose.navigation.NavActionConsumer +import com.adamkobus.compose.navigation.NavigationConsumer import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class HomeScreenVM @Inject constructor( - private val navActionConsumer: NavActionConsumer, - @DispatcherMain private val mainDispatcher: CoroutineDispatcher + private val navigationConsumer: NavigationConsumer, ) : LifecycleAwareViewModel() { val interactions = HomeScreenInteractions( onLaunchLogsClicked = { - viewModelScope.launch(mainDispatcher) { - navActionConsumer.offer(FromHome.ToLogsList) + viewModelScope.launch() { + navigationConsumer.offer(FromHome.ToLogsList) } } ) diff --git a/demo/src/main/java/com/adamkobus/android/vm/demo/ui/logs/LogsScreenVM.kt b/demo/src/main/java/com/adamkobus/android/vm/demo/ui/logs/LogsScreenVM.kt index b36f732..3fe6499 100644 --- a/demo/src/main/java/com/adamkobus/android/vm/demo/ui/logs/LogsScreenVM.kt +++ b/demo/src/main/java/com/adamkobus/android/vm/demo/ui/logs/LogsScreenVM.kt @@ -7,14 +7,14 @@ import com.adamkobus.android.vm.LifecycleAwareViewModel import com.adamkobus.android.vm.demo.model.datetime.DemoDateFormatter import com.adamkobus.android.vm.demo.model.logs.DemoLogsStore import com.adamkobus.android.vm.demo.nav.FromLogs -import com.adamkobus.compose.navigation.NavActionConsumer +import com.adamkobus.compose.navigation.NavigationConsumer import dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @HiltViewModel class LogsScreenVM @Inject constructor( private val logsStore: DemoLogsStore, - private val navActionConsumer: NavActionConsumer, + private val navigationConsumer: NavigationConsumer, private val dateFormatter: DemoDateFormatter ) : LifecycleAwareViewModel() { @@ -29,12 +29,12 @@ class LogsScreenVM @Inject constructor( val interactions = LogsInteractions( onLogClicked = { item -> runOnMain { - navActionConsumer.offer(FromLogs.ToDemoDialog(item.id)) + navigationConsumer.offer(FromLogs.ToDemoDialog(item.id)) } }, onBackClicked = { runOnMain { - navActionConsumer.offer(FromLogs.Back) + navigationConsumer.offer(FromLogs.Back) } } ) diff --git a/detekt/config/custom.yml b/detekt/config/custom.yml index 60f48eb..bb7c5d1 100644 --- a/detekt/config/custom.yml +++ b/detekt/config/custom.yml @@ -3,14 +3,6 @@ naming: ignoreAnnotated: - Composable -formatting: - ArgumentListWrapping: - maxLineLength: 140 - MaximumLineLength: - maxLineLength: 140 - ParameterListWrapping: - maxLineLength: 140 - style: MaxLineLength: maxLineLength: 140 @@ -21,6 +13,13 @@ style: active: true ignoreAnnotated: - 'Module' + ReturnCount: + active: true + max: 3 + excludedFunctions: 'equals' + excludeLabeled: false + excludeReturnFromLambda: true + excludeGuardClauses: false complexity: TooManyFunctions: diff --git a/detekt/config/default.yml b/detekt/config/default.yml index d777d87..17ba2f4 100644 --- a/detekt/config/default.yml +++ b/detekt/config/default.yml @@ -1,4 +1,3 @@ -# current config: https://github.com/detekt/detekt/blob/main/detekt-core/src/main/resources/default-detekt-config.yml build: maxIssues: 0 excludeCorrectable: false @@ -37,9 +36,9 @@ console-reports: - 'ProjectStatisticsReport' - 'ComplexityReport' - 'NotificationReport' - # - 'FindingsReport' + - 'FindingsReport' - 'FileBasedFindingsReport' - - 'LiteFindingsReport' + # - 'LiteFindingsReport' output-reports: active: true @@ -47,6 +46,7 @@ output-reports: # - 'TxtOutputReport' # - 'XmlOutputReport' # - 'HtmlOutputReport' + # - 'MdOutputReport' comments: active: true @@ -63,10 +63,14 @@ comments: EndOfSentenceFormat: active: false endOfSentenceFormat: '([.?!][ \t\n\r\f<])|([.?!:]$)' + KDocReferencesNonPublicProperty: + active: false + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] OutdatedDocumentation: active: false matchTypeParameters: true matchDeclarationsOrder: true + allowParamOnConstructorProperties: false UndocumentedPublicClass: active: false excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] @@ -129,9 +133,19 @@ complexity: NamedArguments: active: false threshold: 3 + ignoreArgumentsMatchingNames: false NestedBlockDepth: active: true threshold: 4 + NestedScopeFunctions: + active: false + threshold: 1 + functions: + - 'kotlin.apply' + - 'kotlin.run' + - 'kotlin.with' + - 'kotlin.let' + - 'kotlin.also' ReplaceSafeCallChainWithRun: active: false StringLiteralDuplication: @@ -158,17 +172,19 @@ coroutines: GlobalCoroutineUsage: active: false InjectDispatcher: - active: false + active: true dispatcherNames: - 'IO' - 'Default' - 'Unconfined' RedundantSuspendModifier: - active: false + active: true SleepInsteadOfDelay: + active: true + SuspendFunWithCoroutineScopeReceiver: active: false SuspendFunWithFlowReturnType: - active: false + active: true empty-blocks: active: true @@ -215,7 +231,7 @@ exceptions: - 'hashCode' - 'toString' InstanceOfCheckForException: - active: false + active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] NotImplementedDeclaration: active: false @@ -276,192 +292,50 @@ 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: true - autoCorrect: true - layout: '*,java.**,javax.**,kotlin.**,^' - Indentation: - active: true - autoCorrect: true - indentSize: 4 - continuationIndentSize: 4 - MaximumLineLength: - active: true - maxLineLength: 120 - ignoreBackTickedIdentifier: false - ModifierOrdering: - active: true - autoCorrect: true - MultiLineIfElse: - active: false - 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: true - PackageName: - active: false - 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: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] allowedPattern: '^(is|has|are)' + ignoreOverridden: true ClassNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] classPattern: '[A-Z][a-zA-Z0-9]*' ConstructorParameterNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] 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/**'] enumEntryPattern: '[A-Z][_a-zA-Z0-9]*' ForbiddenClassName: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] forbiddenName: [] FunctionMaxLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] maximumFunctionNameLength: 30 FunctionMinLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] minimumFunctionNameLength: 3 FunctionNaming: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] - functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)' + functionPattern: '[a-z][a-zA-Z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true FunctionParameterNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] parameterPattern: '[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' ignoreOverridden: true InvalidPackageDeclaration: - active: false + active: true rootPackage: '' + requireRootInDeclaration: false LambdaParameterNaming: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] parameterPattern: '[a-z][A-Za-z0-9]*|_' MatchingDeclarationName: active: true @@ -470,37 +344,30 @@ naming: active: true ignoreOverridden: true NoNameShadowing: - active: false + active: true NonBooleanPropertyPrefixedWithIs: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] ObjectPropertyNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] constantPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' PackageNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*' TopLevelPropertyNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] constantPattern: '[A-Z][_A-Z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' VariableMaxLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] maximumVariableNameLength: 64 VariableMinLength: active: false - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] minimumVariableNameLength: 1 VariableNaming: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] variablePattern: '[a-z][A-Za-z0-9]*' privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' excludeClassPattern: '$^' @@ -510,6 +377,9 @@ performance: active: true ArrayPrimitive: active: true + CouldBeSequence: + active: false + threshold: 3 ForEachOnRange: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] @@ -522,7 +392,7 @@ performance: potential-bugs: active: true AvoidReferentialEquality: - active: false + active: true forbiddenTypePatterns: - 'kotlin.String' CastToNullableType: @@ -532,9 +402,20 @@ potential-bugs: DontDowncastCollectionTypes: active: false DoubleMutabilityForCollection: - active: false + active: true + mutableTypes: + - 'kotlin.collections.MutableList' + - 'kotlin.collections.MutableMap' + - 'kotlin.collections.MutableSet' + - 'java.util.ArrayList' + - 'java.util.LinkedHashSet' + - 'java.util.HashSet' + - 'java.util.LinkedHashMap' + - 'java.util.HashMap' DuplicateCaseInWhenExpression: active: true + ElseCaseInsteadOfExhaustiveWhen: + active: false EqualsAlwaysReturnsTrueOrFalse: active: true EqualsWithHashCodeExist: @@ -544,15 +425,16 @@ potential-bugs: ExplicitGarbageCollectionCall: active: true HasPlatformType: - active: false + active: true IgnoredReturnValue: - active: false + active: true restrictToAnnotatedMethods: true returnValueAnnotations: - '*.CheckResult' - '*.CheckReturnValue' ignoreReturnValueAnnotations: - '*.CanIgnoreReturnValue' + ignoreFunctionCall: [] ImplicitDefaultLocale: active: true ImplicitUnitReturnType: @@ -569,13 +451,15 @@ potential-bugs: excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] ignoreOnClassesPattern: '' MapGetWithNotNullAssertionOperator: - active: false + active: true MissingPackageDeclaration: active: false excludes: ['**/*.kts'] MissingWhenCase: active: true allowElseExpression: true + NullCheckOnMutableProperty: + active: false NullableToStringCall: active: false RedundantElseInWhen: @@ -587,7 +471,7 @@ potential-bugs: UnnecessarySafeCall: active: true UnreachableCatchBlock: - active: false + active: true UnreachableCode: active: true UnsafeCallOnNullableType: @@ -596,14 +480,19 @@ potential-bugs: UnsafeCast: active: true UnusedUnaryOperator: - active: false + active: true UselessPostfixExpression: - active: false + active: true WrongEqualsTypeParameter: active: true style: active: true + CanBeNonNullable: + active: false + CascadingCallWrapping: + active: false + includeElvis: true ClassOrdering: active: false CollapsibleIfStatements: @@ -614,7 +503,7 @@ style: DataClassShouldBeImmutable: active: false DestructuringDeclarationWithTooManyEntries: - active: false + active: true maxDestructuringEntries: 3 EqualsNullCall: active: true @@ -623,7 +512,7 @@ style: ExplicitCollectionElementAccessMethod: active: false ExplicitItLambdaParameter: - active: false + active: true ExpressionBodySyntax: active: false includeLineWrapping: false @@ -650,8 +539,11 @@ style: ignorePackages: - '*.internal' - '*.internal.*' - ForbiddenVoid: + ForbiddenSuppress: active: false + rules: [] + ForbiddenVoid: + active: true ignoreOverridden: false ignoreUsageInGenerics: false FunctionOnlyReturningConstant: @@ -670,7 +562,7 @@ style: maxJumpCount: 1 MagicNumber: active: true - excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] + excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts'] ignoreNumbers: - '-1' - '0' @@ -690,6 +582,9 @@ style: active: false MandatoryBracesLoops: active: false + MaxChainedCallsOnSameLine: + active: false + maxChainedCalls: 5 MaxLineLength: active: true maxLineLength: 120 @@ -708,8 +603,10 @@ style: active: true NoTabs: active: false - ObjectLiteralToLambda: + NullableBooleanCheck: active: false + ObjectLiteralToLambda: + active: true OptionalAbstractKeyword: active: true OptionalUnit: @@ -723,7 +620,7 @@ style: RedundantExplicitType: active: false RedundantHigherOrderMapUsage: - active: false + active: true RedundantVisibilityModifierRule: active: false ReturnCount: @@ -748,16 +645,21 @@ style: UnderscoresInNumericLiterals: active: false acceptableLength: 4 + allowNonStandardGrouping: false UnnecessaryAbstractClass: active: true UnnecessaryAnnotationUseSiteTarget: active: false UnnecessaryApply: active: true - UnnecessaryFilter: + UnnecessaryBackticks: active: false + UnnecessaryFilter: + active: true UnnecessaryInheritance: active: true + UnnecessaryInnerClass: + active: false UnnecessaryLet: active: false UnnecessaryParentheses: @@ -772,13 +674,13 @@ style: active: true allowedNames: '(_|ignored|expected|serialVersionUID)' UseAnyOrNoneInsteadOfFind: - active: false + active: true UseArrayLiteralsInAnnotations: - active: false + active: true UseCheckNotNull: - active: false + active: true UseCheckOrError: - active: false + active: true UseDataClass: active: false allowVars: false @@ -789,21 +691,22 @@ style: UseIfInsteadOfWhen: active: false UseIsNullOrEmpty: - active: false + active: true UseOrEmpty: - active: false + active: true UseRequire: - active: false + active: true UseRequireNotNull: - active: false + active: true UselessCallOnNotNull: active: true UtilityClassWithPublicConstructor: active: true VarCouldBeVal: active: true + ignoreLateinitVar: false WildcardImport: active: true excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**'] excludeImports: - - 'java.util.*' + - 'java.util.*' \ No newline at end of file diff --git a/gradle/publishing-root.gradle b/gradle/publishing-root.gradle index 28781e1..23ea858 100644 --- a/gradle/publishing-root.gradle +++ b/gradle/publishing-root.gradle @@ -4,7 +4,7 @@ rootProject.ext["adamkobusSonatypeStagingProfileId"] = "" rootProject.ext["snapshot"] = System.getenv().getOrDefault("MAVEN_SNAPSHOT", "true") -def VERSION_BASE = "1.0.1" +def VERSION_BASE = "1.0.2" def VERSION_SUFFIX = "" if (rootProject.ext["snapshot"] == "true") { VERSION_SUFFIX = "-SNAPSHOT" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4ac6e02..d657694 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri Feb 04 20:02:20 CET 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME