Skip to content

Conversation

@ZaidMadanat
Copy link
Collaborator

Shows status of each dining hall with an open/closed status.
Image 11-24-25 at 7 50 PM

Comment on lines +39 to +50
private var toolbarOpenClosedStatusView: some View {
let isOpen = diningHall.isOpen
let indicatorColor = (isOpen ? Color.green : Color.red).opacity(0.8)
return HStack(spacing: 8) {
Circle()
.fill(indicatorColor)
.frame(width: 8, height: 8)
Text(isOpen ? "Open" : "Closed")
.foregroundStyle(Color(BMColor.blackText))
.font(Font(BMFont.light(12)))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't recreate this view from scratch as we already have something implemented in OpenClosedStatusView.swift. We should reuse the current implementation in OpenClosedStatusView.

Image

On a second thought, I think something like this looks better as right now there's too much going on at the top with the text. The filled circle should communicate open and closed status perfectly in a much more succinct manner.

To accomplish this we can add an additional enum under OpenClosedStatusView.swift something like

enum Type {
    case indicatorOnly
    case indicatorAndText
}

OpenClosedStatusView takes in an additional parameter of type OpenClosedStatusView.Type. var type: OpenClosedStatusView.Type

We can initialize with a default value to indicatorAndText like this: var type: OpenClosedStatusView.Type = .indicatorAndText

In the Haystack, we can do the following:

HStack(spacing: 10) {
    switch type {
    case .indicatorOnly:
        indicatorView
    case .indicatorAndText:
        indicatorView
        statusTextView
    }
}

and within the struct but outside var body, we can create private variables to refactor away the indicator and status text view implementations.

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.

3 participants