placeholders looking good and sync page sizes with android

This commit is contained in:
Diogo
2024-11-06 15:25:10 +00:00
parent 9b6365ca88
commit 9155a2f02a
4 changed files with 11 additions and 9 deletions
@@ -62,8 +62,6 @@ struct ChatItemView: View {
CIVoiceView(chat: chat, chatItem: ci, recordingFile: ci.file, duration: duration, allowMenu: $allowMenu)
} else if ci.content.msgContent == nil {
ChatItemContentView(chat: chat, chatItem: chatItem, msgContentView: { Text(ci.text) }) // msgContent is unreachable branch in this case
} else if ci.isPlaceholder {
EmptyView()
} else {
framedItemView()
}
+5 -1
View File
@@ -220,7 +220,11 @@ struct ReverseList<Content: View>: UIViewControllerRepresentable {
var snapshot = NSDiffableDataSourceSnapshot<Section, ChatItem>()
if let gap = gap {
var itemsCopy = items
let blanks = (0..<gap.size).map { index in ChatItem.placeholder(index + 1) }
let blanks = (0..<gap.size).map { index in
// Using existing text instead of random rumble or empty text does make long scroll look natural.
let sourceItem = items[index % items.count]
return ChatItem.placeholder(idx: index + 1, text: sourceItem.text, chatDir: sourceItem.chatDir)
}
itemsCopy.insert(contentsOf: blanks, at: gap.index)
renderedItems = itemsCopy
} else {