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