Skip to content

Commit

Permalink
fix 首次快捷键失效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed Apr 22, 2024
1 parent be59f85 commit d4e10f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
17 changes: 15 additions & 2 deletions SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ struct InfoListView: View {
} label: {
Text("检索重置")
}
.keyboardShortcut(KeyEquivalent("d"), modifiers: .command)
}
}
ToolbarItem(placement: .primaryAction) {
Expand All @@ -95,6 +94,20 @@ struct InfoListView: View {
})
.disabled(modelContext.undoManager?.canRedo == false)
}
if searchText != "" || filterCate != "" {
ToolbarItem(placement: .primaryAction) {
Button {
searchText = ""
filterCate = ""
} label: {
Image(systemName: "xmark.circle")
Text("检索")
}
.help("CMD + d")
.keyboardShortcut(KeyEquivalent("d"), modifiers: .command)
}
}

}
.searchable(text: $searchText)
.onAppear {
Expand All @@ -116,7 +129,7 @@ struct InfoListView: View {
})
.sheet(isPresented: $showSheet, content: {
Text("选择一个检索词")
.font(.title).bold().padding(10)
.font(.title).bold().padding(EdgeInsets(top: 10, leading: 0, bottom: 0, trailing: 0))
ScrollView(.vertical) {
ForEach(parseSearchTerms(), id: \.self) { term in
HStack {
Expand Down
3 changes: 0 additions & 3 deletions SwiftPamphletApp/InfoOrganizer/Info/InfoRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ struct InfoRowView: View {
if info.category != nil {
Text(info.category?.name ?? "")
.padding(4)
// .background(.tertiary)
// .clipShape(.rect(cornerRadius: 4))
// .foregroundColor(.white)
.overlay {
RoundedRectangle(cornerRadius: 4)
.stroke(lineWidth: 1)
Expand Down
3 changes: 3 additions & 0 deletions SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ struct InfosView: View {
@Binding var limit: Int

init(filterCateName: String = "", searchString: String = "", filterStar: Bool = false ,selectInfo: Binding<IOInfo?>, sortOrder: [SortDescriptor<IOInfo>] = [], limit: Binding<Int>) {

var fd = FetchDescriptor<IOInfo>(predicate: #Predicate { info in

if !filterCateName.isEmpty && !searchString.isEmpty {
(info.name.localizedStandardContains(searchString)
|| info.url.localizedStandardContains(searchString)
Expand All @@ -29,6 +31,7 @@ struct InfosView: View {
|| info.url.localizedStandardContains(searchString)
|| info.des.localizedStandardContains(searchString)
}

}, sortBy: sortOrder)
fd.fetchLimit = limit.wrappedValue
_infos = Query(fd)
Expand Down

0 comments on commit d4e10f7

Please sign in to comment.