Skip to content

Commit

Permalink
Merge pull request #154 from Zolon-DOL/master
Browse files Browse the repository at this point in the history
Sprint 8 changes
  • Loading branch information
pbhatt17 authored Aug 12, 2022
2 parents 9b802d5 + 3e3d548 commit 2243b26
Show file tree
Hide file tree
Showing 54 changed files with 2,398 additions and 197 deletions.
168 changes: 156 additions & 12 deletions Child Labor.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
20 changes: 16 additions & 4 deletions Child Labor/CountryController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class CountryController: UITableViewController, UICollectionViewDataSource, UICo
let childLaborStatusForGood = good["Child_Labor"].element?.text
let forcedLaborStatusForGood = good["Forced_Labor"].element?.text
let forcedChildLaborStatusForGood = good["Forced_Child_Labor"].element?.text
let derivedLaborStatus = good["Derived_Labor_Exploitation"].element?.text

goods.add(goodName!)

Expand All @@ -126,9 +127,9 @@ class CountryController: UITableViewController, UICollectionViewDataSource, UICo
exploitations.add(1)
} else if childLaborStatusForGood == "Yes" && forcedLaborStatusForGood == "Yes" && forcedChildLaborStatusForGood == "No" {
exploitations.add(2)
}

else {
} else if derivedLaborStatus == "Yes" {
exploitations.add(4)
} else {
exploitations.add(3)
}
}
Expand Down Expand Up @@ -196,6 +197,7 @@ class CountryController: UITableViewController, UICollectionViewDataSource, UICo
//
let cl : UIView? = cell.viewWithTag(101)
let fl : UIView? = cell.viewWithTag(102)
let dl : UIView? = cell.viewWithTag(103)

let clImage : UIImageView? = cl!.viewWithTag(401) as? UIImageView
let clLabel : UILabel? = cl!.viewWithTag(402) as? UILabel
Expand All @@ -218,35 +220,45 @@ class CountryController: UITableViewController, UICollectionViewDataSource, UICo
goodButton?.accessibilityLabel = goodName as? String
if #available(iOS 13.0, *) {
goodLabel?.textColor = UIColor.black
} else {
} else {
// Fallback on earlier versions
}
//
switch exploitations[indexPath.row] as! Int {
case 0:
cl?.isHidden = false
fl?.isHidden = true
dl?.isHidden = true
clImage?.image = UIImage(named: "hand")
clLabel?.textColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
clLabel?.text = "CL"
clLabel?.accessibilityLabel = "Child Labor"
case 1:
cl?.isHidden = true
fl?.isHidden = false
dl?.isHidden = true
clImage?.image = UIImage(named: "hand")
clLabel?.textColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
clLabel?.text = "CL"
clLabel?.accessibilityLabel = "Child Labor"
case 2:
cl?.isHidden = false
fl?.isHidden = false
dl?.isHidden = true
clImage?.image = UIImage(named: "hand")
clLabel?.textColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
clLabel?.text = "CL"
clLabel?.accessibilityLabel = "Child Labor"
case 4:
cl?.isHidden = true
fl?.isHidden = true
dl?.isHidden = false

clLabel?.accessibilityLabel = "Derived Labor"
default:
cl?.isHidden = false
fl?.isHidden = false
dl?.isHidden = true
clImage?.image = UIImage(named: "hand-black")
clLabel?.textColor = UIColor.black
clLabel?.text = "FCL"
Expand Down
24 changes: 24 additions & 0 deletions Child Labor/CustomExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,27 @@ extension UIDevice {
return .portrait
}
}

