SplitViews.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. extension BackendFeatures {
  2. /// Backend methods for split views.
  3. ///
  4. /// These are used by ``NavigationSplitView`` and sidebar-style ``List``s.
  5. @MainActor
  6. public protocol SplitViews: Core {
  7. /// Creates a split view containing two children visible side by side.
  8. ///
  9. /// If you need to modify the leading and trailing children after creation,
  10. /// nest them inside another container such as a ``VStack`` (avoiding update
  11. /// methods makes maintaining a multitude of backends a bit easier).
  12. ///
  13. /// - Parameters:
  14. /// - leadingChild: The widget to show in the sidebar.
  15. /// - trailingChild: The widget to show in the detail section.
  16. func createSplitView(leadingChild: Widget, trailingChild: Widget) -> Widget
  17. /// Sets the function to be called when the split view's panes get resized.
  18. ///
  19. /// - Parameters:
  20. /// - splitView: The split view.
  21. /// - action: The action to perform when the split view's panes are
  22. /// resized.
  23. func setResizeHandler(
  24. ofSplitView splitView: Widget,
  25. to action: @escaping () -> Void
  26. )
  27. /// Gets the width of a split view's sidebar.
  28. ///
  29. /// - Parameter splitView: The split view.
  30. /// - Returns: The split view's sidebar width.
  31. func sidebarWidth(ofSplitView splitView: Widget) -> Int
  32. /// Sets the minimum and maximum width of a split view's sidebar.
  33. ///
  34. /// - Parameters:
  35. /// - splitView: The split view.
  36. /// - minimumWidth: The minimum width of the split view's sidebar.
  37. /// - maximumWidth: The maximum width of the split view's sidebar.
  38. func setSidebarWidthBounds(
  39. ofSplitView splitView: Widget,
  40. minimum minimumWidth: Int,
  41. maximum maximumWidth: Int
  42. )
  43. }
  44. }