Checkboxes.swift 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. extension BackendFeatures {
  2. /// Backend methods for checkboxes.
  3. ///
  4. /// These are used by ``Toggle`` when ``EnvironmentValues/toggleStyle`` is
  5. /// ``ToggleStyle/checkbox``.
  6. @MainActor
  7. public protocol Checkboxes: Core {
  8. /// Creates a checkbox that is either on or off.
  9. ///
  10. /// - Returns: A checkbox.
  11. func createCheckbox() -> Widget
  12. /// Sets the change handler of a checkbox.
  13. ///
  14. /// - Parameters:
  15. /// - checkboxWidget: The checkbox to update.
  16. /// - environment: The current environment.
  17. /// - onChange: The action to perform when the checkbox is toggled on or
  18. /// off. This replaces any existing change handlers.
  19. func updateCheckbox(
  20. _ checkboxWidget: Widget,
  21. environment: EnvironmentValues,
  22. onChange: @escaping (Bool) -> Void
  23. )
  24. /// Sets the state of a checkbox.
  25. ///
  26. /// - Parameters:
  27. /// - checkboxWidget: The checkbox to set the state of.
  28. /// - state: The new state.
  29. func setState(ofCheckbox checkboxWidget: Widget, to state: Bool)
  30. }
  31. }