mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Merge remote-tracking branch 'refs/remotes/origin/feature/conversations_tableview'
Conflicts: Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift
This commit is contained in:
commit
75ae95007b
4 changed files with 59 additions and 45 deletions
|
|
@ -244,9 +244,6 @@
|
|||
},
|
||||
"Contacts" : {
|
||||
|
||||
},
|
||||
"Content" : {
|
||||
|
||||
},
|
||||
"Continue" : {
|
||||
|
||||
|
|
@ -591,9 +588,6 @@
|
|||
},
|
||||
"This contact will be deleted definitively." : {
|
||||
|
||||
},
|
||||
"Title" : {
|
||||
|
||||
},
|
||||
"TLS" : {
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ struct ChatBubbleView: View {
|
|||
|
||||
let message: Message
|
||||
|
||||
let geometryProxy: GeometryProxy
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
|
|
@ -36,8 +38,44 @@ struct ChatBubbleView: View {
|
|||
VStack {
|
||||
if !message.attachments.isEmpty {
|
||||
if message.attachments.count == 1 {
|
||||
let result = imageDimensions(url: message.attachments.first!.full.absoluteString)
|
||||
if message.attachments.first!.type != .gif {
|
||||
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()
|
||||
.interpolation(.low)
|
||||
.scaledToFit()
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
} placeholder: {
|
||||
ProgressView()
|
||||
}
|
||||
.frame(
|
||||
height: result.0 > result.1
|
||||
? result.1 / (result.0 / (geometryProxy.size.width - 80))
|
||||
: UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5
|
||||
)
|
||||
} else {
|
||||
if result.0 < result.1 {
|
||||
GifImageView(message.attachments.first!.full)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.frame(
|
||||
width: result.1 > (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5)
|
||||
? result.0 / (result.1 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5))
|
||||
: result.0,
|
||||
height: result.1 > (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5)
|
||||
? UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5
|
||||
: result.1
|
||||
)
|
||||
} else {
|
||||
GifImageView(message.attachments.first!.full)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.frame(
|
||||
height: result.1 / (result.0 / (geometryProxy.size.width - 80))
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let result = imageDimensions(url: message.attachments.first!.full.absoluteString)
|
||||
AsyncImage(url: message.attachments.first!.full) { image in
|
||||
image.resizable()
|
||||
.interpolation(.low)
|
||||
|
|
@ -48,29 +86,9 @@ struct ChatBubbleView: View {
|
|||
}
|
||||
.frame(
|
||||
height: result.0 > result.1
|
||||
? (result.1 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3)))
|
||||
: (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3)
|
||||
? result.1 / (result.0 / (geometryProxy.size.width - 80))
|
||||
: UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 2.5 : UIScreen.main.bounds.width / 2.5
|
||||
)
|
||||
} else {
|
||||
if result.0 < result.1 {
|
||||
GifImageView(message.attachments.first!.full)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.frame(
|
||||
width: result.1 > UIScreen.main.bounds.height / 3
|
||||
? (result.0 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3)))
|
||||
: result.0,
|
||||
height: result.1 > UIScreen.main.bounds.height / 3
|
||||
? (result.1 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3)))
|
||||
: result.1
|
||||
)
|
||||
} else {
|
||||
GifImageView(message.attachments.first!.full)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||
.frame(maxWidth: .infinity)
|
||||
.frame(
|
||||
height: result.1 / (result.0 / (UIScreen.main.bounds.height > UIScreen.main.bounds.width ? UIScreen.main.bounds.height / 3 : UIScreen.main.bounds.width / 3))
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,15 @@ struct ConversationFragment: View {
|
|||
|
||||
if #available(iOS 16.0, *) {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
list
|
||||
UIList(viewModel: viewModel,
|
||||
paginationState: paginationState,
|
||||
conversationViewModel: conversationViewModel,
|
||||
isScrolledToBottom: $isScrolledToBottom,
|
||||
showMessageMenuOnLongPress: showMessageMenuOnLongPress,
|
||||
geometryProxy: geometry,
|
||||
sections: conversationViewModel.conversationMessagesSection,
|
||||
ids: conversationViewModel.conversationMessagesIds
|
||||
)
|
||||
|
||||
if !isScrolledToBottom {
|
||||
Button {
|
||||
|
|
@ -209,6 +217,7 @@ struct ConversationFragment: View {
|
|||
conversationViewModel.resetMessage()
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
ScrollViewReader { proxy in
|
||||
List {
|
||||
ForEach(0..<conversationViewModel.conversationMessagesList.count, id: \.self) { index in
|
||||
|
|
@ -249,6 +258,7 @@ struct ConversationFragment: View {
|
|||
conversationViewModel.resetMessage()
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
|
|
@ -379,18 +389,6 @@ struct ConversationFragment: View {
|
|||
}
|
||||
.navigationViewStyle(.stack)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
var list: some View {
|
||||
UIList(viewModel: viewModel,
|
||||
paginationState: paginationState,
|
||||
conversationViewModel: conversationViewModel,
|
||||
isScrolledToBottom: $isScrolledToBottom,
|
||||
showMessageMenuOnLongPress: showMessageMenuOnLongPress,
|
||||
sections: conversationViewModel.conversationMessagesSection,
|
||||
ids: conversationViewModel.conversationMessagesIds
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension UIApplication {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ struct UIList: UIViewRepresentable {
|
|||
@Binding var isScrolledToBottom: Bool
|
||||
|
||||
let showMessageMenuOnLongPress: Bool
|
||||
let geometryProxy: GeometryProxy
|
||||
let sections: [MessagesSection]
|
||||
let ids: [String]
|
||||
|
||||
|
|
@ -310,6 +311,7 @@ struct UIList: UIViewRepresentable {
|
|||
isScrolledToBottom: $isScrolledToBottom,
|
||||
isScrolledToTop: $isScrolledToTop,
|
||||
showMessageMenuOnLongPress: showMessageMenuOnLongPress,
|
||||
geometryProxy: geometryProxy,
|
||||
sections: sections,
|
||||
ids: ids
|
||||
)
|
||||
|
|
@ -325,16 +327,18 @@ struct UIList: UIViewRepresentable {
|
|||
@Binding var isScrolledToTop: Bool
|
||||
|
||||
let showMessageMenuOnLongPress: Bool
|
||||
let geometryProxy: GeometryProxy
|
||||
var sections: [MessagesSection]
|
||||
var ids: [String]
|
||||
|
||||
init(conversationViewModel: ConversationViewModel, viewModel: ChatViewModel, paginationState: PaginationState, isScrolledToBottom: Binding<Bool>, isScrolledToTop: Binding<Bool>, showMessageMenuOnLongPress: Bool, sections: [MessagesSection], ids: [String]) {
|
||||
init(conversationViewModel: ConversationViewModel, viewModel: ChatViewModel, paginationState: PaginationState, isScrolledToBottom: Binding<Bool>, isScrolledToTop: Binding<Bool>, showMessageMenuOnLongPress: Bool, geometryProxy: GeometryProxy, sections: [MessagesSection], ids: [String]) {
|
||||
self.conversationViewModel = conversationViewModel
|
||||
self.viewModel = viewModel
|
||||
self.paginationState = paginationState
|
||||
self._isScrolledToBottom = isScrolledToBottom
|
||||
self._isScrolledToTop = isScrolledToTop
|
||||
self.showMessageMenuOnLongPress = showMessageMenuOnLongPress
|
||||
self.geometryProxy = geometryProxy
|
||||
self.sections = sections
|
||||
self.ids = ids
|
||||
}
|
||||
|
|
@ -373,7 +377,7 @@ struct UIList: UIViewRepresentable {
|
|||
let row = sections[indexPath.section].rows[indexPath.row]
|
||||
if #available(iOS 16.0, *) {
|
||||
tableViewCell.contentConfiguration = UIHostingConfiguration {
|
||||
ChatBubbleView(conversationViewModel: conversationViewModel, message: row)
|
||||
ChatBubbleView(conversationViewModel: conversationViewModel, message: row, geometryProxy: geometryProxy)
|
||||
.padding(.vertical, 1)
|
||||
.padding(.horizontal, 10)
|
||||
.onTapGesture { }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue