Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multi module setup #39

Merged
merged 9 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 47 additions & 103 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import com.loodos.buildsrc.getDateTime

// TODO: Remove once https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
kotlin("kapt")
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.dagger.hilt)
alias(libs.plugins.kotlinter)
id("samplecomposeanroid.android.application")
id("samplecomposeanroid.android.application.compose")
id("samplecomposeanroid.android.room")
id("samplecomposeanroid.android.hilt")
id("samplecomposeanroid.kotlinter")
}

android {
namespace = "com.loodos.samplecomposeandroid"
compileSdk = 33

buildFeatures {
buildConfig = true
}
defaultConfig {
applicationId = "com.loodos.samplecomposeandroid"
minSdk = 21
targetSdk = 33
versionCode = 1
versionName = "1.0"
flavorDimensions("version")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
Expand All @@ -36,126 +30,76 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)

}

getByName("debug") {
isMinifyEnabled = false
isDebuggable = true
isMinifyEnabled = false
isShrinkResources = false
versionNameSuffix = ".${getDateTime()}"
enableUnitTestCoverage = true
proguardFiles(
ahmeterloodos marked this conversation as resolved.
Show resolved Hide resolved
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

productFlavors {
create("dev") {
dimension = "version"
applicationIdSuffix = ".dev"
versionNameSuffix = "-dev"
resValue("string", "app_name", "Sample Compose Android Dev")
buildConfigField("String", "BASE_URL", "\"https://fakestoreapi.com/\"")

}
create("prod") {
dimension = "version"
applicationIdSuffix = ".prod"
versionNameSuffix = "-prod"
resValue("string", "app_name", "Sample Compose Android")
buildConfigField("String", "BASE_URL", "\"https://fakestoreapi.com/\"")

}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
buildConfig = true
compose = true
}
ahmeterloodos marked this conversation as resolved.
Show resolved Hide resolved
composeOptions {
kotlinCompilerExtensionVersion = "1.4.7"
}
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
lint {
baseline = file("lint-baseline.xml")
}
}

namespace = "com.loodos.samplecomposeandroid"
}
dependencies {
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

implementation(libs.accompanist.systemuicontroller)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.compose.ui)

implementation(libs.androidx.compose.material3)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.android.material)
implementation(libs.compose.ui)
implementation(libs.compose.material)
implementation(libs.androidx.compose.material.iconsExtended)
implementation(libs.compose.ui.tooling)
implementation(libs.square.moshi.kotlin)
implementation(libs.square.retrofit)
implementation(libs.square.retrofit.converter.moshi)
implementation(libs.androidx.core.splashscreen)
implementation(libs.okhttp.logging.interceptor)

implementation(libs.androidx.compose.ui.tooling.preview)
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.testManifest)

implementation(libs.androidx.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.runtimeCompose)
implementation(projects.core.common)
implementation(projects.core.designsystem)
implementation(projects.core.data)
implementation(projects.core.domain)

//Splash
implementation(libs.androidx.core.splashscreen)
testImplementation(libs.junit4)

//Hilt
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
androidTestImplementation(libs.compose.ui.test.junit)
androidTestImplementation(libs.hilt.android.testing)
implementation(libs.androidx.hilt.navigation.compose)

// lint
lintChecks(libs.lint.checks)
// compose state events
implementation(libs.compose.state.events)

// Retrofit
implementation(libs.retrofit)
debugImplementation(libs.compose.ui.test.manifest)
debugImplementation(libs.compose.ui.tooling)
debugImplementation(libs.square.leakcanary)
implementation(libs.retrofit.converter.gson)
implementation(libs.okhttp)
implementation(libs.okhttp.logging.interceptor)

// chucker
kapt(libs.square.moshi.kotlin.codegen)

debugImplementation(libs.chucker)
releaseImplementation(libs.chucker.no.op)

implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.runtimeCompose)
implementation(libs.compose.state.events)
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.navigation.compose)

testImplementation(libs.turbine)
testImplementation(libs.truth)

// To use the androidx.test.core APIs
androidTestImplementation(libs.androidx.test.core)
// Kotlin extensions for androidx.test.core
androidTestImplementation(libs.androidx.test.ktx)

// To use the JUnit Extension APIs
testImplementation(libs.androidx.test.ext)
// Kotlin extensions for androidx.test.ext.junit
testImplementation(libs.androidx.test.ext.ktx)

// To use the Truth Extension APIs
testImplementation(libs.truth.ext)
testImplementation(libs.jetbrains.kotlin.test)
implementation(libs.androidx.navigation.testing)
testImplementation(libs.junit4)
androidTestImplementation(libs.androidx.test.ext)
androidTestImplementation(libs.androidx.test.espresso.core)
androidTestImplementation(libs.androidx.compose.ui.test)

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.loodos.samplecomposeandroid.util

import com.loodos.samplecomposeandroid.core.util.NetworkMonitor
import com.loodos.data.util.NetworkMonitor
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow

/**
* Created by mertcantoptas on 21.03.2023
*/

class TestNetworkMonitor : NetworkMonitor {
class TestNetworkMonitor : com.loodos.data.util.NetworkMonitor {

private val connectivityFlow = MutableStateFlow(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
import com.loodos.data.util.NetworkMonitor
import com.loodos.designsystems.component.MainAppScaffold
import com.loodos.designsystems.icon.Icon
import com.loodos.samplecomposeandroid.R
import com.loodos.samplecomposeandroid.core.designsystem.icon.Icon
import com.loodos.samplecomposeandroid.core.designsystem.slideIn
import com.loodos.samplecomposeandroid.core.designsystem.slideOut
import com.loodos.samplecomposeandroid.core.util.NetworkMonitor
import com.loodos.samplecomposeandroid.feature.navigation.MainNavHost
import com.loodos.samplecomposeandroid.feature.navigation.TopLevelDestination
import com.loodos.samplecomposeandroid.ui.components.MainAppScaffold
import com.loodos.samplecomposeandroid.navigation.MainNavHost
import com.loodos.samplecomposeandroid.navigation.TopLevelDestination

/**
* Created by mertcantoptas on 10.03.2023
Expand Down Expand Up @@ -68,8 +66,8 @@ fun MainApp(
bottomBar = {
AnimatedVisibility(
visible = appState.shouldShowBottomBar,
enter = slideIn,
exit = slideOut,
enter = com.loodos.designsystems.animation.slideIn,
exit = com.loodos.designsystems.animation.slideOut,
) {
AppNavBar(
destinations = AppDestinations(appState.topLevelDestinations),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navOptions
import com.loodos.samplecomposeandroid.core.util.NetworkMonitor
import com.loodos.data.util.NetworkMonitor
import com.loodos.samplecomposeandroid.feature.category.navigateToCategory
import com.loodos.samplecomposeandroid.feature.home.navigation.HomeNavigationRoute
import com.loodos.samplecomposeandroid.feature.home.navigation.navigateToHome
import com.loodos.samplecomposeandroid.feature.navigation.TopLevelDestination
import com.loodos.samplecomposeandroid.feature.profile.navigateToProfile
import com.loodos.samplecomposeandroid.navigation.TopLevelDestination
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
Expand All @@ -27,7 +27,7 @@ import kotlinx.coroutines.flow.stateIn

@Composable
fun rememberMainAppState(
networkMonitor: NetworkMonitor,
networkMonitor: com.loodos.data.util.NetworkMonitor,
coroutineScope: CoroutineScope = rememberCoroutineScope(),
navController: NavHostController = rememberNavController(),
): MainAppState {
Expand All @@ -40,7 +40,7 @@ fun rememberMainAppState(
class MainAppState(
val navController: NavHostController,
val coroutineScope: CoroutineScope,
networkMonitor: NetworkMonitor,
networkMonitor: com.loodos.data.util.NetworkMonitor,
) {
val currentDestination: NavDestination?
@Composable get() = navController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.loodos.samplecomposeandroid.R
import com.loodos.samplecomposeandroid.ui.components.MainAppScaffold
import de.palm.composestateevents.EventEffect

/**
Expand Down Expand Up @@ -65,7 +64,7 @@ fun HomeScreen(
onProductClick: (ProductItem) -> Unit,
modifier: Modifier = Modifier,
) {
MainAppScaffold(
com.loodos.designsystems.component.MainAppScaffold(
modifier = modifier.fillMaxSize(),
topBar = {
CenterAlignedTopAppBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.loodos.samplecomposeandroid.R
import com.loodos.samplecomposeandroid.ui.components.CustomTextField
import com.loodos.samplecomposeandroid.ui.components.MainAppScaffold
import com.loodos.samplecomposeandroid.ui.theme.SampleComposeAndroidTheme
import de.palm.composestateevents.EventEffect

/**
Expand Down Expand Up @@ -75,7 +72,7 @@ fun LoginScreen(
modifier: Modifier = Modifier,
onLoginClicked: () -> Unit,
) {
MainAppScaffold(
com.loodos.designsystems.component.MainAppScaffold(
modifier = modifier.fillMaxSize(),
) {
Content(
Expand Down Expand Up @@ -140,7 +137,7 @@ private fun UserNameTextField(
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier,
) {
CustomTextField(
com.loodos.designsystems.component.CustomTextField(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
Expand Down Expand Up @@ -183,7 +180,7 @@ private fun PasswordTextField(
modifier: Modifier = Modifier,
) {
var isPasswordVisible by remember { mutableStateOf(false) }
CustomTextField(
com.loodos.designsystems.component.CustomTextField(
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
Expand Down Expand Up @@ -229,7 +226,7 @@ private fun PasswordTextField(
@Preview(showBackground = true)
@Composable
fun LoginScreenPreview() {
SampleComposeAndroidTheme() {
com.loodos.designsystems.theme.SampleComposeAndroidTheme() {
Content(
LoginViewState(),
onUserNameValueChange = {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.loodos.samplecomposeandroid.feature.login

import androidx.lifecycle.viewModelScope
import com.loodos.common.result.Resource
import com.loodos.common.result.asResource
import com.loodos.domain.login.LoginUseCase
import com.loodos.domain.login.ValidateAuthUseCase
import com.loodos.samplecomposeandroid.R
import com.loodos.samplecomposeandroid.arch.BaseViewModel
import com.loodos.samplecomposeandroid.arch.IViewState
import com.loodos.samplecomposeandroid.core.common.Resource
import com.loodos.samplecomposeandroid.core.common.asResource
import com.loodos.samplecomposeandroid.core.domain.PasswordLengthException
import com.loodos.samplecomposeandroid.core.domain.PasswordRequiredException
import com.loodos.samplecomposeandroid.core.domain.UsernameLengthException
import com.loodos.samplecomposeandroid.core.domain.UsernameRequiredException
import com.loodos.samplecomposeandroid.core.domain.login.LoginUseCase
import com.loodos.samplecomposeandroid.core.domain.login.ValidateAuthUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import de.palm.composestateevents.StateEvent
import de.palm.composestateevents.StateEventWithContent
Expand Down
Loading
Loading