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/base module #45

Merged
merged 2 commits into from
Jul 8, 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
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ android {

dependencies {
implementation(project(":library:sync"))
implementation(project(":library:base"))
implementation(project(":library:navigation"))
implementation(project(":library:designsystem"))
DIDependencies.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.navigation.compose.NavHost
import ir.kaaveh.navigation.graph.favoriteMarketList
import ir.kaaveh.navigation.graph.marketDetail
import ir.kaaveh.navigation.graph.marketList
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.navigation.Destinations

@Composable
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ir/kaaveh/composenews/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import ir.kaaveh.composenews.permission.enum.PermissionType
import ir.kaaveh.composenews.permission.manager.PermissionManager
import ir.kaaveh.composenews.permission.manager.PermissionManagerImpl
import ir.kaaveh.composenews.ui.component.BottomNavigationBar
import ir.kaaveh.designsystem.base.BaseRoute
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseRoute
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.designsystem.theme.ComposeNewsTheme
import ir.kaaveh.navigation.BottomNavItem
import ir.kaaveh.navigation.Destinations
Expand Down
1 change: 1 addition & 0 deletions feature/marketdetail/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ android {

dependencies {
api(project(":library:designsystem"))
api(project(":library:base"))
implementation(project(":data:market-repository"))
implementation(ComposeDependencies.accompanistWebview)
DIDependencies.apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ir.kaaveh.marketdetail

import ir.kaaveh.designsystem.UnidirectionalViewModel
import ir.kaaveh.base.UnidirectionalViewModel
import ir.kaaveh.domain.model.Chart
import ir.kaaveh.domain.model.Market

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import coil.compose.rememberAsyncImagePainter
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.designsystem.component.FavoriteIcon
import ir.kaaveh.designsystem.component.QuadLineChart
import ir.kaaveh.designsystem.preview.ThemePreviews
import ir.kaaveh.designsystem.theme.ComposeNewsTheme
import ir.kaaveh.designsystem.use
import ir.kaaveh.base.use
import ir.kaaveh.domain.model.Market
import ir.kaaveh.marketdetail.preview_provider.MarketDetailStateProvider

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ir.kaaveh.marketdetail
import androidx.lifecycle.viewModelScope
import ir.kaaveh.core_test.dispatcher.DispatcherProvider
import dagger.hilt.android.lifecycle.HiltViewModel
import ir.kaaveh.designsystem.base.BaseContract
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseContract
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.domain.model.Market
import ir.kaaveh.domain.model.Resource
import ir.kaaveh.domain.use_case.GetMarketChartUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ir.kaaveh.core_test.dispatcher.TestDispatcherProvider
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.mockk
import ir.kaaveh.designsystem.base.BaseContract
import ir.kaaveh.base.BaseContract
import ir.kaaveh.domain.model.Chart
import ir.kaaveh.domain.model.Market
import ir.kaaveh.domain.model.Resource
Expand Down
1 change: 1 addition & 0 deletions feature/marketlist/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ android {

dependencies {
api(project(":library:designsystem"))
api(project(":library:base"))
implementation(project(":data:market-repository"))
DIDependencies.apply {
implementation(hiltAndroid)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ir.kaaveh.marketlist

import ir.kaaveh.designsystem.UnidirectionalViewModel
import ir.kaaveh.base.UnidirectionalViewModel
import ir.kaaveh.domain.model.Market

interface MarketListContract :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.hilt.navigation.compose.hiltViewModel
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.designsystem.preview.ThemePreviews
import ir.kaaveh.designsystem.theme.ComposeNewsTheme
import ir.kaaveh.designsystem.use
import ir.kaaveh.base.use
import ir.kaaveh.domain.model.Market
import ir.kaaveh.marketlist.component.MarketListItem
import ir.kaaveh.marketlist.preview_provider.MarketListStateProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ir.kaaveh.marketlist

import androidx.lifecycle.viewModelScope
import ir.kaaveh.core_test.dispatcher.DispatcherProvider
import dagger.hilt.android.lifecycle.HiltViewModel
import ir.kaaveh.designsystem.base.BaseContract
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseContract
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.core_test.dispatcher.DispatcherProvider
import ir.kaaveh.domain.model.Market
import ir.kaaveh.domain.use_case.GetFavoriteMarketListUseCase
import ir.kaaveh.domain.use_case.GetMarketListUseCase
Expand Down
1 change: 1 addition & 0 deletions library/base/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions library/base/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
}

android {
namespace = "ir.kaaveh.base"
compileSdk = projectCompileSdkVersion

defaultConfig {
minSdk = projectMinSdkVersion

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = ComposeDependencies.kotlinCompilerExtensionVersion
}
}

dependencies {

api(project(":library:core-test"))
implementation(project(":library:designsystem"))

LifeCycleDependencies.apply {
implementation(lifeCycleViewModelKtx)
}
}
Empty file added library/base/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions library/base/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
2 changes: 2 additions & 0 deletions library/base/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
package ir.kaaveh.designsystem.base

import ir.kaaveh.designsystem.BaseUnidirectionalViewModel
package ir.kaaveh.base

interface BaseContract :
BaseUnidirectionalViewModel<BaseContract.BaseEvent, BaseContract.BaseEffect, BaseContract.BaseState> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package ir.kaaveh.designsystem.base
package ir.kaaveh.base

import android.app.Activity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import ir.kaaveh.designsystem.collectInLaunchedEffect
import ir.kaaveh.designsystem.useBase
import ir.kaaveh.designsystem.widget.ErrorView
import ir.kaaveh.designsystem.widget.LoadingView

Expand Down Expand Up @@ -49,10 +47,12 @@ private fun BaseScreen(
BaseContract.BaseState.OnLoading -> {
LoadingView(modifier = Modifier.fillMaxSize())
}

BaseContract.BaseState.OnLoadingDialog -> TODO()
is BaseContract.BaseState.OnError -> {
ErrorView(errorMessage = baseState.errorMessage)
}

BaseContract.BaseState.OnSuccess -> content()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ir.kaaveh.designsystem.base
package ir.kaaveh.base

import androidx.lifecycle.ViewModel
import ir.kaaveh.core_test.dispatcher.DispatcherProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ir.kaaveh.designsystem
package ir.kaaveh.base

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down
2 changes: 0 additions & 2 deletions library/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ android {
}

dependencies {
api(project(":library:core-test"))
ComposeDependencies.apply {
api(platform(composeBOM))
api(composeUi)
Expand All @@ -50,6 +49,5 @@ dependencies {
}
LifeCycleDependencies.apply {
api(lifeCycleRuntimeCompose)
implementation(lifeCycleViewModelKtx)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import androidx.core.os.bundleOf
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.marketlist.MarketListRoute
import ir.kaaveh.navigation.Destinations
import ir.kaaveh.navigation.extension_function.navigate
import ir.kaaveh.marketlist.MarketListRoute

fun NavGraphBuilder.favoriteMarketList(
navController: NavController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package ir.kaaveh.navigation.graph

import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import ir.kaaveh.navigation.Destinations
import ir.kaaveh.navigation.extension_function.parcelableData
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.domain.model.Market
import ir.kaaveh.marketdetail.MarketDetailRoute
import ir.kaaveh.navigation.Destinations
import ir.kaaveh.navigation.extension_function.parcelableData

fun NavGraphBuilder.marketDetail(
onProvideBaseViewModel: (baseViewModel: BaseViewModel) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import androidx.core.os.bundleOf
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import ir.kaaveh.base.BaseViewModel
import ir.kaaveh.marketlist.MarketListRoute
import ir.kaaveh.navigation.Destinations
import ir.kaaveh.navigation.extension_function.navigate
import ir.kaaveh.designsystem.base.BaseViewModel
import ir.kaaveh.marketlist.MarketListRoute

fun NavGraphBuilder.marketList(
navController: NavController,
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ include ':feature:marketdetail'
include ':library:sync'
include ':library:navigation'
include ':library:core-test'
include ':library:base'