diff --git a/Sources/DynamicNotchKit/DynamicNotch/DynamicNotch.swift b/Sources/DynamicNotchKit/DynamicNotch/DynamicNotch.swift index 65a933f..e22e76d 100644 --- a/Sources/DynamicNotchKit/DynamicNotch/DynamicNotch.swift +++ b/Sources/DynamicNotchKit/DynamicNotch/DynamicNotch.swift @@ -74,8 +74,11 @@ public final class DynamicNotch: Obse let expandedContent: Expanded let compactLeadingContent: CompactLeading let compactTrailingContent: CompactTrailing - @Published var disableCompactLeading: Bool = false - @Published var disableCompactTrailing: Bool = false + /// When `true`, hides the compact leading content and removes it from layout. + @Published public var disableCompactLeading: Bool = false + + /// When `true`, hides the compact trailing content and removes it from layout. + @Published public var disableCompactTrailing: Bool = false /// Center content shown in floating fallback mode (hidden by notch in notch mode). /// Set this to display a title or other UI between the leading and trailing indicators. diff --git a/Sources/DynamicNotchKit/Views/NotchlessView.swift b/Sources/DynamicNotchKit/Views/NotchlessView.swift index 2b4d903..bed6f52 100644 --- a/Sources/DynamicNotchKit/Views/NotchlessView.swift +++ b/Sources/DynamicNotchKit/Views/NotchlessView.swift @@ -82,31 +82,25 @@ struct NotchlessView: View where Expa /// The center content is only rendered in NotchlessView (floating mode), not in NotchView. @ViewBuilder private func compactIndicatorsRow() -> some View { - HStack(spacing: 0) { - // Always render but hide if disabled - avoids SwiftUI conditional rendering issues - // Only constrain height to allow text content (e.g., "Pasted") to expand horizontally - dynamicNotch.compactLeadingContent - .environment(\.notchSection, .compactLeading) - .frame(minWidth: compactIconSize, minHeight: compactIconSize, maxHeight: compactIconSize) - .opacity(dynamicNotch.disableCompactLeading ? 0 : 1) - .accessibilityHidden(dynamicNotch.disableCompactLeading) - - // Minimum spacing ensures elements don't touch when fixedSize() shrinks the container - Spacer(minLength: 12) + // Use HStack spacing for automatic gaps between present elements + HStack(spacing: 12) { + // Conditional rendering ensures disabled views don't reserve space (matches NotchView.swift) + if !dynamicNotch.disableCompactLeading { + dynamicNotch.compactLeadingContent + .environment(\.notchSection, .compactLeading) + .frame(minWidth: compactIconSize, minHeight: compactIconSize, maxHeight: compactIconSize) + } // Center content - visible in floating fallback, hidden by notch in notch mode dynamicNotch.compactCenterContent .environment(\.notchSection, .compactCenter) - Spacer(minLength: 12) - - // Always render but hide if disabled - avoids SwiftUI conditional rendering issues - // Only constrain height to allow text content (e.g., "Pasted") to expand horizontally - dynamicNotch.compactTrailingContent - .environment(\.notchSection, .compactTrailing) - .frame(minWidth: compactIconSize, minHeight: compactIconSize, maxHeight: compactIconSize) - .opacity(dynamicNotch.disableCompactTrailing ? 0 : 1) - .accessibilityHidden(dynamicNotch.disableCompactTrailing) + // Conditional rendering ensures disabled views don't reserve space (matches NotchView.swift) + if !dynamicNotch.disableCompactTrailing { + dynamicNotch.compactTrailingContent + .environment(\.notchSection, .compactTrailing) + .frame(minWidth: compactIconSize, minHeight: compactIconSize, maxHeight: compactIconSize) + } } .frame(height: dynamicNotch.notchSize.height) .padding(.horizontal, safeAreaInset)