From ec190a28bdf137a1134762400fda080ebdd90328 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 8 Oct 2019 11:47:08 -0400 Subject: [PATCH] Further updates made. --- MVMCoreUI/Atoms/Views/Checkbox.swift | 32 ++++++---------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index f82d6bed..187d9d7c 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -8,22 +8,6 @@ import MVMCore -/* - !!! -- DO NOT REMOVE -- !!! - (Unless Design changes the appearance of the checkmark). - - // Offsets based on the 124x124 example checkmark - let startXOffset: Float = 42.0 / 124.0 ~~ 0.33871 - let startYOffset: Float = 66.0 / 124.0 ~~ 0.53225 - let pivotXOffset: Float = 58.0 / 124.0 ~~ 0.46774 - let pivotYOffset: Float = 80.0 / 124.0 ~~ 0.64516 - let endXOffset: Float = 83.0 / 124.0 ~~ 0.66935 - let endYOffset: Float = 46.0 / 124.0 ~~ 0.37097 - let pivotPercentage: Float = 0.34 - let endPercentage = 1.0 - pivotPercentage - let animationInterval: Float = 0.01 - */ - /** This class expects its height and width to be equal. */ @@ -182,7 +166,7 @@ import MVMCore override open func layoutSubviews() { super.layoutSubviews() - drawCheck() + drawShapeLayer() layer.cornerRadius = isRound ? cornerRadiusValue : 0 layer.borderWidth = borderWidth layer.borderColor = borderColor.cgColor @@ -220,8 +204,8 @@ import MVMCore // MARK: - Methods //-------------------------------------------------- - /// Creates the check mark used for the checkbox. - private func drawCheck() { + /// Creates the check mark layer. + private func drawShapeLayer() { if shapeLayer == nil { @@ -241,16 +225,14 @@ import MVMCore } } - /// Returns a UIBezierPath detailing the path of a checkmark + /// - returns: The CGPath of a UIBezierPath detailing the path of a checkmark func checkMarkPath() -> CGPath { let length = max(bounds.size.height, bounds.size.width) let xInsetLeft = length * 0.25 - let xInsetRight = length * 0.25 let yInsetTop = length * 0.3 - let yInsetBottom = length * 0.35 - let innerWidth = length - (xInsetLeft + xInsetRight) - let innerHeight = length - (yInsetTop + yInsetBottom) + let innerWidth = length - (xInsetLeft + length * 0.25) // + Right X Inset + let innerHeight = length - (yInsetTop + length * 0.35) // + Bottom Y Inset let startPoint = CGPoint(x: xInsetLeft, y: yInsetTop + (innerHeight / 2)) let pivotOffSet = CGPoint(x: xInsetLeft + (innerWidth * 0.33), y: yInsetTop + innerHeight) @@ -274,7 +256,7 @@ import MVMCore self.updateSelectionOnly = true self.isSelected = selected self.updateSelectionOnly = false - self.drawCheck() + self.drawShapeLayer() self.shapeLayer?.removeAllAnimations() self.updateCheckboxUI(isSelected: selected, isAnimated: animated) }