Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Sources/DynamicNotchKit/DynamicNotch/DynamicNotch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ public final class DynamicNotch<Expanded, CompactLeading, CompactTrailing>: 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.
Expand Down
34 changes: 14 additions & 20 deletions Sources/DynamicNotchKit/Views/NotchlessView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,25 @@ struct NotchlessView<Expanded, CompactLeading, CompactTrailing>: 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved conciseness, you can use the height parameter in the .frame modifier since minHeight and maxHeight are set to the same value (compactIconSize).

Suggested change
.frame(minWidth: compactIconSize, minHeight: compactIconSize, maxHeight: compactIconSize)
.frame(minWidth: compactIconSize, height: compactIconSize)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is correct: When minHeight == maxHeight, using height: is cleaner.

But SwiftUI's API doesn't allow it: SwiftUI has two separate .frame() overloads:

  1. .frame(width:height:alignment:)
  2. .frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)

You can't mix minWidth: (from overload 2) with height: (from overload 1) in the same call.

}

// 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For improved conciseness, you can use the height parameter in the .frame modifier since minHeight and maxHeight are set to the same value (compactIconSize).

Suggested change
.frame(minWidth: compactIconSize, minHeight: compactIconSize, maxHeight: compactIconSize)
.frame(minWidth: compactIconSize, height: compactIconSize)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini's suggestion was incorrect - SwiftUI doesn't have a .frame(minWidth:height:) overload. The original code is correct.

}
}
.frame(height: dynamicNotch.notchSize.height)
.padding(.horizontal, safeAreaInset)
Expand Down