wip
This commit is contained in:
parent
47943f15ff
commit
9f91741354
|
@ -1,3 +1,3 @@
|
||||||
enum ConversationAction: Codable {
|
enum ConversationAction: Codable {
|
||||||
case dumb
|
case makeConversationActive(chat: Chat)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,12 @@ final class ConversationMiddleware {
|
||||||
|
|
||||||
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
func middleware(state _: AppState, action: AppAction) -> AnyPublisher<AppAction, Never> {
|
||||||
switch action {
|
switch action {
|
||||||
|
case .chatsAction(.chatStarted(let chat)):
|
||||||
|
return Just(AppAction.conversationAction(.makeConversationActive(chat: chat))).eraseToAnyPublisher()
|
||||||
|
|
||||||
|
case .conversationAction(.makeConversationActive):
|
||||||
|
return Just(AppAction.changeFlow(.conversation)).eraseToAnyPublisher()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Empty().eraseToAnyPublisher()
|
return Empty().eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
extension ConversationState {
|
extension ConversationState {
|
||||||
static func reducer(state: inout ConversationState, action: ConversationAction) {
|
static func reducer(state: inout ConversationState, action: ConversationAction) {
|
||||||
switch action {
|
switch action {
|
||||||
case .dumb:
|
case .makeConversationActive(let chat):
|
||||||
state.dumb = true
|
state.currentChat = chat
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
|
|
@ -6,6 +6,7 @@ enum AppFlow: Codable {
|
||||||
case chats
|
case chats
|
||||||
case contacts
|
case contacts
|
||||||
case settings
|
case settings
|
||||||
|
case conversation
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AppState: Stateable {
|
struct AppState: Stateable {
|
||||||
|
|
|
@ -30,6 +30,9 @@ struct BaseNavigationView: View {
|
||||||
|
|
||||||
case .settings:
|
case .settings:
|
||||||
SettingsScreen()
|
SettingsScreen()
|
||||||
|
|
||||||
|
case .conversation:
|
||||||
|
ConversationScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,13 @@ import Foundation
|
||||||
import Martin
|
import Martin
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ChatScreen: View {
|
struct ConversationScreen: View {
|
||||||
// @EnvironmentObject var state: AppState
|
@EnvironmentObject var store: AppStore
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
// Header
|
// Header
|
||||||
ChatScreenHeader()
|
ConversationScreenHeader()
|
||||||
|
|
||||||
// Msg list
|
// Msg list
|
||||||
// if !state.messages.isEmpty {
|
// if !state.messages.isEmpty {
|
||||||
|
@ -26,7 +26,7 @@ struct ChatScreen: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct ChatScreenHeader: View {
|
private struct ConversationScreenHeader: View {
|
||||||
// @EnvironmentObject var state: AppState
|
// @EnvironmentObject var state: AppState
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -48,7 +48,7 @@ private struct ChatScreenHeader: View {
|
||||||
Image(systemName: "chevron.left")
|
Image(systemName: "chevron.left")
|
||||||
.foregroundColor(Color.Tango.orangeMedium)
|
.foregroundColor(Color.Tango.orangeMedium)
|
||||||
.tappablePadding(.symmetric(12)) {
|
.tappablePadding(.symmetric(12)) {
|
||||||
// state.flow = .chatsList
|
store.dispatch(.changeFlow(store.state.previousFlow))
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
// Image(systemName: "plus.viewfinder")
|
// Image(systemName: "plus.viewfinder")
|
||||||
|
@ -63,7 +63,7 @@ private struct ChatScreenHeader: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct ChatMessageView: View {
|
private struct ConversationMessageView: View {
|
||||||
// @EnvironmentObject var state: AppState
|
// @EnvironmentObject var state: AppState
|
||||||
|
|
||||||
let message: Message
|
let message: Message
|
Loading…
Reference in a new issue