extension UIImage {

class func textEmbededImage(image: UIImage, string: String, color:UIColor, imageAlignment: Int = 0, segFont: UIFont? = nil) -> UIImage {
let font = segFont ?? UIFont.systemFont(ofSize: 10.0)
let expectedTextSize: CGSize = (string as NSString).size(withAttributes: [NSAttributedString.Key.font: font])
let width: CGFloat = expectedTextSize.width + 5.0
let height: CGFloat = max(expectedTextSize.height, 20)
let size: CGSize = CGSize(width: width, height: height)
UIGraphicsBeginImageContextWithOptions(size, false, 0)
let context: CGContext = UIGraphicsGetCurrentContext()!
context.setFillColor(color.cgColor)
let fontTopPosition: CGFloat = 20
let textOrigin: CGFloat = 5
let flipVertical: CGAffineTransform = CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: size.height)
context.concatenate(flipVertical)
context.draw(image.cgImage!, in: CGRect.init(x: ((width - 20) / 2.0), y: 0, width: 10, height: 20))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

return newImage!
}

}
64 changes: 52 additions & 12 deletions Child Labor/GoodController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class GoodController: UITableViewController {
@IBOutlet weak var goodTitle: UILabel!
@IBOutlet weak var goodImage: UIImageView!
@IBOutlet weak var sector: UILabel!

@IBOutlet weak var segmentControl : UISegmentedControl!

var state = 0

override func viewDidLoad() {
Expand Down Expand Up @@ -57,16 +58,18 @@ class GoodController: UITableViewController {
countries.add((country["Country_Name"].element?.text)!)

// Add the exploitation type to an array
if country["Child_Labor"].element?.text == "Yes" && country["Forced_Labor"].element?.text == "No" {
if country["Child_Labor"].element?.text == "Yes" && country["Forced_Labor"].element?.text == "No" && country["Derived_Labor_Exploitation"].element?.text == "No" {
exploitations.add(0)
}
else if country["Child_Labor"].element?.text == "No" && country["Forced_Labor"].element?.text == "Yes" && country["Forced_Child_Labor"].element?.text == "Yes" {
exploitations.add(3)
}
else if country["Child_Labor"].element?.text == "No" && country["Forced_Labor"].element?.text == "Yes" {
} else if country["Child_Labor"].element?.text == "No" && country["Forced_Labor"].element?.text == "Yes" && country["Derived_Labor_Exploitation"].element?.text == "No" {
exploitations.add(1)
} else if country["Child_Labor"].element?.text == "Yes" && country["Forced_Labor"].element?.text == "Yes" && country["Forced_Child_Labor"].element?.text == "No" {

} else if country["Child_Labor"].element?.text == "Yes" && country["Forced_Labor"].element?.text == "Yes" && country["Forced_Child_Labor"].element?.text == "No" && country["Derived_Labor_Exploitation"].element?.text == "No" {
exploitations.add(2)

} else if country["Child_Labor"].element?.text == "No" && country["Forced_Labor"].element?.text == "Yes" && country["Forced_Child_Labor"].element?.text == "Yes" && country["Derived_Labor_Exploitation"].element?.text == "No" {
exploitations.add(3)
} else if country["Derived_Labor_Exploitation"].element?.text == "Yes" {
exploitations.add(4)
} else {
exploitations.add(3)
}
Expand All @@ -86,6 +89,8 @@ class GoodController: UITableViewController {
}
}



override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
Expand Down Expand Up @@ -121,6 +126,14 @@ class GoodController: UITableViewController {
numCountriesWithThisType += 1
}
}
case 4:
typeOfLabor = "Derived Labor"

for i in 0...countries.count - 1 {
if exploitations[i] as! Int == 4 {
numCountriesWithThisType += 1
}
}
default:
typeOfLabor = "Forced Child"

Expand All @@ -129,7 +142,8 @@ class GoodController: UITableViewController {
numCountriesWithThisType += 1
}
}
}
}

