Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion berkeley-mobile/Home/Dining/DiningDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ struct DiningDetailView: View {
}
}

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)))
}
}
Comment on lines +39 to +50
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.


var body: some View {
VStack {
if let allDayString {
Expand Down Expand Up @@ -66,9 +79,16 @@ struct DiningDetailView: View {
.onAppear {
viewModel.logOpenedDiningDetailViewAnalytics(for: diningHall.name)
}
.navigationTitle(diningHall.name)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .principal) {
VStack(spacing: 4) {
Text(diningHall.name)
.font(.headline)
toolbarOpenClosedStatusView
}
}

ToolbarItemGroup(placement: .topBarTrailing) {
if diningHall.hasCoordinate {
Button(action: {
Expand Down