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