Compare commits
No commits in common. "8c03574e6a88a79b88f821cc17005379b6da5267" and "ea927d1e78381914ab4a8c40f6796737b5284616" have entirely different histories.
8c03574e6a
...
ea927d1e78
@ -15,7 +15,6 @@ struct ChatsTab: View {
|
|||||||
@Binding var searchRevealProgress: CGFloat
|
@Binding var searchRevealProgress: CGFloat
|
||||||
@Binding var searchText: String
|
@Binding var searchText: String
|
||||||
private let searchService = SearchService()
|
private let searchService = SearchService()
|
||||||
@AppStorage("chatRowMessageLineLimit") private var messageLineLimitSetting: Int = 2
|
|
||||||
@StateObject private var viewModel = PrivateChatsViewModel()
|
@StateObject private var viewModel = PrivateChatsViewModel()
|
||||||
@State private var selectedChatId: String?
|
@State private var selectedChatId: String?
|
||||||
@State private var searchDragStartProgress: CGFloat = 0
|
@State private var searchDragStartProgress: CGFloat = 0
|
||||||
@ -179,17 +178,6 @@ struct ChatsTab: View {
|
|||||||
!searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
!searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
private var messagePreviewLineLimit: Int {
|
|
||||||
switch messageLineLimitSetting {
|
|
||||||
case ..<1:
|
|
||||||
return 1
|
|
||||||
case 1...2:
|
|
||||||
return messageLineLimitSetting
|
|
||||||
default:
|
|
||||||
return 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private var filteredChats: [PrivateChatListItem] {
|
private var filteredChats: [PrivateChatListItem] {
|
||||||
let trimmedQuery = searchText.trimmingCharacters(in: .whitespacesAndNewlines)
|
let trimmedQuery = searchText.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
guard !trimmedQuery.isEmpty else { return viewModel.chats }
|
guard !trimmedQuery.isEmpty else { return viewModel.chats }
|
||||||
@ -313,11 +301,7 @@ struct ChatsTab: View {
|
|||||||
Button {
|
Button {
|
||||||
selectedChatId = chat.chatId
|
selectedChatId = chat.chatId
|
||||||
} label: {
|
} label: {
|
||||||
ChatRowView(
|
ChatRowView(chat: chat, currentUserId: currentUserId)
|
||||||
chat: chat,
|
|
||||||
currentUserId: currentUserId,
|
|
||||||
messageLimitLine: messagePreviewLineLimit
|
|
||||||
)
|
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
@ -344,8 +328,6 @@ struct ChatsTab: View {
|
|||||||
}
|
}
|
||||||
.hidden()
|
.hidden()
|
||||||
)
|
)
|
||||||
.listRowInsets(EdgeInsets(top: 8, leading: 16, bottom: 8, trailing: 16))
|
|
||||||
// .listRowSeparator(.hidden)
|
|
||||||
.onAppear {
|
.onAppear {
|
||||||
guard !isSearching else { return }
|
guard !isSearching else { return }
|
||||||
viewModel.loadMoreIfNeeded(currentItem: chat)
|
viewModel.loadMoreIfNeeded(currentItem: chat)
|
||||||
@ -621,8 +603,6 @@ private struct SearchResultPlaceholderView: View {
|
|||||||
private struct ChatRowView: View {
|
private struct ChatRowView: View {
|
||||||
let chat: PrivateChatListItem
|
let chat: PrivateChatListItem
|
||||||
let currentUserId: String?
|
let currentUserId: String?
|
||||||
let messageLimitLine: Int
|
|
||||||
private let avatarSize: CGFloat = 52
|
|
||||||
|
|
||||||
private var title: String {
|
private var title: String {
|
||||||
switch chat.chatType {
|
switch chat.chatType {
|
||||||
@ -802,17 +782,17 @@ private struct ChatRowView: View {
|
|||||||
HStack(spacing: 12) {
|
HStack(spacing: 12) {
|
||||||
Circle()
|
Circle()
|
||||||
.fill(avatarBackgroundColor)
|
.fill(avatarBackgroundColor)
|
||||||
.frame(width: avatarSize, height: avatarSize)
|
.frame(width: 44, height: 44)
|
||||||
.overlay(
|
.overlay(
|
||||||
Group {
|
Group {
|
||||||
if isDeletedUser {
|
if isDeletedUser {
|
||||||
Image(systemName: deletedUserSymbolName)
|
Image(systemName: deletedUserSymbolName)
|
||||||
.symbolRenderingMode(.hierarchical)
|
.symbolRenderingMode(.hierarchical)
|
||||||
.font(.system(size: avatarSize * 0.45, weight: .semibold))
|
.font(.system(size: 20, weight: .semibold))
|
||||||
.foregroundColor(avatarTextColor)
|
.foregroundColor(avatarTextColor)
|
||||||
} else {
|
} else {
|
||||||
Text(initial)
|
Text(initial)
|
||||||
.font(.system(size: avatarSize * 0.5, weight: .semibold))
|
.font(.headline)
|
||||||
.foregroundColor(avatarTextColor)
|
.foregroundColor(avatarTextColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -868,7 +848,7 @@ private struct ChatRowView: View {
|
|||||||
Text(messagePreview)
|
Text(messagePreview)
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
.foregroundColor(subtitleColor)
|
.foregroundColor(subtitleColor)
|
||||||
.lineLimit(messageLimitLine)
|
.lineLimit(2)
|
||||||
.truncationMode(.tail)
|
.truncationMode(.tail)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user