Skip to content

Commit

Permalink
Fix a bug with the toolbar appearance.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Dec 13, 2024
1 parent 72600b4 commit 443d9df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ import SwiftUIIntrospect

extension PlatformViewVersionPredicate<TextFieldType, UITextField> {
static var supportedVersions: Self {
.iOS(.v16, .v17, .v18)
.iOS(.v17, .v18)
}
}

extension PlatformViewVersionPredicate<ScrollViewType, UIScrollView> {
static var supportedVersions: Self {
.iOS(.v16, .v17, .v18)
.iOS(.v17, .v18)
}
}

extension PlatformViewVersionPredicate<ViewControllerType, UIViewController> {
static var supportedVersions: Self {
.iOS(.v16, .v17, .v18)
.iOS(.v17, .v18)
}
}

extension PlatformViewVersionPredicate<NavigationStackType, UINavigationController> {
static var supportedVersions: Self {
.iOS(.v17, .v18)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ struct TimelineMediaPreviewView: View {
Color.clear
.overlay { QuickLookView(viewModelContext: context).ignoresSafeArea() } // Overlay to stop QL hijacking the toolbar.
.toolbar { toolbar }
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar) // The toolbar's scrollEdgeAppearance isn't aware of the quicklook view 🤷‍♂️
.toolbarBackground(.visible, for: .bottomBar)
.navigationBarTitleDisplayMode(.inline)
.safeAreaInset(edge: .bottom, spacing: 0) { caption }
}
.introspect(.navigationStack, on: .supportedVersions) {
// Fixes a bug where the QuickLook view overrides the .toolbarBackground(.visible) after it loads the real item.
$0.navigationBar.scrollEdgeAppearance = $0.navigationBar.standardAppearance
$0.toolbar.scrollEdgeAppearance = $0.toolbar.standardAppearance
}
.sheet(item: $context.mediaDetailsItem) { item in
TimelineMediaPreviewDetailsView(item: item, context: context)
}
Expand Down

0 comments on commit 443d9df

Please sign in to comment.