Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. struct TokenButtonStyle: ButtonStyle {
  2. /// Global properties
  3. private let styleType: StyleType
  4. private var iconSize: TokenButton.IconSize?
  5. private var backgroundColor: Color?
  6. private var borderStyle: StyleAlias.BorderStyle?
  7. private var textColor: Color?
  8.  
  9. /// Circle Icon Button
  10. init(iconSize: TokenButton.IconSize,
  11. backgroundColor: BackgroundColor,
  12. border: BorderStyle? = .none) {
  13. // --snip--
  14. }
  15.  
  16. /// Icon Button
  17. init(iconSize: TokenButton.IconSize) {
  18. // --snip--
  19. }
  20.  
  21. /// Capsule Button
  22. init(backgroundColor: BackgroundColor, textColor: TextColor) {
  23. // --snip--
  24. }
  25.  
  26. /// Text Button
  27. init(textColor: TextColor) {
  28. // --snip--
  29. }
  30.  
  31. /// Rendering Button Style
  32. func makeBody(configuration: Self.Configuration) -> some View {
  33. var renderView: AnyView!
  34. let verticalMargin = CapsuleValue.verticalMargin.rawValue
  35. let horizontalMargin = CapsuleValue.horizontalMargin.rawValue
  36.  
  37. switch styleType {
  38. case .circleIcon:
  39. renderView = AnyView(configuration.label
  40. // --snip--
  41. )
  42. case .icon:
  43. renderView = AnyView(configuration.label
  44. // --snip--
  45. )
  46. case .capsule:
  47. renderView = AnyView(configuration.label
  48. // --snip--
  49. )
  50. case .text:
  51. renderView = AnyView(configuration.label
  52. // --snip--
  53. )
  54. }
  55.  
  56. return renderView.opacity(getOpacityValue(configuration.isPressed))
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement