Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Schedule Page for HackIllinois 2024 #572

Merged
merged 37 commits into from
Feb 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d1f943c
Updating UI
s0phialiu Dec 19, 2023
3710402
Updating UI
s0phialiu Dec 19, 2023
2f63742
Updating UI
s0phialiu Dec 19, 2023
cb178cc
changes
s0phialiu Jan 8, 2024
05f7fdf
changes
s0phialiu Jan 8, 2024
137b5c4
changes
s0phialiu Jan 8, 2024
6a8cbb8
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 8, 2024
874582b
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 9, 2024
9ddc2fd
changes
s0phialiu Jan 9, 2024
9920893
fixed event favorites, added in follow and unfollow endpoints
s0phialiu Jan 10, 2024
55bc4a3
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 10, 2024
51f5408
added functionality to toggle between schedule/shifts
s0phialiu Jan 10, 2024
1237af1
added functionality to toggle between schedule/shifts
s0phialiu Jan 10, 2024
4eb1116
cleaning up
s0phialiu Jan 11, 2024
b40ffcf
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 12, 2024
7c9ac67
started setting up staff shifts
s0phialiu Jan 12, 2024
2eb173a
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 12, 2024
09aead5
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 14, 2024
3bae756
Added some iPad UI changes
s0phialiu Jan 18, 2024
b8ba313
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Jan 19, 2024
ba0c9f9
Fixed iPad potion sizes
s0phialiu Jan 19, 2024
889173f
Fix schedule view on iPad, need to fix iPad Pro 12.9
s0phialiu Jan 21, 2024
aa7f065
Trying to add mapImageURL
s0phialiu Jan 23, 2024
f95b680
Fixed error where events didn't show up, added optional handling
s0phialiu Jan 24, 2024
8ef058b
Added static maps
s0phialiu Jan 24, 2024
9436e2e
editing static map
s0phialiu Jan 26, 2024
af8858b
replace bg pad img
s0phialiu Feb 3, 2024
31af507
Revert "replace bg pad img"
s0phialiu Feb 3, 2024
2c87580
changed content bg
s0phialiu Feb 4, 2024
58f8e62
improved schedule ui layout for ipad
s0phialiu Feb 5, 2024
7fdfd5c
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Feb 5, 2024
87640fc
Added model and service for staff shifts
s0phialiu Feb 5, 2024
d778c72
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Feb 6, 2024
7b9f06f
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Feb 10, 2024
132ac56
laid out staff shifts ui view, updated staff hiapi to pass in body
s0phialiu Feb 10, 2024
be0d7d3
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Feb 11, 2024
a3ea64b
Merge remote-tracking branch 'origin/dev' into sophia/update-schedule…
s0phialiu Feb 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
laid out staff shifts ui view, updated staff hiapi to pass in body
s0phialiu committed Feb 10, 2024

Verified

This commit was signed with the committer’s verified signature.
bdemann Benjamin DeMann
commit 132ac566990d16fd43c99d31c64a5d454ac2e65b
11 changes: 8 additions & 3 deletions HIAPI/Models/Staff.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//
// Staff.swift
// HIAPI
// HackIllinois
//
// Created by Dev Patel on 2/7/24.
// Copyright © 2024 HackIllinois. All rights reserved.
// Created by HackIllinois Team on 2/7/24.
// Copyright © 2017 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
import APIManager

23 changes: 16 additions & 7 deletions HIAPI/Services/StaffService.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//
// StaffService.swift
// HIAPI
// HackIllinois
//
// Created by Dev Patel on 2/7/24.
// Copyright © 2024 HackIllinois. All rights reserved.
// Created by HackIllinois Team on 2/7/24.
// Copyright © 2017 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
@@ -20,15 +24,20 @@ public final class StaffService: BaseService {
return APIRequest<StaffContainer>(service: self, endpoint: "shift/", headers: headers, method: .GET)
}

