From 95c528b658d956c898cbe62e93fe84f593aaca17 Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Wed, 18 Dec 2019 21:20:58 +0530 Subject: [PATCH 1/3] progress bar percentage is been treated as Double for two decimal places(Like 54.17) in iOS JSON object, due to that progress percentage is not shown, where as working on Android. So, changing Float to Double. --- MVMCoreUI/Atoms/Views/ProgressBar.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 1aecd537..affd6761 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -54,8 +54,8 @@ import Foundation if let thickness = json?.optionalCGFloatForKey("thickness") { self.thickness = thickness } - if let percentage = json?["percent"] as? Float { - progress = percentage/100.0 + if let percentage = json?["percent"] as? Double { + progress = Float(percentage/100.0) } if let progressColor = json?.optionalStringForKey("progressColor") { progressTintColor = UIColor.mfGet(forHex: progressColor) From aff4b7536839d340a56fb4aee9cf39a47901b9bb Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Wed, 18 Dec 2019 22:28:22 +0530 Subject: [PATCH 2/3] Changing to CGFloat, instead of Double as per feedback provided by Ryan. Root Cause: Swift was treating it as Double, instead of Float. --- MVMCoreUI/Atoms/Views/ProgressBar.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index affd6761..1f75b1d0 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -54,7 +54,7 @@ import Foundation if let thickness = json?.optionalCGFloatForKey("thickness") { self.thickness = thickness } - if let percentage = json?["percent"] as? Double { + if let percentage = json?["percent"] as? CGFloat { progress = Float(percentage/100.0) } if let progressColor = json?.optionalStringForKey("progressColor") { From eec15fc65ecf75a3c877553233eb4d327a24f38b Mon Sep 17 00:00:00 2001 From: "Khan, Arshad" Date: Thu, 19 Dec 2019 19:21:49 +0530 Subject: [PATCH 3/3] added comment as per Scott feedback --- MVMCoreUI/Atoms/Views/ProgressBar.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/MVMCoreUI/Atoms/Views/ProgressBar.swift b/MVMCoreUI/Atoms/Views/ProgressBar.swift index 1f75b1d0..c73c77b4 100644 --- a/MVMCoreUI/Atoms/Views/ProgressBar.swift +++ b/MVMCoreUI/Atoms/Views/ProgressBar.swift @@ -54,6 +54,7 @@ import Foundation if let thickness = json?.optionalCGFloatForKey("thickness") { self.thickness = thickness } + // as? Float returns nil, apple defect. if let percentage = json?["percent"] as? CGFloat { progress = Float(percentage/100.0) }