wip
This commit is contained in:
parent
a4ccd9af0d
commit
57ba06a94e
|
@ -5,4 +5,6 @@ enum ConversationAction: Codable {
|
||||||
|
|
||||||
case sendMessage(from: String, to: String, body: String)
|
case sendMessage(from: String, to: String, body: String)
|
||||||
case setReplyText(String)
|
case setReplyText(String)
|
||||||
|
|
||||||
|
case showAttachmentPicker(Bool)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,9 @@ extension ConversationState {
|
||||||
state.replyText = text.makeReply
|
state.replyText = text.makeReply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case .showAttachmentPicker(let flag):
|
||||||
|
state.attachmentPickerVisible = flag
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ struct ConversationState: Stateable {
|
||||||
var currentMessages: [Message]
|
var currentMessages: [Message]
|
||||||
|
|
||||||
var replyText: String
|
var replyText: String
|
||||||
|
var attachmentPickerVisible: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Init
|
// MARK: Init
|
||||||
|
@ -11,5 +12,6 @@ extension ConversationState {
|
||||||
init() {
|
init() {
|
||||||
currentMessages = []
|
currentMessages = []
|
||||||
replyText = ""
|
replyText = ""
|
||||||
|
attachmentPickerVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct AttachmentPickerScreen: View {
|
||||||
|
@EnvironmentObject var store: AppStore
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
Button {
|
||||||
|
store.dispatch(.conversationAction(.showAttachmentPicker(false)))
|
||||||
|
} label: {
|
||||||
|
Text("Back")
|
||||||
|
}
|
||||||
|
Text("Do It")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -89,7 +89,7 @@ struct ConversationScreen: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.safeAreaInset(edge: .bottom, spacing: 0) {
|
.safeAreaInset(edge: .bottom, spacing: 0) {
|
||||||
ConversationTextInput()
|
ConversationTextInput(autoScroll: $autoScroll)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ struct ConversationTextInput: View {
|
||||||
|
|
||||||
@State private var messageStr = ""
|
@State private var messageStr = ""
|
||||||
@FocusState private var isFocused: Bool
|
@FocusState private var isFocused: Bool
|
||||||
|
@Binding var autoScroll: Bool
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
|
@ -19,7 +20,7 @@ struct ConversationTextInput: View {
|
||||||
Text(replyText)
|
Text(replyText)
|
||||||
.font(.body3)
|
.font(.body3)
|
||||||
.foregroundColor(Color.Main.black)
|
.foregroundColor(Color.Main.black)
|
||||||
.multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/)
|
.multilineTextAlignment(.leading)
|
||||||
.lineLimit(3)
|
.lineLimit(3)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
Spacer()
|
Spacer()
|
||||||
|
@ -48,7 +49,7 @@ struct ConversationTextInput: View {
|
||||||
.foregroundColor(.Tango.blueLight)
|
.foregroundColor(.Tango.blueLight)
|
||||||
.padding(.leading, 8)
|
.padding(.leading, 8)
|
||||||
.tappablePadding(.symmetric(8)) {
|
.tappablePadding(.symmetric(8)) {
|
||||||
print("Attach file")
|
store.dispatch(.conversationAction(.showAttachmentPicker(true)))
|
||||||
}
|
}
|
||||||
TextField(L10n.Chat.textfieldPrompt, text: $messageStr)
|
TextField(L10n.Chat.textfieldPrompt, text: $messageStr)
|
||||||
.font(.body1)
|
.font(.body1)
|
||||||
|
@ -75,6 +76,7 @@ struct ConversationTextInput: View {
|
||||||
messageStr = ""
|
messageStr = ""
|
||||||
// UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
// UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||||
store.dispatch(.conversationAction(.setReplyText("")))
|
store.dispatch(.conversationAction(.setReplyText("")))
|
||||||
|
autoScroll = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +88,12 @@ struct ConversationTextInput: View {
|
||||||
isFocused = true
|
isFocused = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.fullScreenCover(isPresented: Binding<Bool>(
|
||||||
|
get: { store.state.conversationsState.attachmentPickerVisible },
|
||||||
|
set: { _ in }
|
||||||
|
)) {
|
||||||
|
AttachmentPickerScreen()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var replyText: String {
|
private var replyText: String {
|
||||||
|
|
Loading…
Reference in a new issue