diff --git a/ConversationsClassic/AppCore/Actions/ConversationActions.swift b/ConversationsClassic/AppCore/Actions/ConversationActions.swift index 9294677..f299693 100644 --- a/ConversationsClassic/AppCore/Actions/ConversationActions.swift +++ b/ConversationsClassic/AppCore/Actions/ConversationActions.swift @@ -5,4 +5,6 @@ enum ConversationAction: Codable { case sendMessage(from: String, to: String, body: String) case setReplyText(String) + + case showAttachmentPicker(Bool) } diff --git a/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift b/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift index cc76c62..a4d980a 100644 --- a/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift +++ b/ConversationsClassic/AppCore/Reducers/ConversationReducer.swift @@ -17,6 +17,9 @@ extension ConversationState { state.replyText = text.makeReply } + case .showAttachmentPicker(let flag): + state.attachmentPickerVisible = flag + default: break } diff --git a/ConversationsClassic/AppCore/State/ConversationState.swift b/ConversationsClassic/AppCore/State/ConversationState.swift index 9267bbd..bfb03ce 100644 --- a/ConversationsClassic/AppCore/State/ConversationState.swift +++ b/ConversationsClassic/AppCore/State/ConversationState.swift @@ -4,6 +4,7 @@ struct ConversationState: Stateable { var currentMessages: [Message] var replyText: String + var attachmentPickerVisible: Bool } // MARK: Init @@ -11,5 +12,6 @@ extension ConversationState { init() { currentMessages = [] replyText = "" + attachmentPickerVisible = false } } diff --git a/ConversationsClassic/View/Screens/AttachmentPickerScreen.swift b/ConversationsClassic/View/Screens/AttachmentPickerScreen.swift new file mode 100644 index 0000000..9bf47f3 --- /dev/null +++ b/ConversationsClassic/View/Screens/AttachmentPickerScreen.swift @@ -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") + } + } +} diff --git a/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift b/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift index f1b53e2..cc667df 100644 --- a/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift +++ b/ConversationsClassic/View/Screens/Conversation/ConversationScreen.swift @@ -89,7 +89,7 @@ struct ConversationScreen: View { } } .safeAreaInset(edge: .bottom, spacing: 0) { - ConversationTextInput() + ConversationTextInput(autoScroll: $autoScroll) } } } diff --git a/ConversationsClassic/View/Screens/Conversation/ConversationTextInput.swift b/ConversationsClassic/View/Screens/Conversation/ConversationTextInput.swift index a7ba660..4ea3961 100644 --- a/ConversationsClassic/View/Screens/Conversation/ConversationTextInput.swift +++ b/ConversationsClassic/View/Screens/Conversation/ConversationTextInput.swift @@ -6,6 +6,7 @@ struct ConversationTextInput: View { @State private var messageStr = "" @FocusState private var isFocused: Bool + @Binding var autoScroll: Bool var body: some View { VStack(spacing: 0) { @@ -19,7 +20,7 @@ struct ConversationTextInput: View { Text(replyText) .font(.body3) .foregroundColor(Color.Main.black) - .multilineTextAlignment(/*@START_MENU_TOKEN@*/ .leading/*@END_MENU_TOKEN@*/) + .multilineTextAlignment(.leading) .lineLimit(3) .padding(8) Spacer() @@ -48,7 +49,7 @@ struct ConversationTextInput: View { .foregroundColor(.Tango.blueLight) .padding(.leading, 8) .tappablePadding(.symmetric(8)) { - print("Attach file") + store.dispatch(.conversationAction(.showAttachmentPicker(true))) } TextField(L10n.Chat.textfieldPrompt, text: $messageStr) .font(.body1) @@ -75,6 +76,7 @@ struct ConversationTextInput: View { messageStr = "" // UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil) store.dispatch(.conversationAction(.setReplyText(""))) + autoScroll = true } } } @@ -86,6 +88,12 @@ struct ConversationTextInput: View { isFocused = true } } + .fullScreenCover(isPresented: Binding( + get: { store.state.conversationsState.attachmentPickerVisible }, + set: { _ in } + )) { + AttachmentPickerScreen() + } } private var replyText: String {