Skip to content

Commit 2134f7c

Browse files
AllDaGearNoIdeaclaude
authored andcommitted
fix: use page background color for webview containers and speed up sidebar animation
Use each tab's pageBackgroundColor instead of windowBackgroundColor for webview and split pane backgrounds. Switch sidebar pin/unpin animation to .smooth(duration: 0.1) for a snappier feel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e153154 commit 2134f7c

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Nook/Components/WebsiteView/WebsiteView.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ struct WebsiteView: View {
214214
windowState: windowState
215215
)
216216
.coordinateSpace(name: dragCoordinateSpace)
217-
.background(shouldShowSplit ? Color.clear : Color(nsColor: .windowBackgroundColor))
217+
.background(shouldShowSplit ? Color.clear : Color(nsColor: browserManager.currentTab(for: windowState)?.pageBackgroundColor ?? .windowBackgroundColor))
218218
.frame(maxWidth: .infinity, maxHeight: .infinity)
219219
.clipShape(webViewClipShape)
220220
.shadow(color: Color.black.opacity(0.3), radius: 4, x: 0, y: 0)
@@ -645,19 +645,19 @@ struct TabCompositorWrapper: NSViewRepresentable {
645645
if let lId = leftId, let leftTab = allKnownTabs.first(where: { $0.id == lId }) {
646646
// Force-create/ensure loaded when visible in split
647647
let lWeb = webView(for: leftTab, windowId: windowState.id)
648-
let pane = makePaneContainer(frame: leftRect, isActive: (activeSide == .left), accent: accent, side: .left)
648+
let pane = makePaneContainer(frame: leftRect, isActive: (activeSide == .left), accent: accent, side: .left, pageBackground: leftTab.pageBackgroundColor)
649649
containerView.addSubview(pane)
650650
lWeb.frame = pane.bounds
651651
lWeb.autoresizingMask = [NSView.AutoresizingMask.width, NSView.AutoresizingMask.height]
652652
lWeb.isHidden = false
653653
pane.addSubview(lWeb)
654-
654+
655655
}
656656

657657
if let rId = rightId, let rightTab = allKnownTabs.first(where: { $0.id == rId }) {
658658
// Force-create/ensure loaded when visible in split
659659
let rWeb = webView(for: rightTab, windowId: windowState.id)
660-
let pane = makePaneContainer(frame: rightRect, isActive: (activeSide == .right), accent: accent, side: .right)
660+
let pane = makePaneContainer(frame: rightRect, isActive: (activeSide == .right), accent: accent, side: .right, pageBackground: rightTab.pageBackgroundColor)
661661
containerView.addSubview(pane)
662662
rWeb.frame = pane.bounds
663663
rWeb.autoresizingMask = [NSView.AutoresizingMask.width, NSView.AutoresizingMask.height]
@@ -706,16 +706,16 @@ struct TabCompositorWrapper: NSViewRepresentable {
706706
print("🔍 [MEMDEBUG] updateCompositor() COMPLETE - Window: \(windowState.id.uuidString.prefix(8)), WebViews in container: \(webViewCount), Total subviews: \(totalSubviews)")
707707
}
708708

709-
private func makePaneContainer(frame: NSRect, isActive: Bool, accent: NSColor, side: SplitViewManager.Side) -> NSView {
709+
private func makePaneContainer(frame: NSRect, isActive: Bool, accent: NSColor, side: SplitViewManager.Side, pageBackground: NSColor? = nil) -> NSView {
710710
let cornerRadius: CGFloat = {
711711
if #available(macOS 26.0, *) { return 8 } else { return 8 }
712712
}()
713-
713+
714714
let v = NSView(frame: frame)
715715
v.wantsLayer = true
716-
716+
717717
if let layer = v.layer {
718-
layer.backgroundColor = NSColor.windowBackgroundColor.cgColor
718+
layer.backgroundColor = (pageBackground ?? .windowBackgroundColor).cgColor
719719

720720
// Create mask layer for uneven rounded corners
721721
let maskLayer = CAShapeLayer()

Nook/Managers/BrowserManager/BrowserManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ class BrowserManager: ObservableObject {
811811
let floatingVisible = windowState.hoverSidebarManager?.isOverlayVisible ?? false
812812
toggleSidebar(for: windowState, floatingVisible: floatingVisible)
813813
} else {
814-
withAnimation(.easeInOut(duration: 0.2)) {
814+
withAnimation(.smooth(duration: 0.1)) {
815815
isSidebarVisible.toggle()
816816
}
817817
saveSidebarSettings()
@@ -823,7 +823,7 @@ class BrowserManager: ObservableObject {
823823
// Skip animation when pinning while the floating sidebar is already showing
824824
let shouldAnimate = unpinning || !floatingVisible
825825
if shouldAnimate {
826-
withAnimation(.easeInOut(duration: 0.2)) {
826+
withAnimation(.smooth(duration: 0.1)) {
827827
windowState.isSidebarVisible = !unpinning
828828
}
829829
} else {

0 commit comments

Comments
 (0)