let announcement:String = "Produced With \(typeOfLabor) Labor in \(numCountriesWithThisType) Countr" + (numCountriesWithThisType == 1 ? "y/Area" : "ies/Areas")
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, announcement);
return announcement
Expand Down Expand Up @@ -157,6 +171,7 @@ class GoodController: UITableViewController {
//
let cl : UIView? = cell.viewWithTag(101)
let fl : UIView? = cell.viewWithTag(102)
let dl : UIView? = cell.viewWithTag(103)
let titleLabel : UILabel? = cell.viewWithTag(301) as? UILabel

let clImage : UIImageView? = cl!.viewWithTag(201) as? UIImageView
Expand Down Expand Up @@ -210,12 +225,13 @@ class GoodController: UITableViewController {
case 0:
cl?.isHidden = false
fl?.isHidden = true
dl?.isHidden = true
clImage?.image = UIImage(named: "hand")
clLabel?.textColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
clLabel?.text = "CL"
clLabel?.accessibilityLabel = "Child Labor"

if state == 2 || state == 3 {
if state == 2 || state == 3 || state == 4 {
cell.backgroundColor = UIColor(red: 0.97, green: 0.97, blue: 0.97, alpha: 1)
titleLabel?.textColor = UIColor(red: 0.9, green: 0.9, blue: 0.9, alpha: 1)
cell.isUserInteractionEnabled = false
Expand All @@ -224,12 +240,13 @@ class GoodController: UITableViewController {
case 1:
cl?.isHidden = true
fl?.isHidden = false
dl?.isHidden = true
clImage?.image = UIImage(named: "hand")
clLabel?.textColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
clLabel?.text = "CL"
clLabel?.accessibilityLabel = "Child Labor"

if state == 1 || state == 3 {
if state == 1 || state == 3 || state == 4 {
cell.backgroundColor = UIColor(red: 0.97, green: 0.97, blue: 0.97, alpha: 1)
titleLabel?.textColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 1)
cell.isUserInteractionEnabled = false
Expand All @@ -238,12 +255,26 @@ class GoodController: UITableViewController {
case 2:
cl?.isHidden = false
fl?.isHidden = false
dl?.isHidden = true
clImage?.image = UIImage(named: "hand")
clLabel?.textColor = UIColor(red: 0.0, green: 0.48, blue: 1.0, alpha: 1.0)
clLabel?.text = "CL"
clLabel?.accessibilityLabel = "Child Labor"

if state == 3 {
if state == 3 || state == 4 {
cell.backgroundColor = UIColor(red: 0.97, green: 0.97, blue: 0.97, alpha: 1)
titleLabel?.textColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 1)
cell.isUserInteractionEnabled = false
cell.accessibilityElementsHidden = true;
}
case 4:
cl?.isHidden = true
fl?.isHidden = true
dl?.isHidden = false
clLabel?.text = ""
clLabel?.accessibilityLabel = "Derived Labor"

if state == 1 || state == 2 || state == 3 {
cell.backgroundColor = UIColor(red: 0.97, green: 0.97, blue: 0.97, alpha: 1)
titleLabel?.textColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 1)
cell.isUserInteractionEnabled = false
Expand All @@ -252,10 +283,19 @@ class GoodController: UITableViewController {
default:
cl?.isHidden = false
fl?.isHidden = false
dl?.isHidden = true
clImage?.image = UIImage(named: "hand-black")
clLabel?.textColor = UIColor.black
clLabel?.text = "FCL"
clLabel?.accessibilityLabel = "Forced Child Labor"

if state == 4 {
cell.backgroundColor = UIColor(red: 0.97, green: 0.97, blue: 0.97, alpha: 1)
titleLabel?.textColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 1)
cell.isUserInteractionEnabled = false
cell.accessibilityElementsHidden = true;
}

}
if #available(iOS 13.0, *) {
clLabel?.textColor = .label
Expand Down
6 changes: 3 additions & 3 deletions Child Labor/GoodsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ class GoodsTableViewController: UITableViewController, UISearchBarDelegate, UITe
{
goodsCount.text = "1 result found for search " + searchBarFilter.text!
}
if(getGoodsCount() == 157)
if(getGoodsCount() == 169)
{
goodsCount.text = ""
}
else{
if #available(iOS 12.0, *) {
if (self.traitCollection.userInterfaceStyle == .dark) {

if(getGoodsCount() == 157 && searchBarFilter.text! == "")
if(getGoodsCount() == 169 && searchBarFilter.text! == "")
{
goodsCount.text = ""
} else {
Expand All @@ -337,7 +337,7 @@ class GoodsTableViewController: UITableViewController, UISearchBarDelegate, UITe
{
goodsCount.text = String(getGoodsCount()) + " results found for " + searchBarFilter.text!
}
if(getGoodsCount() == 157)
if(getGoodsCount() == 169)
{
goodsCount.text = ""
}
Expand Down
2 changes: 0 additions & 2 deletions Child Labor/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
Loading

0 comments on commit 2243b26

Please sign in to comment.