From 854313451f30356d7c41c13c2cc4bce3a2e06caf Mon Sep 17 00:00:00 2001 From: anmol verma Date: Sun, 27 Feb 2022 13:24:41 +0530 Subject: [PATCH 1/6] Move to CompositeBuilds from buildSrc --- app/build.gradle.kts | 132 +-------------- build.gradle.kts | 11 -- buildSrc/build.gradle.kts | 21 ++- buildSrc/src/main/kotlin/AppVersions.kt | 3 +- buildSrc/src/main/kotlin/Dependencies.kt | 12 +- buildSrc/src/main/kotlin/Extensions.kt | 89 ++++++++++ .../main/kotlin/gradle/plugins/AppModule.kt | 159 ++++++++++++++++++ .../main/kotlin/gradle/plugins/BasePlugins.kt | 30 ++++ .../main/kotlin/gradle/plugins/Extensions.kt | 22 +++ .../kotlin/gradle/plugins/FeatureModule.kt | 90 ++++++++++ .../gradle-plugins/AppModule.properties | 1 + .../gradle-plugins/FeatureModule.properties | 1 + common/build.gradle.kts | 23 +-- .../dispatcher/CoroutineDispatcherProvider.kt | 2 +- .../RealCoroutineDispatcherProvider.kt | 2 +- commonui/build.gradle.kts | 94 ++++------- data/build.gradle.kts | 4 +- .../praxis/data/local/AppDatabase.kt | 2 +- domain/build.gradle.kts | 4 +- navigator/build.gradle.kts | 6 +- ui-authentication/build.gradle.kts | 77 +-------- .../feat/authentication/vm/AuthVMTest.kt | 8 +- ui-onboarding/build.gradle.kts | 78 +-------- 23 files changed, 479 insertions(+), 392 deletions(-) create mode 100644 buildSrc/src/main/kotlin/Extensions.kt create mode 100644 buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt create mode 100644 buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt create mode 100644 buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt create mode 100644 buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5f8997ff..d549dd9e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,105 +1,5 @@ -// Manifest version information! - plugins { - id(BuildPlugins.ANDROID_APPLICATION_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.ktLint) -} - -// def preDexEnabled = "true" == System.getProperty("pre-dex", "true") - -android { - compileSdk = (AppVersions.COMPILE_SDK) - - defaultConfig { - applicationId = (AppVersions.APPLICATION_ID) - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - versionCode = AppVersions.versionCode - versionName = AppVersions.versionName - testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" - vectorDrawables.useSupportLibrary = true - - javaCompileOptions { - annotationProcessorOptions { - arguments += mapOf( - "room.schemaLocation" to "$projectDir/schemas", - "room.incremental" to "true", - "room.expandProjection" to "true" - ) - } - } - } - - signingConfigs { - - getByName("debug") { - keyAlias = "praxis-debug" - keyPassword = "utherNiC" - storeFile = file("keystore/praxis-debug.jks") - storePassword = "uRgeSCIt" - } - - create("release") { - keyAlias = "praxis-release" - keyPassword = "ITHOmptI" - storeFile = file("keystore/praxis-release.jks") - storePassword = "PoTHatHR" - } - - } - buildTypes { - getByName("release") { - isDebuggable = false - versionNameSuffix = "-release" - - isMinifyEnabled = true - isShrinkResources = true - - proguardFiles( - getDefaultProguardFile("proguard-android.txt"), "proguard-common.txt", - "proguard-specific.txt" - ) - signingConfig = signingConfigs.getByName("release") - } - getByName("debug") { - isDebuggable = true - versionNameSuffix = "-debug" - applicationIdSuffix = ".debug" - signingConfig = signingConfigs.getByName("debug") - } - } - - buildFeatures { - dataBinding = true - } - - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion - } - - packagingOptions { - resources.excludes.add("META-INF/LICENSE.txt") - resources.excludes.add("META-INF/NOTICE.txt") - resources.excludes.add("LICENSE.txt") - resources.excludes.add( "/META-INF/{AL2.0,LGPL2.1}") - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } + id("AppModule") } // Required for annotation processing plugins like Dagger @@ -108,7 +8,6 @@ kapt { correctErrorTypes = true } - hilt { // The Hilt configuration option 'enableTransformForLocalTests' // is no longer necessary when com.android.tools.build:gradle:4.2.0+ is used. @@ -122,36 +21,7 @@ hilt { } dependencies { - - - Lib.Androidx.list.forEach(::api) - Lib.Androidx.Compose.list.forEach(::api) - Lib.ThirdParty.list.forEach(::api) - Lib.Accompanist.list.forEach(::api) - Lib.Google.list.forEach(::api) - Lib.Kotlin.list.forEach(::api) - - api(project(":ui-onboarding")) - api(project(":ui-authentication")) - api(project(":navigator")) - api(project(":data")) - api(project(":domain")) - api(project(":common")) - api(project(":commonui")) - - /*DI*/ - api(Lib.Di.hilt) - api(Lib.Di.hiltNavigationCompose) - api(Lib.Di.viewmodel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - - // Room - api(Lib.Room.roomKtx) - api(Lib.Room.roomRuntime) - add("kapt", Lib.Room.roomCompiler) testApi(Lib.Room.testing) - UnitTesting.list.forEach(::testApi) DevDependencies.debugList.forEach(::debugApi) DevDependencies.list.forEach(::api) diff --git a/build.gradle.kts b/build.gradle.kts index 7dd80b6e..c396e5dc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,17 +5,6 @@ buildscript { google() maven("https://plugins.gradle.org/m2/") } - dependencies { - classpath(BuildPlugins.TOOLS_BUILD_GRADLE) - classpath(BuildPlugins.SAFE_ARGS_GRADLE_PLUGIN) - classpath(BuildPlugins.DAGGER_HILT_PLUGIN) - classpath(BuildPlugins.KOTLIN_GRADLE_PLUGIN) - classpath(kotlin("serialization", version = Lib.Kotlin.KOTLIN_VERSION)) - classpath(BuildPlugins.KTLINT_GRADLE_PLUGIN) - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } } allprojects { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 148f55f3..aa772a73 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,7 +1,22 @@ +plugins { + `kotlin-dsl` +} + repositories { + mavenCentral() jcenter() + google() + maven("https://plugins.gradle.org/m2/") } -plugins { - `kotlin-dsl` -} + +dependencies{ + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") + implementation("com.android.tools.build:gradle:7.1.1") + implementation("com.google.dagger:hilt-android-gradle-plugin:2.40.5") + implementation("org.jlleitschuh.gradle:ktlint-gradle:9.2.1") + + /* Depend on the default Gradle API's since we want to build a custom plugin */ + implementation(gradleApi()) + implementation(localGroovy()) +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/AppVersions.kt b/buildSrc/src/main/kotlin/AppVersions.kt index 60b5dae6..7712ff5d 100644 --- a/buildSrc/src/main/kotlin/AppVersions.kt +++ b/buildSrc/src/main/kotlin/AppVersions.kt @@ -6,7 +6,8 @@ object AppVersions { const val versionCode = versionMajor * 10000 + versionMinor * 100 + versionPatch const val versionName = "$versionMajor.$versionMinor.$versionPatch" - const val COMPILE_SDK = 31 + const val COMPILE_SDK = "android-31" + const val BUILD_TOOLS = "31.0.0" const val MIN_SDK = 21 const val TARGET_SDK = 31 const val APPLICATION_ID = "com.mutualmobile.praxis" diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 07eb0b87..be739908 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,7 +1,13 @@ -/** This file contains versions of all the dependencies used in the module */ +import com.android.build.gradle.BaseExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile object BuildPlugins { - private const val TOOLS_BUILD = "7.1.0" + private const val TOOLS_BUILD = "7.1.1" private const val KT_LINT = "9.2.1" private const val SAFE_ARGS = "2.3.5" @@ -96,7 +102,7 @@ object Lib { const val hilt = "com.google.dagger:hilt-android:${DAGGER_VERSION}" const val hiltAndroidCompiler = "com.google.dagger:hilt-android-compiler:${DAGGER_VERSION}" - const val viewmodel = "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03" + const val hiltViewModel = "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03" const val hiltCompiler = "androidx.hilt:hilt-compiler:1.0.0" const val hiltNavigationCompose = "androidx.hilt:hilt-navigation-compose:1.0.0-rc01" } diff --git a/buildSrc/src/main/kotlin/Extensions.kt b/buildSrc/src/main/kotlin/Extensions.kt new file mode 100644 index 00000000..f9f94ba5 --- /dev/null +++ b/buildSrc/src/main/kotlin/Extensions.kt @@ -0,0 +1,89 @@ +import org.gradle.api.Project +import org.gradle.api.artifacts.dsl.DependencyHandler +import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.artifacts.repositories.MavenArtifactRepository +import org.gradle.kotlin.dsl.ScriptHandlerScope +import org.gradle.kotlin.dsl.maven + +fun RepositoryHandler.maven(repoUrl: String): MavenArtifactRepository { + return maven(repoUrl) +} + +fun Project.repositoriesFrom(listOfRepos: Collection): Project = + also { + + repositories.run { + listOfRepos.forEach { repo -> + maven(repo) + } + } + } + +fun Project.implementationDependenciesFrom(listOfDeps: Collection): Project = + also { + dependencies.run { + listOfDeps.forEach { dep -> + implementation(dep) + } + } + } + +fun Project.implementationProjectsFrom(listOfDeps: Collection): Project = + also { + dependencies.run { + listOfDeps.forEach { dep -> + implementation(project(":${dep}")) + } + } + } + +fun Project.annotationProcessors(listOfDeps: Collection): Project = + also { + dependencies.run { + listOfDeps.forEach { dep -> + kapt(dep) + } + } + } + +fun ScriptHandlerScope.repositoriesFrom(listOfRepos: Collection) { + repositories.run { + listOfRepos.forEach { repo -> + maven(repo) + } + } +} + +fun ScriptHandlerScope.dependenciesFrom(listOfDeps: List) { + dependencies.run { + listOfDeps.forEach { repo -> + classpath(repo) + } + } +} + +fun DependencyHandler.implementation(dependency: Any) { + add("implementation", dependency) +} + +fun DependencyHandler.androidTestImplementation(dependency: Any) { + add("androidTestImplementation", dependency) +} + +fun DependencyHandler.testImplementation(dependency: Any) { + add("testImplementation", dependency) +} + +fun DependencyHandler.kapt(dependency: Any) { + add("kapt", dependency) +} + +fun DependencyHandler.kaptTest(dependency: Any) { + add("kaptTest", dependency) +} + +fun DependencyHandler.kaptAndroidTest(dependency: Any) { + add("kaptAndroidTest", dependency) +} + + diff --git a/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt b/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt new file mode 100644 index 00000000..e22938af --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt @@ -0,0 +1,159 @@ +package gradle.plugins + +import com.android.build.gradle.* +import implementationDependenciesFrom +import annotationProcessors +import implementationProjectsFrom +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +class AppModule : BaseAndroidPlugin() { + + override fun apply(project: Project) { + project.apply(plugin = BuildPlugins.ANDROID_APPLICATION_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_KAPT) + project.apply(plugin = BuildPlugins.DAGGER_HILT) + project.apply(plugin = BuildPlugins.ktLint) + + super.apply(project) + + project.implementationProjectsFrom( + listOf( + ":ui-onboarding", + ":ui-authentication", + ":navigator", + ":data", + ":domain", + ":common", + ":commonui", + ) + ) + + project.implementationDependenciesFrom( + Lib.Androidx.list + + Lib.Androidx.Compose.list + + Lib.ThirdParty.list + + Lib.Accompanist.list + roomImplDeps + + Lib.Google.list + hiltImplDeps + ) + + project.annotationProcessors( + hiltKapt + listOf(Lib.Room.roomCompiler) + ) + + project.extensions.getByType().apply { + configureAndroidAppBlock(project) + } + } + + +} + +fun AppExtension.configureAndroidAppBlock(project: Project) { + buildToolsVersion = (AppVersions.BUILD_TOOLS) + compileSdkVersion = AppVersions.COMPILE_SDK + + defaultConfig { + applicationId = (AppVersions.APPLICATION_ID) + minSdk = (AppVersions.MIN_SDK) + targetSdk = (AppVersions.TARGET_SDK) + versionCode = (AppVersions.versionCode) + versionName = (AppVersions.versionName) + testInstrumentationRunner = ("android.support.test.runner.AndroidJUnitRunner") + vectorDrawables.useSupportLibrary = true + + javaCompileOptions { + annotationProcessorOptions { + arguments += mapOf( + "room.schemaLocation" to "${project.projectDir}/schemas", + "room.incremental" to "true", + "room.expandProjection" to "true" + ) + } + } + } + + project.tasks.withType().configureEach { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + } + + signingConfigs { + getByName("debug") { + keyAlias = "praxis-debug" + keyPassword = "utherNiC" + storeFile = project.file("keystore/praxis-debug.jks") + storePassword = "uRgeSCIt" + } + + create("release") { + keyAlias = "praxis-release" + keyPassword = "ITHOmptI" + storeFile = project.file("keystore/praxis-release.jks") + storePassword = "PoTHatHR" + } + } + + buildTypes.apply { + this.getByName("release").apply { + isDebuggable = false + versionNameSuffix = "-release" + isMinifyEnabled = true + isShrinkResources = true + signingConfig = signingConfigs.getByName("release") + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + this.getByName("debug").apply { + isMinifyEnabled = false + isShrinkResources = false + isDebuggable = true + versionNameSuffix = "-debug" + applicationIdSuffix = ".debug" + signingConfig = signingConfigs.getByName("debug") + } + } + + buildFeatures.viewBinding = true + buildFeatures.compose = true + + composeOptions { + kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion + } + + packagingOptions { + resources.excludes.add("META-INF/LICENSE.txt") + resources.excludes.add("META-INF/NOTICE.txt") + resources.excludes.add("LICENSE.txt") + resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + dataBinding.isEnabled = true +} + +val hiltKapt = listOf( + Lib.Di.hiltCompiler, + Lib.Di.hiltAndroidCompiler, +) + +val hiltImplDeps = listOf( + Lib.Di.hilt, + Lib.Di.hiltNavigationCompose, + Lib.Di.hiltViewModel, +) + +val roomImplDeps = listOf( + Lib.Room.roomKtx, + Lib.Room.roomRuntime +) \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt b/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt new file mode 100644 index 00000000..faf759f9 --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt @@ -0,0 +1,30 @@ +package gradle.plugins + +import com.android.build.gradle.* +import implementationDependenciesFrom +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin +import org.gradle.kotlin.dsl.getByType + +open class BaseAndroidPlugin : Plugin { + override fun apply(project: Project) { + project.plugins.all { + when (this) { + is JavaPlugin -> { + project.extensions.getByType().apply { + configureJava() + } + } + is LibraryPlugin -> { + project.configureRepositories() + .implementationDependenciesFrom(Lib.Kotlin.list) + } + is AppPlugin -> { + project.configureRepositories() + .implementationDependenciesFrom(Lib.Kotlin.list) + } + } + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt b/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt new file mode 100644 index 00000000..1a69f418 --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt @@ -0,0 +1,22 @@ +package gradle.plugins + +import com.android.build.gradle.BaseExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.kotlin.dsl.buildscript + +fun BaseExtension.configureJava() { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + + +fun Project.configureRepositories(): Project = + this.also { + it.buildscript { + repositories.google() + } + it.repositories.google() + } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt b/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt new file mode 100644 index 00000000..d08b35fa --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt @@ -0,0 +1,90 @@ +package gradle.plugins + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import implementationProjectsFrom +import implementationDependenciesFrom +import annotationProcessors +import com.android.build.gradle.LibraryExtension +import org.gradle.api.JavaVersion +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +class FeatureModule : BaseAndroidPlugin() { + override fun apply(project: Project) { + project.apply(plugin = BuildPlugins.ANDROID_LIBRARY_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_KAPT) + project.apply(plugin = BuildPlugins.DAGGER_HILT) + project.apply(plugin = BuildPlugins.ktLint) + super.apply(project) + + project.implementationProjectsFrom( + listOf( + ":navigator", + ":data", + ":domain", + ":common", + ":commonui", + ) + ) + + project.implementationDependenciesFrom( + Lib.Androidx.list + + Lib.Androidx.Compose.list + + Lib.ThirdParty.list + + Lib.Accompanist.list + + Lib.Google.list + + hiltImplDeps + ) + + project.annotationProcessors( + hiltKapt + ) + + project.extensions.getByType().apply { + configureAndroidLibraryBlock(project) + } + } +} + +fun LibraryExtension.configureAndroidLibraryBlock(project: Project) { + compileSdkVersion = AppVersions.COMPILE_SDK + + defaultConfig { + minSdk = (AppVersions.MIN_SDK) + targetSdk = (AppVersions.TARGET_SDK) + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + buildFeatures.compose = true + + composeOptions { + kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion + } + packagingOptions { + resources.excludes.add("META-INF/LICENSE.txt") + resources.excludes.add("META-INF/NOTICE.txt") + resources.excludes.add("LICENSE.txt") + resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + project.tasks.withType().configureEach { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + } +} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties new file mode 100644 index 00000000..1c8207ae --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/AppModule.properties @@ -0,0 +1 @@ +implementation-class=gradle.plugins.AppModule \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties new file mode 100644 index 00000000..54e499d4 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/FeatureModule.properties @@ -0,0 +1 @@ +implementation-class=gradle.plugins.FeatureModule \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index e9bdb2fd..8cecc901 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } android { - compileSdk = AppVersions.COMPILE_SDK + compileSdk = 31 defaultConfig { minSdk = (AppVersions.MIN_SDK) @@ -31,29 +31,10 @@ kapt { } dependencies { - - - Lib.Androidx.list.forEach(::implementation) - Lib.Androidx.Compose.list.forEach(::implementation) - Lib.ThirdParty.list.forEach(::implementation) - Lib.Accompanist.list.forEach(::implementation) - Lib.Google.list.forEach(::implementation) - Lib.Kotlin.list.forEach(::implementation) - - /*DI*/ implementation(Lib.Di.hilt) implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) + implementation(Lib.Di.hiltViewModel) kapt(Lib.Di.hiltCompiler) kapt(Lib.Di.hiltAndroidCompiler) - // Room - implementation(Lib.Room.roomKtx) - implementation(Lib.Room.roomRuntime) - add("kapt", Lib.Room.roomCompiler) - testImplementation(Lib.Room.testing) - - UnitTesting.list.forEach(::testImplementation) - DevDependencies.debugList.forEach(::debugImplementation) - DevDependencies.list.forEach(::implementation) } \ No newline at end of file diff --git a/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/CoroutineDispatcherProvider.kt b/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/CoroutineDispatcherProvider.kt index 7c25893a..1cc7505e 100644 --- a/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/CoroutineDispatcherProvider.kt +++ b/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/CoroutineDispatcherProvider.kt @@ -6,5 +6,5 @@ interface CoroutineDispatcherProvider { val main: CoroutineDispatcher val io: CoroutineDispatcher val default: CoroutineDispatcher - val unconfirmed: CoroutineDispatcher + val unconfined: CoroutineDispatcher } diff --git a/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/RealCoroutineDispatcherProvider.kt b/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/RealCoroutineDispatcherProvider.kt index 0b3d3d84..e75bbbc2 100644 --- a/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/RealCoroutineDispatcherProvider.kt +++ b/common/src/main/java/com/mutualmobile/praxis/injection/dispatcher/RealCoroutineDispatcherProvider.kt @@ -7,5 +7,5 @@ open class RealCoroutineDispatcherProvider : CoroutineDispatcherProvider { override val main: CoroutineDispatcher by lazy { Dispatchers.Main } override val io: CoroutineDispatcher by lazy { Dispatchers.IO } override val default: CoroutineDispatcher by lazy { Dispatchers.Default } - override val unconfirmed: CoroutineDispatcher by lazy { Dispatchers.Unconfined } + override val unconfined: CoroutineDispatcher by lazy { Dispatchers.Unconfined } } diff --git a/commonui/build.gradle.kts b/commonui/build.gradle.kts index 73940cf7..42be19c1 100644 --- a/commonui/build.gradle.kts +++ b/commonui/build.gradle.kts @@ -1,71 +1,51 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.ktLint) + id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) + id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) + id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) + id(BuildPlugins.KOTLIN_KAPT) + id(BuildPlugins.ktLint) } android { - compileSdk = AppVersions.COMPILE_SDK - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion + compileSdk = 31 + + defaultConfig { + minSdk = (AppVersions.MIN_SDK) + targetSdk = (AppVersions.TARGET_SDK) + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + getByName("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } - packagingOptions { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" - } + } + buildFeatures { + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion + } + packagingOptions { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" } + } } // Required for annotation processing plugins like Dagger kapt { - generateStubs = true - correctErrorTypes = true + generateStubs = true + correctErrorTypes = true } dependencies { - - - Lib.Androidx.list.forEach(::implementation) - Lib.Androidx.Compose.list.forEach(::implementation) - Lib.ThirdParty.list.forEach(::implementation) - Lib.Accompanist.list.forEach(::implementation) - Lib.Google.list.forEach(::implementation) - Lib.Kotlin.list.forEach(::implementation) - - /*DI*/ - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - - // Room - implementation(Lib.Room.roomKtx) - implementation(Lib.Room.roomRuntime) - add("kapt", Lib.Room.roomCompiler) - testImplementation(Lib.Room.testing) - - UnitTesting.list.forEach(::testImplementation) - DevDependencies.debugList.forEach(::debugImplementation) - DevDependencies.list.forEach(::implementation) + Lib.Androidx.list.forEach(::implementation) + Lib.Androidx.Compose.list.forEach(::implementation) + Lib.ThirdParty.list.forEach(::implementation) + Lib.Accompanist.list.forEach(::implementation) + Lib.Google.list.forEach(::implementation) + Lib.Kotlin.list.forEach(::implementation) } \ No newline at end of file diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 00e49bff..7c62ceea 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } android { - compileSdk = AppVersions.COMPILE_SDK + compileSdk = 31 defaultConfig { minSdk = (AppVersions.MIN_SDK) @@ -37,7 +37,7 @@ dependencies { /*DI*/ implementation(Lib.Di.hilt) implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) + implementation(Lib.Di.hiltViewModel) kapt(Lib.Di.hiltCompiler) kapt(Lib.Di.hiltAndroidCompiler) diff --git a/data/src/main/java/com/mutualmobile/praxis/data/local/AppDatabase.kt b/data/src/main/java/com/mutualmobile/praxis/data/local/AppDatabase.kt index 0fb49b56..92b5adc2 100644 --- a/data/src/main/java/com/mutualmobile/praxis/data/local/AppDatabase.kt +++ b/data/src/main/java/com/mutualmobile/praxis/data/local/AppDatabase.kt @@ -4,6 +4,6 @@ import androidx.room.Database import androidx.room.RoomDatabase import com.mutualmobile.praxis.data.local.model.SampleEntity -@Database(entities = [SampleEntity::class], version = 1) +@Database(entities = [SampleEntity::class], version = 1, exportSchema = false) abstract class AppDatabase : RoomDatabase() diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index 5de4d367..6fc2377d 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } android { - compileSdk = (AppVersions.COMPILE_SDK) + compileSdk = 31 defaultConfig { minSdk = (AppVersions.MIN_SDK) @@ -37,7 +37,7 @@ dependencies { /*DI*/ implementation(Lib.Di.hilt) implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) + implementation(Lib.Di.hiltViewModel) kapt(Lib.Di.hiltCompiler) kapt(Lib.Di.hiltAndroidCompiler) diff --git a/navigator/build.gradle.kts b/navigator/build.gradle.kts index fe83c7e6..b199e2dc 100644 --- a/navigator/build.gradle.kts +++ b/navigator/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } android { - compileSdk = AppVersions.COMPILE_SDK + compileSdk = 31 defaultConfig { minSdk = (AppVersions.MIN_SDK) @@ -42,7 +42,7 @@ kapt { dependencies { /*Kotlin*/ - + Lib.Androidx.list.forEach(::implementation) Lib.Androidx.Compose.list.forEach(::implementation) @@ -54,7 +54,7 @@ dependencies { /*DI*/ implementation(Lib.Di.hilt) implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) + implementation(Lib.Di.hiltViewModel) kapt(Lib.Di.hiltCompiler) kapt(Lib.Di.hiltAndroidCompiler) diff --git a/ui-authentication/build.gradle.kts b/ui-authentication/build.gradle.kts index f976ad7b..9e19af77 100644 --- a/ui-authentication/build.gradle.kts +++ b/ui-authentication/build.gradle.kts @@ -1,51 +1,5 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id("org.jlleitschuh.gradle.ktlint") -} - -android { - compileSdk = AppVersions.COMPILE_SDK - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion - } - packagingOptions { - resources.excludes.add("META-INF/LICENSE.txt") - resources.excludes.add("META-INF/NOTICE.txt") - resources.excludes.add("LICENSE.txt") - resources.excludes.add( "/META-INF/{AL2.0,LGPL2.1}") - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } - + id("FeatureModule") } // Required for annotation processing plugins like Dagger @@ -55,35 +9,6 @@ kapt { } dependencies { - /*Kotlin*/ - implementation(project(":data")) - implementation(project(":domain")) - implementation(project(":common")) - implementation(project(":navigator")) - implementation(project(":commonui")) - - - - Lib.Androidx.list.forEach(::implementation) - Lib.Androidx.Compose.list.forEach(::implementation) - Lib.ThirdParty.list.forEach(::implementation) - Lib.Accompanist.list.forEach(::implementation) - Lib.Google.list.forEach(::implementation) - Lib.Kotlin.list.forEach(::implementation) - - /*DI*/ - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - - // Room - implementation(Lib.Room.roomKtx) - implementation(Lib.Room.roomRuntime) - add("kapt", Lib.Room.roomCompiler) - testImplementation(Lib.Room.testing) - UnitTesting.list.forEach(::testImplementation) DevDependencies.debugList.forEach(::debugImplementation) DevDependencies.list.forEach(::implementation) diff --git a/ui-authentication/src/test/java/com/praxis/feat/authentication/vm/AuthVMTest.kt b/ui-authentication/src/test/java/com/praxis/feat/authentication/vm/AuthVMTest.kt index cedb7586..e5d4cd5a 100644 --- a/ui-authentication/src/test/java/com/praxis/feat/authentication/vm/AuthVMTest.kt +++ b/ui-authentication/src/test/java/com/praxis/feat/authentication/vm/AuthVMTest.kt @@ -2,6 +2,7 @@ package com.praxis.feat.authentication.vm import androidx.lifecycle.SavedStateHandle import app.cash.turbine.test +import com.mutualmobile.praxis.domain.usecases.FetchRandomPhotoUseCase import com.mutualmobile.praxis.navigator.ComposeNavigator import com.praxis.feat.authentication.ui.model.LoginForm import io.mockk.MockKAnnotations @@ -25,6 +26,9 @@ class AuthVMTest { private lateinit var authVM: AuthVM + @MockK + private lateinit var photoUseCase: FetchRandomPhotoUseCase + @Before fun setUp() { MockKAnnotations.init(this, true) @@ -48,7 +52,7 @@ class AuthVMTest { savedStateHandle.get(any()) } returns "" - authVM = AuthVM(savedStateHandle, navigator) + authVM = AuthVM(savedStateHandle, navigator, photoUseCase) authVM.formUiState.test { assert(awaitItem() is AuthVM.UiState.Empty) @@ -74,7 +78,7 @@ class AuthVMTest { savedStateHandle.get(any()) } returns "" - authVM = AuthVM(savedStateHandle, navigator) + authVM = AuthVM(savedStateHandle, navigator, photoUseCase) authVM.credentials.value = LoginForm("anmol@gmail.com", "sdkfkjkjfdsjkfds") authVM.formUiState.test { diff --git a/ui-onboarding/build.gradle.kts b/ui-onboarding/build.gradle.kts index ced77d9d..9e19af77 100644 --- a/ui-onboarding/build.gradle.kts +++ b/ui-onboarding/build.gradle.kts @@ -1,51 +1,5 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id("org.jlleitschuh.gradle.ktlint") -} - -android { - compileSdk = AppVersions.COMPILE_SDK - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion - } - packagingOptions { - resources.excludes.add("META-INF/LICENSE.txt") - resources.excludes.add("META-INF/NOTICE.txt") - resources.excludes.add("LICENSE.txt") - resources.excludes.add( "/META-INF/{AL2.0,LGPL2.1}") - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } - + id("FeatureModule") } // Required for annotation processing plugins like Dagger @@ -55,36 +9,6 @@ kapt { } dependencies { - - - /*Kotlin*/ - implementation(project(":data")) - implementation(project(":domain")) - implementation(project(":common")) - implementation(project(":navigator")) - implementation(project(":commonui")) - - - Lib.Androidx.list.forEach(::implementation) - Lib.Androidx.Compose.list.forEach(::implementation) - Lib.ThirdParty.list.forEach(::implementation) - Lib.Accompanist.list.forEach(::implementation) - Lib.Google.list.forEach(::implementation) - Lib.Kotlin.list.forEach(::implementation) - - /*DI*/ - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.viewmodel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - - // Room - implementation(Lib.Room.roomKtx) - implementation(Lib.Room.roomRuntime) - kapt(Lib.Room.roomCompiler) - testImplementation(Lib.Room.testing) - UnitTesting.list.forEach(::testImplementation) DevDependencies.debugList.forEach(::debugImplementation) DevDependencies.list.forEach(::implementation) From c40ccbba62fd5edc88ed50ab113b3aca069f86c9 Mon Sep 17 00:00:00 2001 From: anmol verma Date: Sun, 27 Feb 2022 13:33:05 +0530 Subject: [PATCH 2/6] CI on push --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3957992..f23201b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,8 +2,6 @@ name: Minimal Android CI Workflow on: push: - branches: - - master jobs: test: From 02984f6ead854cc39973ec166ebc67cb4ed74ea7 Mon Sep 17 00:00:00 2001 From: anmol verma Date: Sun, 27 Feb 2022 13:40:36 +0530 Subject: [PATCH 3/6] clean, WIP --- .github/workflows/build.yml | 2 ++ buildSrc/src/main/kotlin/Dependencies.kt | 18 ------------------ 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f23201b4..e3957992 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,8 @@ name: Minimal Android CI Workflow on: push: + branches: + - master jobs: test: diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index be739908..254312b5 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,22 +1,5 @@ -import com.android.build.gradle.BaseExtension -import org.gradle.api.JavaVersion -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.getByType -import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile object BuildPlugins { - private const val TOOLS_BUILD = "7.1.1" - private const val KT_LINT = "9.2.1" - private const val SAFE_ARGS = "2.3.5" - - const val TOOLS_BUILD_GRADLE = "com.android.tools.build:gradle:${TOOLS_BUILD}" - const val KTLINT_GRADLE_PLUGIN = "org.jlleitschuh.gradle:ktlint-gradle:${KT_LINT}" - const val SAFE_ARGS_GRADLE_PLUGIN = - "androidx.navigation:navigation-safe-args-gradle-plugin:${SAFE_ARGS}" - const val DAGGER_HILT_PLUGIN = "com.google.dagger:hilt-android-gradle-plugin:2.38.1" - const val KOTLIN_GRADLE_PLUGIN = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" const val ANDROID_APPLICATION_PLUGIN = "com.android.application" const val ANDROID_LIBRARY_PLUGIN = "com.android.library" const val KOTLIN_ANDROID_PLUGIN = "kotlin-android" @@ -24,7 +7,6 @@ object BuildPlugins { const val KOTLIN_KAPT = "kotlin-kapt" const val DAGGER_HILT = "dagger.hilt.android.plugin" const val ktLint = "org.jlleitschuh.gradle.ktlint" - const val SAFE_ARGS_KOTLIN = "androidx.navigation.safeargs.kotlin" } object Lib { From e62e73e2184dba2d233c37d2312d576739e7f013 Mon Sep 17 00:00:00 2001 From: anmol verma Date: Sun, 27 Feb 2022 14:49:09 +0530 Subject: [PATCH 4/6] domain acts as a KotlinModule.kt --- buildSrc/src/main/kotlin/Dependencies.kt | 10 +++-- .../main/kotlin/gradle/plugins/BasePlugins.kt | 7 +-- .../main/kotlin/gradle/plugins/Extensions.kt | 10 ++--- .../kotlin/gradle/plugins/KotlinModule.kt | 20 +++++++++ .../gradle-plugins/KotlinModule.properties | 1 + commonui/build.gradle.kts | 2 +- data/build.gradle.kts | 2 +- .../praxis/data}/injection/UseCaseModule.kt | 2 +- domain/build.gradle.kts | 43 +------------------ domain/proguard-rules.pro | 21 --------- .../praxis/domain/ExampleInstrumentedTest.kt | 24 ----------- domain/src/main/AndroidManifest.xml | 5 --- .../praxis/domain/ExampleUnitTest.kt | 9 ---- navigator/build.gradle.kts | 2 +- 14 files changed, 41 insertions(+), 117 deletions(-) create mode 100644 buildSrc/src/main/kotlin/gradle/plugins/KotlinModule.kt create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties rename {domain/src/main/java/com/mutualmobile/praxis/domain => data/src/main/java/com/mutualmobile/praxis/data}/injection/UseCaseModule.kt (78%) delete mode 100644 domain/proguard-rules.pro delete mode 100644 domain/src/androidTest/java/com/mutualmobile/praxis/domain/ExampleInstrumentedTest.kt delete mode 100644 domain/src/main/AndroidManifest.xml delete mode 100644 domain/src/test/java/com/mutualmobile/praxis/domain/ExampleUnitTest.kt diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 254312b5..8934d560 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -1,4 +1,3 @@ - object BuildPlugins { const val ANDROID_APPLICATION_PLUGIN = "com.android.application" const val ANDROID_LIBRARY_PLUGIN = "com.android.library" @@ -7,6 +6,8 @@ object BuildPlugins { const val KOTLIN_KAPT = "kotlin-kapt" const val DAGGER_HILT = "dagger.hilt.android.plugin" const val ktLint = "org.jlleitschuh.gradle.ktlint" + const val JAVA_LIB = "java-library" + const val KOTLIN_JVM = "org.jetbrains.kotlin.jvm" } object Lib { @@ -17,11 +18,13 @@ object Lib { private const val KTX_CORE = "androidx.core:core-ktx:${KTX_CORE_VERSION}" private const val DATE_TIME = "org.jetbrains.kotlinx:kotlinx-datetime:0.3.2" - private const val COROUTINES = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${KOTLIN_VERSION}" + const val COROUTINES = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${KOTLIN_VERSION}" private const val COROUTINES_ANDROID = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${KOTLIN_VERSION}" - val list = listOf(KT_STD, KTX_CORE, DATE_TIME, COROUTINES, COROUTINES_ANDROID) + val kotlinList = listOf(KT_STD, KTX_CORE, DATE_TIME, COROUTINES) + val androidList = kotlinList + listOf(COROUTINES_ANDROID) + } object Google { @@ -93,6 +96,7 @@ object Lib { private const val PAGING_VERSION = "3.1.0" const val PAGING_3 = "androidx.paging:paging-runtime:${PAGING_VERSION}" const val PAGING_COMPOSE = "androidx.paging:paging-compose:1.0.0-alpha14" + const val PAGING_COMMON = "androidx.paging:paging-common-ktx:${PAGING_VERSION}" } object Room { diff --git a/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt b/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt index faf759f9..0a6ffd44 100644 --- a/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt +++ b/buildSrc/src/main/kotlin/gradle/plugins/BasePlugins.kt @@ -5,6 +5,7 @@ import implementationDependenciesFrom import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.kotlin.dsl.getByType open class BaseAndroidPlugin : Plugin { @@ -12,17 +13,17 @@ open class BaseAndroidPlugin : Plugin { project.plugins.all { when (this) { is JavaPlugin -> { - project.extensions.getByType().apply { + project.extensions.getByType().apply { configureJava() } } is LibraryPlugin -> { project.configureRepositories() - .implementationDependenciesFrom(Lib.Kotlin.list) + .implementationDependenciesFrom(Lib.Kotlin.androidList) } is AppPlugin -> { project.configureRepositories() - .implementationDependenciesFrom(Lib.Kotlin.list) + .implementationDependenciesFrom(Lib.Kotlin.androidList) } } } diff --git a/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt b/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt index 1a69f418..aff0b8cd 100644 --- a/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt +++ b/buildSrc/src/main/kotlin/gradle/plugins/Extensions.kt @@ -1,15 +1,13 @@ package gradle.plugins -import com.android.build.gradle.BaseExtension import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension import org.gradle.kotlin.dsl.buildscript -fun BaseExtension.configureJava() { - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } +fun JavaPluginExtension.configureJava() { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } diff --git a/buildSrc/src/main/kotlin/gradle/plugins/KotlinModule.kt b/buildSrc/src/main/kotlin/gradle/plugins/KotlinModule.kt new file mode 100644 index 00000000..4c97a93a --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle/plugins/KotlinModule.kt @@ -0,0 +1,20 @@ +package gradle.plugins + +import org.gradle.api.Project +import implementationDependenciesFrom +import org.gradle.kotlin.dsl.apply + +class KotlinModule : BaseAndroidPlugin() { + + override fun apply(project: Project) { + project.apply(plugin = BuildPlugins.JAVA_LIB) + project.apply(plugin = BuildPlugins.KOTLIN_JVM) + + project.implementationDependenciesFrom( + listOf( + Lib.Paging.PAGING_COMMON + ) + Lib.Kotlin.kotlinList + ) + super.apply(project) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties new file mode 100644 index 00000000..1f074e4a --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/KotlinModule.properties @@ -0,0 +1 @@ +implementation-class=gradle.plugins.KotlinModule \ No newline at end of file diff --git a/commonui/build.gradle.kts b/commonui/build.gradle.kts index 42be19c1..91af05b4 100644 --- a/commonui/build.gradle.kts +++ b/commonui/build.gradle.kts @@ -47,5 +47,5 @@ dependencies { Lib.ThirdParty.list.forEach(::implementation) Lib.Accompanist.list.forEach(::implementation) Lib.Google.list.forEach(::implementation) - Lib.Kotlin.list.forEach(::implementation) + Lib.Kotlin.androidList.forEach(::implementation) } \ No newline at end of file diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 7c62ceea..203063d5 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { implementation(project(":common")) implementation(project(":domain")) - Lib.Kotlin.list.forEach(::implementation) + Lib.Kotlin.androidList.forEach(::implementation) Lib.Networking.ktorList.forEach(::implementation) /*DI*/ implementation(Lib.Di.hilt) diff --git a/domain/src/main/java/com/mutualmobile/praxis/domain/injection/UseCaseModule.kt b/data/src/main/java/com/mutualmobile/praxis/data/injection/UseCaseModule.kt similarity index 78% rename from domain/src/main/java/com/mutualmobile/praxis/domain/injection/UseCaseModule.kt rename to data/src/main/java/com/mutualmobile/praxis/data/injection/UseCaseModule.kt index 2c86dfa3..74be5708 100644 --- a/domain/src/main/java/com/mutualmobile/praxis/domain/injection/UseCaseModule.kt +++ b/data/src/main/java/com/mutualmobile/praxis/data/injection/UseCaseModule.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.domain.injection +package com.mutualmobile.praxis.data.injection import dagger.Module import dagger.hilt.InstallIn diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index 6fc2377d..86b90b57 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -1,44 +1,3 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.ktLint) -} - -android { - compileSdk = 31 - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } -} - -// Required for annotation processing plugins like Dagger -kapt { - generateStubs = true - correctErrorTypes = true -} - -dependencies { - Lib.Kotlin.list.forEach(::implementation) - - /*DI*/ - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.hiltViewModel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - + id("KotlinModule") } \ No newline at end of file diff --git a/domain/proguard-rules.pro b/domain/proguard-rules.pro deleted file mode 100644 index ff59496d..00000000 --- a/domain/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle.kts. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/domain/src/androidTest/java/com/mutualmobile/praxis/domain/ExampleInstrumentedTest.kt b/domain/src/androidTest/java/com/mutualmobile/praxis/domain/ExampleInstrumentedTest.kt deleted file mode 100644 index b0c4c406..00000000 --- a/domain/src/androidTest/java/com/mutualmobile/praxis/domain/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.mutualmobile.praxis.domain - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.mutualmobile.praxis.domain.test", appContext.packageName) - } -} \ No newline at end of file diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml deleted file mode 100644 index d1dd9a9c..00000000 --- a/domain/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/domain/src/test/java/com/mutualmobile/praxis/domain/ExampleUnitTest.kt b/domain/src/test/java/com/mutualmobile/praxis/domain/ExampleUnitTest.kt deleted file mode 100644 index f1cf0ca6..00000000 --- a/domain/src/test/java/com/mutualmobile/praxis/domain/ExampleUnitTest.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.mutualmobile.praxis.domain - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { -} \ No newline at end of file diff --git a/navigator/build.gradle.kts b/navigator/build.gradle.kts index b199e2dc..b738813e 100644 --- a/navigator/build.gradle.kts +++ b/navigator/build.gradle.kts @@ -49,7 +49,7 @@ dependencies { Lib.ThirdParty.list.forEach(::implementation) Lib.Accompanist.list.forEach(::implementation) Lib.Google.list.forEach(::implementation) - Lib.Kotlin.list.forEach(::implementation) + Lib.Kotlin.androidList.forEach(::implementation) /*DI*/ implementation(Lib.Di.hilt) From a7f278e378b9315a80c0fdb7ce8e9eb196255759 Mon Sep 17 00:00:00 2001 From: anmol verma Date: Sun, 27 Feb 2022 22:18:24 +0530 Subject: [PATCH 5/6] reduced to common module, removed common-ui --- .../main/kotlin/gradle/plugins/AppModule.kt | 117 +++++--- .../kotlin/gradle/plugins/CommonModule.kt | 45 ++++ .../kotlin/gradle/plugins/FeatureModule.kt | 27 +- .../gradle-plugins/CommonModule.properties | 1 + common/build.gradle.kts | 33 +-- .../mutualmobile/praxis}/keyboard/Keyboard.kt | 2 +- .../praxis}/material/DefaultSnackbar.kt | 6 +- .../praxis}/material/PraxisSurfaceAppBar.kt | 4 +- .../praxis/reusable/PraxisImageBox.kt | 2 +- .../praxis/reusable/PraxisListItem.kt | 6 +- .../com/mutualmobile/praxis}/theme/Color.kt | 2 +- .../praxis}/theme/PraxisSurface.kt | 2 +- .../com/mutualmobile/praxis}/theme/Shape.kt | 2 +- .../com/mutualmobile/praxis}/theme/Theme.kt | 2 +- .../com/mutualmobile/praxis}/theme/Type.kt | 4 +- .../src/main/res/drawable/ic_email.xml | 0 .../src/main/res/drawable/ic_eye.xml | 0 .../src/main/res/font/lato_bold.ttf | Bin .../src/main/res/font/lato_light.ttf | Bin .../src/main/res/font/lato_regular.ttf | Bin .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin .../src/main/res/values-v21/styles.xml | 0 .../src/main/res/values/colors.xml | 0 .../src/main/res/values/dimens.xml | 0 .../src/main/res/values/integer.xml | 0 common/src/main/res/values/strings.xml | 2 + .../src/main/res/values/styles.xml | 0 commonui/.gitignore | 1 - commonui/build.gradle.kts | 51 ---- commonui/consumer-rules.pro | 0 commonui/proguard-rules.pro | 21 -- commonui/src/main/AndroidManifest.xml | 5 - .../reusable/SlackDragComposableView.kt | 249 ------------------ commonui/src/main/res/anim/slide_left_in.xml | 8 - commonui/src/main/res/anim/slide_left_out.xml | 8 - commonui/src/main/res/anim/slide_right_in.xml | 8 - .../src/main/res/anim/slide_right_out.xml | 8 - commonui/src/main/res/values/strings.xml | 3 - settings.gradle.kts | 1 - .../authentication/ui/AuthenticationUI.kt | 6 +- .../authentication/ui/ForgotPasswordUI.kt | 4 +- .../uionboarding/compose/CommonInputUI.kt | 8 +- .../uionboarding/compose/EmailInputView.kt | 4 +- .../uionboarding/compose/GettingStarted.kt | 2 +- .../uionboarding/compose/ScreenInputUI.kt | 2 +- .../uionboarding/compose/SkipTypingScreen.kt | 4 +- .../compose/WorkspaceInputView.kt | 4 +- 51 files changed, 178 insertions(+), 476 deletions(-) create mode 100644 buildSrc/src/main/kotlin/gradle/plugins/CommonModule.kt create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/keyboard/Keyboard.kt (95%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/material/DefaultSnackbar.kt (87%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/material/PraxisSurfaceAppBar.kt (93%) rename commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackImageBox.kt => common/src/main/java/com/mutualmobile/praxis/reusable/PraxisImageBox.kt (92%) rename commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackListItem.kt => common/src/main/java/com/mutualmobile/praxis/reusable/PraxisListItem.kt (90%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/theme/Color.kt (90%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/theme/PraxisSurface.kt (98%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/theme/Shape.kt (85%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/theme/Theme.kt (99%) rename {commonui/src/main/java/com/mutualmobile/praxis/commonui => common/src/main/java/com/mutualmobile/praxis}/theme/Type.kt (91%) rename {commonui => common}/src/main/res/drawable/ic_email.xml (100%) rename {commonui => common}/src/main/res/drawable/ic_eye.xml (100%) rename {commonui => common}/src/main/res/font/lato_bold.ttf (100%) rename {commonui => common}/src/main/res/font/lato_light.ttf (100%) rename {commonui => common}/src/main/res/font/lato_regular.ttf (100%) rename {commonui => common}/src/main/res/mipmap-hdpi/ic_launcher.png (100%) rename {commonui => common}/src/main/res/mipmap-mdpi/ic_launcher.png (100%) rename {commonui => common}/src/main/res/mipmap-xhdpi/ic_launcher.png (100%) rename {commonui => common}/src/main/res/mipmap-xxhdpi/ic_launcher.png (100%) rename {commonui => common}/src/main/res/mipmap-xxxhdpi/ic_launcher.png (100%) rename {commonui => common}/src/main/res/values-v21/styles.xml (100%) rename {commonui => common}/src/main/res/values/colors.xml (100%) rename {commonui => common}/src/main/res/values/dimens.xml (100%) rename {commonui => common}/src/main/res/values/integer.xml (100%) rename {commonui => common}/src/main/res/values/styles.xml (100%) delete mode 100644 commonui/.gitignore delete mode 100644 commonui/build.gradle.kts delete mode 100644 commonui/consumer-rules.pro delete mode 100644 commonui/proguard-rules.pro delete mode 100644 commonui/src/main/AndroidManifest.xml delete mode 100644 commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackDragComposableView.kt delete mode 100644 commonui/src/main/res/anim/slide_left_in.xml delete mode 100644 commonui/src/main/res/anim/slide_left_out.xml delete mode 100644 commonui/src/main/res/anim/slide_right_in.xml delete mode 100644 commonui/src/main/res/anim/slide_right_out.xml delete mode 100644 commonui/src/main/res/values/strings.xml diff --git a/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt b/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt index e22938af..18752d4b 100644 --- a/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt +++ b/buildSrc/src/main/kotlin/gradle/plugins/AppModule.kt @@ -14,15 +14,18 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile class AppModule : BaseAndroidPlugin() { override fun apply(project: Project) { - project.apply(plugin = BuildPlugins.ANDROID_APPLICATION_PLUGIN) - project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) - project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - project.apply(plugin = BuildPlugins.KOTLIN_KAPT) - project.apply(plugin = BuildPlugins.DAGGER_HILT) - project.apply(plugin = BuildPlugins.ktLint) + appPlugins(project) super.apply(project) + dependencies(project) + + project.extensions.getByType().apply { + configureAndroidAppBlock(project) + } + } + + private fun dependencies(project: Project) { project.implementationProjectsFrom( listOf( ":ui-onboarding", @@ -31,7 +34,7 @@ class AppModule : BaseAndroidPlugin() { ":data", ":domain", ":common", - ":commonui", + ) ) @@ -46,10 +49,15 @@ class AppModule : BaseAndroidPlugin() { project.annotationProcessors( hiltKapt + listOf(Lib.Room.roomCompiler) ) + } - project.extensions.getByType().apply { - configureAndroidAppBlock(project) - } + private fun appPlugins(project: Project) { + project.apply(plugin = BuildPlugins.ANDROID_APPLICATION_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_KAPT) + project.apply(plugin = BuildPlugins.DAGGER_HILT) + project.apply(plugin = BuildPlugins.ktLint) } @@ -59,6 +67,23 @@ fun AppExtension.configureAndroidAppBlock(project: Project) { buildToolsVersion = (AppVersions.BUILD_TOOLS) compileSdkVersion = AppVersions.COMPILE_SDK + defaultConfig(project) + + kotlinCompileJVMVersion(project) + + signingConfig(project) + + buildTypes() + + buildFeatures() + + packagingOptions() + + compileOptions() + +} + +private fun AppExtension.defaultConfig(project: Project) { defaultConfig { applicationId = (AppVersions.APPLICATION_ID) minSdk = (AppVersions.MIN_SDK) @@ -78,29 +103,42 @@ fun AppExtension.configureAndroidAppBlock(project: Project) { } } } +} +private fun kotlinCompileJVMVersion(project: Project) { project.tasks.withType().configureEach { kotlinOptions { jvmTarget = JavaVersion.VERSION_1_8.toString() } } +} - signingConfigs { - getByName("debug") { - keyAlias = "praxis-debug" - keyPassword = "utherNiC" - storeFile = project.file("keystore/praxis-debug.jks") - storePassword = "uRgeSCIt" - } +private fun AppExtension.compileOptions() { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} - create("release") { - keyAlias = "praxis-release" - keyPassword = "ITHOmptI" - storeFile = project.file("keystore/praxis-release.jks") - storePassword = "PoTHatHR" - } +private fun AppExtension.packagingOptions() { + packagingOptions { + resources.excludes.add("META-INF/LICENSE.txt") + resources.excludes.add("META-INF/NOTICE.txt") + resources.excludes.add("LICENSE.txt") + resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}") } +} +private fun AppExtension.buildFeatures() { + buildFeatures.viewBinding = true + buildFeatures.compose = true + dataBinding.isEnabled = true + composeOptions { + kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion + } +} + +private fun AppExtension.buildTypes() { buildTypes.apply { this.getByName("release").apply { isDebuggable = false @@ -119,27 +157,24 @@ fun AppExtension.configureAndroidAppBlock(project: Project) { signingConfig = signingConfigs.getByName("debug") } } +} - buildFeatures.viewBinding = true - buildFeatures.compose = true - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion - } - - packagingOptions { - resources.excludes.add("META-INF/LICENSE.txt") - resources.excludes.add("META-INF/NOTICE.txt") - resources.excludes.add("LICENSE.txt") - resources.excludes.add("/META-INF/{AL2.0,LGPL2.1}") - } +private fun AppExtension.signingConfig(project: Project) { + signingConfigs { + getByName("debug") { + keyAlias = "praxis-debug" + keyPassword = "utherNiC" + storeFile = project.file("keystore/praxis-debug.jks") + storePassword = "uRgeSCIt" + } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + create("release") { + keyAlias = "praxis-release" + keyPassword = "ITHOmptI" + storeFile = project.file("keystore/praxis-release.jks") + storePassword = "PoTHatHR" + } } - - dataBinding.isEnabled = true } val hiltKapt = listOf( diff --git a/buildSrc/src/main/kotlin/gradle/plugins/CommonModule.kt b/buildSrc/src/main/kotlin/gradle/plugins/CommonModule.kt new file mode 100644 index 00000000..6d197c63 --- /dev/null +++ b/buildSrc/src/main/kotlin/gradle/plugins/CommonModule.kt @@ -0,0 +1,45 @@ +package gradle.plugins + +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import implementationDependenciesFrom +import annotationProcessors +import com.android.build.gradle.LibraryExtension +import org.gradle.kotlin.dsl.getByType + +class CommonModule : BaseAndroidPlugin() { + override fun apply(project: Project) { + featureLibPlugins(project) + super.apply(project) + + dependencies(project) + + project.extensions.getByType().apply { + configureAndroidLibraryBlock(project) + } + } + + private fun dependencies(project: Project) { + project.implementationDependenciesFrom( + Lib.Androidx.list + + Lib.Androidx.Compose.list + + Lib.ThirdParty.list + + Lib.Accompanist.list + + Lib.Google.list + + hiltImplDeps + ) + + project.annotationProcessors( + hiltKapt + ) + } + + private fun featureLibPlugins(project: Project) { + project.apply(plugin = BuildPlugins.ANDROID_LIBRARY_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_KAPT) + project.apply(plugin = BuildPlugins.DAGGER_HILT) + project.apply(plugin = BuildPlugins.ktLint) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt b/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt index d08b35fa..00766e43 100644 --- a/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt +++ b/buildSrc/src/main/kotlin/gradle/plugins/FeatureModule.kt @@ -13,21 +13,23 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile class FeatureModule : BaseAndroidPlugin() { override fun apply(project: Project) { - project.apply(plugin = BuildPlugins.ANDROID_LIBRARY_PLUGIN) - project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) - project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - project.apply(plugin = BuildPlugins.KOTLIN_KAPT) - project.apply(plugin = BuildPlugins.DAGGER_HILT) - project.apply(plugin = BuildPlugins.ktLint) + featureLibPlugins(project) super.apply(project) + dependencies(project) + + project.extensions.getByType().apply { + configureAndroidLibraryBlock(project) + } + } + + private fun dependencies(project: Project) { project.implementationProjectsFrom( listOf( ":navigator", ":data", ":domain", ":common", - ":commonui", ) ) @@ -43,10 +45,15 @@ class FeatureModule : BaseAndroidPlugin() { project.annotationProcessors( hiltKapt ) + } - project.extensions.getByType().apply { - configureAndroidLibraryBlock(project) - } + private fun featureLibPlugins(project: Project) { + project.apply(plugin = BuildPlugins.ANDROID_LIBRARY_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_ANDROID_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) + project.apply(plugin = BuildPlugins.KOTLIN_KAPT) + project.apply(plugin = BuildPlugins.DAGGER_HILT) + project.apply(plugin = BuildPlugins.ktLint) } } diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties new file mode 100644 index 00000000..bb7e60b4 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/CommonModule.properties @@ -0,0 +1 @@ +implementation-class=gradle.plugins.CommonModule \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 8cecc901..5e53d117 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,27 +1,5 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.DAGGER_HILT) - id(BuildPlugins.ktLint) -} - -android { - compileSdk = 31 - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } + id("CommonModule") } // Required for annotation processing plugins like Dagger @@ -31,10 +9,7 @@ kapt { } dependencies { - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.hiltViewModel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - + UnitTesting.list.forEach(::testImplementation) + DevDependencies.debugList.forEach(::debugImplementation) + DevDependencies.list.forEach(::implementation) } \ No newline at end of file diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/keyboard/Keyboard.kt b/common/src/main/java/com/mutualmobile/praxis/keyboard/Keyboard.kt similarity index 95% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/keyboard/Keyboard.kt rename to common/src/main/java/com/mutualmobile/praxis/keyboard/Keyboard.kt index 1192aa28..1d7e70bc 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/keyboard/Keyboard.kt +++ b/common/src/main/java/com/mutualmobile/praxis/keyboard/Keyboard.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.keyboard +package com.mutualmobile.praxis.keyboard import android.graphics.Rect import android.view.ViewTreeObserver diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/material/DefaultSnackbar.kt b/common/src/main/java/com/mutualmobile/praxis/material/DefaultSnackbar.kt similarity index 87% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/material/DefaultSnackbar.kt rename to common/src/main/java/com/mutualmobile/praxis/material/DefaultSnackbar.kt index f0406600..31c0d44c 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/material/DefaultSnackbar.kt +++ b/common/src/main/java/com/mutualmobile/praxis/material/DefaultSnackbar.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.material +package com.mutualmobile.praxis.material import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.wrapContentHeight @@ -7,8 +7,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import com.mutualmobile.praxis.commonui.theme.PraxisColorProvider -import com.mutualmobile.praxis.commonui.theme.PraxisTypography +import com.mutualmobile.praxis.theme.PraxisColorProvider +import com.mutualmobile.praxis.theme.PraxisTypography @Composable fun DefaultSnackbar( diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/material/PraxisSurfaceAppBar.kt b/common/src/main/java/com/mutualmobile/praxis/material/PraxisSurfaceAppBar.kt similarity index 93% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/material/PraxisSurfaceAppBar.kt rename to common/src/main/java/com/mutualmobile/praxis/material/PraxisSurfaceAppBar.kt index a73c5721..9dc075aa 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/material/PraxisSurfaceAppBar.kt +++ b/common/src/main/java/com/mutualmobile/praxis/material/PraxisSurfaceAppBar.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.material +package com.mutualmobile.praxis.material import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.RowScope @@ -7,7 +7,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp -import com.mutualmobile.praxis.commonui.theme.PraxisSurface +import com.mutualmobile.praxis.theme.PraxisSurface @Composable fun PraxisSurfaceAppBar( diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackImageBox.kt b/common/src/main/java/com/mutualmobile/praxis/reusable/PraxisImageBox.kt similarity index 92% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackImageBox.kt rename to common/src/main/java/com/mutualmobile/praxis/reusable/PraxisImageBox.kt index da069d44..5da3c9a9 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackImageBox.kt +++ b/common/src/main/java/com/mutualmobile/praxis/reusable/PraxisImageBox.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.reusable +package com.mutualmobile.praxis.reusable import androidx.compose.foundation.Image import androidx.compose.runtime.Composable diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackListItem.kt b/common/src/main/java/com/mutualmobile/praxis/reusable/PraxisListItem.kt similarity index 90% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackListItem.kt rename to common/src/main/java/com/mutualmobile/praxis/reusable/PraxisListItem.kt index 285e8685..2a632a14 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackListItem.kt +++ b/common/src/main/java/com/mutualmobile/praxis/reusable/PraxisListItem.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.reusable +package com.mutualmobile.praxis.reusable import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Row @@ -12,8 +12,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp -import com.mutualmobile.praxis.commonui.theme.PraxisColorProvider -import com.mutualmobile.praxis.commonui.theme.PraxisTypography +import com.mutualmobile.praxis.theme.PraxisColorProvider +import com.mutualmobile.praxis.theme.PraxisTypography @OptIn(ExperimentalMaterialApi::class) @Composable diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Color.kt b/common/src/main/java/com/mutualmobile/praxis/theme/Color.kt similarity index 90% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Color.kt rename to common/src/main/java/com/mutualmobile/praxis/theme/Color.kt index 875c335c..7115c365 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Color.kt +++ b/common/src/main/java/com/mutualmobile/praxis/theme/Color.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.theme +package com.mutualmobile.praxis.theme import androidx.compose.ui.graphics.Color diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/PraxisSurface.kt b/common/src/main/java/com/mutualmobile/praxis/theme/PraxisSurface.kt similarity index 98% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/PraxisSurface.kt rename to common/src/main/java/com/mutualmobile/praxis/theme/PraxisSurface.kt index 65b341eb..84b5806f 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/PraxisSurface.kt +++ b/common/src/main/java/com/mutualmobile/praxis/theme/PraxisSurface.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.theme +package com.mutualmobile.praxis.theme import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Shape.kt b/common/src/main/java/com/mutualmobile/praxis/theme/Shape.kt similarity index 85% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Shape.kt rename to common/src/main/java/com/mutualmobile/praxis/theme/Shape.kt index 472db0ec..0347795b 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Shape.kt +++ b/common/src/main/java/com/mutualmobile/praxis/theme/Shape.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.theme +package com.mutualmobile.praxis.theme import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Shapes diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Theme.kt b/common/src/main/java/com/mutualmobile/praxis/theme/Theme.kt similarity index 99% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Theme.kt rename to common/src/main/java/com/mutualmobile/praxis/theme/Theme.kt index fd0b2e5d..25f007a0 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Theme.kt +++ b/common/src/main/java/com/mutualmobile/praxis/theme/Theme.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.theme +package com.mutualmobile.praxis.theme import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material.Colors diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Type.kt b/common/src/main/java/com/mutualmobile/praxis/theme/Type.kt similarity index 91% rename from commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Type.kt rename to common/src/main/java/com/mutualmobile/praxis/theme/Type.kt index 1b40ff3e..e575bc56 100644 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/theme/Type.kt +++ b/common/src/main/java/com/mutualmobile/praxis/theme/Type.kt @@ -1,4 +1,4 @@ -package com.mutualmobile.praxis.commonui.theme +package com.mutualmobile.praxis.theme import androidx.compose.material.Typography import androidx.compose.ui.text.TextStyle @@ -6,7 +6,7 @@ import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.sp -import com.mutualmobile.praxis.commonui.R +import com.mutualmobile.praxis.common.R // Set of Material typography styles to start with diff --git a/commonui/src/main/res/drawable/ic_email.xml b/common/src/main/res/drawable/ic_email.xml similarity index 100% rename from commonui/src/main/res/drawable/ic_email.xml rename to common/src/main/res/drawable/ic_email.xml diff --git a/commonui/src/main/res/drawable/ic_eye.xml b/common/src/main/res/drawable/ic_eye.xml similarity index 100% rename from commonui/src/main/res/drawable/ic_eye.xml rename to common/src/main/res/drawable/ic_eye.xml diff --git a/commonui/src/main/res/font/lato_bold.ttf b/common/src/main/res/font/lato_bold.ttf similarity index 100% rename from commonui/src/main/res/font/lato_bold.ttf rename to common/src/main/res/font/lato_bold.ttf diff --git a/commonui/src/main/res/font/lato_light.ttf b/common/src/main/res/font/lato_light.ttf similarity index 100% rename from commonui/src/main/res/font/lato_light.ttf rename to common/src/main/res/font/lato_light.ttf diff --git a/commonui/src/main/res/font/lato_regular.ttf b/common/src/main/res/font/lato_regular.ttf similarity index 100% rename from commonui/src/main/res/font/lato_regular.ttf rename to common/src/main/res/font/lato_regular.ttf diff --git a/commonui/src/main/res/mipmap-hdpi/ic_launcher.png b/common/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from commonui/src/main/res/mipmap-hdpi/ic_launcher.png rename to common/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/commonui/src/main/res/mipmap-mdpi/ic_launcher.png b/common/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from commonui/src/main/res/mipmap-mdpi/ic_launcher.png rename to common/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/commonui/src/main/res/mipmap-xhdpi/ic_launcher.png b/common/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from commonui/src/main/res/mipmap-xhdpi/ic_launcher.png rename to common/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/commonui/src/main/res/mipmap-xxhdpi/ic_launcher.png b/common/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from commonui/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to common/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/commonui/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/common/src/main/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from commonui/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to common/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/commonui/src/main/res/values-v21/styles.xml b/common/src/main/res/values-v21/styles.xml similarity index 100% rename from commonui/src/main/res/values-v21/styles.xml rename to common/src/main/res/values-v21/styles.xml diff --git a/commonui/src/main/res/values/colors.xml b/common/src/main/res/values/colors.xml similarity index 100% rename from commonui/src/main/res/values/colors.xml rename to common/src/main/res/values/colors.xml diff --git a/commonui/src/main/res/values/dimens.xml b/common/src/main/res/values/dimens.xml similarity index 100% rename from commonui/src/main/res/values/dimens.xml rename to common/src/main/res/values/dimens.xml diff --git a/commonui/src/main/res/values/integer.xml b/common/src/main/res/values/integer.xml similarity index 100% rename from commonui/src/main/res/values/integer.xml rename to common/src/main/res/values/integer.xml diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 92178db5..fe667749 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1,5 +1,7 @@ + PraxisClone + Home DMs Mentions diff --git a/commonui/src/main/res/values/styles.xml b/common/src/main/res/values/styles.xml similarity index 100% rename from commonui/src/main/res/values/styles.xml rename to common/src/main/res/values/styles.xml diff --git a/commonui/.gitignore b/commonui/.gitignore deleted file mode 100644 index 42afabfd..00000000 --- a/commonui/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/commonui/build.gradle.kts b/commonui/build.gradle.kts deleted file mode 100644 index 91af05b4..00000000 --- a/commonui/build.gradle.kts +++ /dev/null @@ -1,51 +0,0 @@ -plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_PARCELABLE_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) - id(BuildPlugins.ktLint) -} - -android { - compileSdk = 31 - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion - } - packagingOptions { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" - } - } -} - -// Required for annotation processing plugins like Dagger -kapt { - generateStubs = true - correctErrorTypes = true -} - -dependencies { - Lib.Androidx.list.forEach(::implementation) - Lib.Androidx.Compose.list.forEach(::implementation) - Lib.ThirdParty.list.forEach(::implementation) - Lib.Accompanist.list.forEach(::implementation) - Lib.Google.list.forEach(::implementation) - Lib.Kotlin.androidList.forEach(::implementation) -} \ No newline at end of file diff --git a/commonui/consumer-rules.pro b/commonui/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/commonui/proguard-rules.pro b/commonui/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/commonui/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/commonui/src/main/AndroidManifest.xml b/commonui/src/main/AndroidManifest.xml deleted file mode 100644 index 642e1366..00000000 --- a/commonui/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackDragComposableView.kt b/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackDragComposableView.kt deleted file mode 100644 index 321d83cc..00000000 --- a/commonui/src/main/java/com/mutualmobile/praxis/commonui/reusable/SlackDragComposableView.kt +++ /dev/null @@ -1,249 +0,0 @@ -package com.mutualmobile.praxis.commonui.reusable - -import androidx.compose.animation.core.* -import androidx.compose.foundation.gestures.detectHorizontalDragGestures -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.offset -import androidx.compose.runtime.* -import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.input.pointer.PointerInputChange -import androidx.compose.ui.input.pointer.consumePositionChange -import androidx.compose.ui.input.pointer.pointerInput -import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.IntOffset -import androidx.compose.ui.unit.dp -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch -import kotlin.math.roundToInt - -@Composable -fun PraxisDragComposableView( - isLeftNavOpen: Boolean, - isChatViewClosed: Boolean, - mainScreenOffset: Float, - chatScreenOffset: Float, - onOpenCloseLeftView: (Boolean) -> Unit, - onOpenCloseRightView: (Boolean) -> Unit, - mainScreenComposable: @Composable (modifier: Modifier) -> Unit, - leftViewComposable: @Composable (modifier: Modifier) -> Unit, - rightViewComposable: @Composable (modifier: Modifier) -> Unit, -) { - val sideNavOffX = remember { - Animatable(viewOffset(isLeftNavOpen, mainScreenOffset)) - } - val chatViewOffX = remember { - Animatable(viewOffset(isChatViewClosed, chatScreenOffset)) - } - - val coroutineScope = rememberCoroutineScope() - - InitialOffsetsSideEffect( - coroutineScope, - sideNavOffX, - isLeftNavOpen, - mainScreenOffset, - chatViewOffX, - isChatViewClosed, - chatScreenOffset - ) - - Box(Modifier.fillMaxWidth()) { - leftViewComposable(Modifier) - mainScreenComposable( - mainScreenModifier( - sideNavOffX, - mainScreenOffset, - coroutineScope, - onOpenCloseLeftView, - onOpenCloseRightView, - chatViewOffX, - chatScreenOffset - ) - ) - rightViewComposable( - chatScreenModifier( - chatViewOffX, - chatScreenOffset, - coroutineScope, - onOpenCloseRightView - ) - ) - } - - -} - -@Composable -private fun InitialOffsetsSideEffect( - coroutineScope: CoroutineScope, - sideNavOffX: Animatable, - isLeftNavOpen: Boolean, - mainScreenOffset: Float, - chatViewOffX: Animatable, - isChatViewClosed: Boolean, - chatScreenOffset: Float -) { - SideEffect { - coroutineScope.launch { - sideNavOffX.snapTo(viewOffset(isLeftNavOpen, mainScreenOffset)) - } - coroutineScope.launch { - chatViewOffX.snapTo(viewOffset(isChatViewClosed, chatScreenOffset)) - } - } -} - -private fun viewOffset(needsOpen: Boolean, offset: Float) = - if (needsOpen) offset else 0f - - -@Composable -private fun chatScreenModifier( - offsetX: Animatable, - requiredOffset: Float, - coroutineScope: CoroutineScope, - onOpen: (Boolean) -> Unit, -) = Modifier - .offset { - IntOffset( - (offsetX.value).roundToInt(), - 0 - ) - } - .pointerInput(Unit) { - detectHorizontalDragGestures({ - //start - }, { - rightViewEndTransition(offsetX, requiredOffset, coroutineScope, onOpen) - }, { - //cancel - - }, { change, dragAmount -> - // this moves the chat view left/right - val summedMain = Offset(x = offsetX.targetValue + dragAmount, y = 0f) - val newDragValueMain = Offset(x = summedMain.x.coerceIn(0f, requiredOffset), y = 0f) - change.consumePositionChange() - coroutineScope.launch { - offsetX.animateTo(newDragValueMain.x, animationSpec = tween(50)) - } - }) - } - -private fun mainScreenModifier( - offsetX: Animatable, - dragOffset: Float, - coroutineScope: CoroutineScope, - onOpenSideNav: (Boolean) -> Unit, - onOpenCloseRightView: (Boolean) -> Unit, - chatViewOffX: Animatable, - chatScreenOffset: Float, -) = Modifier - .offset { - IntOffset( - (offsetX.value).roundToInt(), - 0 - ) - } - .pointerInput(Unit) { - detectHorizontalDragGestures({ - //start - }, { - sideNavigationEndTransition( - offsetX, - dragOffset, - coroutineScope, - onOpenSideNav - ) - rightViewEndTransition( - chatViewOffX, - chatScreenOffset, - coroutineScope, - onOpenCloseRightView - ) - - }, { - //cancel - - }, { change, dragAmount -> - mainAnimateOffset( - offsetX, - dragAmount, - dragOffset, - change, - coroutineScope, - chatViewOffX, - chatScreenOffset - ) - }) - } - -fun rightViewEndTransition( - offsetX: Animatable, - requiredOffset: Float, - coroutineScope: CoroutineScope, - onOpen: (Boolean) -> Unit -) { - //end - if (offsetX.targetValue > requiredOffset / 2) { - coroutineScope.launch { - offsetX.animateTo(requiredOffset, animationSpec = tween(150)) - onOpen(true) - } - } else { - coroutineScope.launch { - offsetX.animateTo(0F, animationSpec = tween(150)) - onOpen(false) - } - } -} - -private fun sideNavigationEndTransition( - offsetX: Animatable, - dragOffset: Float, - coroutineScope: CoroutineScope, - onOpenSideNav: (Boolean) -> Unit -) { - if (offsetX.targetValue > dragOffset / 2) { - coroutineScope.launch { - offsetX.animateTo(dragOffset, animationSpec = tween(150)) - onOpenSideNav(true) - } - } else { - coroutineScope.launch { - offsetX.animateTo(0F, animationSpec = tween(150)) - onOpenSideNav(false) - } - } -} - -private fun mainAnimateOffset( - offsetX: Animatable, - dragAmount: Float, - mainDragOffset: Float, - change: PointerInputChange, - coroutineScope: CoroutineScope, - chatViewOffX: Animatable, - chatScreenOffset: Float -) { - // this moves the chat view from right to left/left to right - if (offsetX.targetValue <= 0f) { - val summedChat = Offset(x = chatViewOffX.targetValue + dragAmount, y = 0f) - val chatNewDragValueMain = Offset(x = summedChat.x.coerceIn(0f, chatScreenOffset), y = 0f) - change.consumePositionChange() - coroutineScope.launch { - chatViewOffX.animateTo(chatNewDragValueMain.x, animationSpec = tween(50)) - } - } - - // this moved the main view left/right - val summedMain = Offset(x = offsetX.targetValue + dragAmount, y = 0f) - val newDragValueMain = Offset(x = summedMain.x.coerceIn(0f, mainDragOffset), y = 0f) - change.consumePositionChange() - coroutineScope.launch { - offsetX.animateTo(newDragValueMain.x, animationSpec = tween(50)) - } - -} \ No newline at end of file diff --git a/commonui/src/main/res/anim/slide_left_in.xml b/commonui/src/main/res/anim/slide_left_in.xml deleted file mode 100644 index eadca525..00000000 --- a/commonui/src/main/res/anim/slide_left_in.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/commonui/src/main/res/anim/slide_left_out.xml b/commonui/src/main/res/anim/slide_left_out.xml deleted file mode 100644 index 5dbc3680..00000000 --- a/commonui/src/main/res/anim/slide_left_out.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/commonui/src/main/res/anim/slide_right_in.xml b/commonui/src/main/res/anim/slide_right_in.xml deleted file mode 100644 index ed0d1967..00000000 --- a/commonui/src/main/res/anim/slide_right_in.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/commonui/src/main/res/anim/slide_right_out.xml b/commonui/src/main/res/anim/slide_right_out.xml deleted file mode 100644 index 633eb37e..00000000 --- a/commonui/src/main/res/anim/slide_right_out.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/commonui/src/main/res/values/strings.xml b/commonui/src/main/res/values/strings.xml deleted file mode 100644 index 1e9aabd0..00000000 --- a/commonui/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - PraxisClone - diff --git a/settings.gradle.kts b/settings.gradle.kts index 56f746d1..b1311e20 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,6 +9,5 @@ include(":ui-authentication") include(":domain") include(":data") include(":common") -include(":commonui") include(":navigator") diff --git a/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/AuthenticationUI.kt b/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/AuthenticationUI.kt index 7449c1e5..ed7f56ad 100644 --- a/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/AuthenticationUI.kt +++ b/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/AuthenticationUI.kt @@ -32,9 +32,9 @@ import coil.compose.rememberImagePainter import com.google.accompanist.insets.navigationBarsPadding import com.google.accompanist.insets.navigationBarsWithImePadding import com.google.accompanist.insets.statusBarsPadding -import com.mutualmobile.praxis.commonui.material.DefaultSnackbar -import com.mutualmobile.praxis.commonui.material.PraxisSurfaceAppBar -import com.mutualmobile.praxis.commonui.theme.* +import com.mutualmobile.praxis.material.DefaultSnackbar +import com.mutualmobile.praxis.material.PraxisSurfaceAppBar +import com.mutualmobile.praxis.theme.* import com.praxis.feat.authentication.R import com.praxis.feat.authentication.vm.AuthVM import com.praxis.feat.authentication.vm.streamProgress diff --git a/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/ForgotPasswordUI.kt b/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/ForgotPasswordUI.kt index b444c5d3..d74b7b74 100644 --- a/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/ForgotPasswordUI.kt +++ b/ui-authentication/src/main/java/com/praxis/feat/authentication/ui/ForgotPasswordUI.kt @@ -13,8 +13,8 @@ import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.google.accompanist.insets.navigationBarsPadding import com.google.accompanist.insets.statusBarsPadding -import com.mutualmobile.praxis.commonui.material.PraxisSurfaceAppBar -import com.mutualmobile.praxis.commonui.theme.* +import com.mutualmobile.praxis.material.PraxisSurfaceAppBar +import com.mutualmobile.praxis.theme.* import com.praxis.feat.authentication.R import com.praxis.feat.authentication.vm.ForgotPasswordVM diff --git a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/CommonInputUI.kt b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/CommonInputUI.kt index 65592eb2..5ee76493 100644 --- a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/CommonInputUI.kt +++ b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/CommonInputUI.kt @@ -12,10 +12,10 @@ import androidx.constraintlayout.compose.ConstraintLayout import com.google.accompanist.insets.navigationBarsPadding import com.google.accompanist.insets.navigationBarsWithImePadding import com.google.accompanist.insets.statusBarsPadding -import com.mutualmobile.praxis.commonui.theme.PraxisSurface -import com.mutualmobile.praxis.commonui.theme.PraxisTheme -import com.mutualmobile.praxis.commonui.theme.PraxisColorProvider -import com.mutualmobile.praxis.commonui.theme.PraxisTypography +import com.mutualmobile.praxis.theme.PraxisSurface +import com.mutualmobile.praxis.theme.PraxisTheme +import com.mutualmobile.praxis.theme.PraxisColorProvider +import com.mutualmobile.praxis.theme.PraxisTypography import com.mutualmobile.praxis.navigator.ComposeNavigator import com.mutualmobile.praxis.navigator.PraxisRoute import com.mutualmobile.praxis.navigator.PraxisScreen diff --git a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/EmailInputView.kt b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/EmailInputView.kt index cd109f50..4dcd8c45 100644 --- a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/EmailInputView.kt +++ b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/EmailInputView.kt @@ -20,8 +20,8 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.mutualmobile.praxis.commonui.theme.PraxisColorProvider -import com.mutualmobile.praxis.commonui.theme.PraxisTypography +import com.mutualmobile.praxis.theme.PraxisColorProvider +import com.mutualmobile.praxis.theme.PraxisTypography @OptIn(ExperimentalComposeUiApi::class) @Composable diff --git a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/GettingStarted.kt b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/GettingStarted.kt index 270d36b0..7aaef8f0 100644 --- a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/GettingStarted.kt +++ b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/GettingStarted.kt @@ -19,7 +19,7 @@ import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp import com.google.accompanist.insets.statusBarsPadding import com.google.accompanist.systemuicontroller.rememberSystemUiController -import com.mutualmobile.praxis.commonui.theme.* +import com.mutualmobile.praxis.theme.* import com.mutualmobile.praxis.navigator.ComposeNavigator import com.mutualmobile.praxis.navigator.PraxisScreen import com.mutualmobile.praxis.uionboarding.R diff --git a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/ScreenInputUI.kt b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/ScreenInputUI.kt index 11751dd1..a1f1fb49 100644 --- a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/ScreenInputUI.kt +++ b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/ScreenInputUI.kt @@ -2,7 +2,7 @@ package com.mutualmobile.praxis.uionboarding.compose import androidx.compose.runtime.* import androidx.compose.ui.res.stringResource -import com.mutualmobile.praxis.commonui.theme.PraxisTheme +import com.mutualmobile.praxis.theme.PraxisTheme import com.mutualmobile.praxis.navigator.ComposeNavigator import com.mutualmobile.praxis.uionboarding.R diff --git a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/SkipTypingScreen.kt b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/SkipTypingScreen.kt index 15e9e023..66dc707d 100644 --- a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/SkipTypingScreen.kt +++ b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/SkipTypingScreen.kt @@ -20,8 +20,8 @@ import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import com.google.accompanist.insets.statusBarsPadding import com.google.accompanist.systemuicontroller.rememberSystemUiController -import com.mutualmobile.praxis.commonui.material.PraxisSurfaceAppBar -import com.mutualmobile.praxis.commonui.theme.* +import com.mutualmobile.praxis.material.PraxisSurfaceAppBar +import com.mutualmobile.praxis.theme.* import com.mutualmobile.praxis.navigator.ComposeNavigator import com.mutualmobile.praxis.navigator.PraxisScreen import com.mutualmobile.praxis.uionboarding.R diff --git a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/WorkspaceInputView.kt b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/WorkspaceInputView.kt index 8c842c70..844db6a6 100644 --- a/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/WorkspaceInputView.kt +++ b/ui-onboarding/src/main/java/com/mutualmobile/praxis/uionboarding/compose/WorkspaceInputView.kt @@ -11,8 +11,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.mutualmobile.praxis.commonui.theme.PraxisColorProvider -import com.mutualmobile.praxis.commonui.theme.PraxisTypography +import com.mutualmobile.praxis.theme.PraxisColorProvider +import com.mutualmobile.praxis.theme.PraxisTypography @Composable fun WorkspaceInputView(modifier: Modifier) { From 4f68b9c05bed9570ee0a480cc94bffaa4c63234d Mon Sep 17 00:00:00 2001 From: anmol verma Date: Sun, 27 Feb 2022 22:26:59 +0530 Subject: [PATCH 6/6] introduce common module to navigator --- navigator/build.gradle.kts | 57 +------------------------------------- 1 file changed, 1 insertion(+), 56 deletions(-) diff --git a/navigator/build.gradle.kts b/navigator/build.gradle.kts index b738813e..f138aa83 100644 --- a/navigator/build.gradle.kts +++ b/navigator/build.gradle.kts @@ -1,37 +1,5 @@ plugins { - id(BuildPlugins.ANDROID_LIBRARY_PLUGIN) - id(BuildPlugins.KOTLIN_ANDROID_PLUGIN) - id(BuildPlugins.KOTLIN_KAPT) -} - -android { - compileSdk = 31 - - defaultConfig { - minSdk = (AppVersions.MIN_SDK) - targetSdk = (AppVersions.TARGET_SDK) - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = "1.8" - } - - composeOptions { - kotlinCompilerExtensionVersion = Lib.Androidx.composeVersion - } + id("CommonModule") } // Required for annotation processing plugins like Dagger @@ -41,29 +9,6 @@ kapt { } dependencies { - /*Kotlin*/ - - - Lib.Androidx.list.forEach(::implementation) - Lib.Androidx.Compose.list.forEach(::implementation) - Lib.ThirdParty.list.forEach(::implementation) - Lib.Accompanist.list.forEach(::implementation) - Lib.Google.list.forEach(::implementation) - Lib.Kotlin.androidList.forEach(::implementation) - - /*DI*/ - implementation(Lib.Di.hilt) - implementation(Lib.Di.hiltNavigationCompose) - implementation(Lib.Di.hiltViewModel) - kapt(Lib.Di.hiltCompiler) - kapt(Lib.Di.hiltAndroidCompiler) - - // Room - implementation(Lib.Room.roomKtx) - implementation(Lib.Room.roomRuntime) - add("kapt", Lib.Room.roomCompiler) - testImplementation(Lib.Room.testing) - UnitTesting.list.forEach(::testImplementation) DevDependencies.debugList.forEach(::debugImplementation) DevDependencies.list.forEach(::implementation)