Skip to content

Commit

Permalink
Fix highlighting issue in workflow list
Browse files Browse the repository at this point in the history
- Defer navigation destinations with the use of new `DeferView` to
  fix the highlighting issue that appears if you have nested navigation
  links
  • Loading branch information
zenangst committed Dec 20, 2020
1 parent 3148d4e commit ea29a05
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
15 changes: 9 additions & 6 deletions ViewKit/Sources/Views/GroupList/GroupList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ public struct GroupList: View {
List {
ForEach(store.groups) { group in
NavigationLink(
destination: WorkflowList(
store: store,
title: group.name,
subtitle: "Workflows: \(group.workflows.count)",
workflows: group.workflows,
selection: $workflowSelection)
destination: DeferView({
WorkflowList(
store: store,
title: group.name,
subtitle: "Workflows: \(group.workflows.count)",
workflows: group.workflows,
selection: $workflowSelection)

})
.frame(minWidth: 250, idealWidth: 250),
tag: group.id,
selection: Binding<String?>(
Expand Down
12 changes: 12 additions & 0 deletions ViewKit/Sources/Views/Shared/DeferedView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import SwiftUI

struct DeferView<Content: View>: View {
let content: () -> Content

init(@ViewBuilder _ content: @escaping () -> Content) {
self.content = content
}
var body: some View {
content()
}
}
7 changes: 5 additions & 2 deletions ViewKit/Sources/Views/WorkflowList/WorkflowList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public struct WorkflowList: View {
List {
ForEach(workflows, id: \.id) { workflow in
NavigationLink(
destination: DetailView(context: store.context,
workflowController: store.context.workflow),
destination: DeferView({
DetailView(context: store.context,
workflowController: store.context.workflow)

}),
tag: workflow.id,
selection: $selection,
label: {
Expand Down
4 changes: 2 additions & 2 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ targets:
base:
ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon"
CODE_SIGN_IDENTITY: "-"
CURRENT_PROJECT_VERSION: 17
CURRENT_PROJECT_VERSION: 18
INFOPLIST_FILE: "App/Resources/Info.plist"
MARKETING_VERSION: 0.4.0
MARKETING_VERSION: 0.4.1
PRODUCT_BUNDLE_IDENTIFIER: "com.zenangst.Keyboard-Cowboy"
PRODUCT_NAME: "Keyboard Cowboy"
ENABLE_HARDENED_RUNTIME: true
Expand Down

0 comments on commit ea29a05

Please sign in to comment.