Skip to content
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

df/FloatingPanelEnhancements #108

Merged
merged 40 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bdb639d
Start
dfeinzimer Jul 29, 2022
60c5839
Progress
dfeinzimer Jul 29, 2022
f5952d8
Progress
dfeinzimer Jul 29, 2022
934595d
Progress
dfeinzimer Jul 29, 2022
1f34502
Update FloatingPanel.swift
dfeinzimer Jul 29, 2022
1c28a80
Progress
dfeinzimer Jul 29, 2022
61e27e7
Progress
dfeinzimer Jul 29, 2022
2bd0f95
Progress
dfeinzimer Jul 29, 2022
1647d8f
Update FloatingPanel.swift
dfeinzimer Jul 29, 2022
100febb
Update FloatingPanel.swift
dfeinzimer Jul 29, 2022
d94f9c7
Progress
dfeinzimer Jul 29, 2022
687e398
Progress
dfeinzimer Jul 29, 2022
5b775ae
Merge in latest
dfeinzimer Jul 29, 2022
2ef0f50
Default detent
dfeinzimer Jul 29, 2022
0c04f28
Progress
dfeinzimer Jul 30, 2022
0cf61b2
Add doc
dfeinzimer Jul 30, 2022
51950f3
Finish doc
dfeinzimer Jul 30, 2022
8143f08
Update FloatingPanelModifier.swift
dfeinzimer Aug 1, 2022
07a39de
Update FloatingPanel.swift
dfeinzimer Aug 1, 2022
4d6de42
Update FloatingPanel.swift
dfeinzimer Aug 1, 2022
6ff6195
Add doc
dfeinzimer Aug 1, 2022
8216d5a
Merge latest
dfeinzimer Aug 3, 2022
902f796
Add padding to content bottom in compact envs
dfeinzimer Aug 3, 2022
060d0f5
Address hidden handle
dfeinzimer Aug 4, 2022
07cff79
Simplification
dfeinzimer Aug 5, 2022
bce92eb
Update FloatingPanel.swift
dfeinzimer Aug 5, 2022
f83b293
Merge latest
dfeinzimer Aug 8, 2022
268bd8d
Merge branch 'v.next' into df/FloatingPanelEnhancements
dfeinzimer Aug 8, 2022
63a44ff
Merge in latest
dfeinzimer Aug 10, 2022
6fc4d81
Merge branch 'v.next' into df/FloatingPanelEnhancements
dfeinzimer Aug 11, 2022
ebfb7ea
Merge branch 'v.next' into df/FloatingPanelEnhancements
dfeinzimer Aug 18, 2022
1af0791
Merge branch 'v.next' into df/FloatingPanelEnhancements
dfeinzimer Aug 22, 2022
6d0175c
`makeHandleArea` -> `makeHandleView`
dfeinzimer Aug 22, 2022
5352247
Doc simplification
dfeinzimer Aug 22, 2022
c75e7e3
Update FloatingPanel.swift
dfeinzimer Aug 22, 2022
2b82038
Doc updates
dfeinzimer Aug 22, 2022
d695cbb
Update FloatingPanelDetent.swift
dfeinzimer Aug 22, 2022
efe7102
Update FloatingPanel.swift
dfeinzimer Aug 22, 2022
9c76d72
Remove deprecated method
dfeinzimer Aug 22, 2022
77e6867
Move padding location
dfeinzimer Aug 22, 2022
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
Prev Previous commit
Next Next commit
Finish doc
  • Loading branch information
dfeinzimer committed Jul 30, 2022
commit 51950f3b6aaf806c358ed3e2823686c3b9f64306
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct FloatingPanel<Content>: View where Content: View {
_isPresented = isPresented
}

/// The detent that is currently set.
/// A binding to the currently selected detent.
@Binding private var activeDetent: FloatingPanelDetent

/// The color of the handle.
Expand All @@ -59,7 +59,7 @@ struct FloatingPanel<Content>: View where Content: View {
/// The height of the content.
@State private var height: CGFloat = .minHeight

/// A Boolean value indicating if the view is presented.
/// A binding to a Boolean value that determines whether the view is presented.
@Binding private var isPresented: Bool

/// The maximum allowed height of the content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@
import SwiftUI

public extension View {
/// Presents a dynamic view with a presentation style similar to that of a sheet in compact
/// environments and a popover otherwise.
/// The resulting view allows for interaction with background contents.
/// A floating panel is a view that overlays a view and supplies view-related
/// content. For a map view, for instance, it could display a legend, bookmarks, search results, etc..
/// Apple Maps, Google Maps, Windows 10, and Collector have floating panel
/// implementations, sometimes referred to as a "bottom sheet".
///
/// Floating panels are non-modal and can be transient, only displaying
/// information for a short period of time like identify results,
/// or persistent, where the information is always displayed, for example a
/// dedicated search panel. They will also be primarily simple containers
/// that clients will fill with their own content.
///
/// The floating panel allows for interaction with background contents, unlike native sheets or popovers.
///
/// - Parameters:
/// - detent: <#detent description#>
/// - isPresented: <#isPresented description#>
/// - maxWidth: <#maxWidth description#>
/// - content: <#content description#>
/// - Returns: <#description#>
/// - backgroundColor: The background color of the floating panel.
/// - detent: A binding to the currently selected detent.
/// - horizontalAlignment: The horizontal alignment of the floating panel.
/// - isPresented: A binding to a Boolean value that determines whether the view is presented.
/// - maxWidth: The maximum width of the floating panel.
/// - content: A closure that returns the content of the floating panel.
/// - Returns: A dynamic view with a presentation style similar to that of a sheet in compact
/// environments and a popover otherwise.
func floatingPanel<Content>(
backgroundColor: Color = Color(uiColor: .systemBackground),
detent: Binding<FloatingPanelDetent> = .constant(.half),
Expand All @@ -38,13 +51,13 @@ public extension View {
horizontalAlignment: horizontalAlignment,
isPresented: isPresented,
maxWidth: maxWidth,
innerContent: content()
content: content()
)
)
}
}

/// <#Description#>
/// Overlays a floating panel on the parent content.
private struct FloatingPanelModifier<InnerContent>: ViewModifier where InnerContent: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Environment(\.verticalSizeClass) var verticalSizeClass
Expand All @@ -54,23 +67,23 @@ private struct FloatingPanelModifier<InnerContent>: ViewModifier where InnerCont
horizontalSizeClass == .compact && verticalSizeClass == .regular
}

/// <#Description#>
/// The background color of the floating panel.
let backgroundColor: Color

/// <#Description#>
/// A binding to the currently selected detent.
let detent: Binding<FloatingPanelDetent>

/// <#Description#>
/// The horizontal alignment of the floating panel.
let horizontalAlignment: HorizontalAlignment

/// <#Description#>
/// A binding to a Boolean value that determines whether the view is presented.
let isPresented: Binding<Bool>

/// <#Description#>
/// The maximum width of the floating panel.
let maxWidth: CGFloat

/// <#Description#>
let innerContent: InnerContent
/// The content to be displayed within the floating panel.
let content: InnerContent

func body(content: Content) -> some View {
content
Expand All @@ -80,7 +93,7 @@ private struct FloatingPanelModifier<InnerContent>: ViewModifier where InnerCont
detent: detent,
isPresented: isPresented
) {
innerContent
content
}
.edgesIgnoringSafeArea(.bottom)
.frame(maxWidth: isCompact ? .infinity : maxWidth)
Expand Down