ENUM
HaapiUIPreviewer
Contents
- Methods
formViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)selectorViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)problemViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)pollingViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)bankIdViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)genericViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)webAuthnViewController(variant:json:theme:bundle:embeddedInFlow:showDiagnostics:)actionableButtonGallery(theme:bundle:showDiagnostics:)messageViewGallery(theme:bundle:showDiagnostics:)inputTextFieldGallery(theme:bundle:showDiagnostics:)headerViewGallery(theme:bundle:showDiagnostics:)checkboxViewGallery(theme:bundle:showDiagnostics:)loadingIndicatorGallery(theme:bundle:showDiagnostics:)linkViewGallery(theme:bundle:showDiagnostics:)notificationBannerGallery(theme:bundle:showDiagnostics:)expandableViewGallery(theme:bundle:showDiagnostics:)loadStyles(theme:bundle:)
public enum HaapiUIPreviewer
A utility providing factory methods to create themed HAAPI view controllers for use in Xcode SwiftUI previews.
Each method returns a SwiftUI View wrapping the corresponding UIKit view controller, making it easy
to preview HAAPI UI screens in the Xcode canvas without running the full application.
All non-gallery methods accept an optional json parameter. When nil (the default), a bundled default
JSON fixture is used. Pass a custom JSON string to preview a specific HAAPI representation.
Set embeddedInFlow to true to wrap the view controller in a container that replicates the
HaapiFlowViewController layout (scroll view, padding, header, background).
Example usage:
#Preview("Login Form") {
try! HaapiUIPreviewer.formViewController(theme: "MyCustomTheme")
}
- Experiment: This is an experimental API. It may be changed or removed in the future.
Methods
formViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func formViewController(
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a FormViewController preview from a HAAPI authentication-step JSON.
- Parameters:
- json: HAAPI JSON representation. Pass
nilto use the bundled default login-form fixture. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- json: HAAPI JSON representation. Pass
- Returns: A SwiftUI view wrapping the
FormViewController.
Parameters
| Name | Description |
|---|---|
| json | HAAPI JSON representation. Pass nil to use the bundled default login-form fixture. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
selectorViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func selectorViewController(
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a SelectorViewController preview from a HAAPI authentication-step JSON.
- Parameters:
- json: HAAPI JSON representation. Pass
nilto use the bundled default selector fixture. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- json: HAAPI JSON representation. Pass
- Returns: A SwiftUI view wrapping the
SelectorViewController.
Parameters
| Name | Description |
|---|---|
| json | HAAPI JSON representation. Pass nil to use the bundled default selector fixture. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
problemViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func problemViewController(
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a ProblemViewController preview from a HAAPI problem JSON.
- Parameters:
- json: HAAPI problem JSON representation. Pass
nilto use the bundled default problem fixture. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- json: HAAPI problem JSON representation. Pass
- Returns: A SwiftUI view wrapping the
ProblemViewController.
Parameters
| Name | Description |
|---|---|
| json | HAAPI problem JSON representation. Pass nil to use the bundled default problem fixture. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
pollingViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func pollingViewController(
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a PollingViewController preview from a HAAPI polling-step JSON.
- Parameters:
- json: HAAPI JSON representation. Pass
nilto use the bundled default polling fixture. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- json: HAAPI JSON representation. Pass
- Returns: A SwiftUI view wrapping the
PollingViewController.
Parameters
| Name | Description |
|---|---|
| json | HAAPI JSON representation. Pass nil to use the bundled default polling fixture. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
bankIdViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func bankIdViewController(
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a BankIdViewController preview from a HAAPI polling-step JSON with BankID metadata.
- Parameters:
- json: HAAPI JSON representation. Pass
nilto use the bundled default BankID fixture. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- json: HAAPI JSON representation. Pass
- Returns: A SwiftUI view wrapping the
BankIdViewController.
Parameters
| Name | Description |
|---|---|
| json | HAAPI JSON representation. Pass nil to use the bundled default BankID fixture. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
genericViewController(json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func genericViewController(
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a GenericViewController preview from a HAAPI authentication-step JSON.
- Parameters:
- json: HAAPI JSON representation. Pass
nilto use the bundled default generic fixture. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- json: HAAPI JSON representation. Pass
- Returns: A SwiftUI view wrapping the
GenericViewController.
Parameters
| Name | Description |
|---|---|
| json | HAAPI JSON representation. Pass nil to use the bundled default generic fixture. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
webAuthnViewController(variant:json:theme:bundle:embeddedInFlow:showDiagnostics:)
public static func webAuthnViewController(
variant: HaapiUIPreviewerWebAuthnVariant = .registration,
json: String? = nil,
theme: String = "Theme",
bundle: Bundle = .main,
embeddedInFlow: Bool = false,
showDiagnostics: Bool = false
) throws -> some View
Creates a WebAuthnViewController preview from a HAAPI WebAuthn JSON.
Use the variant parameter to choose which visual layout to preview.
When json is provided, the variant parameter is ignored and the custom JSON is used instead.
- Parameters:
- variant: The WebAuthn visual layout to preview. Defaults to
.registration. - json: HAAPI JSON representation. Pass
nilto use the default fixture for the chosenvariant. - theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - embeddedInFlow: When
true, wraps the VC inside a container that replicates theHaapiFlowViewControllerlayout (scroll view, padding, header, background). Defaults tofalse. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- variant: The WebAuthn visual layout to preview. Defaults to
- Returns: A SwiftUI view wrapping the
WebAuthnViewController.
Parameters
| Name | Description |
|---|---|
| variant | The WebAuthn visual layout to preview. Defaults to .registration. |
| json | HAAPI JSON representation. Pass nil to use the default fixture for the chosen variant. |
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| embeddedInFlow | When true, wraps the VC inside a container that replicates the HaapiFlowViewController layout (scroll view, padding, header, background). Defaults to false. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
actionableButtonGallery(theme:bundle:showDiagnostics:)
public static func actionableButtonGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing all ActionableButton style variants (Primary, Secondary, Text, Link).
Use this preview to verify button colors, border radii, typography, and minimum heights
across all four button variants defined in your Theme.plist.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
messageViewGallery(theme:bundle:showDiagnostics:)
public static func messageViewGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing all MessageView style variants
(Error, Warn, Info, RecipientOfCommunication, Content, Heading, Username, UserCode).
Use this preview to verify message colors, icons, borders, and text appearance
across all eight message variants defined in your Theme.plist.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
inputTextFieldGallery(theme:bundle:showDiagnostics:)
public static func inputTextFieldGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing the three InputTextField UIKit implementations
(Curity, Filled, Outlined) rendered with the active theme's input text field style.
Use this preview to compare how your custom InputTextField style looks across all three
built-in text field variants before choosing which one your app will use.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
headerViewGallery(theme:bundle:showDiagnostics:)
public static func headerViewGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing HeaderView with the active theme style.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
checkboxViewGallery(theme:bundle:showDiagnostics:)
public static func checkboxViewGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing CheckboxView in unchecked and checked states.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
loadingIndicatorGallery(theme:bundle:showDiagnostics:)
public static func loadingIndicatorGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing LoadingIndicatorView with the active theme style.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
linkViewGallery(theme:bundle:showDiagnostics:)
public static func linkViewGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing LinkView with the active theme style.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
notificationBannerGallery(theme:bundle:showDiagnostics:)
public static func notificationBannerGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing NotificationBannerView with the active theme style.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
expandableViewGallery(theme:bundle:showDiagnostics:)
public static func expandableViewGallery(
theme: String = "Theme",
bundle: Bundle = .main,
showDiagnostics: Bool = false
) throws -> some View
Creates a gallery showing ExpandableView in its default collapsed state.
Tap the component in the preview canvas to toggle expand/collapse.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main. - showDiagnostics: When
true, overlays theme resolution diagnostics on the preview. Defaults tofalse.
- theme: The plist resource name for theme configuration. Defaults to
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |
| showDiagnostics | When true, overlays theme resolution diagnostics on the preview. Defaults to false. |
loadStyles(theme:bundle:)
public static func loadStyles(
theme: String = "Theme",
bundle: Bundle = .main
) throws -> HaapiUIPreviewerStyleProvider
Returns a style provider for developers who have custom VC subclasses and need access to resolved styles for preview.
- Parameters:
- theme: The plist resource name for theme configuration. Defaults to
"Theme". - bundle: The bundle containing the theme plist. Defaults to
.main.
- theme: The plist resource name for theme configuration. Defaults to
- Returns: A
HaapiUIPreviewerStyleProviderwith resolved styles from the theme.
Parameters
| Name | Description |
|---|---|
| theme | The plist resource name for theme configuration. Defaults to "Theme". |
| bundle | The bundle containing the theme plist. Defaults to .main. |