Skip to content

Commit

Permalink
Merge pull request #491 from pennlabs/jhawk0224/laundryid
Browse files Browse the repository at this point in the history
Add laundry ids to display
  • Loading branch information
JHawk0224 authored Nov 10, 2023
2 parents 5675e33 + 8b9be36 commit 57092fc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
10 changes: 5 additions & 5 deletions PennMobile/Laundry/Cells/LaundryCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ extension LaundryCell {
// WashersDryersView
_ = washersDryersView.anchor(dividerLine.bottomAnchor, left: bgView.leftAnchor,
bottom: nil, right: bgView.rightAnchor,
topConstant: 16, leftConstant: 0, bottomConstant: 10, rightConstant: 0,
topConstant: 0, leftConstant: 0, bottomConstant: 10, rightConstant: 0,
widthConstant: 0, heightConstant: 200.0)

dividerLine.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor).isActive = true
Expand All @@ -326,9 +326,9 @@ extension LaundryCell {
widthConstant: 0, heightConstant: 0)

// Dryer View
_ = dryerView.anchor(nil, left: washersDryersView.leftAnchor,
bottom: washersDryersView.bottomAnchor, right: washersDryersView.rightAnchor,
topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0,
_ = dryerView.anchor(washerView.bottomAnchor, left: washersDryersView.leftAnchor,
bottom: nil, right: washersDryersView.rightAnchor,
topConstant: 8, leftConstant: 0, bottomConstant: 0, rightConstant: 0,
widthConstant: 0, heightConstant: 0)
dryerView.heightAnchor.constraint(
equalTo: washersDryersView.heightAnchor,
Expand All @@ -343,7 +343,7 @@ extension LaundryCell {
// Scrollable Graph View
_ = graphViewContainer.anchor(washersDryersView.bottomAnchor, left: bgView.leftAnchor,
bottom: bgView.bottomAnchor, right: bgView.rightAnchor,
topConstant: 0, leftConstant: 0, bottomConstant: 0, rightConstant: 0,
topConstant: 14, leftConstant: 0, bottomConstant: 0, rightConstant: 0,
widthConstant: 0, heightConstant: 0)
_ = scrollableGraphView!.anchor(graphViewContainer.topAnchor, left: graphViewContainer.leftAnchor,
bottom: graphViewContainer.bottomAnchor, right: graphViewContainer.rightAnchor,
Expand Down
18 changes: 18 additions & 0 deletions PennMobile/Laundry/Cells/LaundryMachineCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ class LaundryMachineCell: UICollectionViewCell {
iv.isHidden = true
return iv
}()

private let idLabel: UILabel = {
let label = UILabel()
label.text = ""
label.font = .secondaryInformationFont
label.textColor = .labelTertiary
label.layer.cornerRadius = 4
label.layer.masksToBounds = true
label.textAlignment = .center
return label
}()

private let timerLabel: UILabel = {
let label = UILabel()
Expand Down Expand Up @@ -67,6 +78,12 @@ class LaundryMachineCell: UICollectionViewCell {
self.addSubview(bellView)
bellView.centerYAnchor.constraint(equalTo: topAnchor).isActive = true
_ = bellView.anchor(nil, left: nil, bottom: nil, right: rightAnchor, topConstant: -8, leftConstant: 0, bottomConstant: 0, rightConstant: -8, widthConstant: 20, heightConstant: 20)

self.addSubview(idLabel)
_ = idLabel.anchor(bottomAnchor, left: leftAnchor,
bottom: bottomAnchor, right: rightAnchor,
topConstant: 0, leftConstant: 0, bottomConstant: -20, rightConstant: 0,
widthConstant: 0, heightConstant: 20)
}

func updateCell(with machine: LaundryMachine) {
Expand All @@ -89,6 +106,7 @@ class LaundryMachineCell: UICollectionViewCell {
} else {
timerLabel.text = ""
}
idLabel.text = "#\(machine.id)"

bellView.isHidden = !machine.isUnderNotification()
}
Expand Down
29 changes: 15 additions & 14 deletions PennMobileShared/Laundry/LaundryMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,21 @@ public class LaundryMachine: Hashable, Codable {
// MARK: - Comparable
extension LaundryMachine: Comparable {
public static func < (lhs: LaundryMachine, rhs: LaundryMachine) -> Bool {
switch (lhs.status, rhs.status) {
case (.running, .open):
return true
case (.open, .running):
return false
case (_, .offline),
(_, .outOfOrder):
return true
case (.offline, _),
(.outOfOrder, _):
return false
default:
return lhs.timeRemaining < rhs.timeRemaining
}
// switch (lhs.status, rhs.status) {
// case (.running, .open):
// return true
// case (.open, .running):
// return false
// case (_, .offline),
// (_, .outOfOrder):
// return true
// case (.offline, _),
// (.outOfOrder, _):
// return false
// default:
// return lhs.timeRemaining < rhs.timeRemaining
// }
return lhs.id < rhs.id
}

public static func == (lhs: LaundryMachine, rhs: LaundryMachine) -> Bool {
Expand Down

0 comments on commit 57092fc

Please sign in to comment.