diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..00ae5f1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,31 @@ +# https://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +max_line_length = 120 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{kt,kts}] +indent_size = 4 +ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL +ij_kotlin_continuation_indent_in_if_conditions = false +ktlint_function_naming_ignore_when_annotated_with = Composable + +# Don't allow any wildcard imports +ij_kotlin_packages_to_use_import_on_demand = unset + +# Prevent wildcard imports +ij_kotlin_name_count_to_use_star_import = 99 +ij_kotlin_name_count_to_use_star_import_for_members = 99 + +[*.md] +trim_trailing_whitespace = false +max_line_length = unset + +[*.yml] +ij_yaml_spaces_within_brackets = false \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index df8309c..ad19dfd 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -25,7 +25,7 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } } @@ -42,18 +42,17 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.activity.compose) implementation(platform(libs.androidx.compose.bom)) - implementation(libs.androidx.ui) - implementation(libs.androidx.ui.graphics) - implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) implementation(libs.bundles.layer.presentation) - ksp(libs.com.google.dagger.hilt.android.compiler) + ksp(libs.com.google.dagger.hilt.compiler) + implementation(project(":core:api")) + implementation(project(":core:database")) + implementation(project(":core:presentation")) + implementation(project(":data")) + implementation(project(":domain")) implementation(project(":presentation:feature")) - implementation(project(":core:ui")) -} \ No newline at end of file +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2544bc7..8047c24 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,28 +1,28 @@ + xmlns:tools="http://schemas.android.com/tools"> - - - - + + + + - - - - + + + + - \ No newline at end of file + diff --git a/app/src/main/java/com/example/baseproject/application/BaseProjectApplication.kt b/app/src/main/java/com/example/baseproject/application/BaseProjectApplication.kt index 0d15009..c09d425 100644 --- a/app/src/main/java/com/example/baseproject/application/BaseProjectApplication.kt +++ b/app/src/main/java/com/example/baseproject/application/BaseProjectApplication.kt @@ -4,4 +4,4 @@ import android.app.Application import dagger.hilt.android.HiltAndroidApp @HiltAndroidApp -class BaseProjectApplication : Application() \ No newline at end of file +class BaseProjectApplication : Application() diff --git a/app/src/main/java/com/example/baseproject/navigation/BaseProjectApp.kt b/app/src/main/java/com/example/baseproject/navigation/BaseProjectApplication.kt similarity index 90% rename from app/src/main/java/com/example/baseproject/navigation/BaseProjectApp.kt rename to app/src/main/java/com/example/baseproject/navigation/BaseProjectApplication.kt index dc6efe6..fae1690 100644 --- a/app/src/main/java/com/example/baseproject/navigation/BaseProjectApp.kt +++ b/app/src/main/java/com/example/baseproject/navigation/BaseProjectApplication.kt @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable import androidx.navigation.compose.rememberNavController @Composable -fun BaseProjectApp() { +fun BaseProjectApplication() { val navController = rememberNavController() BaseProjectApplicationNavHost( diff --git a/app/src/main/java/com/example/baseproject/navigation/BaseProjectApplicationNavHost.kt b/app/src/main/java/com/example/baseproject/navigation/BaseProjectApplicationNavHost.kt index 14f7789..b544cd1 100644 --- a/app/src/main/java/com/example/baseproject/navigation/BaseProjectApplicationNavHost.kt +++ b/app/src/main/java/com/example/baseproject/navigation/BaseProjectApplicationNavHost.kt @@ -1,30 +1,33 @@ package com.example.baseproject.navigation -import android.annotation.SuppressLint import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost -import androidx.navigation.compose.composable import androidx.navigation.compose.navigation -import com.example.feature.screen.FeatureScreen +import com.example.baseproject.navigation.viewmodel.NavigationViewModel +import com.example.core.presentation.navigation.BaseProjectNavRoutes -@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") @Composable fun BaseProjectApplicationNavHost( modifier: Modifier = Modifier, navController: NavHostController, + viewModel: NavigationViewModel = hiltViewModel(), ) { NavHost( modifier = modifier, navController = navController, - startDestination = NavigationRoutes.MainGraph, + startDestination = BaseProjectNavRoutes.MainGraph, ) { - navigation( - startDestination = NavigationRoutes.Feature, + navigation( + startDestination = BaseProjectNavRoutes.Feature, ) { - composable { - FeatureScreen() + viewModel.subNavigation.forEach { subNavigation -> + subNavigation.registerNavGraph( + navGraphBuilder = this, + navController = navController, + ) } } } diff --git a/app/src/main/java/com/example/baseproject/navigation/NavigationRoutes.kt b/app/src/main/java/com/example/baseproject/navigation/NavigationRoutes.kt deleted file mode 100644 index b26532b..0000000 --- a/app/src/main/java/com/example/baseproject/navigation/NavigationRoutes.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.baseproject.navigation - -import kotlinx.serialization.Serializable - -sealed class NavigationRoutes { - @Serializable - data object MainGraph : NavigationRoutes() - - @Serializable - data object Feature : NavigationRoutes() -} diff --git a/app/src/main/java/com/example/baseproject/navigation/di/NavigationModule.kt b/app/src/main/java/com/example/baseproject/navigation/di/NavigationModule.kt new file mode 100644 index 0000000..7f23dba --- /dev/null +++ b/app/src/main/java/com/example/baseproject/navigation/di/NavigationModule.kt @@ -0,0 +1,17 @@ +package com.example.baseproject.navigation.di + +import com.example.core.presentation.navigation.FeatureNavigation +import com.example.feature.navigation.FeatureNavigationImpl +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import dagger.multibindings.IntoSet + +@Module +@InstallIn(SingletonComponent::class) +object NavigationModule { + @Provides + @IntoSet + fun provideFeatureNavigation(): FeatureNavigation = FeatureNavigationImpl() +} diff --git a/app/src/main/java/com/example/baseproject/navigation/viewmodel/NavigationViewModel.kt b/app/src/main/java/com/example/baseproject/navigation/viewmodel/NavigationViewModel.kt new file mode 100644 index 0000000..8e3d49b --- /dev/null +++ b/app/src/main/java/com/example/baseproject/navigation/viewmodel/NavigationViewModel.kt @@ -0,0 +1,16 @@ +package com.example.baseproject.navigation.viewmodel + +import androidx.lifecycle.ViewModel +import com.example.core.presentation.navigation.FeatureNavigation +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class NavigationViewModel + @Inject + constructor( + private val featureNavigation: Set<@JvmSuppressWildcards FeatureNavigation>, + ) : ViewModel() { + val subNavigation: Set + get() = featureNavigation + } diff --git a/app/src/main/java/com/example/baseproject/application/MainActivity.kt b/app/src/main/java/com/example/baseproject/view/MainActivity.kt similarity index 69% rename from app/src/main/java/com/example/baseproject/application/MainActivity.kt rename to app/src/main/java/com/example/baseproject/view/MainActivity.kt index 57933fb..48a5c21 100644 --- a/app/src/main/java/com/example/baseproject/application/MainActivity.kt +++ b/app/src/main/java/com/example/baseproject/view/MainActivity.kt @@ -1,11 +1,11 @@ -package com.example.baseproject.application +package com.example.baseproject.view import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import com.example.baseproject.navigation.BaseProjectApp -import com.example.core.ui.theme.BaseProjectTheme +import com.example.baseproject.navigation.BaseProjectApplication +import com.example.core.presentation.ui.theme.BaseProjectTheme import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint @@ -15,7 +15,7 @@ class MainActivity : ComponentActivity() { enableEdgeToEdge() setContent { BaseProjectTheme { - BaseProjectApp() + BaseProjectApplication() } } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 9666e7e..1c7c11b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -11,4 +11,4 @@ repositories { } } mavenCentral() -} \ No newline at end of file +} diff --git a/core/api/build.gradle.kts b/core/api/build.gradle.kts index 36ce87e..358ed31 100644 --- a/core/api/build.gradle.kts +++ b/core/api/build.gradle.kts @@ -1,6 +1,8 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) + alias(libs.plugins.com.google.devtools.ksp) + alias(libs.plugins.com.google.dagger.hilt.android) } android { @@ -17,7 +19,7 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } } @@ -31,10 +33,13 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.appcompat) - implementation(libs.material) implementation(libs.bundles.layer.data) + implementation(libs.arrow.core.retrofit) + implementation(libs.retrofit) + implementation(libs.retrofit.gson) + implementation(libs.okhttp) + + ksp(libs.com.google.dagger.hilt.compiler) testImplementation(libs.bundles.test.unit) -} \ No newline at end of file +} diff --git a/core/api/src/main/kotlin/com/example/core/api/di/ApiModule.kt b/core/api/src/main/kotlin/com/example/core/api/di/ApiModule.kt new file mode 100644 index 0000000..1da210f --- /dev/null +++ b/core/api/src/main/kotlin/com/example/core/api/di/ApiModule.kt @@ -0,0 +1,29 @@ +package com.example.core.api.di + +import arrow.retrofit.adapter.either.EitherCallAdapterFactory +import com.example.core.api.service.MovieApi +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object ApiModule { + @Provides + @Singleton + fun provideRetrofit(): Retrofit = + Retrofit + .Builder() + .baseUrl(MovieApi.BASE_URL) + .addConverterFactory(GsonConverterFactory.create()) + .addCallAdapterFactory(EitherCallAdapterFactory.create()) + .build() + + @Provides + @Singleton + fun provideMovieApi(retrofit: Retrofit): MovieApi = retrofit.create(MovieApi::class.java) +} diff --git a/core/api/src/main/kotlin/com/example/core/api/model/MovieDto.kt b/core/api/src/main/kotlin/com/example/core/api/model/MovieDto.kt new file mode 100644 index 0000000..f03626a --- /dev/null +++ b/core/api/src/main/kotlin/com/example/core/api/model/MovieDto.kt @@ -0,0 +1,11 @@ +package com.example.core.api.model + +import com.google.gson.annotations.SerializedName + +data class MovieDto( + @SerializedName("Title") val title: String, + @SerializedName("Year") val year: String, + @SerializedName("imdbID") val imdbId: String, + @SerializedName("Type") val type: String, + @SerializedName("Poster") val poster: String, +) diff --git a/core/api/src/main/kotlin/com/example/core/api/model/SearchResponseDto.kt b/core/api/src/main/kotlin/com/example/core/api/model/SearchResponseDto.kt new file mode 100644 index 0000000..f31bee1 --- /dev/null +++ b/core/api/src/main/kotlin/com/example/core/api/model/SearchResponseDto.kt @@ -0,0 +1,9 @@ +package com.example.core.api.model + +import com.google.gson.annotations.SerializedName + +data class SearchResponseDto( + @SerializedName("Search") val results: List, + @SerializedName("totalResults") val totalResults: String, + @SerializedName("Response") val response: String, +) diff --git a/core/api/src/main/kotlin/com/example/core/api/service/MovieApi.kt b/core/api/src/main/kotlin/com/example/core/api/service/MovieApi.kt new file mode 100644 index 0000000..5d9bd60 --- /dev/null +++ b/core/api/src/main/kotlin/com/example/core/api/service/MovieApi.kt @@ -0,0 +1,23 @@ +package com.example.core.api.service + +import arrow.core.Either +import arrow.retrofit.adapter.either.networkhandling.CallError +import com.example.core.api.model.SearchResponseDto +import retrofit2.http.GET +import retrofit2.http.Query + +interface MovieApi { + @GET + fun searchMovies( + @Query("s") query: String, + @Query("page") page: Int, + @Query("pageSize") pageSize: Int = PAGE_SIZE, + @Query("apikey") apikey: String = API_KEY, + ): Either + + companion object { + const val PAGE_SIZE = 10 + const val BASE_URL = "https://www.omdbapi.com/" + const val API_KEY = "1a64ba7b" + } +} diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index fac0b40..05a3fff 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -2,6 +2,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) alias(libs.plugins.com.google.devtools.ksp) + alias(libs.plugins.com.google.dagger.hilt.android) } android { @@ -18,7 +19,7 @@ android { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" + "proguard-rules.pro", ) } } @@ -32,12 +33,11 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) - implementation(libs.androidx.appcompat) - implementation(libs.material) implementation(libs.bundles.layer.data) + implementation(libs.room.ktx) + ksp(libs.com.google.dagger.hilt.compiler) ksp(libs.room.compiler) testImplementation(libs.bundles.test.unit) -} \ No newline at end of file +} diff --git a/core/database/src/main/kotlin/com/example/core/database/AppDatabase.kt b/core/database/src/main/kotlin/com/example/core/database/AppDatabase.kt new file mode 100644 index 0000000..7075e52 --- /dev/null +++ b/core/database/src/main/kotlin/com/example/core/database/AppDatabase.kt @@ -0,0 +1,20 @@ +package com.example.core.database + +import androidx.room.Database +import androidx.room.RoomDatabase +import com.example.core.database.dao.MovieDao +import com.example.core.database.model.DeletedMovieEntity + +@Database( + entities = [DeletedMovieEntity::class], + version = AppDatabase.Companion.DB_VERSION, + exportSchema = false, +) +abstract class AppDatabase : RoomDatabase() { + abstract fun movieDao(): MovieDao + + companion object { + const val DB_NAME = "base_project_database" + const val DB_VERSION = 1 + } +} diff --git a/core/database/src/main/kotlin/com/example/core/database/dao/MovieDao.kt b/core/database/src/main/kotlin/com/example/core/database/dao/MovieDao.kt new file mode 100644 index 0000000..4123cac --- /dev/null +++ b/core/database/src/main/kotlin/com/example/core/database/dao/MovieDao.kt @@ -0,0 +1,16 @@ +package com.example.core.database.dao + +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.OnConflictStrategy +import androidx.room.Query +import com.example.core.database.model.DeletedMovieEntity + +@Dao +interface MovieDao { + @Insert(onConflict = OnConflictStrategy.IGNORE) + suspend fun insertDeletedMovie(movie: DeletedMovieEntity) + + @Query("SELECT * FROM deletedmovieentity") + suspend fun getAllDeletedMovies(): List +} diff --git a/core/database/src/main/kotlin/com/example/core/database/di/DatabaseModule.kt b/core/database/src/main/kotlin/com/example/core/database/di/DatabaseModule.kt new file mode 100644 index 0000000..7679ec6 --- /dev/null +++ b/core/database/src/main/kotlin/com/example/core/database/di/DatabaseModule.kt @@ -0,0 +1,32 @@ +package com.example.core.database.di + +import android.content.Context +import androidx.room.Room +import com.example.core.database.AppDatabase +import com.example.core.database.AppDatabase.Companion.DB_NAME +import com.example.core.database.dao.MovieDao +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object DatabaseModule { + @Provides + @Singleton + fun provideDatabase( + @ApplicationContext appContext: Context, + ) = Room + .databaseBuilder( + appContext, + AppDatabase::class.java, + DB_NAME, + ).build() + + @Provides + @Singleton + fun provideMovieDao(db: AppDatabase): MovieDao = db.movieDao() +} diff --git a/core/database/src/main/kotlin/com/example/core/database/model/DeletedMovieEntity.kt b/core/database/src/main/kotlin/com/example/core/database/model/DeletedMovieEntity.kt new file mode 100644 index 0000000..7d07d17 --- /dev/null +++ b/core/database/src/main/kotlin/com/example/core/database/model/DeletedMovieEntity.kt @@ -0,0 +1,10 @@ +package com.example.core.database.model + +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity +data class DeletedMovieEntity( + @PrimaryKey + var id: Int = 0, +) diff --git a/core/ui/.gitignore b/core/presentation/.gitignore similarity index 100% rename from core/ui/.gitignore rename to core/presentation/.gitignore diff --git a/core/ui/build.gradle.kts b/core/presentation/build.gradle.kts similarity index 82% rename from core/ui/build.gradle.kts rename to core/presentation/build.gradle.kts index 4bc7fec..4bf6c1c 100644 --- a/core/ui/build.gradle.kts +++ b/core/presentation/build.gradle.kts @@ -2,6 +2,7 @@ plugins { alias(libs.plugins.android.library) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.compose) + alias(libs.plugins.kotlin.serialization) alias(libs.plugins.com.google.devtools.ksp) alias(libs.plugins.com.google.dagger.hilt.android) } @@ -37,18 +38,14 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) implementation(libs.androidx.appcompat) implementation(libs.androidx.material3) implementation(libs.bundles.layer.presentation) implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.activity.compose) - ksp(libs.com.google.dagger.hilt.android.compiler) + ksp(libs.com.google.dagger.hilt.compiler) testImplementation(libs.bundles.test.unit) testImplementation(libs.bundles.test.compose) - androidTestImplementation(libs.bundles.test.android) - androidTestImplementation(platform(libs.androidx.compose.bom)) - androidTestImplementation(libs.bundles.test.android) } diff --git a/core/ui/proguard-rules.pro b/core/presentation/proguard-rules.pro similarity index 100% rename from core/ui/proguard-rules.pro rename to core/presentation/proguard-rules.pro diff --git a/core/ui/src/androidTest/java/com/example/feature/ExampleInstrumentedTest.kt b/core/presentation/src/androidTest/java/com/example/feature/ExampleInstrumentedTest.kt similarity index 100% rename from core/ui/src/androidTest/java/com/example/feature/ExampleInstrumentedTest.kt rename to core/presentation/src/androidTest/java/com/example/feature/ExampleInstrumentedTest.kt diff --git a/core/presentation/src/main/java/com/example/core/presentation/navigation/BaseProjectNavRoutes.kt b/core/presentation/src/main/java/com/example/core/presentation/navigation/BaseProjectNavRoutes.kt new file mode 100644 index 0000000..8f64290 --- /dev/null +++ b/core/presentation/src/main/java/com/example/core/presentation/navigation/BaseProjectNavRoutes.kt @@ -0,0 +1,11 @@ +package com.example.core.presentation.navigation + +import kotlinx.serialization.Serializable + +sealed class BaseProjectNavRoutes { + @Serializable + data object MainGraph : BaseProjectNavRoutes() + + @Serializable + data object Feature : BaseProjectNavRoutes() +} diff --git a/core/presentation/src/main/java/com/example/core/presentation/navigation/FeatureNavigation.kt b/core/presentation/src/main/java/com/example/core/presentation/navigation/FeatureNavigation.kt new file mode 100644 index 0000000..a3716e9 --- /dev/null +++ b/core/presentation/src/main/java/com/example/core/presentation/navigation/FeatureNavigation.kt @@ -0,0 +1,11 @@ +package com.example.core.presentation.navigation + +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController + +interface FeatureNavigation { + fun registerNavGraph( + navGraphBuilder: NavGraphBuilder, + navController: NavHostController, + ) +} diff --git a/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Color.kt b/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Color.kt new file mode 100644 index 0000000..593708e --- /dev/null +++ b/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Color.kt @@ -0,0 +1,33 @@ +package com.example.core.presentation.ui.theme + +import androidx.compose.ui.graphics.Color + +val PrimaryBlue = Color(0xFF1A4B8C) +val PrimaryBlueLight = Color(0xFF466EAB) +val PrimaryBlueDark = Color(0xFF0D3060) + +val SecondaryOrange = Color(0xFFFF7733) +val SecondaryOrangeLight = Color(0xFFFF986B) +val SecondaryOrangeDark = Color(0xFFD65D22) + +val AccentGreen = Color(0xFF1D9957) +val AccentGreenLight = Color(0xFF4DBB7B) +val AccentGreenDark = Color(0xFF0E7D3F) + +val Grey10 = Color(0xFFF5F7F9) +val Grey20 = Color(0xFFE5E9F0) +val Grey30 = Color(0xFFCDD3DE) +val Grey40 = Color(0xFFADB6C3) +val Grey50 = Color(0xFF8E99A8) +val Grey60 = Color(0xFF707D8D) +val Grey70 = Color(0xFF515F72) +val Grey80 = Color(0xFF3B4857) +val Grey90 = Color(0xFF242E3C) +val Grey100 = Color(0xFF121A26) + +val SuccessColor = Color(0xFF28A745) +val WarningColor = Color(0xFFFFC107) +val ErrorColor = Color(0xFFDC3545) +val ErrorDark = Color(0xFF93000A) +val ErrorLight = Color(0xFFFFDAD6) +val InfoColor = Color(0xFF17A2B8) diff --git a/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Theme.kt b/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Theme.kt new file mode 100644 index 0000000..7a2a278 --- /dev/null +++ b/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Theme.kt @@ -0,0 +1,88 @@ +package com.example.core.presentation.ui.theme + +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = + darkColorScheme( + primary = SecondaryOrange, + onPrimary = Color.White, + primaryContainer = SecondaryOrangeDark, + onPrimaryContainer = Color.White, + secondary = PrimaryBlue, + onSecondary = Color.White, + secondaryContainer = PrimaryBlueDark, + onSecondaryContainer = Color.White, + tertiary = AccentGreen, + onTertiary = Color.White, + tertiaryContainer = AccentGreenDark, + onTertiaryContainer = Color.White, + background = Grey100, + onBackground = Grey20, + surface = Grey90, + onSurface = Grey20, + surfaceVariant = Grey80, + onSurfaceVariant = Grey30, + error = ErrorColor, + onError = Color.White, + errorContainer = ErrorDark, + onErrorContainer = ErrorLight, + ) + +private val LightColorScheme = + lightColorScheme( + primary = PrimaryBlue, + onPrimary = Color.White, + primaryContainer = PrimaryBlueLight, + onPrimaryContainer = Grey100, + secondary = SecondaryOrange, + onSecondary = Color.White, + secondaryContainer = SecondaryOrangeLight, + onSecondaryContainer = Grey100, + tertiary = AccentGreen, + onTertiary = Color.White, + tertiaryContainer = AccentGreenLight, + onTertiaryContainer = Grey100, + background = Grey10, + onBackground = Grey100, + surface = Color.White, + onSurface = Grey100, + surfaceVariant = Grey20, + onSurfaceVariant = Grey90, + error = ErrorColor, + onError = Color.White, + errorContainer = ErrorLight, + onErrorContainer = ErrorDark, + ) + +@Composable +fun BaseProjectTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + dynamicColor: Boolean = true, + content: @Composable () -> Unit, +) { + val colorScheme = + when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content, + ) +} diff --git a/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Type.kt b/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Type.kt new file mode 100644 index 0000000..ef4635f --- /dev/null +++ b/core/presentation/src/main/java/com/example/core/presentation/ui/theme/Type.kt @@ -0,0 +1,36 @@ +package com.example.core.presentation.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = + Typography( + bodyLarge = + TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp, + ), + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ + ) diff --git a/core/ui/src/main/res/values/strings.xml b/core/presentation/src/main/res/values/strings.xml similarity index 100% rename from core/ui/src/main/res/values/strings.xml rename to core/presentation/src/main/res/values/strings.xml diff --git a/core/presentation/src/main/res/values/themes.xml b/core/presentation/src/main/res/values/themes.xml new file mode 100644 index 0000000..c770e66 --- /dev/null +++ b/core/presentation/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +