Skip to content

Commit

Permalink
.toolbarBackground(.visible) should cause background to always be vis…
Browse files Browse the repository at this point in the history
…ible,

even when no content is scrolled beneath
  • Loading branch information
aabewhite committed Oct 30, 2024
1 parent 8c5355c commit ecd36e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions Sources/SkipUI/SkipUI/Containers/Navigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ public struct NavigationStack<Root> : View where Root: View {
topBarModifier = topBarModifier.background(topBarBackgroundBrush)
}
}
let alwaysShowScrolledBackground = topBarPreferences?.backgroundVisibility == Visibility.visible
let topBarColors = TopAppBarDefaults.topAppBarColors(
containerColor: unscrolledTopBarBackgroundColor,
containerColor: alwaysShowScrolledBackground ? topBarBackgroundColor : unscrolledTopBarBackgroundColor,
scrolledContainerColor: topBarBackgroundColor,
titleContentColor: MaterialTheme.colorScheme.onSurface
)
Expand Down Expand Up @@ -388,9 +389,9 @@ public struct NavigationStack<Root> : View where Root: View {
return
}

let canScrollForward = bottomBarPreferences?.scrollableState.canScrollForward == true
let showScrolledBackground = bottomBarPreferences?.backgroundVisibility == Visibility.visible || bottomBarPreferences?.scrollableState.canScrollForward == true
let materialColorScheme: androidx.compose.material3.ColorScheme
if canScrollForward, let customColorScheme = bottomBarPreferences?.colorScheme?.asMaterialTheme() {
if showScrolledBackground, let customColorScheme = bottomBarPreferences?.colorScheme?.asMaterialTheme() {
materialColorScheme = customColorScheme
} else {
materialColorScheme = MaterialTheme.colorScheme
Expand Down Expand Up @@ -434,15 +435,15 @@ public struct NavigationStack<Root> : View where Root: View {
bottomBarHeightPx.value = bounds.bottom - bounds.top
}
}
if canScrollForward, let bottomBarBackgroundForBrush {
if showScrolledBackground, let bottomBarBackgroundForBrush {
if let bottomBarBackgroundBrush = bottomBarBackgroundForBrush.asBrush(opacity: 1.0, animationContext: nil) {
bottomBarModifier = bottomBarModifier.background(bottomBarBackgroundBrush)
}
}
// Pull the bottom bar below the keyboard
let bottomPadding = with(density) { min(bottomBarHeightPx.value, Float(WindowInsets.ime.getBottom(density))).toDp() }
PaddingLayout(padding: EdgeInsets(top: 0.0, leading: 0.0, bottom: Double(-bottomPadding.value), trailing: 0.0), context: context.content()) { context in
let containerColor = canScrollForward ? bottomBarBackgroundColor : unscrolledBottomBarBackgroundColor
let containerColor = showScrolledBackground ? bottomBarBackgroundColor : unscrolledBottomBarBackgroundColor
let windowInsets = EnvironmentValues.shared._isEdgeToEdge == true ? BottomAppBarDefaults.windowInsets : WindowInsets(bottom: 0.dp)
var options = Material3BottomAppBarOptions(modifier: context.modifier.then(bottomBarModifier), containerColor: containerColor, contentColor: MaterialTheme.colorScheme.contentColorFor(containerColor), contentPadding: PaddingValues.Absolute(left: 16.dp, right: 16.dp))
if let updateOptions = EnvironmentValues.shared._material3BottomAppBar {
Expand Down
8 changes: 4 additions & 4 deletions Sources/SkipUI/SkipUI/Containers/TabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public struct TabView : View {
let tint = EnvironmentValues.shared._tint
let hasColorScheme = reducedTabBarPreferences.colorScheme != nil
let isSystemBackground = reducedTabBarPreferences.isSystemBackground == true
let canScrollForward = reducedTabBarPreferences.scrollableState?.canScrollForward == true
let showScrolledBackground = reducedTabBarPreferences.backgroundVisibility == Visibility.visible || reducedTabBarPreferences.scrollableState?.canScrollForward == true
let materialColorScheme: androidx.compose.material3.ColorScheme
if canScrollForward, let customColorScheme = reducedTabBarPreferences.colorScheme?.asMaterialTheme() {
if showScrolledBackground, let customColorScheme = reducedTabBarPreferences.colorScheme?.asMaterialTheme() {
materialColorScheme = customColorScheme
} else {
materialColorScheme = MaterialTheme.colorScheme
Expand Down Expand Up @@ -173,7 +173,7 @@ public struct TabView : View {
tabBarItemColors = NavigationBarItemDefaults.colors(indicatorColor: indicatorColor)
}
}
if canScrollForward, let tabBarBackgroundForBrush {
if showScrolledBackground, let tabBarBackgroundForBrush {
if let tabBarBackgroundBrush = tabBarBackgroundForBrush.asBrush(opacity: 1.0, animationContext: nil) {
tabBarModifier = tabBarModifier.background(tabBarBackgroundBrush)
}
Expand All @@ -184,7 +184,7 @@ public struct TabView : View {
let bottomPadding = with(density) { min(bottomBarHeightPx.value, Float(WindowInsets.ime.getBottom(density))).toDp() }
PaddingLayout(padding: EdgeInsets(top: 0.0, leading: 0.0, bottom: Double(-bottomPadding.value), trailing: 0.0), context: context.content()) { context in
let tabItemsState = rememberUpdatedState(tabItems)
let containerColor = canScrollForward ? tabBarBackgroundColor : unscrolledTabBarBackgroundColor
let containerColor = showScrolledBackground ? tabBarBackgroundColor : unscrolledTabBarBackgroundColor
let onItemClick: (Int) -> Void = { tabIndex in
let route = String(describing: tabIndex)
if let selection, let tagValue = tagValue(route: route, in: tabViews) {
Expand Down

0 comments on commit ecd36e0

Please sign in to comment.