public static func recordStaffAttendance(userToken: String) -> APIRequest<StaffAttendanceContainer> {
public static func recordStaffAttendance(userToken: String, eventId: String) -> APIRequest<StaffAttendanceContainer> {
var body = HTTPBody()
body["eventId"] = eventId
var headers = HTTPHeaders()
headers["Authorization"] = userToken
return APIRequest<StaffAttendanceContainer>(service: self, endpoint: "attendance/", headers: headers, method: .POST)
return APIRequest<StaffAttendanceContainer>(service: self, endpoint: "attendance/", body: body, headers: headers, method: .POST)
}

public static func recordUserAttendance(userToken: String) -> APIRequest<UserAttendanceContainer> {
public static func recordUserAttendance(userToken: String, userId: String, eventId: String) -> APIRequest<UserAttendanceContainer> {
var body = HTTPBody()
body["userId"] = userId
body["eventId"] = eventId
var headers = HTTPHeaders()
headers["Authorization"] = userToken
return APIRequest<UserAttendanceContainer>(service: self, endpoint: "scan-attendee/", headers: headers, method: .PUT)
return APIRequest<UserAttendanceContainer>(service: self, endpoint: "scan-attendee/", body: body, headers: headers, method: .PUT)
}
}
4 changes: 4 additions & 0 deletions HackIllinois.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@
D12B40FF2AC0B0BD001BCB05 /* HIScanAttendanceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12B40FE2AC0B0BD001BCB05 /* HIScanAttendanceViewController.swift */; };
D134D30F296B3F56006EA589 /* Montserrat-VariableFont_wght.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D134D30E296B3F56006EA589 /* Montserrat-VariableFont_wght.ttf */; };
D14D3AE3295FBDA200EB7995 /* HIBannerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D14D3AE2295FBDA100EB7995 /* HIBannerViewController.swift */; };
D187BF582B781A1100AD7356 /* HIShiftCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D187BF572B781A1100AD7356 /* HIShiftCell.swift */; };
D1BBA5682B70AB940017BD13 /* Staff.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1BBA5672B70AB940017BD13 /* Staff.swift */; };
D1BBA56A2B70ACCC0017BD13 /* StaffService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1BBA5692B70ACCC0017BD13 /* StaffService.swift */; };
D1BE81172AC8FC680042C078 /* HIAPI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95E3142A21FAD5B30092C22E /* HIAPI.framework */; };
@@ -344,6 +345,7 @@
D12B40FE2AC0B0BD001BCB05 /* HIScanAttendanceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIScanAttendanceViewController.swift; sourceTree = "<group>"; };
D134D30E296B3F56006EA589 /* Montserrat-VariableFont_wght.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Montserrat-VariableFont_wght.ttf"; sourceTree = "<group>"; };
D14D3AE2295FBDA100EB7995 /* HIBannerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIBannerViewController.swift; sourceTree = "<group>"; };
D187BF572B781A1100AD7356 /* HIShiftCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HIShiftCell.swift; sourceTree = "<group>"; };
D1BBA5672B70AB940017BD13 /* Staff.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Staff.swift; sourceTree = "<group>"; };
D1BBA5692B70ACCC0017BD13 /* StaffService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StaffService.swift; sourceTree = "<group>"; };
D1C5B6572B732E44000E766D /* refresh.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = refresh.json; sourceTree = "<group>"; };
@@ -659,6 +661,7 @@
95A7D282203D4F54005EAEAF /* HIAnnouncementCell.swift */,
95A7D29F203D60E9005EAEAF /* HIBubbleCell.swift */,
95A7D281203D4F54005EAEAF /* HIEventCell.swift */,
D187BF572B781A1100AD7356 /* HIShiftCell.swift */,
3CF8DB1223B419980035ECAE /* HIProjectCell.swift */,
);
path = HIBubbleCell;
@@ -1053,6 +1056,7 @@
E1E4A5DA291C9BF800780BA1 /* HIOnboardingView.swift in Sources */,
95A7D290203D4F54005EAEAF /* HIAnnouncementCell.swift in Sources */,
9515E43722093E1300BCAF92 /* HIEventScannerViewController.swift in Sources */,
D187BF582B781A1100AD7356 /* HIShiftCell.swift in Sources */,
95A7D28F203D4F54005EAEAF /* HIEventCell.swift in Sources */,
ACAA717626017EC4000F42B0 /* HICollectionViewFlowLayout.swift in Sources */,
DF5B27C5299197E80034A8B9 /* Array.swift in Sources */,
1 change: 0 additions & 1 deletion HackIllinois/DataSources/HIEventDataSource.swift
Original file line number Diff line number Diff line change
@@ -41,7 +41,6 @@ final class HIEventDataSource {
do {
let (containedEvents, _) = try result.get()
let apiEvents = containedEvents.events
print(apiEvents)
HICoreDataController.shared.performBackgroundTask { context -> Void in
do {
// 2) Compute all the unique API locations.
Original file line number Diff line number Diff line change
@@ -103,7 +103,6 @@ extension HIEventCell {
return height + 5
}
static func <- (lhs: HIEventCell, rhs: Event) {
print(rhs)
lhs.favoritedButton.isActive = rhs.favorite
var contentStackViewHeight: CGFloat = 0.0; var eventCellSpacing: CGFloat = 8.0
var stackViewSpacing: CGFloat = 4.7; var bubbleConstant: CGFloat = 1.0
141 changes: 141 additions & 0 deletions HackIllinois/UI/TableView/Cells/HIBubbleCell/HIShiftCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//
// HIShiftCell.swift
// HackIllinois
//
// Created by HackIllinois Team on 2/10/24.
// Copyright © 2017 HackIllinois. All rights reserved.
// This file is part of the Hackillinois iOS App.
// The Hackillinois iOS App is open source software, released under the University of
// Illinois/NCSA Open Source License. You should have received a copy of
// this license in a file with the distribution.
//

import Foundation
import UIKit
import HIAPI


class HIShiftCell: HIBubbleCell {
// MARK: - Properties
var headerView = UIStackView()
var contentStackView = UIStackView()
var contentStackViewHeight = NSLayoutConstraint()

var indexPath: IndexPath?
weak var delegate: HIEventCellDelegate?

// MARK: - Init
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
var headerSpacingConstant: CGFloat = 1.0
if UIDevice.current.userInterfaceIdiom == .pad {
headerSpacingConstant = 2.0
}
backgroundColor = UIColor.clear
// add bubble view
contentView.layer.backgroundColor = UIColor.clear.cgColor
bubbleView.addSubview(headerView)
headerView.axis = .vertical
headerView.alignment = .leading
headerView.translatesAutoresizingMaskIntoConstraints = false
headerView.leadingAnchor.constraint(equalTo: bubbleView.leadingAnchor, constant: 17 * headerSpacingConstant).isActive = true
headerView.topAnchor.constraint(equalTo: bubbleView.topAnchor, constant: 16 * headerSpacingConstant).isActive = true

bubbleView.addSubview(contentStackView)
contentStackView.axis = .vertical
contentStackView.alignment = .leading
contentStackView.translatesAutoresizingMaskIntoConstraints = false
contentStackView.leadingAnchor.constraint(equalTo: headerView.leadingAnchor).isActive = true
contentStackView.trailingAnchor.constraint(equalTo: bubbleView.trailingAnchor, constant: -16).isActive = true
contentStackView.topAnchor.constraint(equalTo: headerView.bottomAnchor, constant: 10 * headerSpacingConstant).isActive = true
contentStackView.bottomAnchor.constraint(greaterThanOrEqualTo: bubbleView.bottomAnchor, constant: -16 * headerSpacingConstant).isActive = true
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) should not be used.")
}
}

// MARK: - Population
extension HIShiftCell {
static func heightForCell(with event: Event, width: CGFloat) -> CGFloat {
let heightFromEventName = HILabel.heightForView(text: event.name, font: HIAppearance.Font.eventTitle!, width: width - 137)
var heightConstant: CGFloat = 1.6
if UIDevice.current.userInterfaceIdiom == .pad {
heightConstant = 11.0
}
let height = heightFromEventName + 160
if UIDevice.current.userInterfaceIdiom == .pad {
return height + (22 * (heightConstant / 1.45))
}
return height + 5
}
static func <- (lhs: HIShiftCell, rhs: Event) {
print(rhs)
var contentStackViewHeight: CGFloat = 0.0; var eventCellSpacing: CGFloat = 8.0
var stackViewSpacing: CGFloat = 4.7; var bubbleConstant: CGFloat = 1.0
var locationImageView = UIImageView(image: #imageLiteral(resourceName: "LocationSign")); var timeImageView = UIImageView(image: #imageLiteral(resourceName: "Clock"))
let titleLabel = HILabel(style: .event)
titleLabel.numberOfLines = 2; titleLabel.text = rhs.name
lhs.headerView.addArrangedSubview(titleLabel)
lhs.headerView.setCustomSpacing(9, after: titleLabel)
if UIDevice.current.userInterfaceIdiom == .pad {
eventCellSpacing = 12.0; stackViewSpacing = 15.0; bubbleConstant = 2.0
locationImageView = UIImageView(image: #imageLiteral(resourceName: "VectorPad"))
timeImageView = UIImageView(image: #imageLiteral(resourceName: "TimePad"))
lhs.headerView.setCustomSpacing(18, after: titleLabel)
}
titleLabel.constrain(width: lhs.contentView.frame.width - 120, height: (HILabel.heightForView(text: rhs.name, font: HIAppearance.Font.eventTitle!, width: lhs.contentView.frame.width - 137)) * bubbleConstant)
let upperContainerView = HIView {
lhs.contentStackView.addArrangedSubview($0)
$0.translatesAutoresizingMaskIntoConstraints = false
}
let middleContainerView = HIView {
lhs.contentStackView.addArrangedSubview($0)
$0.translatesAutoresizingMaskIntoConstraints = false
}
let timeLabel = HILabel(style: .time)
// We can check for async events by checking if the event start and end time is 1970-01-01 00:00:00 +0000
if rhs.startTime.timeIntervalSince1970 == 0 || rhs.endTime.timeIntervalSince1970 == 0 {
timeLabel.text = HIConstants.ASYNC_EVENT_TIME_TEXT
} else {
timeLabel.text = Formatter.simpleTime.string(from: rhs.startTime) + " - " + Formatter.simpleTime.string(from: rhs.endTime)
}
upperContainerView.addSubview(timeImageView)
upperContainerView.addSubview(timeLabel)
timeLabel.leadingAnchor.constraint(equalTo: timeImageView.trailingAnchor, constant: eventCellSpacing + 1).isActive = true
timeLabel.centerYAnchor.constraint(equalTo: timeImageView.centerYAnchor).isActive = true
let locationLabel = HILabel(style: .newLocation)
if rhs.locations.count > 0 {
locationLabel.text = rhs.locations.map({ ($0 as AnyObject).name }).joined(separator: ", ")
}
middleContainerView.addSubview(locationImageView)
locationImageView.translatesAutoresizingMaskIntoConstraints = false
middleContainerView.addSubview(locationLabel)
locationImageView.centerYAnchor.constraint(equalTo: timeImageView.centerYAnchor, constant: (stackViewSpacing * 2.5) + 14).isActive = true
locationImageView.centerXAnchor.constraint(equalTo: timeImageView.centerXAnchor).isActive = true
locationLabel.leadingAnchor.constraint(equalTo: timeLabel.leadingAnchor).isActive = true
locationLabel.centerYAnchor.constraint(equalTo: locationImageView.centerYAnchor).isActive = true
let descriptionLabel = HILabel(style: .cellDescription)
descriptionLabel.numberOfLines = 2
descriptionLabel.text = "\(rhs.info)"
lhs.contentStackView.addArrangedSubview(descriptionLabel)
contentStackViewHeight += HILabel.heightForView(text: rhs.name, font: HIAppearance.Font.eventTitle!, width: lhs.contentView.frame.width - 98)
contentStackViewHeight += timeLabel.intrinsicContentSize.height + locationLabel.intrinsicContentSize.height + 13 + 40 + 3 + 40
}
}

// MARK: - UITableViewCell
extension HIShiftCell {
override func prepareForReuse() {
super.prepareForReuse()
headerView.subviews.forEach {(view) in
headerView.willRemoveSubview(view)
view.removeFromSuperview()
}
contentStackView.arrangedSubviews.forEach { (view) in
contentStackView.removeArrangedSubview(view)
view.removeFromSuperview()
}
}
}
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ extension HIEventDetailViewController {
mapView.leadingAnchor.constraint(equalTo: eventDetailContainer.leadingAnchor).isActive = true
mapView.trailingAnchor.constraint(equalTo: eventDetailContainer.trailingAnchor).isActive = true
mapView.topAnchor.constraint(equalTo: locationImageView.bottomAnchor, constant: 15).isActive = true
let mapHeight: CGFloat = UIDevice.current.userInterfaceIdiom == .pad ? 500 : 300
let mapHeight: CGFloat = UIDevice.current.userInterfaceIdiom == .pad ? 450 : 250
mapView.constrain(height: mapHeight)
mapView.layer.cornerRadius = 20
}
49 changes: 36 additions & 13 deletions HackIllinois/ViewControllers/HIScheduleViewController.swift
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ import HIAPI

class HIScheduleViewController: HIEventListViewController {
// MARK: - Properties
var staffShifts: [Staff] = []

lazy var fetchedResultsController: NSFetchedResultsController<Event> = {
let fetchRequest: NSFetchRequest<Event> = Event.fetchRequest()

@@ -69,8 +71,7 @@ class HIScheduleViewController: HIEventListViewController {
}()

// Staff shifts functionality
//private var onlyShifts = false
//private let onlyShiftsPredicate = NSPredicate(format: "shift == YES")
private var onlyShifts = false

@objc dynamic override func setUpBackgroundView() {
super.setUpBackgroundView()
@@ -113,10 +114,10 @@ extension HIScheduleViewController {
if onlyFavorites {
let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [currentTabPredicate, onlyFavoritesPredicate])
return compoundPredicate
} /*else if onlyShifts {
let compoundPredicate = NSCompoundPredicate(andPredicateWithSubpredicates: [currentTabPredicate, onlyShiftsPredicate])
return compoundPredicate
}*/ else {
} else if onlyShifts {
let noEventsPredicate = NSPredicate(value: false)
return noEventsPredicate
} else {
return currentTabPredicate
}
}
@@ -192,7 +193,8 @@ extension HIScheduleViewController {
// MARK: - Staff Shifts Control Setup
extension HIScheduleViewController {
@objc func setStaffShiftsControl() {
let customFont = UIFont(name: "MontserratRoman-Bold", size: 24)
let customFontSize = UIDevice.current.userInterfaceIdiom == .pad ? 44 : 24
let customFont = UIFont(name: "MontserratRoman-Bold", size: CGFloat(customFontSize))

// Create flexible space items to add space to the left
let flexibleSpaceLeft1 = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
@@ -221,16 +223,37 @@ extension HIScheduleViewController {

// Actions for left and right buttons
@objc func scheduleButtonTapped(_ sender: UIButton) {
print("Schedule button tapped")
//onlyShifts = !onlyShifts
if onlyShifts {
onlyShifts = false
updatePredicate()
animateReload()
}
}


@objc func shiftsButtonTapped(_ sender: UIButton) {
print("Shifts button tapped")
//onlyShifts = !onlyShifts
updatePredicate()
animateReload()
if !onlyShifts {
onlyShifts = !onlyShifts

guard let user = HIApplicationStateController.shared.user else { return }

HIAPI.StaffService.getStaffShift(userToken: user.token)
.onCompletion { result in
do {
let (staffShifts, _) = try result.get()
self.staffShifts = staffShifts.shifts
print("Staff shifts: ", self.staffShifts)

DispatchQueue.main.async {
self.updatePredicate()
self.animateReload()
}
} catch {
print("An error has occurred in getting staff shifts \(error)")
}
}
.launch()
}
}
}