SwitchView

public struct SwitchView
extension SwitchView: View
extension SwitchView: _ViewEmptyChecking

SwitchViewprovides a Fiori style title andToggle.

/// Inputs

  • title: A ViewBuilder closure that renders the title content (required).
  • isOn: A binding to a Boolean value that controls the toggle state (required).
  • stateLabel: An optional ViewBuilder closure for custom state text. It is only effective when the controlState is .readOnly. It will replace the toggle which usually shows as On or Off .
  • icon: An optional ViewBuilder closure for an icon in the informationView.
  • description: An optional ViewBuilder closure for descriptive text in the informationView.
  • controlState: The interaction state of the switch (default: .normal). Options: .normal, .disabled, .readOnly.

Usage

@State var isOn: Bool = true

SwitchView(title: "Switch", isOn: self.$isOn)

SwitchView(title: "Switch", isOn: self.$isOn, stateLabel: self.isOn ? "Open" : "Close", description: "Locked by your organization", controlState: .readOnly)
    .informationViewStyle(.warning)