-
Notifications
You must be signed in to change notification settings - Fork 0
feat: expose disableCompactLeading/Trailing as public API #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||
| } | ||||||
|
|
||||||
| // 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) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For improved conciseness, you can use the
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improved conciseness, you can use the
heightparameter in the.framemodifier sinceminHeightandmaxHeightare set to the same value (compactIconSize).There was a problem hiding this comment.
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:
You can't mix minWidth: (from overload 2) with height: (from overload 1) in the same call.