mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Update message bubble helper
This commit is contained in:
parent
05a07b3ba7
commit
50c3b17768
2 changed files with 31 additions and 22 deletions
|
|
@ -37,4 +37,16 @@ class MessageData: ObservableObject {
|
|||
}
|
||||
}
|
||||
}
|
||||
func save() {
|
||||
DispatchQueue.global(qos: .background).async { [weak self] in
|
||||
guard let messages = self?.messages else { fatalError("Self out of scope") }
|
||||
guard let data = try? JSONEncoder().encode(messages) else { fatalError("Error encoding data") }
|
||||
do {
|
||||
let outfile = Self.fileURL
|
||||
try data.write(to: outfile)
|
||||
} catch {
|
||||
fatalError("Can't write to file")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,29 +7,26 @@ struct MessageBubble: View {
|
|||
var shortName: String
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack (alignment: .top) {
|
||||
|
||||
CircleText(text: shortName, color: isCurrentUser ? Color.blue : Color(.darkGray)).padding(.all, 5)
|
||||
VStack (alignment: .leading) {
|
||||
Text(contentMessage)
|
||||
.textSelection(.enabled)
|
||||
.padding(10)
|
||||
.foregroundColor(.white)
|
||||
.background(isCurrentUser ? Color.blue : Color(.darkGray))
|
||||
.cornerRadius(10)
|
||||
HStack (spacing: 4) {
|
||||
let messageDate = Date(timeIntervalSince1970: TimeInterval(time))
|
||||
|
||||
Text(messageDate, style: .date).font(.caption2).foregroundColor(.gray)
|
||||
Text(messageDate, style: .time).font(.caption2).foregroundColor(.gray)
|
||||
}
|
||||
.padding(.bottom, 10)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
HStack (alignment: .top) {
|
||||
|
||||
}.padding(.bottom, 1)
|
||||
CircleText(text: shortName, color: isCurrentUser ? Color.blue : Color(.darkGray)).padding(.all, 5)
|
||||
VStack (alignment: .leading) {
|
||||
Text(contentMessage)
|
||||
.textSelection(.enabled)
|
||||
.padding(10)
|
||||
.foregroundColor(.white)
|
||||
.background(isCurrentUser ? Color.blue : Color(.darkGray))
|
||||
.cornerRadius(10)
|
||||
HStack (spacing: 4) {
|
||||
let messageDate = Date(timeIntervalSince1970: TimeInterval(time))
|
||||
|
||||
Text(messageDate, style: .date).font(.caption2).foregroundColor(.gray)
|
||||
Text(messageDate, style: .time).font(.caption2).foregroundColor(.gray)
|
||||
}
|
||||
.padding(.bottom, 10)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue