Conversation
| 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))) | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
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.
Shows status of each dining hall with an open/closed status.
