View
public extension View
-
bpkBottomSheet(isPresented:peekHeight: contentMode: closeButtonAccessibilityLabel: title: action: bottomSheetContent: ) Presents a bottom sheet that, unless manually toggling the
isPresentedproperty, this sheet will not be dismissed when dragging down.Declaration
Swift
@available(iOS 16.4, *) @ViewBuilder func bpkBottomSheet<BottomSheetContent: View>( isPresented: Binding<Bool>, peekHeight: CGFloat, contentMode: BPKBottomSheetContentMode = .medium, closeButtonAccessibilityLabel: String? = nil, title: String? = nil, action: BPKBottomSheetAction? = nil, @ViewBuilder bottomSheetContent: @escaping () -> BottomSheetContent ) -> some ViewParameters
isPresentedA binding to whether the bottom sheet should be shown.
peekHeightThe height of the sheet when it is peeking the screen.
contentModeThe content mode of the bottom sheet. Defaults to
.medium.closeButtonAccessibilityLabelThe accessibility label for the close button. If
nil, the close button will not be shown.titleThe title of the bottom sheet. If
nil, the title will not be shown.actionThe action button of the bottom sheet. If
nil, the action button will not be shown.bottomSheetContentThe content of the bottom sheet.
-
bpkBottomSheet(isPresented:contentMode: closeButtonAccessibilityLabel: title: action: presentingController: bottomSheetContent: ) Presents a bottom sheet.
Note
For iOS 16 users and above, the bottom sheet will be presented using SwiftUI’s native
BottomSheetview. For iOS 15 users and below, the bottom sheet will be presented using a custom implementation.Declaration
Swift
@ViewBuilder func bpkBottomSheet<BottomSheetContent: View>( isPresented: Binding<Bool>, contentMode: BPKBottomSheetContentMode = .medium, closeButtonAccessibilityLabel: String? = nil, title: String? = nil, action: BPKBottomSheetAction? = nil, presentingController: UIViewController, @ViewBuilder bottomSheetContent: @escaping () -> BottomSheetContent ) -> some ViewParameters
isPresentedA binding to whether the bottom sheet should be shown.
contentModeThe content mode of the bottom sheet. Defaults to
.medium.closeButtonAccessibilityLabelThe accessibility label for the close button. If
nil, the close button will not be shown.titleThe title of the bottom sheet. If
nil, the title will not be shown.actionThe action button of the bottom sheet. If
nil, the action button will not be shown.bottomSheetContentThe content of the bottom sheet.
-
bpkBottomSheet(item:peekHeight: contentMode: closeButtonAccessibilityLabel: title: action: presentingController: bottomSheetContent: ) Presents a bottom sheet that, unless manually setting the
itemproperty to nil, this sheet will not be dismissed when dragging down.Declaration
Swift
@available(iOS 16.4, *) @ViewBuilder func bpkBottomSheet<BottomSheetContent: View, Item: Identifiable>( item: Binding<Item?>, peekHeight: CGFloat, contentMode: BPKBottomSheetContentMode = .medium, closeButtonAccessibilityLabel: String? = nil, title: String? = nil, action: BPKBottomSheetAction? = nil, presentingController: UIViewController, @ViewBuilder bottomSheetContent: @escaping (Item) -> BottomSheetContent ) -> some ViewParameters
itemA binding to an optional source of truth for the sheet. When
itemis non-nil, the system passes the item’s content to the modifier’s closure.peekHeightThe height of the sheet when it is peeking the screen.
contentModeThe content mode of the bottom sheet. Defaults to
.medium.closeButtonAccessibilityLabelThe accessibility label for the close button. If
nil, the close button will not be shown.titleThe title of the bottom sheet. If
nil, the title will not be shown.actionThe action button of the bottom sheet. If
nil, the action button will not be shown.bottomSheetContentThe content of the bottom sheet.
-
bpkBottomSheet(item:contentMode: closeButtonAccessibilityLabel: title: action: presentingController: bottomSheetContent: ) Presents a bottom sheet.
Declaration
Swift
@ViewBuilder func bpkBottomSheet<BottomSheetContent: View, Item: Identifiable>( item: Binding<Item?>, contentMode: BPKBottomSheetContentMode = .medium, closeButtonAccessibilityLabel: String? = nil, title: String? = nil, action: BPKBottomSheetAction? = nil, presentingController: UIViewController, @ViewBuilder bottomSheetContent: @escaping (Item) -> BottomSheetContent ) -> some ViewParameters
itemA binding to an optional source of truth for the sheet. When
itemis non-nil, the system passes the item’s content to the modifier’s closure.contentModeThe content mode of the bottom sheet. Defaults to
.medium.closeButtonAccessibilityLabelThe accessibility label for the close button. If
nil, the close button will not be shown.titleThe title of the bottom sheet. If
nil, the title will not be shown.actionThe action button of the bottom sheet. If
nil, the action button will not be shown.bottomSheetContentThe content of the bottom sheet.
-
Declaration
Swift
func background(_ color: BPKColor, alignment: Alignment = .center) -> some View -
Declaration
Swift
func foregroundColor(_ color: BPKColor) -> some View -
bpkSuccessDialog(presented:icon: title: text: confirmButton: secondaryActions: presentingController: onTouchOutside: ) Displays a success dialog with a title, text and a list of buttons.
Declaration
Swift
func bpkSuccessDialog( presented: Binding<Bool>, icon: BPKIcon, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, presentingController: UIViewController, onTouchOutside: (() -> Void)? = nil ) -> some View -
bpkWarningDialog(presented:icon: title: text: confirmButton: secondaryActions: presentingController: onTouchOutside: ) Displays a warning dialog with a title, text and a list of buttons.
Declaration
Swift
func bpkWarningDialog( presented: Binding<Bool>, icon: BPKIcon, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, presentingController: UIViewController, onTouchOutside: (() -> Void)? = nil ) -> some View -
bpkDestructiveDialog(presented:icon: title: text: confirmButton: linkButton: presentingController: onTouchOutside: ) Displays a destructive dialog with a title, text and a list of buttons.
Declaration
Swift
func bpkDestructiveDialog( presented: Binding<Bool>, icon: BPKIcon, title: String, text: String, confirmButton: BPKDialogButton, linkButton: BPKDialogButton? = nil, presentingController: UIViewController, onTouchOutside: (() -> Void)? = nil ) -> some View -
bpkImageDialog(presented:image: title: text: confirmButton: secondaryActions: presentingController: onTouchOutside: ) Displays a dialog with an image, title, text and a list of buttons.
Declaration
Swift
func bpkImageDialog( presented: Binding<Bool>, image: Image, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, presentingController: UIViewController, onTouchOutside: (() -> Void)? = nil ) -> some View -
bpkFlareDialog(presented:image: title: text: confirmButton: secondaryActions: presentingController: onTouchOutside: ) Displays a dialog with an image with a flare, title, text and a list of buttons.
Declaration
Swift
func bpkFlareDialog( presented: Binding<Bool>, image: Image, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, presentingController: UIViewController, onTouchOutside: (() -> Void)? = nil ) -> some View -
Displays a success dialog with a title, text and a list of buttons.
Declaration
Swift
func bpkSuccessDialogView( presented: Binding<Bool>, icon: BPKIcon, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, onTouchOutside: (() -> Void)? = nil ) -> some View -
Displays a warning dialog with a title, text and a list of buttons.
Declaration
Swift
func bpkWarningDialogView( presented: Binding<Bool>, icon: BPKIcon, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, onTouchOutside: (() -> Void)? = nil ) -> some View -
Displays a destructive dialog with a title, text and a list of buttons.
Declaration
Swift
func bpkDestructiveDialogView( presented: Binding<Bool>, icon: BPKIcon, title: String, text: String, confirmButton: BPKDialogButton, linkButton: BPKDialogButton? = nil, onTouchOutside: (() -> Void)? = nil ) -> some View -
Displays a dialog with an image, title, text and a list of buttons.
Declaration
Swift
func bpkImageDialogView( presented: Binding<Bool>, image: Image, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, onTouchOutside: (() -> Void)? = nil ) -> some View -
Displays a dialog with an image with a flare, title, text and a list of buttons.
Declaration
Swift
func bpkFlareDialogView( presented: Binding<Bool>, image: Image, title: String, text: String, confirmButton: BPKDialogButton, secondaryActions: BPKDialogSecondaryActions? = nil, onTouchOutside: (() -> Void)? = nil ) -> some View -
bpkImageGalleryGrid(isPresented:selectedCategory: categories: closeAccessibilityLabel: onImageTapped: onCloseTapped: ) Declaration
Swift
@ViewBuilder func bpkImageGalleryGrid<CategoryView, GridImage, SlideshowImage>( isPresented: Binding<Bool>, selectedCategory: Binding<Int>, categories: [BPKImageGalleryImageCategory<CategoryView, GridImage, SlideshowImage>], closeAccessibilityLabel: String, onImageTapped: @escaping (_ category: Int, _ image: Int) -> Void, onCloseTapped: @escaping () -> Void ) -> some View -
bpkImageGalleryGrid(isPresented:selectedCategory: categories: closeAccessibilityLabel: onImageTapped: onCloseTapped: ) Declaration
Swift
@ViewBuilder func bpkImageGalleryGrid<GridImage, SlideshowImage>( isPresented: Binding<Bool>, selectedCategory: Binding<Int>, categories: [BPKImageGalleryChipCategory<GridImage, SlideshowImage>], closeAccessibilityLabel: String, onImageTapped: @escaping (_ category: Int, _ image: Int) -> Void, onCloseTapped: @escaping () -> Void ) -> some View -
Declaration
Swift
func bpkImageGallerySlideshow<Content>( isPresented: Binding<Bool>, images: [BPKSlideshowGalleryImage<Content>], closeAccessibilityLabel: String, currentIndex: Binding<Int>, onCloseTapped: @escaping () -> Void ) -> some View -
Applies an overlay to the view.
Declaration
Swift
func bpkOverlay(_ type: BPKOverlayType) -> some ViewParameters
typeThe type of overlay to apply.
Return Value
A view with the overlay applied.
-
Declaration
Swift
func shadow(_ shadow: BPKShadow) -> some View -
Declaration
Swift
@ViewBuilder func shimmering() -> some View -
Adds a specific padding amount to each edge of this view.
Use this modifier to add padding all the way around a view.
VStack { Text("Text padded by BPKSpacing.md on each edge") .padding(.md) Text("Unpadded text for comparison.") }The order in which you apply modifiers matters. The example above applies the padding before applying the border to ensure that the border encompasses the padded region:
To pad a select set of edges by the same amount, use
padding(_:_:).Declaration
Swift
func padding(_ spacing: BPKSpacing) -> some ViewParameters
lengthThe amount to pad this view on all edges.
Return Value
A view that’s padded by the spacing token you specify.
-
Adds an equal padding amount to specific edges of this view.
Use this modifier to add a specified amount of padding to one or more edges of the view. Indicate the edges to pad by naming either a single value from
Edge/Set, or by specifying anOptionSetthat contains edge values:VStack { Text("Text padded by BPKSpacing.base on the bottom and trailing edges.") .padding([.bottom, .trailing], .base) Text("Unpadded text for comparison.") }The order in which you apply modifiers matters. The example above applies the padding before applying the border to ensure that the border encompasses the padded region:
Declaration
Swift
func padding(_ edge: Edge.Set, _ spacing: BPKSpacing) -> some ViewParameters
edgesThe set of edges to pad for this view.
lengthAn amount to pad this view on the specified edges.
Return Value
A view that’s padded by the specified amount on the specified edges.
-
Positions this view within an invisible frame with the specified size.
Use this method to specify a fixed size for a view’s width, height, or both. If you only specify one of the dimensions, the resulting view assumes this view’s sizing behavior in the other dimension.
For example, the following code lays out an ellipse in a fixed
BPKSpacing.mdbyBPKSpacing.smframe. Because a shape always occupies the space offered to it by the layout system, the first ellipse is.md x .smpoints. The second ellipse is laid out in a frame with only a fixed height, so it occupies that height, and whatever width the layout system offers to its parent.VStack { Ellipse() .frame(width: .md, height: .sm) Ellipse() .frame(height: .sm) }The alignmentparameter specifies this view’s alignment within the frame.BPKText("Hello world!") .frame(width: .lg, height: .md, alignment: .topLeading) .border(.lineColor)In the example above, the text is positioned at the top, leading corner of the frame. If the text is taller than the frame, its bounds may extend beyond the bottom of the frame’s bounds.
Declaration
Swift
func frame(width: BPKSpacing? = nil, height: BPKSpacing? = nil, alignment: Alignment = .center) -> some ViewParameters
widthA fixed width for the resulting view. If
widthisnil, the resulting view assumes this view’s sizing behavior.heightA fixed height for the resulting view. If
heightisnil, the resulting view assumes this view’s sizing behavior.alignmentThe alignment of this view inside the resulting frame. Note that most alignment values have no apparent effect when the size of the frame happens to match that of this view.
Return Value
A view with fixed dimensions of
widthandheight, for the parameters that are non-nil. -
Positions this view within an invisible frame having the specified size constraints.
Always specify at least one size characteristic when calling this method. Pass
nilor leave out a characteristic to indicate that the frame should adopt this view’s sizing behavior, constrained by the other non-nilarguments.The size proposed to this view is the size proposed to the frame, limited by any constraints specified, and with any ideal dimensions specified replacing any corresponding unspecified dimensions in the proposal.
If no minimum or maximum constraint is specified in a given dimension, the frame adopts the sizing behavior of its child in that dimension. If both constraints are specified in a dimension, the frame unconditionally adopts the size proposed for it, clamped to the constraints. Otherwise, the size of the frame in either dimension is:
- If a minimum constraint is specified and the size proposed for the frame by the parent is less than the size of this view, the proposed size, clamped to that minimum.
- If a maximum constraint is specified and the size proposed for the frame by the parent is greater than the size of this view, the proposed size, clamped to that maximum.
Otherwise, the size of this view.
Declaration
Swift
func frame( minWidth: BPKSpacing? = nil, idealWidth: BPKSpacing? = nil, maxWidth: BPKSpacing? = nil, minHeight: BPKSpacing? = nil, idealHeight: BPKSpacing? = nil, maxHeight: BPKSpacing? = nil, alignment: Alignment = .center ) -> some ViewParameters
minWidthThe minimum width of the resulting frame.
idealWidthThe ideal width of the resulting frame.
maxWidthThe maximum width of the resulting frame.
minHeightThe minimum height of the resulting frame.
idealHeightThe ideal height of the resulting frame.
maxHeightThe maximum height of the resulting frame.
alignmentThe alignment of this view inside the resulting frame. Note that most alignment values have no apparent effect when the size of the frame happens to match that of this view.
Return Value
A view with flexible dimensions given by the call’s non-
nilparameters. -
Declaration
Swift
@ViewBuilder func `if`<Content>(_ condition: Bool, transform: (Self) -> Content) -> some View where Content : View -
Sets the Dynamic Type size within the view to the given value. (Polyfill for previous versions)
See also
Declaration
Swift
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") @available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") func sizeCategory(_ size: ContentSizeCategory) -> some View -
Limits the Dynamic Type size within the view to the given range. (Polyfill for previous versions)
See also
Declaration
Swift
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") @available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") @available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") @available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "dynamicTypeSize(_:﹚") func sizeCategory<T>(_ range: T) -> some View where T : RangeExpression, T.Bound == ContentSizeCategory