Skip to content

Commit

Permalink
[#791] Remove Hilt dependency in themes
Browse files Browse the repository at this point in the history
  • Loading branch information
florentmaitre committed Jan 29, 2024
1 parent c702fb2 commit 903b1f7
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 74 deletions.
7 changes: 3 additions & 4 deletions app/src/main/java/com/orange/ods/app/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ package com.orange.ods.app.ui
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import com.orange.ods.theme.OdsThemeConfigurationContract
import com.orange.ods.theme.innovationcup.InnovationCupThemeConfiguration
import com.orange.ods.theme.orange.OrangeThemeConfiguration
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class MainActivity : ComponentActivity() {

@Inject
lateinit var themeConfigurations: Set<@JvmSuppressWildcards OdsThemeConfigurationContract>
private val themeConfigurations = listOf(OrangeThemeConfiguration(), InnovationCupThemeConfiguration())

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/orange/ods/app/ui/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import kotlinx.coroutines.flow.onEach

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun MainScreen(themeConfigurations: Set<OdsThemeConfigurationContract>, mainViewModel: MainViewModel = viewModel()) {
fun MainScreen(themeConfigurations: List<OdsThemeConfigurationContract>, mainViewModel: MainViewModel = viewModel()) {
val isSystemInDarkTheme = isSystemInDarkTheme()
val mainState = rememberMainState(
themeState = rememberThemeState(
Expand All @@ -84,7 +84,7 @@ fun MainScreen(themeConfigurations: Set<OdsThemeConfigurationContract>, mainView
)
},
darkModeEnabled = rememberSaveable { mutableStateOf(isSystemInDarkTheme) },
themeConfigurations = themeConfigurations.toList()
themeConfigurations = themeConfigurations
)
)

Expand Down Expand Up @@ -202,7 +202,7 @@ fun MainScreen(themeConfigurations: Set<OdsThemeConfigurationContract>, mainView
}
}

private fun getCurrentThemeConfiguration(storedUserThemeName: String?, themeConfigurations: Set<OdsThemeConfigurationContract>): OdsThemeConfigurationContract {
private fun getCurrentThemeConfiguration(storedUserThemeName: String?, themeConfigurations: List<OdsThemeConfigurationContract>): OdsThemeConfigurationContract {
// Return the stored user theme configuration if it exists. If not, return the Orange theme configuration or the first existing theme configuration
return themeConfigurations.firstOrNull { it.name == storedUserThemeName }
.orElse { themeConfigurations.firstOrNull { it.isOrange } }
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- \[Lib\] Update `OdsLinearProgressIndicator` and `OdsCircularProgressIndicator` APIs ([#607](https://github.com/Orange-OpenSource/ods-android/issues/607))
- \[Lib\] Update `OdsImageItem` API and rename it into `OdsImageTile` ([#609](https://github.com/Orange-OpenSource/ods-android/issues/609))
- \[Lib\] Update `OdsChip`, `OdsChoiceChipsFlowRow`and `OdsFilterChip` APIs ([#603](https://github.com/Orange-OpenSource/ods-android/issues/603))
- \[ThemeInnovationCup/ThemeOrange] Remove Hilt dependency in themes ([#791](https://github.com/Orange-OpenSource/ods-android/issues/791))

### Fixed

Expand Down
3 changes: 0 additions & 3 deletions theme-innovation-cup/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.orange.ods.gradle.Dependencies
plugins {
id("library")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
id("kotlin-parcelize")
}

Expand All @@ -28,6 +27,4 @@ dependencies {

implementation(platform(Dependencies.composeBom))
implementation(Dependencies.composeMaterial)
implementation(Dependencies.hiltAndroid)
kapt(Dependencies.hiltCompiler)
}

This file was deleted.

3 changes: 0 additions & 3 deletions theme-orange/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.orange.ods.gradle.Dependencies
plugins {
id("library")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
id("kotlin-parcelize")
}

Expand All @@ -28,7 +27,5 @@ dependencies {

implementation(platform(Dependencies.composeBom))
implementation(Dependencies.composeMaterial)
implementation(Dependencies.hiltAndroid)
kapt(Dependencies.hiltCompiler)
implementation(Dependencies.material)
}

This file was deleted.

0 comments on commit 903b1f7

Please sign in to comment.