Skip to content

Commit

Permalink
misc fix: added pro attribute to event
Browse files Browse the repository at this point in the history
  • Loading branch information
s0phialiu committed Feb 16, 2024
1 parent 88119c0 commit 34d9b0e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions HIAPI/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public struct Event: Codable {
case isAsync
case mapImageUrl
case displayOnStaffCheckIn
case isPro
}

public let id: String
Expand All @@ -97,6 +98,7 @@ public struct Event: Codable {
public let isAsync: Bool
public let mapImageUrl: String?
public let displayOnStaffCheckIn: Bool?
public let isPro: Bool?
}

public struct Location: Codable {
Expand Down
3 changes: 3 additions & 0 deletions HackIllinois/DataSources/HIEventDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ final class HIEventDataSource {
coreDataEvent.points = Int32(apiEvent.points)
coreDataEvent.favorite = false
coreDataEvent.mapImageUrl = apiEvent.mapImageUrl ?? "None"
coreDataEvent.isPro = apiEvent.isPro ?? false
}

apiEventsToInsert.forEach { apiEvent in
Expand All @@ -144,6 +145,7 @@ final class HIEventDataSource {
coreDataEvent.favorite = false
coreDataEvent.isAsync = apiEvent.isAsync
coreDataEvent.mapImageUrl = apiEvent.mapImageUrl ?? "None"
coreDataEvent.isPro = apiEvent.isPro ?? false
}

// 10) Save changes, call completion handler, unlock refresh
Expand Down Expand Up @@ -198,6 +200,7 @@ final class HIEventDataSource {
coreDataEvent.points = Int32(apiEvent.points)
coreDataEvent.favorite = apiFavorites.contains(coreDataEvent.id)
coreDataEvent.mapImageUrl = apiEvent.mapImageUrl ?? "None"
coreDataEvent.isPro = apiEvent.isPro ?? false
}

try context.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extension Event {
@NSManaged public var points: Int32
@NSManaged public var isAsync: Bool
@NSManaged public var mapImageUrl: String
@NSManaged public var isPro: Bool

@objc dynamic var sectionIdentifier: Date {
let excessComponents: Set<Calendar.Component> = [.second, .nanosecond]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<attribute name="id" attributeType="String"/>
<attribute name="info" attributeType="String"/>
<attribute name="isAsync" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="isPro" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
<attribute name="mapImageUrl" optional="YES" attributeType="String"/>
<attribute name="name" attributeType="String"/>
<attribute name="points" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ extension HIEventCell {
pointsView.constrain(height: 20 * bubbleConstant)
pointsView.leadingAnchor.constraint(equalTo: eventTypeView.trailingAnchor, constant: 8 * bubbleConstant).isActive = true
pointsView.centerYAnchor.constraint(equalTo: eventTypeView.centerYAnchor).isActive = true
if rhs.isPro {
upperContainerView.addSubview(proTypeView); proTypeView.addSubview(proLabel); proLabel.text = "Pro"
proTypeView.constrain(height: 20 * bubbleConstant); proTypeView.centerYAnchor.constraint(equalTo: pointsView.centerYAnchor).isActive = true
proTypeView.leadingAnchor.constraint(equalTo: pointsView.trailingAnchor, constant: 8 * bubbleConstant).isActive = true
proLabel.constrain(to: proTypeView, topInset: 4, trailingInset: -8, bottomInset: -4, leadingInset: 8)
}
upperContainerView.addSubview(timeImageView)
upperContainerView.addSubview(timeLabel)
timeLabel.leadingAnchor.constraint(equalTo: timeImageView.trailingAnchor, constant: eventCellSpacing + 1).isActive = true
Expand Down
3 changes: 3 additions & 0 deletions HackIllinois/ViewControllers/HIScheduleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ extension HIScheduleViewController {
@objc func scheduleButtonTapped(_ sender: UIButton) {
if onlyShifts {
onlyShifts = false
backgroundView.image = #imageLiteral(resourceName: "PurpleBackground")
updatePredicate()
animateReload()
}
Expand All @@ -234,6 +235,8 @@ extension HIScheduleViewController {
@objc func shiftsButtonTapped(_ sender: UIButton) {
if !onlyShifts {
onlyShifts = !onlyShifts
backgroundView.image = #imageLiteral(resourceName: "Pink Background")
//let label = HILabel(style: (UIDevice.current.userInterfaceIdiom == .pad) ? .viewTitle : .viewTitleBrown)

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

Expand Down

0 comments on commit 34d9b0e

Please sign in to comment.