From 8b9be36d574fba86e82c6867a293d92554cb822f Mon Sep 17 00:00:00 2001 From: JHawk0224 Date: Thu, 9 Nov 2023 21:35:57 -0500 Subject: [PATCH] Add laundry ids --- PennMobile/Laundry/Cells/LaundryCell.swift | 10 +++---- .../Laundry/Cells/LaundryMachineCell.swift | 18 ++++++++++++ PennMobileShared/Laundry/LaundryMachine.swift | 29 ++++++++++--------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/PennMobile/Laundry/Cells/LaundryCell.swift b/PennMobile/Laundry/Cells/LaundryCell.swift index 01625e08f..cdee4bd1d 100755 --- a/PennMobile/Laundry/Cells/LaundryCell.swift +++ b/PennMobile/Laundry/Cells/LaundryCell.swift @@ -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 @@ -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, @@ -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, diff --git a/PennMobile/Laundry/Cells/LaundryMachineCell.swift b/PennMobile/Laundry/Cells/LaundryMachineCell.swift index d04bf5aa3..c6fa19cfe 100755 --- a/PennMobile/Laundry/Cells/LaundryMachineCell.swift +++ b/PennMobile/Laundry/Cells/LaundryMachineCell.swift @@ -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() @@ -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) { @@ -89,6 +106,7 @@ class LaundryMachineCell: UICollectionViewCell { } else { timerLabel.text = "" } + idLabel.text = "#\(machine.id)" bellView.isHidden = !machine.isUnderNotification() } diff --git a/PennMobileShared/Laundry/LaundryMachine.swift b/PennMobileShared/Laundry/LaundryMachine.swift index c90351f98..bf5a2ef79 100755 --- a/PennMobileShared/Laundry/LaundryMachine.swift +++ b/PennMobileShared/Laundry/LaundryMachine.swift @@ -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 {