-
Notifications
You must be signed in to change notification settings - Fork 0
Replaced building hours #35
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
Changes from 4 commits
e42183c
28e3924
e7f9d4c
a99a7cf
6dcf1ce
0c1b693
cfa9cc5
2dcee99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // | ||
| // HomeGymCellViewModel.swift | ||
| // Uplift | ||
| // | ||
| // Created by Caitlyn Jin on 2/24/24. | ||
| // Copyright © 2024 Cornell AppDev. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftUI | ||
|
|
||
| extension HomeGymCell { | ||
|
|
||
| /// The ViewModel for a Gym Cell on the main view. | ||
| @MainActor | ||
| class ViewModel: ObservableObject { | ||
caitlynjin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // MARK: - Helpers | ||
|
|
||
| /// Determine whether at least one fitness center is open at this `Gym`. | ||
| func fitnessCenterIsOpen(gym: Gym) -> Bool { | ||
| gym.fitnessCenters.allSatisfy { | ||
| switch $0.status { | ||
| case .closed: | ||
| return false | ||
| default: | ||
| return true | ||
| } | ||
| } | ||
| } | ||
caitlynjin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Determine the close time of the latest closing fitness center that is currently open at this `Gym`. | ||
| func determineCloseTime(gym: Gym) -> Date? { | ||
| var possibleCloseTimes: [Date] = [] | ||
|
|
||
| gym.fitnessCenters.forEach { | ||
| switch $0.status { | ||
| case .open(let closeTime): | ||
| possibleCloseTimes.append(closeTime) | ||
| default: | ||
| break | ||
| } | ||
| } | ||
|
|
||
| return possibleCloseTimes.sorted(by: { | ||
| switch $0.compare($1) { | ||
| case .orderedDescending: | ||
| return true | ||
| default: | ||
| return false | ||
| } | ||
| }).first | ||
| } | ||
caitlynjin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Determine the open time of the earliest opening fitness center of this `Gym`. | ||
| func determineOpenTime(gym: Gym) -> Date? { | ||
| var possibleOpenTimes: [Date] = [] | ||
|
|
||
| gym.fitnessCenters.forEach { | ||
| switch $0.status { | ||
| case .closed(let openTime): | ||
| possibleOpenTimes.append(openTime) | ||
| default: | ||
| break | ||
| } | ||
| } | ||
|
|
||
| return possibleOpenTimes.sorted(by: { | ||
| switch $0.compare($1) { | ||
| case .orderedAscending: | ||
| return true | ||
| default: | ||
| return false | ||
| } | ||
| }).first | ||
| } | ||
caitlynjin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,20 +118,33 @@ struct GymDetailView: View { | |
| VStack(spacing: 4) { | ||
| Spacer() | ||
|
|
||
| switch gym.status { | ||
| case .closed: | ||
| Text("CLOSED") | ||
| .font(Constants.Fonts.h3) | ||
| .foregroundStyle(Constants.Colors.closed) | ||
| case .open: | ||
| if viewModel.fitnessCenterIsOpen(gym: gym) { | ||
| Text("OPEN") | ||
| .font(Constants.Fonts.h3) | ||
| .foregroundStyle(Constants.Colors.open) | ||
| case .none: | ||
| EmptyView() | ||
| .padding(12) | ||
| } else { | ||
| Text("CLOSED") | ||
| .font(Constants.Fonts.h3) | ||
| .foregroundStyle(Constants.Colors.closed) | ||
| .padding(12) | ||
| } | ||
caitlynjin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| viewHoursButton | ||
| // TODO: Removed building hours. Determine what should be displayed here. | ||
| // switch gym.status { | ||
| // case .closed: | ||
| // Text("CLOSED") | ||
| // .font(Constants.Fonts.h3) | ||
| // .foregroundStyle(Constants.Colors.closed) | ||
| // case .open: | ||
| // Text("OPEN") | ||
| // .font(Constants.Fonts.h3) | ||
| // .foregroundStyle(Constants.Colors.open) | ||
| // case .none: | ||
| // EmptyView() | ||
| // } | ||
| // | ||
| // viewHoursButton | ||
|
Comment on lines
+135
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably need to delete this for style right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we're holding onto this code for now because we had to remove building hours, not sure what we're going to do with it yet. |
||
| } | ||
| .frame(height: 120) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.