Skip to content

Commit

Permalink
Refactor to conditionally use Scaffold or NavigationSuiteScaffold
Browse files Browse the repository at this point in the history
Modify RYScaffold to use NavigationSuiteScaffold only when navigationSuiteItems is not null, otherwise default to using Scaffold. This ensures appropriate usage of components based on the availability of navigationSuiteItems while maintaining UI consistency.
  • Loading branch information
kdroidFilter committed Nov 14, 2024
1 parent 9e2dd6c commit 35da15d
Showing 1 changed file with 69 additions and 26 deletions.
95 changes: 69 additions & 26 deletions app/src/main/java/me/ash/reader/ui/component/base/RYScaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,59 @@ fun RYScaffold(
currentWindowAdaptiveInfo()
)

NavigationSuiteScaffold(
modifier = modifier
.background(
MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation,
color = containerColor
)
),
layoutType = layoutType,
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
containerTonalElevation,
color = containerColor
) onDark MaterialTheme.colorScheme.surface,
navigationSuiteItems = navigationSuiteItems ?: {},
content = {
Column {
if (navigationSuiteItems != null) {
NavigationSuiteScaffold(
modifier = modifier
.background(
MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation,
color = containerColor
)
),
layoutType = layoutType,
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
containerTonalElevation,
color = containerColor
) onDark MaterialTheme.colorScheme.surface,
navigationSuiteItems = navigationSuiteItems,
content = {
Column {
if (topBar != null) {
topBar()
} else if (navigationIcon != null || actions != null) {
TopAppBar(
title = {},
navigationIcon = { navigationIcon?.invoke() },
actions = { actions?.invoke(this) },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation
),
)
)
}
content()
if (floatingActionButton != null) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.BottomEnd
) {
floatingActionButton()
}
}
}
}
)
} else {
Scaffold(
modifier = modifier
.background(
MaterialTheme.colorScheme.surfaceColorAtElevation(
topBarTonalElevation,
color = containerColor
)
),
topBar = {
if (topBar != null) {
topBar()
} else if (navigationIcon != null || actions != null) {
Expand All @@ -64,17 +101,23 @@ fun RYScaffold(
)
)
}
content()
},
floatingActionButton = {
if (floatingActionButton != null) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.BottomEnd
) {
floatingActionButton()
}
floatingActionButton()
}
}
}
)
},
content = {
Column {
Spacer(modifier = Modifier.height(it.calculateTopPadding()))
content()
}
},
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
containerTonalElevation,
color = containerColor
) onDark MaterialTheme.colorScheme.surface
)
}
}

0 comments on commit 35da15d

Please sign in to comment.