Configuration

public struct Configuration<View> where View : UIView

Represents the configuration of a specific UIView type.

  • A closure that is applied to the native view instance during an update cycle.

    Declaration

    Swift

    public typealias Update = (_ view: View) -> Void

    Parameters

    view

    The native view instance.

  • A closure that is responsible for instantiating an instance of the native view. The default value instantiates the view using init(frame:).

    Declaration

    Swift

    public var builder: () -> View
  • An array of update closures.

    Declaration

    Swift

    public var updates: [Update]
  • A closure that takes a native view instance as the single argument, and returns a subview of that view into which child views should be added and managed.

    Declaration

    Swift

    public var contentView: (View) -> UIView
  • The transition to use during layout changes.

    Declaration

    Swift

    public var layoutTransition: LayoutTransition
  • The transition to use when this view appears.

    Declaration

    Swift

    public var appearingTransition: VisibilityTransition?
  • The transition to use when this view disappears.

    Declaration

    Swift

    public var disappearingTransition: VisibilityTransition?
  • A hook to call when the element appears.

    Declaration

    Swift

    public var onAppear: LifecycleCallback?
  • A hook to call when the element disappears.

    Declaration

    Swift

    public var onDisappear: LifecycleCallback?
  • The prioritization method to use when snapping the native view’s frame to pixel boundaries.

    When snapping views to pixel boundaries, Blueprint prioritizes placing frame edges as close to the correct value as possible. This ensures that flush edges stay flush after rounding, but can result in frame sizes growing or shrinking by 1 pixel in either axis.

    Backing views that are particularly sensitive to size changes can opt-in to prioritize preserving their frame size instead of maximally correct edges. This will guarantee frame sizes, with the tradeoff that their edges may no longer be flush to other edges as they were laid out.

    Generally you should not change this value except in specific circumstances when all criteria are met:

    • The backing view is sensitive to frame size, such as a text label.
    • And the backing view has a transparent background, so that overlapping frames or gaps between frames are not visible.

    Declaration

    Swift

    public var frameRoundingBehavior: FrameRoundingBehavior
  • Initializes a default configuration object.

    Declaration

    Swift

    public init()
  • Adds the given update closure to the updates array.

    Declaration

    Swift

    public mutating func apply(_ update: @escaping Update)
  • Subscript for values that are not optional. We must represent these values as optional so that we can return nil from the subscript in the case where no value has been assigned for the given keypath.

    When getting a value for a keypath:

    • If a value has previously been assigned, it will be returned.
    • If no value has been assigned, nil will be returned.

    When assigning a value for a keypath:

    • If a value is provided, it will be applied to the view.
    • If nil is provided, no value will be applied to the view (any previous assignment will be cleared).

    Declaration

    Swift

    public subscript<Value>(keyPath: ReferenceWritableKeyPath<View, Value>) -> Value? { get set }
  • Subscript for values that are optional.

    When getting a value for a keypath:

    • If a value has previously been assigned (including nil), it will be returned.
    • If no value has been assigned, nil will be returned.

    When assigning a value for a keypath:

    • Any provided value will be applied to the view (including nil). This means that there is a difference between the initial state of a view description (where the view’s property will not be touched), and the state after nil is assigned. After assigning nil to an optional keypath, view.property = nil will be called on the next update.

    Declaration

    Swift

    public subscript<Value>(keyPath: ReferenceWritableKeyPath<View, Value?>) -> Value? { get set }