mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-11 19:45:00 +00:00
53040dbe1d
* iOS: chats and messages layout * model update for updated API * improve chat list view * chat view layouts * delete contacts * larger headers, clean up, move message reception loop to ContentView * settings: user profile
47 lines
1.1 KiB
Swift
47 lines
1.1 KiB
Swift
//
|
|
// SendMessageView.swift
|
|
// SimpleX
|
|
//
|
|
// Created by Evgeny Poberezkin on 29/01/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct SendMessageView: View {
|
|
var sendMessage: (String) -> Void
|
|
var inProgress: Bool = false
|
|
@State var command: String = ""
|
|
|
|
var body: some View {
|
|
HStack {
|
|
TextField("Message...", text: $command)
|
|
.textFieldStyle(.roundedBorder)
|
|
.textInputAutocapitalization(.never)
|
|
.disableAutocorrection(true)
|
|
.onSubmit(submit)
|
|
|
|
if (inProgress) {
|
|
ProgressView()
|
|
.frame(width: 40, height: 20, alignment: .center)
|
|
} else {
|
|
Button("Send", action :submit)
|
|
.disabled(command.isEmpty)
|
|
}
|
|
}
|
|
.frame(minHeight: 30)
|
|
.padding(12)
|
|
}
|
|
|
|
func submit() {
|
|
sendMessage(command)
|
|
command = ""
|
|
}
|
|
}
|
|
|
|
struct SendMessageView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
SendMessageView(sendMessage: { print ($0) })
|
|
}
|
|
}
|