Skip to content

add-to-calendar and the ticketing#54

Open
durualayli wants to merge 1 commit intomainfrom
Duru/calendar-and-ticketing
Open

add-to-calendar and the ticketing#54
durualayli wants to merge 1 commit intomainfrom
Duru/calendar-and-ticketing

Conversation

@durualayli
Copy link
Contributor

@durualayli durualayli commented Feb 11, 2026

  • Fixed the UI of add to calendar and the ticketing button (if no link for ticketing is found, only shows the add to calendar button)
  • When add to calendar is clicked, it first requests access to the calendar
  • Adds the game with its name, location, and time to the Apple Calendar and opens Calendar, going to that specific date and time
  • If a game was already added to the calendar, it displays a message saying the game was already added before
  • After adding the game, it displays a message that the game was successfully added.

Next steps: Some of the endpoints for the ticketing links for the away games open the general athletics websites instead of the specific games, which is a detail that would be better if fixed in the future.

(I edited the video that's why the demo is like below)

Score.calendar.mp4

struct GameView : View {
var game : Game
@ObservedObject var viewModel: PastGameViewModel
@StateObject var calendarViewModel = CalendarViewModel.shared
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ObservedObject since it's not owned by the view and is a singleton. I don't think this could cause bugs in this specific use case, but it's still better to change it just in case.

} else {
DispatchQueue.main.async {
self.alertTitle = "Game can't be added."
self.alertMessage = "Can't access to the calendar. The request was denied."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Can't access to the calendar" has a grammar mistake. "Can't access the calendar", or something else.

}

let calendarEvent = EKEvent(eventStore: self.eventStore)
calendarEvent.title = "Cornell vs. \(event.opponent.name) \(event.sex) \(event.sport)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string here is duplicated from line 26. This can be changed to calendarEvent.title = title


if let url = URL(string: "calshow:\(event.date.timeIntervalSinceReferenceDate)") {
UIApplication.shared.open(url)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After saving the event, the code sets the alert and immediately opens the Calendar app in the same dispatch block. The UIApplication.shared.open(url) might background the app before SwiftUI has a chance to render the alert. The user will be taken to the Calendar app without seeing the "Game added" confirmation. The calshow: open should either be moved into the alert's dismiss action, or the alert should be removed in favor of just opening the Calendar app.
This is not a huge deal in my opinion. Maybe @Xhether has an opinion on which one to do. I think either the alert or opening the calendar is enough, but I don't mind both as well.

self.alertTitle = "Game can't be added."
self.alertMessage = "There was an error adding Cornell vs. \(event.opponent.name) to your calendar."
self.showAlert = true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user denies calendar permission, they get a dead-end alert with no way to fix it. Best practice is to include a button that opens UIApplication.openSettingsURLString so the user can grant access in Settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments