Skip to content

Commit

Permalink
Improve the workflow list
Browse files Browse the repository at this point in the history
- Add content shape to `ContentItemView` to make it easier to click
- Add initial focus to the workflow list
- Refactor `ContentItemView` to resize more efficient
  • Loading branch information
zenangst committed Nov 2, 2023
1 parent d734093 commit 41f3ba1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions App/Sources/UI/Views/ContentItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ struct ContentItemView: View {
Text(workflow.name)
.lineLimit(1)
.allowsTightening(true)
.frame(maxWidth: .infinity, alignment: .leading)

Spacer()
if let binding = workflow.binding {
KeyboardShortcutView(shortcut: .init(key: binding, lhs: true, modifiers: []))
.fixedSize()
.font(.caption)
.lineLimit(1)
.allowsTightening(true)
.frame(minWidth: 32, maxWidth: .infinity, alignment: .trailing)
.layoutPriority(-1)
.frame(minWidth: 32, alignment: .trailing)
}
}
.contentShape(Rectangle())
Expand Down
8 changes: 8 additions & 0 deletions App/Sources/UI/Views/ContentListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct ContentListView: View {
ForEach(publisher.data.filter(search).lazy, id: \.id) { element in
ContentItemView(element, focusPublisher: focusPublisher, publisher: publisher,
contentSelectionManager: contentSelectionManager, onAction: onAction)
.contentShape(Rectangle())
.onTapGesture {
contentSelectionManager.handleOnTap(publisher.data, element: element)
focusPublisher.publish(element.id)
Expand Down Expand Up @@ -164,6 +165,13 @@ struct ContentListView: View {
}
}
}
.onAppear {
if !publisher.data.isEmpty {
DispatchQueue.main.async {
focus.wrappedValue = .workflows
}
}
}
}
}

Expand Down

0 comments on commit 41f3ba1

Please sign in to comment.