Class
SheetInputFormLayout
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.
Relationships
Nested Types
SheetInputFormLayout.AccessoryState
Superclass
LabelInputFormLayout
A layout used in forms for gathering input from a user.
Initializers
init()
required public init()
Properties
didSelectValue
public var didSelectValue: (String) -> Void
Called when the use selected a value from the sheet.
sheetTitle
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.
sheetItemTitles
public var sheetItemTitles: [String]?
Alternate titles to use in the sheet. The positions should match up with the items
property.
selectedItemPublisher
public var selectedItemPublisher: AnyPublisher<String?, Never>
The currently selected item, if there is one, as a Publisher.
wantsToShowSheet
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.
accessoryState
public var accessoryState: AccessoryState = .down
Methods
selectItem(_:)
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
Name | Type | Description |
---|---|---|
item | String |
The item that should be selected. |
makeSheet(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
Name | Type | Description |
---|---|---|
configuration | SheetInputFormConfiguration |
The configuration object to use to configure the sheet. |
Returns
A UIViewController that should be presented via presentPanModal(_:)
.
presentSheet(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
Name | Type | Description |
---|---|---|
presenter | UIViewController |
The UIViewController to present the sheet. |