CreationKit Documentation

Class Sheet​Input​Form​Layout

public final class SheetInputFormLayout: LabelInputFormLayout  

A LabelInputFormLayout subclass that uses a BottomSheet for user input.

After initializing this type, you should set the available items that the user can select via the items property. Then call makeSheet() to generate a view controller that can be presented to the user.

You can use selectItem(_:) to programmatically set a selected item on the input field.

SheetInputFormLayout SheetInputFormLayout LabelInputFormLayout LabelInputFormLayout SheetInputFormLayout->LabelInputFormLayout

Nested Types

SheetInputFormLayout.AccessoryState

Superclass

LabelInputFormLayout

A layout used in forms for gathering input from a user.

Initializers

init()

required public init()  

Properties

did​Select​Value

public var didSelectValue: (String) -> Void  

Called when the use selected a value from the sheet.

items

public var items: [String] = [] 

The available items to show that the user can select.

sheet​Title

public var sheetTitle: String? 

The title to display at the top of the sheet. If this value is nil, the form layout's title property will be used instead.

sheet​Item​Titles

public var sheetItemTitles: [String]? 

Alternate titles to use in the sheet. The positions should match up with the items property.

selected​Item​Publisher

public var selectedItemPublisher: AnyPublisher<String?, Never>  

The currently selected item, if there is one, as a Publisher.

selected​Item

public var selectedItem: String?  

The currently selected item, if there is one.

wants​ToShow​Sheet

public var wantsToShowSheet: () -> Void  

Called when CreationKit wants to show the sheet. This could happen if something causes the input field to become the first responder. You should call presentSheet(presenter:) when CreationKit calls this closure.

accessory​State

public var accessoryState: AccessoryState = .down  

Methods

select​Item(_:​)

public func selectItem(_ item: String)  

Sets the field to have a selected item. This method is useful when you want to have the field default to a value.

This validates that the item passed in exists in the items property. If it does not, this does nothing.

Parameters

item String

The item that should be selected.

make​Sheet(configuration:​)

public func makeSheet(configuration: SheetInputFormConfiguration = .default) -> UIViewController & PanModalPresentable  

Call this method when you want to show the sheet, i.e when the view is tapped.

This will make the sheet and pass it back to you to present.

Parameters

configuration Sheet​Input​Form​Configuration

The configuration object to use to configure the sheet.

Returns

A UIViewController that should be presented via presentPanModal(_:).

present​Sheet(presenter:​)

public func presentSheet(presenter: UIViewController)  

Call this method when you want to show the sheet, i.e when the view is tapped.

This will make the sheet and then present it for you.

Parameters

presenter UIView​Controller

The UIViewController to present the sheet.