Skip to content

Commit

Permalink
Merge pull request #160 from Zolon-DOL/master
Browse files Browse the repository at this point in the history
Sprint 2 changes 2023
  • Loading branch information
pbhatt17 authored Apr 29, 2023
2 parents 682cfe5 + 43b4f03 commit 498ae36
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 32 deletions.
32 changes: 16 additions & 16 deletions Child Labor/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="FQM-HS-dU1">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="FQM-HS-dU1">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -247,13 +247,13 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zar-Fb-UJ0" userLabel="imageview">
<rect key="frame" x="0.0" y="219" width="320" height="300"/>
<rect key="frame" x="0.0" y="225" width="320" height="294"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="BackgroundNew.png" translatesAutoresizingMaskIntoConstraints="NO" id="Ejl-hO-RVy">
<rect key="frame" x="0.0" y="0.0" width="320" height="300"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="294"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="detailDisclosure" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="l3Q-78-HdS">
<rect key="frame" x="284" y="264" width="26" height="26"/>
<rect key="frame" x="284" y="258" width="26" height="26"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<segue destination="3s6-C9-493" kind="presentation" id="omh-cQ-qP8"/>
Expand All @@ -273,7 +273,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="h0l-lG-nag" userLabel="tablemenuview">
<rect key="frame" x="0.0" y="44" width="320" height="175"/>
<rect key="frame" x="0.0" y="50" width="320" height="175"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="pWh-8J-7Ww">
<rect key="frame" x="0.0" y="0.0" width="320" height="175"/>
Expand Down Expand Up @@ -438,7 +438,7 @@
<nil key="title"/>
<barButtonItem key="backBarButtonItem" title="Countries/Areas" id="bsP-lW-rNn"/>
<segmentedControl key="titleView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" id="9d8-lJ-Jve">
<rect key="frame" x="50" y="3" width="245" height="33"/>
<rect key="frame" x="50" y="5.5" width="245" height="33"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="A–Z"/>
Expand All @@ -460,7 +460,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="g3U-sG-6HW" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1980" y="42"/>
<point key="canvasLocation" x="1545" y="48"/>
</scene>
<!--Country Controller-->
<scene sceneID="x3s-On-bG9">
Expand Down Expand Up @@ -1324,13 +1324,13 @@ Standards</string>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Agriculture" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6fL-Qs-XwV">
<rect key="frame" x="28" y="9" width="84" height="20.5"/>
<rect key="frame" x="28" y="8.5" width="84" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Unavailable" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ke0-Xr-lPt">
<rect key="frame" x="221.5" y="9.5" width="83.5" height="19.5"/>
<rect key="frame" x="221.5" y="9.5" width="83.5" height="19"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand All @@ -1352,13 +1352,13 @@ Standards</string>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Industry" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ie8-Wq-XsI">
<rect key="frame" x="28" y="9" width="62.5" height="20.5"/>
<rect key="frame" x="28" y="8.5" width="62.5" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Unavailable" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c5R-Zo-rNh">
<rect key="frame" x="221.5" y="9.5" width="83.5" height="19.5"/>
<rect key="frame" x="221.5" y="9.5" width="83.5" height="19"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand All @@ -1380,13 +1380,13 @@ Standards</string>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Services" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CJf-D2-mcH">
<rect key="frame" x="28" y="9" width="65.5" height="20.5"/>
<rect key="frame" x="28" y="8.5" width="65.5" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Unavailable" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OOu-BL-agz">
<rect key="frame" x="221.5" y="9.5" width="83.5" height="19.5"/>
<rect key="frame" x="221.5" y="9.5" width="83.5" height="19"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -1730,7 +1730,7 @@ and School</string>
<nil key="title"/>
<barButtonItem key="backBarButtonItem" title="Goods" id="Yto-wh-IYj"/>
<segmentedControl key="titleView" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" id="d0V-2m-jRq">
<rect key="frame" x="80.5" y="3" width="159" height="32"/>
<rect key="frame" x="80.5" y="9" width="159" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<segments>
<segment title="A–Z"/>
Expand Down Expand Up @@ -6099,7 +6099,7 @@ Standards </string>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="o2e-dV-zlY"/>
<segue reference="Qkd-VV-gmI"/>
<segue reference="3NZ-qU-LZw"/>
<segue reference="q6X-np-kmw"/>
<segue reference="lgx-uC-KzH"/>
</inferredMetricsTieBreakers>
Expand Down
35 changes: 34 additions & 1 deletion charts/AssesmentLevelParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,38 @@ class AssesmentLevelParser {

self.onCompletionGoodsParsing?(self.goodsSectors)
}


func parseNewDVAsCoutryData() {
let urlPath = Bundle.main.path(forResource: kCountriesXmlFile, ofType: "xml")
var contents: NSString?
do {
contents = try NSString(contentsOfFile: urlPath!, encoding: String.Encoding.utf8.rawValue)
} catch _ {
contents = nil
}

goodsXML = SWXMLHash.parse(contents! as String)

for country in goodsXML[kCountries][kCountry].all {
if let countryRegion = country["Region"].element?.text, !countryRegion.isEmpty {

if var enforcements = country["Enforcements"]["Labor_Inspectors_Intl_Standards"].element?.text, !enforcements.isEmpty {
if var currentSector = self.goodsSectors[countryRegion] as? Dictionary<String, Any> {
if var advancementInfo = currentSector[enforcements] as? Int {
advancementInfo += 1
currentSector[enforcements] = advancementInfo
} else {
currentSector[enforcements] = 1
}
self.goodsSectors[countryRegion] = currentSector
} else {
self.goodsSectors[countryRegion] = [enforcements : 1]
}
}
}
}

self.onCompletionGoodsParsing?(self.goodsSectors)
}

}
58 changes: 50 additions & 8 deletions charts/AssesmentsPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,54 @@ struct AssesmentPageDetails {
var chartData: [Segment]
}

enum ScreenType {
case assesmentLevelByRegion
case newDVASCountries
}

class AssesmentsPageViewController: UIPageViewController {

private(set) var screenType: ScreenType?
private var pageController: UIPageViewController?
private var currentIndex: Int = 0
private var advancementsArr: [AssesmentPageDetails] = [AssesmentPageDetails]()
var colorCodes = ["Moderate Advancement" : UIColor(red: 36/255.0, green: 132/255.0, blue: 21/255.0, alpha: 1),
"Minimal Advancement" : UIColor(red: 63/255.0, green: 81/255.0, blue: 163/255.0, alpha: 1),
"No Assessment" : UIColor(red: 126/255.0, green: 105/255.0, blue: 165/255.0, alpha: 1),
"No Advancement" : UIColor(red: 202/255.0, green: 31/255.0, blue: 65/255.0, alpha: 1),
"Significant Advancement" : UIColor(red: 51/255.0, green: 128/255.0, blue: 116/255.0, alpha: 1)]
var colorCodes = [String: UIColor]()
var goodsSectors = Dictionary<String, Any>()

override func viewDidLoad() {
super.viewDidLoad()

self.view.backgroundColor = .lightGray
if screenType == .assesmentLevelByRegion {
colorCodes = ["Moderate Advancement" : UIColor(red: 36/255.0, green: 132/255.0, blue: 21/255.0, alpha: 1),
"Minimal Advancement" : UIColor(red: 63/255.0, green: 81/255.0, blue: 163/255.0, alpha: 1),
"No Assessment" : UIColor(red: 126/255.0, green: 105/255.0, blue: 165/255.0, alpha: 1),
"No Advancement" : UIColor(red: 202/255.0, green: 31/255.0, blue: 65/255.0, alpha: 1),
"Significant Advancement" : UIColor(red: 51/255.0, green: 128/255.0, blue: 116/255.0, alpha: 1)]
} else if screenType == .newDVASCountries {
colorCodes = ["Unknown" : UIColor(red: 63/255.0, green: 81/255.0, blue: 163/255.0, alpha: 1),
"N/A" : UIColor(red: 126/255.0, green: 105/255.0, blue: 165/255.0, alpha: 1),
"No" : UIColor(red: 202/255.0, green: 31/255.0, blue: 65/255.0, alpha: 1),
"Yes" : UIColor(red: 51/255.0, green: 128/255.0, blue: 116/255.0, alpha: 1)]
}

self.setupNavigationBar()
self.parseAssesmentLevelData()
}

//MARK: - Initialisation methods.
/// Convenience init declaration
required convenience init?(coder: NSCoder) {
self.init(coder: coder)
}

/// Convenience delcaration for charttype view initialization.
convenience init(screenType: ScreenType? = nil) {
self.init(nibName: "AssesmentsPageViewController",
bundle: Bundle(for: AssesmentsPageViewController.self))
self.screenType = screenType
}

private func setupPageController() {

self.pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
Expand All @@ -49,6 +77,7 @@ class AssesmentsPageViewController: UIPageViewController {
self.view.addSubview(self.pageController!.view)

let initialVC = AssesmentsPieChartViewController.loadFromNib()
initialVC.screenType = screenType
if advancementsArr.count > 0 {
initialVC.chartDetails = advancementsArr[0]
}
Expand All @@ -58,8 +87,11 @@ class AssesmentsPageViewController: UIPageViewController {
}

private func setupNavigationBar() {

self.title = "Assesment Level By Region"
if screenType == .assesmentLevelByRegion {
self.title = "Assesment Level By Region"
} else if screenType == .newDVASCountries {
self.title = "Labor Inspector Meet ILO by Region"
}

// Navigation bar color
self.navigationController?.navigationBar.topItem?.title = " "
Expand Down Expand Up @@ -88,7 +120,11 @@ class AssesmentsPageViewController: UIPageViewController {
self.formatAssesmentData(assesmentData: self.goodsSectors)
self.setupPageController()
}
parserModel.parseGoodsData()
if screenType == .assesmentLevelByRegion {
parserModel.parseGoodsData()
} else if screenType == .newDVASCountries {
parserModel.parseNewDVAsCoutryData()
}
}

private func formatAssesmentData(assesmentData : [String : Any]) {
Expand All @@ -106,6 +142,10 @@ class AssesmentsPageViewController: UIPageViewController {
}

}

func setScreenType(type: ScreenType) {
screenType = type
}
}

extension AssesmentsPageViewController: UIPageViewControllerDataSource, UIPageViewControllerDelegate {
Expand All @@ -126,6 +166,7 @@ extension AssesmentsPageViewController: UIPageViewControllerDataSource, UIPageVi

let vc: AssesmentsPieChartViewController = AssesmentsPieChartViewController.loadFromNib()
vc.chartDetails = advancementsArr[index]
vc.screenType = screenType
return vc
}

Expand All @@ -145,6 +186,7 @@ extension AssesmentsPageViewController: UIPageViewControllerDataSource, UIPageVi

let vc: AssesmentsPieChartViewController = AssesmentsPieChartViewController.loadFromNib()
vc.chartDetails = advancementsArr[index]
vc.screenType = screenType
return vc
}

Expand Down
Loading

0 comments on commit 498ae36

Please sign in to comment.