1
0

ButtonStyle.swift 1.2 KB

1234567891011121314151617181920212223242526272829
  1. /// A type that applies standard interaction behavior and a custom appearance to all buttons within a view hierarchy.
  2. public struct ButtonStyle: Hashable, Sendable {
  3. package enum Kind {
  4. case bordered
  5. case plain
  6. case borderless
  7. }
  8. package var kind: Kind
  9. /// A button style that applies the standard border style based on the button’s context.
  10. @available(iOS 15.0, tvOS 15.0, macCatalyst 15.0, *)
  11. public static let bordered = Self(kind: .bordered)
  12. /// A button style that doesn’t style or decorate its content while idle,
  13. /// but may apply a visual effect to indicate the pressed, focused, or enabled state of the button.
  14. public static let plain = Self(kind: .plain)
  15. /// A button style that doesn’t apply a border.
  16. ///
  17. /// On desktop operating systems it behaves mostly the same as ``ButtonStyle/plain``
  18. /// due to the SwiftUI borderless behavior on mac being stupid.
  19. /// The only difference is a default foreground color of gray being applied.
  20. public static let borderless = Self(kind: .borderless)
  21. }
  22. extension ButtonStyle: CustomStringConvertible {
  23. public var description: String {
  24. "\(self.kind)"
  25. }
  26. }