diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt index 052329b28..cd13f19d0 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/MainScaffold.kt @@ -40,6 +40,7 @@ import com.infomaniak.swisstransfer.ui.navigation.MainNavigation import com.infomaniak.swisstransfer.ui.navigation.NavigationItem import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.PreviewMobile +import com.infomaniak.swisstransfer.ui.utils.PreviewTablet @Composable fun MainScaffold( @@ -65,25 +66,15 @@ fun MainScaffold( } } - MainScaffold(navType, currentDestination, navController, content) + MainScaffold(navType, currentDestination, navController::navigateToSelectedItem, content) } @Composable private fun MainScaffold( navType: NavigationSuiteType, - currentDestination: MainNavigation, - navController: NavHostController, - content: @Composable () -> Unit, -) { - Navigation(currentDestination, navController::navigateToSelectedItem, navType, content) -} - -@Composable -private fun Navigation( currentDestination: MainNavigation, navigateToSelectedItem: (MainNavigation) -> Unit, - navType: NavigationSuiteType, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { val isNavigationBar = navType == NavigationSuiteType.NavigationBar @@ -148,9 +139,9 @@ private fun NavHostController.navigateToSelectedItem(destination: MainNavigation @PreviewMobile @Composable -private fun NavigationPreview() { +private fun NavigationPreviewMobile() { SwissTransferTheme { - Navigation( + MainScaffold( currentDestination = MainNavigation.SentDestination, navigateToSelectedItem = {}, navType = NavigationSuiteType.NavigationBar, @@ -158,3 +149,16 @@ private fun NavigationPreview() { ) } } + +@PreviewTablet +@Composable +private fun NavigationPreviewTablet() { + SwissTransferTheme { + MainScaffold( + currentDestination = MainNavigation.SentDestination, + navigateToSelectedItem = {}, + navType = NavigationSuiteType.NavigationRail, + content = {}, + ) + } +} diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/ColorLight.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/ColorLight.kt index 0d5d1c2c9..8ff5e90cf 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/ColorLight.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/ColorLight.kt @@ -62,11 +62,3 @@ val LightColors = CustomColors( navigationItemBackground = light_background, divider = Color(mouse), ) - -@Immutable -data class CustomColors( - val primaryTextColor: Color, - val secondaryTextColor: Color, - val navigationItemBackground: Color, - val divider: Color, -) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Theme.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Theme.kt index dfb03c6fa..8f67d0198 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Theme.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/theme/Theme.kt @@ -19,14 +19,9 @@ package com.infomaniak.swisstransfer.ui.theme import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material3.LocalTextStyle -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.darkColorScheme -import androidx.compose.material3.lightColorScheme -import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.ProvidableCompositionLocal -import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.material3.* +import androidx.compose.runtime.* +import androidx.compose.ui.graphics.Color private val DarkColorScheme = darkColorScheme( primary = dark_primary, @@ -57,7 +52,7 @@ private val LightColorScheme = lightColorScheme( ) val LocalCustomTypography = staticCompositionLocalOf { Typography } -val LocalCustomColors: ProvidableCompositionLocal = staticCompositionLocalOf { null } +val LocalCustomColors: ProvidableCompositionLocal = staticCompositionLocalOf { CustomColors() } @Composable fun SwissTransferTheme( @@ -84,5 +79,16 @@ object SwissTransferTheme { get() = LocalCustomTypography.current val colors: CustomColors @Composable - get() = LocalCustomColors.current ?: error("Cannot access uninitialized LocalCustomColors") + get() = LocalCustomColors.current + val materialColors: ColorScheme + @Composable + get() = MaterialTheme.colorScheme } + +@Immutable +data class CustomColors( + val primaryTextColor: Color = Color.Unspecified, + val secondaryTextColor: Color = Color.Unspecified, + val navigationItemBackground: Color = Color.Unspecified, + val divider: Color = Color.Unspecified, +)