Sliders.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. extension BackendFeatures {
  2. /// Backend methods for sliders.
  3. ///
  4. /// These are used by ``Slider``.
  5. @MainActor
  6. public protocol Sliders: Core {
  7. /// Creates a slider for choosing a numerical value from a range. Predominantly used
  8. /// by ``Slider``.
  9. func createSlider() -> Widget
  10. /// Sets the minimum and maximum selectable value of a slider, the number of
  11. /// decimal places displayed by the slider, and the slider's change handler.
  12. ///
  13. /// - Parameters:
  14. /// - slider: The slider to update.
  15. /// - minimum: The minimum selectable value of the slider (inclusive).
  16. /// - maximum: The maximum selectable value of the slider (inclusive).
  17. /// - decimalPlaces: The number of decimal places displayed by the slider.
  18. /// - environment: The current environment.
  19. /// - onChange: The action to perform when the slider's value changes.
  20. /// This replaces any existing change handlers.
  21. func updateSlider(
  22. _ slider: Widget,
  23. minimum: Double,
  24. maximum: Double,
  25. decimalPlaces: Int,
  26. environment: EnvironmentValues,
  27. onChange: @escaping (Double) -> Void
  28. )
  29. /// Sets the selected value of a slider.
  30. ///
  31. /// - Parameters:
  32. /// - slider: The slider to set the value of.
  33. /// - value: The new value.
  34. func setValue(ofSlider slider: Widget, to value: Double)
  35. }
  36. }