Code changes after review.
This commit is contained in:
parent
439fe0d202
commit
2702f105b7
@ -6,14 +6,13 @@
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers open class Star: View {
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
private var starLayer: CAShapeLayer?
|
||||
private var progressLayer: CAShapeLayer?
|
||||
private let maskLayer = CAShapeLayer()
|
||||
public var starModel: StarModel? {
|
||||
return model as? StarModel
|
||||
@ -52,11 +51,10 @@ import Foundation
|
||||
//------------------------------------------------------
|
||||
open override func draw(_ rect: CGRect) {
|
||||
//Draw progress
|
||||
let width = bounds.size.width * percent / 100.0
|
||||
let progressRect = CGRect(x: 0, y: 0, width: width, height: bounds.height)
|
||||
fillColor.set()
|
||||
guard let context = UIGraphicsGetCurrentContext() else { return }
|
||||
context.fill(progressRect)
|
||||
progressLayer?.removeFromSuperlayer()
|
||||
let progress = drawProgress()
|
||||
layer.addSublayer(progress)
|
||||
progressLayer = progress
|
||||
|
||||
//Draw the star
|
||||
starLayer?.removeFromSuperlayer()
|
||||
@ -70,6 +68,14 @@ import Foundation
|
||||
layer.mask = maskLayer
|
||||
}
|
||||
|
||||
func drawProgress() -> CAShapeLayer {
|
||||
let shapeLayer = CAShapeLayer()
|
||||
let width = bounds.size.width * percent / 100.0
|
||||
shapeLayer.path = UIBezierPath(rect: CGRect(x: 0, y: 0, width: width, height: bounds.height)).cgPath
|
||||
shapeLayer.fillColor = fillColor.cgColor
|
||||
return shapeLayer
|
||||
}
|
||||
|
||||
func drawStar() -> CAShapeLayer {
|
||||
let shapeLayer = CAShapeLayer()
|
||||
shapeLayer.frame = bounds
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class StarModel: MoleculeModelProtocol {
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class Stars: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class StarsModel: MoleculeModelProtocol {
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user