From dabbd069e7e8731c98ad6737b5cb62bcce61148b Mon Sep 17 00:00:00 2001 From: Shawn Huang Date: Sat, 30 Jan 2021 17:05:29 -0800 Subject: [PATCH] remove covid (#247) --- berkeley-mobile.xcodeproj/project.pbxproj | 20 - .../Resources/Covid/CovidResource.swift | 36 -- .../Covid/CovidResourceDataSource.swift | 45 --- .../Covid/CovidResourceViewController.swift | 346 ------------------ .../Resources/ResourcesViewController.swift | 24 +- 5 files changed, 7 insertions(+), 464 deletions(-) delete mode 100644 berkeley-mobile/Resources/Covid/CovidResource.swift delete mode 100644 berkeley-mobile/Resources/Covid/CovidResourceDataSource.swift delete mode 100644 berkeley-mobile/Resources/Covid/CovidResourceViewController.swift diff --git a/berkeley-mobile.xcodeproj/project.pbxproj b/berkeley-mobile.xcodeproj/project.pbxproj index 2f453eac1..68fd96b97 100644 --- a/berkeley-mobile.xcodeproj/project.pbxproj +++ b/berkeley-mobile.xcodeproj/project.pbxproj @@ -129,7 +129,6 @@ 5516088624392E5100B1E55B /* DiningViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5516088524392E5100B1E55B /* DiningViewController.swift */; }; 5516088824393F3F00B1E55B /* MissingDataView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5516088724393F3F00B1E55B /* MissingDataView.swift */; }; 552F4A4C254E13BF0061D0F2 /* CampusResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552F4A4B254E13BF0061D0F2 /* CampusResourceViewController.swift */; }; - 552F4A51254E16350061D0F2 /* CovidResourceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 552F4A50254E16350061D0F2 /* CovidResourceViewController.swift */; }; 5532B67B2390CBF600293BE0 /* MaterialLoadingIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5532B67A2390CBF600293BE0 /* MaterialLoadingIndicator.swift */; }; 5546CB91251B0A4500BE1876 /* UIDevice+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5546CB90251B0A4500BE1876 /* UIDevice+Extensions.swift */; }; 554CB9A023F3A83F00BB1715 /* EventTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 554CB99F23F3A83F00BB1715 /* EventTableViewCell.swift */; }; @@ -153,8 +152,6 @@ 55DCF79B237243D4001B01B8 /* MaterialTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DCF79A237243D4001B01B8 /* MaterialTextField.swift */; }; 55DCF79D237243F5001B01B8 /* RippleLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DCF79C237243F5001B01B8 /* RippleLayer.swift */; }; 55DCF7A123724835001B01B8 /* MaterialButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55DCF7A023724835001B01B8 /* MaterialButton.swift */; }; - 55EDAA702569D622006BAFAC /* CovidResourceDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EDAA6F2569D622006BAFAC /* CovidResourceDataSource.swift */; }; - 55EDAA742569D730006BAFAC /* CovidResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55EDAA732569D730006BAFAC /* CovidResource.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -283,7 +280,6 @@ 5516088524392E5100B1E55B /* DiningViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiningViewController.swift; sourceTree = ""; }; 5516088724393F3F00B1E55B /* MissingDataView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissingDataView.swift; sourceTree = ""; }; 552F4A4B254E13BF0061D0F2 /* CampusResourceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampusResourceViewController.swift; sourceTree = ""; }; - 552F4A50254E16350061D0F2 /* CovidResourceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CovidResourceViewController.swift; sourceTree = ""; }; 5532B67A2390CBF600293BE0 /* MaterialLoadingIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaterialLoadingIndicator.swift; sourceTree = ""; }; 553EF6AB2404E2C600D2955E /* Resource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Resource.swift; sourceTree = ""; }; 5546CB90251B0A4500BE1876 /* UIDevice+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIDevice+Extensions.swift"; sourceTree = ""; }; @@ -311,8 +307,6 @@ 55DCF79A237243D4001B01B8 /* MaterialTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaterialTextField.swift; sourceTree = ""; }; 55DCF79C237243F5001B01B8 /* RippleLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RippleLayer.swift; sourceTree = ""; }; 55DCF7A023724835001B01B8 /* MaterialButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaterialButton.swift; sourceTree = ""; }; - 55EDAA6F2569D622006BAFAC /* CovidResourceDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CovidResourceDataSource.swift; sourceTree = ""; }; - 55EDAA732569D730006BAFAC /* CovidResource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CovidResource.swift; sourceTree = ""; }; B5DD1FA9F5CF4BCFD4A64306 /* Pods-bm-persona.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bm-persona.debug.xcconfig"; path = "Target Support Files/Pods-bm-persona/Pods-bm-persona.debug.xcconfig"; sourceTree = ""; }; CB9A33BEF33ABF885BD30304 /* Pods-berkeley-mobile.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-berkeley-mobile.release.xcconfig"; path = "Target Support Files/Pods-berkeley-mobile/Pods-berkeley-mobile.release.xcconfig"; sourceTree = ""; }; EC01CCF388C7E41052CEB683 /* Pods-bm-persona.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-bm-persona.release.xcconfig"; path = "Target Support Files/Pods-bm-persona/Pods-bm-persona.release.xcconfig"; sourceTree = ""; }; @@ -741,16 +735,6 @@ path = Campus; sourceTree = ""; }; - 552F4A4F254E16230061D0F2 /* Covid */ = { - isa = PBXGroup; - children = ( - 552F4A50254E16350061D0F2 /* CovidResourceViewController.swift */, - 55EDAA6F2569D622006BAFAC /* CovidResourceDataSource.swift */, - 55EDAA732569D730006BAFAC /* CovidResource.swift */, - ); - path = Covid; - sourceTree = ""; - }; 553EF6AA2404E29800D2955E /* ResourcesDataSource */ = { isa = PBXGroup; children = ( @@ -772,7 +756,6 @@ 556DB0DD23E7F5ED00F12721 /* Resources */ = { isa = PBXGroup; children = ( - 552F4A4F254E16230061D0F2 /* Covid */, 553EF6AA2404E29800D2955E /* ResourcesDataSource */, 552F4A4A254E13960061D0F2 /* Campus */, 556DB0DE23E7F60900F12721 /* ResourcesViewController.swift */, @@ -974,7 +957,6 @@ 13B8E9592425819D00E7FCBF /* ResourceDataSource.swift in Sources */, 01FA50F324E8BA5400DCC490 /* LocationDetailView.swift in Sources */, 29CB28092404DD53009A2CFB /* LibraryViewController.swift in Sources */, - 552F4A51254E16350061D0F2 /* CovidResourceViewController.swift in Sources */, 55AF44292453A4EC00F13232 /* CafeDataSource.swift in Sources */, 306A550023614C0000D59A7F /* MainContainerViewController.swift in Sources */, 29F11EC72516C150007DCFD7 /* BarView.swift in Sources */, @@ -1088,8 +1070,6 @@ 01D11B902504560700BDF660 /* GymDetailViewController.swift in Sources */, 55AF442D2453ACE600F13232 /* DiningLocation.swift in Sources */, 1336A329241DA56100949F32 /* DiningHallDataSource.swift in Sources */, - 55EDAA742569D730006BAFAC /* CovidResource.swift in Sources */, - 55EDAA702569D622006BAFAC /* CovidResourceDataSource.swift in Sources */, 136DC97B2398B4D1009B1810 /* UIViewController+Extensions.swift in Sources */, 2913595724B136BE00DE9AD6 /* CollapsibleCardView.swift in Sources */, 13491DB6241E21740033F9AB /* Colors+TagView.swift in Sources */, diff --git a/berkeley-mobile/Resources/Covid/CovidResource.swift b/berkeley-mobile/Resources/Covid/CovidResource.swift deleted file mode 100644 index f0ae2b134..000000000 --- a/berkeley-mobile/Resources/Covid/CovidResource.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// CovidResource.swift -// berkeley-mobile -// -// Created by Oscar Bjorkman on 11/21/20. -// Copyright © 2020 ASUC OCTO. All rights reserved. -// - -import Foundation -import UIKit - -class CovidResource { - - let dailyScreeningLink: String - let lastUpdated: String - let positivityRate: String - let totalCases: String - let dailyIncrease: String - - init(dailyScreeningLink: String, lastUpdated: Double, positivityRate: String, totalCases: String, dailyIncrease: String) { - self.dailyScreeningLink = dailyScreeningLink - - if lastUpdated != 0.0 { - let formatter = DateFormatter() - formatter.dateFormat = "hh:mm a 'on' MM-dd-yyyy" - self.lastUpdated = formatter.string(from: Date(timeIntervalSince1970: lastUpdated)) - } else { - self.lastUpdated = "Unknown" - } - - self.positivityRate = positivityRate - self.totalCases = totalCases - self.dailyIncrease = dailyIncrease - } - -} diff --git a/berkeley-mobile/Resources/Covid/CovidResourceDataSource.swift b/berkeley-mobile/Resources/Covid/CovidResourceDataSource.swift deleted file mode 100644 index eff889dc5..000000000 --- a/berkeley-mobile/Resources/Covid/CovidResourceDataSource.swift +++ /dev/null @@ -1,45 +0,0 @@ -// -// CovidDataSource.swift -// berkeley-mobile -// -// Created by Oscar Bjorkman on 11/21/20. -// Copyright © 2020 ASUC OCTO. All rights reserved. -// - -import Foundation -import Firebase - -fileprivate let kCovidResourcesEndpoint = "Covid Data" - -class CovidResourceDataSource: DataSource { - - static var fetchDispatch: DispatchGroup = DispatchGroup() - - // Fetch the covid data and report back to the completionHandler. - static func fetchItems(_ completion: @escaping DataSource.completionHandler) - { - let db = Firestore.firestore() - db.collection(kCovidResourcesEndpoint).getDocuments() { (querySnapshot, err) in - if let err = err { - print("Error getting documents: \(err)") - return - } else { - let covidResources = querySnapshot!.documents.map { (document) -> CovidResource in - let dict = document.data() - return parseCovidResource(dict) - } - completion(covidResources) - } - } - } - - private static func parseCovidResource(_ dict: [String: Any]) -> CovidResource { - return CovidResource( - dailyScreeningLink: dict["daily_screen_link"] as? String ?? "", - lastUpdated: dict["last_updated"] as? Double ?? 0.0, - positivityRate: dict["positivity_rate"] as? String ?? "", - totalCases: dict["total_cases"] as? String ?? "", - dailyIncrease: dict["daily_increase"] as? String ?? "") - } - -} diff --git a/berkeley-mobile/Resources/Covid/CovidResourceViewController.swift b/berkeley-mobile/Resources/Covid/CovidResourceViewController.swift deleted file mode 100644 index f2c30477c..000000000 --- a/berkeley-mobile/Resources/Covid/CovidResourceViewController.swift +++ /dev/null @@ -1,346 +0,0 @@ -// -// CovidResourceViewController.swift -// berkeley-mobile -// -// Created by Oscar Bjorkman on 10/31/20. -// Copyright © 2020 ASUC OCTO. All rights reserved. -// - -import UIKit -import Firebase - -fileprivate let kCardPadding: UIEdgeInsets = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) -fileprivate let kViewMargin: CGFloat = 16 - -class CovidResourceViewController: UIViewController { - private var scrollingStack: ScrollingStackView! - private var overviewStack: UIStackView! - private var overviewCard: CardView! - - private var valueOne: UILabel! - private var valueTwo: UILabel! - private var lastUpdated: UILabel! - - private var screeningUrl = "https://calcentral.berkeley.edu/" // fallback url - private var bookingUrl = "https://etang.berkeley.edu/appointments_home.aspx" - - override func viewDidLoad() { - super.viewDidLoad() - - view.layoutMargins = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) - - scrollingView() - covidOverview() - getTestedCard() - screeningCard() - - DataManager.shared.fetch(source: CovidResourceDataSource.self) { resourceEntries in - guard let covidData = resourceEntries[0] as? CovidResource else { return } - - self.screeningUrl = covidData.dailyScreeningLink - self.valueOne.text = covidData.totalCases - self.valueTwo.text = covidData.dailyIncrease - self.lastUpdated.text = "Last Updated: \(covidData.lastUpdated)" - } - } -} - -extension CovidResourceViewController { - func scrollingView() { - let scrollingStackView = ScrollingStackView() - - scrollingStackView.setLayoutMargins(view.layoutMargins) - scrollingStackView.scrollView.showsVerticalScrollIndicator = false - scrollingStackView.stackView.spacing = kViewMargin - - view.addSubview(scrollingStackView) - - scrollingStackView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true - scrollingStackView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - scrollingStackView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - scrollingStackView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true - - scrollingStack = scrollingStackView - } - - func covidOverview() { - let card = CardView() - card.layoutMargins = kCardPadding - - scrollingStack.stackView.addArrangedSubview(card) - - let headerLabel = UILabel() - headerLabel.font = Font.bold(24) - headerLabel.text = "Testing Dashboard" - - card.addSubview(headerLabel) - - headerLabel.translatesAutoresizingMaskIntoConstraints = false - headerLabel.topAnchor.constraint(equalTo: card.layoutMarginsGuide.topAnchor).isActive = true - headerLabel.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - headerLabel.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - let stack = UIStackView() - stack.axis = .horizontal - stack.distribution = .fillEqually - stack.alignment = .center - stack.spacing = 9 - - let (uhsTests, uhsLabel) = createOverviewCard(cardHeader: "Total Cases") - let (positiveTests, positiveLabel) = createOverviewCard(cardHeader: "New Cases") - - stack.addArrangedSubview(uhsTests) - stack.addArrangedSubview(positiveTests) - - stack.translatesAutoresizingMaskIntoConstraints = false - - card.addSubview(stack) - - stack.topAnchor.constraint(equalTo: headerLabel.bottomAnchor, constant: kViewMargin).isActive = true - stack.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - stack.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - let updatedLabel = UILabel() - updatedLabel.font = Font.light(14) - updatedLabel.textColor = Color.lightGrayText - updatedLabel.textAlignment = .left - updatedLabel.text = "Last Updated: " - - card.addSubview(updatedLabel) - - updatedLabel.translatesAutoresizingMaskIntoConstraints = false - updatedLabel.topAnchor.constraint(equalTo: stack.bottomAnchor, constant: kViewMargin).isActive = true - updatedLabel.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - updatedLabel.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - card.bottomAnchor.constraint(equalTo: updatedLabel.bottomAnchor, constant: kViewMargin).isActive = true - - overviewStack = stack - overviewCard = card - - valueOne = uhsLabel - valueTwo = positiveLabel - lastUpdated = updatedLabel - } - - func createOverviewCard(cardHeader: String, cardValue: Int? = nil) -> (UIView, UILabel) { - let subView = UIView() - subView.backgroundColor = UIColor.white.withAlphaComponent(0.0) - subView.layer.cornerRadius = 12 - subView.layer.masksToBounds = true - subView.layer.borderWidth = 3 - subView.layer.borderColor = Color.selectedButtonBackground.cgColor - - let cardStack = UIStackView() - cardStack.axis = .vertical - cardStack.alignment = .center - cardStack.distribution = .fill - cardStack.spacing = 10 - cardStack.layoutMargins = UIEdgeInsets(top: 19, left: 19, bottom: 19, right: 19) - cardStack.isLayoutMarginsRelativeArrangement = true - - let headerLabel = UILabel() - headerLabel.text = cardHeader - headerLabel.font = Font.medium(20) - headerLabel.textAlignment = .center - headerLabel.textColor = Color.selectedButtonBackground - headerLabel.numberOfLines = 1 - headerLabel.adjustsFontSizeToFitWidth = true - headerLabel.minimumScaleFactor = 0.7 - - let numberFormatter = NumberFormatter() - numberFormatter.numberStyle = .decimal - - let valueLabel = UILabel() - if let value = cardValue { - valueLabel.text = String(numberFormatter.string(from: NSNumber(value: value)) ?? "N/A") - } else { - valueLabel.text = "N/A" - } - valueLabel.font = Font.bold(40) - valueLabel.textAlignment = .center - valueLabel.textColor = Color.selectedButtonBackground - valueLabel.numberOfLines = 1 - valueLabel.adjustsFontSizeToFitWidth = true - valueLabel.minimumScaleFactor = 0.5 - - subView.addSubview(cardStack) - cardStack.addArrangedSubview(headerLabel) - cardStack.addArrangedSubview(valueLabel) - - subView.translatesAutoresizingMaskIntoConstraints = false - cardStack.translatesAutoresizingMaskIntoConstraints = false - - cardStack.topAnchor.constraint(equalTo: subView.topAnchor).isActive = true - cardStack.leftAnchor.constraint(equalTo: subView.leftAnchor).isActive = true - cardStack.rightAnchor.constraint(equalTo: subView.rightAnchor).isActive = true - cardStack.bottomAnchor.constraint(equalTo: subView.bottomAnchor).isActive = true - - return (subView, valueLabel) - } - - func getTestedCard() { - let card = CardView() - card.layoutMargins = kCardPadding - - scrollingStack.stackView.addArrangedSubview(card) - - let headerLabel = UILabel() - headerLabel.text = "Need to get tested?" - headerLabel.font = Font.medium(20) - headerLabel.textAlignment = .left - headerLabel.textColor = Color.blackText - headerLabel.numberOfLines = 1 - headerLabel.adjustsFontSizeToFitWidth = true - headerLabel.minimumScaleFactor = 0.7 - - let subtitleLabel = UILabel() - subtitleLabel.text = "Book an appointment directly through University Health Services:" - subtitleLabel.font = Font.medium(12) - subtitleLabel.numberOfLines = 2 - subtitleLabel.textAlignment = .left - subtitleLabel.textColor = Color.blackText - - card.addSubview(headerLabel) - card.addSubview(subtitleLabel) - - headerLabel.translatesAutoresizingMaskIntoConstraints = false - headerLabel.topAnchor.constraint(equalTo: card.layoutMarginsGuide.topAnchor).isActive = true - headerLabel.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - headerLabel.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - subtitleLabel.translatesAutoresizingMaskIntoConstraints = false - subtitleLabel.topAnchor.constraint(equalTo: headerLabel.bottomAnchor, constant: 8).isActive = true - subtitleLabel.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - subtitleLabel.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - let bookButton = UIButton() - bookButton.titleLabel?.font = Font.medium(16) - bookButton.setTitle("Book Now", for: .normal) - bookButton.setTitleColor(.white, for: .normal) - bookButton.backgroundColor = Color.lowOccupancyTag - bookButton.layer.cornerRadius = 16.5 - bookButton.addTarget(self, action: #selector(bookButtonPressed), for: .touchUpInside) - - card.addSubview(bookButton) - - bookButton.translatesAutoresizingMaskIntoConstraints = false - bookButton.topAnchor.constraint(equalTo: subtitleLabel.bottomAnchor, constant: kViewMargin).isActive = true - bookButton.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - - bookButton.setHeightConstraint(33) - bookButton.setWidthConstraint(110) - - bookButton.bottomAnchor.constraint(equalTo: card.layoutMarginsGuide.bottomAnchor).isActive = true - } - - func screeningCard() { - let card = CardView() - card.layoutMargins = kCardPadding - - scrollingStack.stackView.addArrangedSubview(card) - - let stack = UIStackView() - stack.axis = .vertical - stack.alignment = .center - stack.distribution = .fill - stack.spacing = 14 - stack.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: kViewMargin, right: 0) - stack.isLayoutMarginsRelativeArrangement = true - - let image = UIImage(named: "CovidScreening") - let imageView = UIImageView(image: image) - imageView.contentMode = .scaleAspectFill - imageView.layer.masksToBounds = true - imageView.layer.cornerRadius = 12 - - let bear = UIImage(named: "CovidBear") - let bearView = UIImageView(image: bear) - bearView.contentMode = .scaleAspectFill - - let onCampusLabel = UILabel() - onCampusLabel.text = "Will you be on campus today?" - onCampusLabel.font = Font.bold(22) - onCampusLabel.numberOfLines = 2 - onCampusLabel.adjustsFontSizeToFitWidth = true - onCampusLabel.minimumScaleFactor = 0.7 - onCampusLabel.textAlignment = .center - onCampusLabel.textColor = Color.blackText - - let subtitleLabel = UILabel() - subtitleLabel.text = "Complete the symptom screener before entering campus." - subtitleLabel.font = Font.regular(12) - subtitleLabel.numberOfLines = 2 - subtitleLabel.adjustsFontSizeToFitWidth = true - subtitleLabel.minimumScaleFactor = 0.7 - subtitleLabel.textAlignment = .center - subtitleLabel.textColor = Color.blackText - - let screenButton = ActionButton(title: "Start Daily Screening", font: Font.regular(12)) - screenButton.addTarget(self, action: #selector(screeningButtonPressed), for: .touchUpInside) - - card.addSubview(stack) - - stack.translatesAutoresizingMaskIntoConstraints = false - - stack.addArrangedSubview(imageView) - stack.addArrangedSubview(bearView) - stack.addArrangedSubview(onCampusLabel) - stack.addArrangedSubview(subtitleLabel) - stack.addArrangedSubview(screenButton) - - // Resolve smaller screens - stack.bringSubviewToFront(onCampusLabel) - stack.bringSubviewToFront(subtitleLabel) - stack.bringSubviewToFront(screenButton) - - stack.topAnchor.constraint(equalTo: card.topAnchor).isActive = true - stack.leftAnchor.constraint(equalTo: card.leftAnchor).isActive = true - stack.rightAnchor.constraint(equalTo: card.rightAnchor).isActive = true - stack.bottomAnchor.constraint(equalTo: card.bottomAnchor).isActive = true - - imageView.setHeightConstraint(101) - imageView.leftAnchor.constraint(equalTo: card.leftAnchor).isActive = true - imageView.rightAnchor.constraint(equalTo: card.rightAnchor).isActive = true - - onCampusLabel.translatesAutoresizingMaskIntoConstraints = false - onCampusLabel.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - onCampusLabel.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - subtitleLabel.translatesAutoresizingMaskIntoConstraints = false - subtitleLabel.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - subtitleLabel.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - - stack.setCustomSpacing(-65, after: imageView) // Bless whoever created this - - bearView.setHeightConstraint(130) - bearView.setWidthConstraint(130) - - stack.setCustomSpacing(-5, after: bearView) - - screenButton.leftAnchor.constraint(equalTo: card.layoutMarginsGuide.leftAnchor).isActive = true - screenButton.rightAnchor.constraint(equalTo: card.layoutMarginsGuide.rightAnchor).isActive = true - } - - @objc private func screeningButtonPressed(sender: UIButton) { - guard let url = URL(string: screeningUrl) else { return } - - presentAlertLinkUrl(title: "Are you sure you want to open Safari?", message: "Berkeley Mobile wants to navigate to the Daily Symptom Screener", options: "Cancel", "Yes", website_url: url) - } - - @objc private func bookButtonPressed(sender: UIButton) { - guard let url = URL(string: bookingUrl) else { return } - - presentAlertLinkUrl(title: "Are you sure you want to open Safari?", message: "Berkeley Mobile wants to navigate to the UHS Appointments Booking Page", options: "Cancel", "Yes", website_url: url) - } - -} - -// MARK: - Analytics - -extension CovidResourceViewController { - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - Analytics.logEvent("opened_covid_resource", parameters: [:]) - } -} diff --git a/berkeley-mobile/Resources/ResourcesViewController.swift b/berkeley-mobile/Resources/ResourcesViewController.swift index 67c23e186..3313150d8 100644 --- a/berkeley-mobile/Resources/ResourcesViewController.swift +++ b/berkeley-mobile/Resources/ResourcesViewController.swift @@ -22,7 +22,13 @@ class ResourcesViewController: UIViewController { self.view.backgroundColor = Color.modalBackground setupHeader() - setupSegmentedControls() + let vc = CampusResourceViewController() + self.add(child: vc) + vc.view.translatesAutoresizingMaskIntoConstraints = false + vc.view.topAnchor.constraint(equalTo: resourcesLabel.bottomAnchor, constant: kViewMargin).isActive = true + vc.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + vc.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true + vc.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true } } @@ -56,22 +62,6 @@ extension ResourcesViewController { blobImageView = blobView } - - // SegmentedControl and Page views - private func setupSegmentedControls() { - // Add some right-padding to the segmented control so it doesn't overlap with the blob. - // Don't add this padding for now. - let segmentedControl = SegmentedControlViewController(pages: [ - Page(viewController: CovidResourceViewController(), label: "COVID-19"), - Page(viewController: CampusResourceViewController(), label: "Campus-Wide") - ], controlInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: blobImageView.frame.width / 4), centerControl: false) - self.add(child: segmentedControl) - segmentedControl.view.translatesAutoresizingMaskIntoConstraints = false - segmentedControl.view.topAnchor.constraint(equalTo: resourcesLabel.bottomAnchor, constant: kViewMargin).isActive = true - segmentedControl.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - segmentedControl.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - segmentedControl.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true - } } // MARK: - Analytics