This commit is contained in:
fmodf 2024-06-27 09:23:09 +02:00
parent 1e27b8643c
commit b0ef155be8
3 changed files with 80 additions and 2 deletions

View file

@ -120,6 +120,7 @@ final class XMPPService: ObservableObject {
switch res {
case .success:
completion(true)
case .failure:
completion(false)
}

View file

@ -123,6 +123,7 @@ private struct ConversationMessageRow: View {
@EnvironmentObject var store: AppStore
let message: Message
@State private var offset: CGSize = .zero
var body: some View {
VStack(spacing: 0) {
@ -143,6 +144,27 @@ private struct ConversationMessageRow: View {
}
.padding(.vertical, 10)
.padding(.horizontal, 16)
.background(Color.clearTappable)
.offset(offset)
.gesture(
DragGesture(minimumDistance: 20, coordinateSpace: .local)
.onEnded { value in
withAnimation(.easeOut(duration: 0.1)) {
if value.translation.width < 0 {
offset = CGSize(width: -50, height: 0)
// TODO: Quick message replay here
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
withAnimation(.easeOut(duration: 0.1)) {
offset = .zero
}
}
} else {
offset = .zero
}
}
}
)
}
.sharedListRow()
}
@ -200,6 +222,22 @@ struct MessageAttr: View {
}
}
// self.conversationLogController?.getTextOfSelectedRows(paths: [indexPath], withTimestamps: false, handler: { [weak self] texts in
// let text: String = texts.flatMap { $0.split(separator: "\n")}.map {
// if $0.starts(with: ">") {
// return ">\($0)";
// } else {
// return "> \($0)"
// }
// }.joined(separator: "\n");
//
// if let current = self?.messageText, !current.isEmpty {
// self?.messageText = "\(current)\n\(text)\n";
// } else {
// self?.messageText = "\(text)\n";
// }
// })
// Preview
#if DEBUG
struct ConversationScreen_Previews: PreviewProvider {
@ -234,9 +272,35 @@ struct MessageAttr: View {
date: Date(),
pending: true, sentError: false
),
Message(id: "2", type: .chat, contentType: .text, from: contact, to: acc, body: "this is for testsdfsdf sdfsdf sdfs sdf sdffsdf sdf sdf sdf sdf sdf sdff sdfffwwe ", subject: nil, thread: nil, oobUrl: nil, date: Date(), pending: false, sentError: false),
Message(
id: "2",
type: .chat,
contentType: .text,
from: contact,
to: acc,
body: "this is for testsdfsdf sdfsdf sdfs sdf sdffsdf sdf sdf sdf sdf sdf sdff sdfffwwe ",
subject: nil,
thread: nil,
oobUrl: nil,
date: Date(),
pending: false,
sentError: false
),
Message(id: "3", type: .chat, contentType: .text, from: contact, to: acc, body: "this is for test", subject: nil, thread: nil, oobUrl: nil, date: Date(), pending: false, sentError: true),
Message(id: "4", type: .chat, contentType: .text, from: acc, to: contact, body: "this is for test sdfkjwek jwkjfh jwerf jdfhskjdhf jsdhfjhwefh sjdhfh fsdjhfh sd ", subject: nil, thread: nil, oobUrl: nil, date: Date(), pending: false, sentError: false),
Message(
id: "4",
type: .chat,
contentType: .text,
from: acc,
to: contact,
body: "this is for test sdfkjwek jwkjfh jwerf jdfhskjdhf jsdhfjhwefh sjdhfh fsdjhfh sd ",
subject: nil,
thread: nil,
oobUrl: nil,
date: Date(),
pending: false,
sentError: false
),
Message(id: "5", type: .chat, contentType: .text, from: contact, to: acc, body: "this is for test sdfjkkeke kekkddjw;; w;edkdjfj l kjwekrjfk wef", subject: nil, thread: nil, oobUrl: nil, date: Date(), pending: false, sentError: false),
Message(id: "6", type: .chat, contentType: .text, from: acc, to: contact, body: "this is for testsdf dsdkkekkddn wejkjfj ", subject: nil, thread: nil, oobUrl: nil, date: Date(), pending: false, sentError: false),
Message(

View file

@ -0,0 +1,13 @@
import SwiftUI
public extension Color {
static let clearTappable = Color.white.opacity(0.0001)
// static func random(randomOpacity: Bool = false) -> Color {
// Color(
// red: .random(in: 0 ... 1),
// green: .random(in: 0 ... 1),
// blue: .random(in: 0 ... 1),
// opacity: randomOpacity ? .random(in: 0 ... 1) : 1
// )
// }
}