Guest User

Untitled

a guest
Sep 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. protocol ThatHidable {
  2. var isHidden: Bool { get set }
  3. }
  4.  
  5. protocol ThatShapeLayer: ThatHidable {
  6. var fillColor: CGColor? { get set }
  7. var strokeColor: CGColor? { get set }
  8. }
  9.  
  10. protocol ThatConfigurableBattery {
  11. var border: ThatShapeLayer { get }
  12. var happyFace: ThatShapeLayer { get }
  13. var sadFace: ThatShapeLayer { get }
  14. var chargeBar: ThatShapeLayer { get }
  15. }
  16.  
  17. extension CAShapeLayer: ThatShapeLayer {}
  18.  
  19. class ThatBattery: UIView, ThatConfigurableBattery {
  20. private let borderLayer = CAShapeLayer()
  21. private let happyFaceLayer = CAShapeLayer()
  22. private let sadFaceLayer = CAShapeLayer()
  23. private let chargeBarLayer = CAShapeLayer()
  24.  
  25. var border: ThatShapeLayer {
  26. return borderLayer
  27. }
  28.  
  29. var happyFace: ThatShapeLayer {
  30. return happyFaceLayer
  31. }
  32.  
  33. var sadFace: ThatShapeLayer {
  34. return sadFaceLayer
  35. }
  36.  
  37. var chargeBar: ThatShapeLayer {
  38. return chargeBarLayer
  39. }
  40. }
Add Comment
Please, Sign In to add comment