SwiftUI Drawer v0.1.0 Release Notes

Release Date: 2020-08-21 // about 2 years ago
  • Landscape!

    Check out the new .onLayoutForSizeClass modifier!

    ⚡️ With .onLayoutForSizeClass you can update your state variables to layout your drawer for landscape.

    Resting heights are now binding!

    This means you can keep a state variable to contain your view heights. Instead of using the old .locked modifier, just change the resting heights parameter to a single height.

    🆕 New Documentation Layout

    The Readme is more concise, but it now contains links to other markdown files for Examples and Reference.


Previous changes from v0.0.4-beta

  • [Beta] Landscape

    Introducing behaviors for landscape and split view orientations

    🆕 New View Modifiers

    Alignment

    0️⃣ Defines the horizontal alignment for the drawer. The default is fullscreen.

    public enum DrawerAlignment { case leading, center, trailing, fullscreen}
    

    Usage

    Drawer(heights: [100, 340]) { Color.blue} .width(.constant(340)) .alignment($alignment)
    

    Width

    Defines a width for the drawer when not in fullscreen alignment.

    Usage

    Drawer(heights: [100, 340]) { Color.blue}.width(.constant(340))
    

    OnLayoutForSizeClass

    ⚡️ A callback to receive updates when the drawer is laid out for a new size class.

    This closure is executed every time the device layout changes (portrait, landscape, and split view).
    👉 Use this to modify your view when the drawer's layout changes.

    Usage
    Alter the resting heights and alignment when the screen layout changes.

    Drawer(heights: [100, 340]) { Color.blue} .onLayoutForSizeClass { (sizeClass) inswitch (sizeClass.horizontal, sizeClass.vertical) { case (.compact, .compact):// smaller iPhone landscapebreakcase (.compact, .regular):// iPhone portrait// iPad portrait splitview// iPad landscape smaller splitviewbreakcase (.regular, .compact):// larger iPhone landscapebreakcase (.regular, .regular):// iPad fullscreen// iPad landscape larger splitviewbreakdefault:// Unknown layoutbreak } }