add mock global search
This commit is contained in:
parent
3d5ba0538f
commit
15ef27b42f
@ -201,6 +201,9 @@
|
|||||||
"Где найти сохранённые черновики?" : {
|
"Где найти сохранённые черновики?" : {
|
||||||
"comment" : "FAQ question: drafts"
|
"comment" : "FAQ question: drafts"
|
||||||
},
|
},
|
||||||
|
"Глобальный поиск" : {
|
||||||
|
"comment" : "Global search section"
|
||||||
|
},
|
||||||
"Данные" : {
|
"Данные" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -480,6 +483,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Локальные чаты" : {
|
||||||
|
"comment" : "Local search section"
|
||||||
|
},
|
||||||
"Мини-приложения" : {
|
"Мини-приложения" : {
|
||||||
"comment" : "Applets",
|
"comment" : "Applets",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
@ -730,7 +736,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Ничего не найдено" : {
|
"Ничего не найдено" : {
|
||||||
|
"comment" : "Global search placeholder"
|
||||||
},
|
},
|
||||||
"Новый пароль" : {
|
"Новый пароль" : {
|
||||||
"comment" : "Новый пароль",
|
"comment" : "Новый пароль",
|
||||||
|
|||||||
@ -79,53 +79,36 @@ struct ChatsTab: View {
|
|||||||
.listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
|
.listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
|
||||||
}
|
}
|
||||||
|
|
||||||
if filteredChats.isEmpty && isSearching {
|
if isSearching {
|
||||||
Section {
|
Section(header: localSearchHeader) {
|
||||||
emptySearchResultView
|
if localSearchResults.isEmpty {
|
||||||
|
emptySearchResultView
|
||||||
|
.listRowInsets(EdgeInsets(top: 24, leading: 16, bottom: 24, trailing: 16))
|
||||||
|
.listRowSeparator(.hidden)
|
||||||
|
} else {
|
||||||
|
ForEach(localSearchResults) { chat in
|
||||||
|
chatRowItem(for: chat)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section(header: globalSearchHeader) {
|
||||||
|
Text(NSLocalizedString("Ничего не найдено", comment: "Global search placeholder"))
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
.padding(.vertical, 12)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.listRowInsets(EdgeInsets(top: 12, leading: 16, bottom: 12, trailing: 16))
|
||||||
|
.listRowSeparator(.hidden)
|
||||||
}
|
}
|
||||||
.listRowInsets(EdgeInsets(top: 24, leading: 16, bottom: 24, trailing: 16))
|
|
||||||
.listRowSeparator(.hidden)
|
|
||||||
} else {
|
} else {
|
||||||
ForEach(filteredChats) { chat in
|
ForEach(viewModel.chats) { chat in
|
||||||
Button {
|
chatRowItem(for: chat)
|
||||||
selectedChatId = chat.chatId
|
|
||||||
} label: {
|
|
||||||
ChatRowView(chat: chat, currentUserId: currentUserId)
|
|
||||||
.contentShape(Rectangle())
|
|
||||||
}
|
|
||||||
.buttonStyle(.plain)
|
|
||||||
.contextMenu {
|
|
||||||
Button(action: {}) {
|
|
||||||
Label(NSLocalizedString("Закрепить (скоро)", comment: ""), systemImage: "pin")
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(action: {}) {
|
|
||||||
Label(NSLocalizedString("Без звука (скоро)", comment: ""), systemImage: "speaker.slash")
|
|
||||||
}
|
|
||||||
|
|
||||||
Button(role: .destructive, action: {}) {
|
|
||||||
Label(NSLocalizedString("Удалить чат (скоро)", comment: ""), systemImage: "trash")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.background(
|
|
||||||
NavigationLink(
|
|
||||||
destination: ChatPlaceholderView(chat: chat),
|
|
||||||
tag: chat.chatId,
|
|
||||||
selection: $selectedChatId
|
|
||||||
) {
|
|
||||||
EmptyView()
|
|
||||||
}
|
|
||||||
.hidden()
|
|
||||||
)
|
|
||||||
.onAppear {
|
|
||||||
guard !isSearching else { return }
|
|
||||||
viewModel.loadMoreIfNeeded(currentItem: chat)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if viewModel.isLoadingMore && !isSearching {
|
if viewModel.isLoadingMore {
|
||||||
loadingMoreRow
|
loadingMoreRow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
@ -201,6 +184,18 @@ struct ChatsTab: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var localSearchResults: [PrivateChatListItem] {
|
||||||
|
Array(filteredChats.prefix(5))
|
||||||
|
}
|
||||||
|
|
||||||
|
private var localSearchHeader: some View {
|
||||||
|
Text(NSLocalizedString("Локальные чаты", comment: "Local search section"))
|
||||||
|
}
|
||||||
|
|
||||||
|
private var globalSearchHeader: some View {
|
||||||
|
Text(NSLocalizedString("Глобальный поиск", comment: "Global search section"))
|
||||||
|
}
|
||||||
|
|
||||||
private var emptySearchResultView: some View {
|
private var emptySearchResultView: some View {
|
||||||
VStack(spacing: 8) {
|
VStack(spacing: 8) {
|
||||||
Image(systemName: "text.magnifyingglass")
|
Image(systemName: "text.magnifyingglass")
|
||||||
@ -271,6 +266,44 @@ struct ChatsTab: View {
|
|||||||
}
|
}
|
||||||
.listRowSeparator(.hidden)
|
.listRowSeparator(.hidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func chatRowItem(for chat: PrivateChatListItem) -> some View {
|
||||||
|
Button {
|
||||||
|
selectedChatId = chat.chatId
|
||||||
|
} label: {
|
||||||
|
ChatRowView(chat: chat, currentUserId: currentUserId)
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
.contextMenu {
|
||||||
|
Button(action: {}) {
|
||||||
|
Label(NSLocalizedString("Закрепить (скоро)", comment: ""), systemImage: "pin")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(action: {}) {
|
||||||
|
Label(NSLocalizedString("Без звука (скоро)", comment: ""), systemImage: "speaker.slash")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(role: .destructive, action: {}) {
|
||||||
|
Label(NSLocalizedString("Удалить чат (скоро)", comment: ""), systemImage: "trash")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.background(
|
||||||
|
NavigationLink(
|
||||||
|
destination: ChatPlaceholderView(chat: chat),
|
||||||
|
tag: chat.chatId,
|
||||||
|
selection: $selectedChatId
|
||||||
|
) {
|
||||||
|
EmptyView()
|
||||||
|
}
|
||||||
|
.hidden()
|
||||||
|
)
|
||||||
|
.onAppear {
|
||||||
|
guard !isSearching else { return }
|
||||||
|
viewModel.loadMoreIfNeeded(currentItem: chat)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private extension ChatsTab {
|
private extension ChatsTab {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user