Useful SwiftUI container view's. FittingGeometry, ScrollableView, LayoutReader, PageView, UIKitView. (iOS)

Overview

ios

Containers

Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+

Useful SwiftUI container view's for additional convenience.

Includes:

  • FittingGeometryReader (auto-sizes its height)
  • ScrollableView (support various contentMode options)
  • LayoutReader (supports readable and other other guides)
  • PageView (TabView in paging style but supports auto-sizing)
  • UIKit View (Easily nest UIView's in SwiftUI, including auto-sizing)

FittingGeometry

A geometry reader that automatically sizes its height to 'fit' its content.

FittingGeometryReader { geo in
    Text("The height is now \(geo.size.height)")
}

LayoutReader

A container view that provides a layout proxy, allowing you to query various layout properties usually only available via UIKit.

The most useful example is layout-relative to the readableContentGuide

Features

  • Familiar API (similar to GeometryReader)
  • SafeArea, content (layoutMargins) and readable content guide layouts
  • Responds automatically to dynamic type changes
  • Respects interface orientation and other layout changes
LayoutReader { layout in
    Rectangle()
        .foregroundColor(.red)
        .frame(maxWidth: layout.frame(in: .readable).width)
}

ScrollView

A scrollview that behaves more similarly to a VStack when its content size is small enough.

ScrollView(contentMode: .fit) {
    Text("I'm aligned to the top")
    Spacer()
    Text("I'm aligned to the bottom, until you scroll ;)")
}

PageView

A page view that behaves similarly to UIPageViewController but adds auto-sizing configuration.

// Passing `fit` for the contentMode forces the PageView to hug its content. To fill the available space, set this to `fill` (its default value)
PageView(selection: $currentPage, contentMode: .fit) {
    Group {
        Text("Page 1")
        Text("Page 2")
        Text("Page 3")
    }
}

Note: This view requires iOS 14+

UIKitView

A SwiftUI view that accepts a single UIView instance to be presented in the hierarchy.

UIKitView {
    let label = UILabel(frame: .zero)
    label.text = "foo"
    return label
}

Installation

The code is packaged as a framework. You can install manually (by copying the files in the Sources directory) or using Swift Package Manager (preferred)

To install using Swift Package Manager, add this to the dependencies section of your Package.swift file:

.package(url: "https://github.com/SwiftUI-Plus/Containers.git", .upToNextMinor(from: "1.0.0"))

Other Packages

If you want easy access to this and more packages, add the following collection to your Xcode 13+ configuration:

https://benkau.com/packages.json

You might also like...
Swift-picker-views - inline single and multi picker views for UIKit. Without tableview! Easy and simple
Swift-picker-views - inline single and multi picker views for UIKit. Without tableview! Easy and simple

swift-picker-views Inline single and multiple picker views for UIKit. No tablevi

A Swift utility to make updating table views/collection views trivially easy and reliable.

ArrayDiff An efficient Swift utility to compute the difference between two arrays. Get the removedIndexes and insertedIndexes and pass them directly a

SwiftUI Animation Library. Useful SwiftUI animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can directly implement in your next iOS application or project. The library also contains huge examples of spring animations such as Inertial Bounce, Shake, Twirl, Jelly, Jiggle, Rubber Band, Kitchen Sink and Wobble effects. Browse, find and download the animation that fits your needs. The most powerful Grid container missed in SwiftUI
The most powerful Grid container missed in SwiftUI

Grid Grid view inspired by CSS Grid and written with SwiftUI We are a development agency building phenomenal apps. Overview Grid is a powerful and eas

Recipes app written in SwiftUI using Single State Container
Recipes app written in SwiftUI using Single State Container

swiftui-recipes-app Recipes app is written in SwiftUI using Single State Container This app implemented as an example of a Single State Container conc

Zoomable - A container that allows you to zoom in and out of an image using only SwiftUI

Zoomable It is a container that allows you to zoom in and out of an image using

A new approach to Container-Based Dependency Injection for Swift and SwiftUI.
A new approach to Container-Based Dependency Injection for Swift and SwiftUI.

A new approach to Container-Based Dependency Injection for Swift and SwiftUI. Why do something new? Resolver was my first Dependency Injection system.

VTMagic is a page container library for iOS.
VTMagic is a page container library for iOS.

VTMagic VTMagic is a page container library for iOS, you can custom every page controller by different identifier if you need. It's so easy to use!(中文

ViperServices - Simple dependency injection container for services written for iOS in swift supporting boot order

ViperServices Introduction ViperServices is dependency injection container for iOS applications written in Swift. It is more lightweight and simple in

Deli is an easy-to-use Dependency Injection Container that creates DI containers
Deli is an easy-to-use Dependency Injection Container that creates DI containers

Deli is an easy-to-use Dependency Injection Container that creates DI containers with all required registrations and corresponding factories.

Dip is a simple Dependency Injection Container.

Dip is a simple Dependency Injection Container. It's aimed to be as simple as possible yet p

RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.
RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.

About Architecture concerns RxReduce Installation The key principles How to use RxReduce Tools and dependencies Travis CI Frameworks Platform Licence

A container view that responds to scrolling of UIScrollView
A container view that responds to scrolling of UIScrollView

FlexibleHeader A container view that responds to scrolling of UIScrollView. normal threshold FlexibleHeaderExecutantType Getting Started Progressive I

A framework that provides CurtainController. CurtainController is a container view controller that implements a content-curtain interface. You can find a similar implementation in applications like Apple Maps, Find My, Stocks, etc. Someone calls it XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers
XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers

XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers. Pan gesture can be used to move on to next or previous view controller. It shows a interactive indicator of the current, previous, next child view controllers.

A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

DIContainer Swift is an ultra-light dependency injection container made to help developers to handle dependencies easily. It works with Swift 5.1 or above.

🏺 DIContainer Swift It is an ultra-light dependency injection container made to help developers to handle dependencies easily. We know that handle wi

A flexible container view featuring a solid background with rounded corners.
A flexible container view featuring a solid background with rounded corners.

A flexible container view featuring a solid background with rounded corners.

A library that provides the ability to import/export Realm files from a variety of data container formats.

Realm Converter Realm Converter is an open source software utility framework to make it easier to get data both in and out of Realm. It has been built

Owner
SwiftUI+
A collection of SwiftUI backports and more. Fully certificate signed, so please do not use any of the packages if Xcode warns otherwise.
SwiftUI+
A mirror of Apple's sample code for high performance collection views in iOS 15.

Building High-Performance Lists and Collection Views Improve the performance of lists and collections in your app with prefetching and image preparati

Tim Oliver 14 Nov 12, 2022
Easy way to integrate pagination with dummy views in CollectionView, make Instagram "Discover" within minutes.

AZCollectionView Controller Features Automatic pagination handling No more awkward empty CollectionView screen AZ CollectionVIew controller give you a

Afroz Zaheer 95 May 11, 2022
This component allows for the transfer of data items between collection views through drag and drop

Drag and Drop Collection Views Written for Swift 4.0, it is an implementation of Dragging and Dropping data across multiple UICollectionViews. Try it

Michael Michailidis 508 Dec 19, 2022
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI

A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI.

Billy 4 Sep 26, 2022
iOS custom view to display books on shelf

ShelfView (iOS) iOS custom view to display books on shelf (Android version is available here) Requirements iOS 10.0+ Swift 4.2 Installation ShelfView

Adeyinka Adediji 268 Dec 10, 2022
↕️ VegaScroll is a lightweight animation flowlayout for UICollectionView completely written in Swift 4, compatible with iOS 11 and Xcode 9.

Made by Applikey Solutions Find this project on Dribbble Also check another flowlayout for UICollectionView: https://github.com/ApplikeySolutions/Grav

Applikey Solutions 2.8k Jan 1, 2023
A PageView Swiping to the left will go to previous page and swiping to the right will go to next page

PageView This package creates a PageView. Swiping to the left will go to previous page and swiping to the right will go to next page. You can find how

null 0 Oct 20, 2021
A PageView, which supporting scrolling to transition between a UIView and a UITableView

YXTPageView ##A Page View, which support scrolling to transition between a UIView and a UITableView UIView (at the top) UITableView (at the bottom) In

Hanton Yang 68 May 25, 2022
Highly configurable iOS Alert Views with custom content views

NYAlertViewController NYAlertViewController is a replacement for UIAlertController/UIAlertView with support for content views and UI customization. Fe

Nealon Young 609 Nov 20, 2022
Protocol to handle initial Loadings, Empty Views and Error Handling in a ViewController & views

StatusProvider Protocol to handle initial Loadings, Empty Views and Error Handling in a ViewController & views CocoaPods Podfile pod 'StatusProvider'

Mario Hahn 887 Dec 22, 2022