Skip to content

Commit

Permalink
Fixed attendee login
Browse files Browse the repository at this point in the history
  • Loading branch information
s0phialiu committed Nov 23, 2023
1 parent 914f708 commit b9a9f28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
24 changes: 15 additions & 9 deletions HackIllinois/ViewControllers/HIProfileCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ import SwiftUI
import HIAPI

struct HIProfileCardView: View {
let firstName: String
let lastName: String
let displayName: String
let dietaryRestrictions: [String]
let points: Int
let tier: String
let foodWave: Int
let background = (\HIAppearance.profileCardBackground).value
let baseText = (\HIAppearance.profileBaseText).value
let id: String
let userId: String
let isIpad = UIDevice.current.userInterfaceIdiom == .pad
@State var flipped: Bool = false
@State var ticketRotation = 0.0
Expand Down Expand Up @@ -157,10 +156,18 @@ struct HIProfileCardView: View {
}

func formatName() -> String {
if lastName.count + firstName.count > 20 {
return firstName + " " + lastName.prefix(1) + "."
if displayName.count > 20 {
let names = displayName.split(separator: " ")
if names.count >= 2 {
let firstName = String(names[0])
let lastName = String(names[1])
let abbreviatedName = firstName + " " + String(lastName.prefix(1)) + "."
return abbreviatedName
} else {
return displayName
}
} else {
return firstName + " " + lastName
return displayName
}
}

Expand Down Expand Up @@ -268,13 +275,12 @@ struct HIProfileCardView: View {

struct HIProfileCardView_Previews: PreviewProvider {
static var previews: some View {
HIProfileCardView(firstName: "first",
lastName: "last",
HIProfileCardView(displayName: "first last",
dietaryRestrictions: ["Vegetarian", "Lactose-Intolerant", "None", "no beef"],
points: 100,
tier: "no tier",
foodWave: 1,
id: "https://www.hackillinois.org"
userId: "https://www.hackillinois.org"
)
}
}
5 changes: 2 additions & 3 deletions HackIllinois/ViewControllers/HIProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ extension HIProfileViewController {
view.willRemoveSubview(profileCardController!.view)
profileCardController?.removeFromParent()
}
profileCardController = UIHostingController(rootView: HIProfileCardView(firstName: profile.displayName,
lastName: profile.displayName,
profileCardController = UIHostingController(rootView: HIProfileCardView(displayName: profile.displayName,
dietaryRestrictions: dietaryRestrictions,
points: profile.points,
tier: profileTier,
foodWave: 1,//profile.foodWave,
id: profile.userId
userId: profile.userId
))

addChild(profileCardController!)
Expand Down

0 comments on commit b9a9f28

Please sign in to comment.