Skip to content

Commit

Permalink
Merge branch 'main.fixed-navigation'
Browse files Browse the repository at this point in the history
  • Loading branch information
buresdv committed Oct 15, 2024
2 parents 341de6a + 535c88e commit 2a88c81
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
59 changes: 36 additions & 23 deletions Cork/Views/Services/Homebrew Services View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct HomebrewServicesView: View
@State private var hasTriedToUpdateHomebrewThroughCork: Bool = false
@State private var isShowingHomebrewUpdateInstructions: Bool = false

@State private var navigationTargetLocal: NavigationTargetServices?

var activeServices: Set<HomebrewService>
{
return servicesTracker.services.filter { $0.status == .scheduled || $0.status == .started }
Expand All @@ -42,7 +44,7 @@ struct HomebrewServicesView: View
{
NavigationSplitView
{
ServicesSidebarView()
ServicesSidebarView(navigationTargetLocal: $navigationTargetLocal)
} detail: {
if servicesState.isLoadingServices
{
Expand All @@ -68,32 +70,43 @@ struct HomebrewServicesView: View
}
else
{
FullSizeGroupedForm
if let selectedService = navigationTargetLocal
{
Section
switch selectedService
{
if !activeServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.badge.play"), title: "service-status-page.active-services-\(activeServices.count)", mainText: "service-status-page.active-services.description", animateNumberChanges: true)
}

if !erroredOutServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.trianglebadge.exclamationmark"), title: "service-status-page.errored-out-services-\(erroredOutServices.count)", mainText: "service-status-page.errored-out-services.description", animateNumberChanges: true)
}

if !inactiveServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.badge.pause"), title: "service-status-page.inactive-services-\(inactiveServices.count)", mainText: "service-status-page.inactive-services.description", animateNumberChanges: true)
}

if !unknownServices.isEmpty
case .service(let homebrewService):
ServiceDetailView(service: homebrewService)
}
}
else
{
FullSizeGroupedForm
{
Section
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.badge.questionmark"), title: "service-status-page.unknown-services-\(unknownServices.count)", mainText: "service-status-page.unknown-services.description", animateNumberChanges: true)
if !activeServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.badge.play"), title: "service-status-page.active-services-\(activeServices.count)", mainText: "service-status-page.active-services.description", animateNumberChanges: true)
}

if !erroredOutServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.trianglebadge.exclamationmark"), title: "service-status-page.errored-out-services-\(erroredOutServices.count)", mainText: "service-status-page.errored-out-services.description", animateNumberChanges: true)
}

if !inactiveServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.badge.pause"), title: "service-status-page.inactive-services-\(inactiveServices.count)", mainText: "service-status-page.inactive-services.description", animateNumberChanges: true)
}

if !unknownServices.isEmpty
{
GroupBoxHeadlineGroupWithArbitraryImage(image: Image("custom.square.stack.badge.questionmark"), title: "service-status-page.unknown-services-\(unknownServices.count)", mainText: "service-status-page.unknown-services.description", animateNumberChanges: true)
}
} header: {
Text("service-status-page.title")
.font(.title)
}
} header: {
Text("service-status-page.title")
.font(.title)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Cork/Views/Services/Service Detail/Service Detail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct ServiceDetailView: View
}
}
}
.task(priority: .userInitiated)
.task(id: service.id, priority: .userInitiated)
{
AppConstants.logger.log("Service details pane for service \(service.name) appeared; will try to load details")

Expand Down
4 changes: 3 additions & 1 deletion Cork/Views/Services/Services Sidebar/Services Sidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ struct ServicesSidebarView: View
@EnvironmentObject var servicesTracker: ServicesTracker

@State private var searchText: String = ""

@Binding var navigationTargetLocal: NavigationTargetServices?

var body: some View
{
List(selection: $servicesState.navigationSelection)
List(selection: $navigationTargetLocal)
{
ForEach(displayedServices.sorted(by: { $0.name < $1.name }))
{ homebrewService in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ struct SidebarServiceRow: View

var body: some View
{
NavigationLink
{
ServiceDetailView(service: service)
.id(service.id)
} label: {
NavigationLink(value: NavigationTargetServices.service(service)) {
Text(service.name)
}
.contextMenu
Expand Down

0 comments on commit 2a88c81

Please sign in to comment.