Skip to content

Commit

Permalink
refactor: Replace LocalNavType with LocalWindowAdptiveInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Sep 25, 2024
1 parent e5b4ba7 commit 3c62bb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ import com.infomaniak.swisstransfer.ui.utils.PreviewMobile
import com.infomaniak.swisstransfer.ui.utils.PreviewTablet
import com.infomaniak.swisstransfer.ui.utils.isWindowLarge

val LocalNavType = staticCompositionLocalOf { NavigationSuiteType.None }

@Composable
fun MainScaffold(
navController: NavHostController,
Expand All @@ -45,9 +43,7 @@ fun MainScaffold(
) {
val navType by rememberNavType(currentDestination)

CompositionLocalProvider(LocalNavType provides navType) {
MainScaffold(navType, currentDestination, navController::navigateToSelectedItem, content)
}
MainScaffold(navType, currentDestination, navController::navigateToSelectedItem, content)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Scaffold
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteType
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
Expand All @@ -32,7 +31,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.infomaniak.swisstransfer.ui.components.SwissTransferTobAppBar
import com.infomaniak.swisstransfer.ui.components.TopAppBarButton
import com.infomaniak.swisstransfer.ui.screen.main.LocalNavType
import com.infomaniak.swisstransfer.ui.theme.LocalWindowAdaptiveInfo
import com.infomaniak.swisstransfer.ui.utils.isWindowSmall

@Composable
fun OptionScaffold(
Expand All @@ -43,8 +43,10 @@ fun OptionScaffold(
setSelectedSettingOptionPosition: (Int) -> Unit,
navigateBack: (() -> Unit)? = null,
) {
val windowAdaptiveInfo = LocalWindowAdaptiveInfo.current

Scaffold(topBar = {
val backNavigationMenu = if (LocalNavType.current == NavigationSuiteType.NavigationBar) {
val backNavigationMenu = if (windowAdaptiveInfo.isWindowSmall()) {
TopAppBarButton.backButton(navigateBack ?: {})
} else {
null
Expand Down

0 comments on commit 3c62bb7

Please sign in to comment.