mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Fix messages list in iOS 15
This commit is contained in:
parent
75ae95007b
commit
f3d2f1cf6a
3 changed files with 47 additions and 39 deletions
|
|
@ -35,11 +35,11 @@ struct ChatBubbleView: View {
|
|||
Spacer()
|
||||
}
|
||||
|
||||
VStack {
|
||||
VStack(alignment: message.isOutgoing ? .trailing : .leading) {
|
||||
if !message.attachments.isEmpty {
|
||||
if message.attachments.count == 1 {
|
||||
let result = imageDimensions(url: message.attachments.first!.full.absoluteString)
|
||||
if message.attachments.first!.type == .image || message.attachments.first!.type == .gif {
|
||||
let result = imageDimensions(url: message.attachments.first!.full.absoluteString)
|
||||
if message.attachments.first!.type != .gif {
|
||||
AsyncImage(url: message.attachments.first!.full) { image in
|
||||
image.resizable()
|
||||
|
|
@ -96,8 +96,8 @@ struct ChatBubbleView: View {
|
|||
|
||||
if !message.text.isEmpty {
|
||||
Text(message.text)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.default_text_style(styleSize: 16)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.default_text_style(styleSize: 16)
|
||||
}
|
||||
}
|
||||
.padding(.all, 15)
|
||||
|
|
@ -126,17 +126,17 @@ struct ChatBubbleView: View {
|
|||
}
|
||||
|
||||
enum URLType {
|
||||
case name(String) // local file name of gif
|
||||
case url(URL) // remote url
|
||||
|
||||
var url: URL? {
|
||||
switch self {
|
||||
case .name(let name):
|
||||
return Bundle.main.url(forResource: name, withExtension: "gif")
|
||||
case .url(let remoteURL):
|
||||
return remoteURL
|
||||
case name(String) // local file name of gif
|
||||
case url(URL) // remote url
|
||||
|
||||
var url: URL? {
|
||||
switch self {
|
||||
case .name(let name):
|
||||
return Bundle.main.url(forResource: name, withExtension: "gif")
|
||||
case .url(let remoteURL):
|
||||
return remoteURL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct GifImageView: UIViewRepresentable {
|
||||
|
|
|
|||
|
|
@ -217,23 +217,26 @@ struct ConversationFragment: View {
|
|||
conversationViewModel.resetMessage()
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
ScrollViewReader { proxy in
|
||||
List {
|
||||
ForEach(0..<conversationViewModel.conversationMessagesList.count, id: \.self) { index in
|
||||
ChatBubbleView(conversationViewModel: conversationViewModel, message: conversationViewModel.conversationMessagesSection.first!.rows[index])
|
||||
.id(conversationViewModel.conversationMessagesList[index])
|
||||
.listRowInsets(EdgeInsets(top: 2, leading: 10, bottom: 2, trailing: 10))
|
||||
.listRowSeparator(.hidden)
|
||||
.onAppear {
|
||||
if index == 0 && conversationViewModel.displayedConversationHistorySize > conversationViewModel.conversationMessagesList.count {
|
||||
//DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
conversationViewModel.getOldMessages()
|
||||
//}
|
||||
}
|
||||
}
|
||||
if index < conversationViewModel.conversationMessagesSection.first!.rows.count {
|
||||
ChatBubbleView(conversationViewModel: conversationViewModel, message: conversationViewModel.conversationMessagesSection.first!.rows[index], geometryProxy: geometry)
|
||||
.id(conversationViewModel.conversationMessagesList[index])
|
||||
.listRowInsets(EdgeInsets(top: 2, leading: 10, bottom: 2, trailing: 10))
|
||||
.listRowSeparator(.hidden)
|
||||
.scaleEffect(x: 1, y: -1, anchor: .center)
|
||||
.onAppear {
|
||||
if index == conversationViewModel.conversationMessagesList.count - 1 && conversationViewModel.displayedConversationHistorySize > conversationViewModel.conversationMessagesList.count {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
conversationViewModel.getOldMessages()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.scaleEffect(x: 1, y: -1, anchor: .center)
|
||||
.listStyle(.plain)
|
||||
.onTapGesture {
|
||||
UIApplication.shared.endEditing()
|
||||
|
|
@ -242,23 +245,26 @@ struct ConversationFragment: View {
|
|||
conversationViewModel.getMessages()
|
||||
}
|
||||
.onChange(of: conversationViewModel.conversationMessagesList) { _ in
|
||||
if conversationViewModel.conversationMessagesList.count <= 30 {
|
||||
proxy.scrollTo(
|
||||
conversationViewModel.conversationMessagesList.last, anchor: .top
|
||||
)
|
||||
} else if conversationViewModel.conversationMessagesList.count >= conversationViewModel.displayedConversationHistorySize {
|
||||
proxy.scrollTo(
|
||||
conversationViewModel.conversationMessagesList[conversationViewModel.displayedConversationHistorySize%30], anchor: .top
|
||||
)
|
||||
} else {
|
||||
proxy.scrollTo(30, anchor: .top)
|
||||
/*
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
if conversationViewModel.conversationMessagesList.count <= 30 {
|
||||
proxy.scrollTo(
|
||||
conversationViewModel.conversationMessagesList.first, anchor: .top
|
||||
)
|
||||
} else if conversationViewModel.conversationMessagesList.count >= conversationViewModel.displayedConversationHistorySize {
|
||||
proxy.scrollTo(
|
||||
conversationViewModel.conversationMessagesList[conversationViewModel.displayedConversationHistorySize%30], anchor: .top
|
||||
)
|
||||
} else {
|
||||
proxy.scrollTo(30, anchor: .top)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
.onDisappear {
|
||||
conversationViewModel.resetMessage()
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
|
|
|
|||
|
|
@ -116,8 +116,10 @@ class ConversationViewModel: ObservableObject {
|
|||
if content.filePath == nil || content.filePath!.isEmpty {
|
||||
self.downloadContent(chatMessage: eventLog.chatMessage!, content: content)
|
||||
} else {
|
||||
let attachment = Attachment(id: UUID().uuidString, url: URL(string: self.getNewFilePath(name: content.name ?? ""))!, type: (content.name?.lowercased().hasSuffix("gif"))! ? .gif : .image)
|
||||
attachmentList.append(attachment)
|
||||
if URL(string: self.getNewFilePath(name: content.name ?? "")) != nil {
|
||||
let attachment = Attachment(id: UUID().uuidString, url: URL(string: self.getNewFilePath(name: content.name ?? ""))!, type: (content.name?.lowercased().hasSuffix("gif"))! ? .gif : .image)
|
||||
attachmentList.append(attachment)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue