diff --git a/Package.swift b/Package.swift index a8139cb..5ff9d4c 100644 --- a/Package.swift +++ b/Package.swift @@ -27,6 +27,7 @@ let package = Package( name: "ChatKit", dependencies: [ "CorePersistence", + .product(name: "MarkdownUI", package: "SwiftUIZ"), "Swallow", "SwiftUIX", "SwiftUIZ", diff --git a/Sources/Intramodular/ChatView.swift b/Sources/Intramodular/ChatView.swift index e371c64..20165c0 100644 --- a/Sources/Intramodular/ChatView.swift +++ b/Sources/Intramodular/ChatView.swift @@ -14,30 +14,27 @@ public struct ChatView: View { let content: Content let inputView: AnyView? - @State public var _chatViewPreferences = _ChatViewPreferences() - public var body: some View { - _SwiftUI_UnaryViewAdaptor { - XStack(alignment: .top) { - content + _PreferenceReader(_ChatViewPreferences._PreferenceKey.self) { _chatViewPreferences in + _SwiftUI_UnaryViewAdaptor { + XStack(alignment: .top) { + content + } } - } - .modify(forUnwrapped: inputView) { inputView in - AnyViewModifier { - $0._bottomBar { - inputView - .padding(.horizontal) + .environment(\._chatViewPreferences, merging: _chatViewPreferences) + .modify(forUnwrapped: inputView) { inputView in + AnyViewModifier { + $0._bottomBar { + inputView + .padding(.horizontal) + } } } } - .environment(\._chatViewPreferences, merging: _chatViewPreferences) - .onPreferenceChange(_ChatViewPreferences._PreferenceKey.self) { - self._chatViewPreferences = $0 - } } } -extension View { +extension View { public func onChatInterrupt( perform action: @escaping () -> Void ) -> some View { diff --git a/Sources/Intramodular/Core/_ChatItemConfiguration.swift b/Sources/Intramodular/Core/_ChatItemConfiguration.swift index b351241..06a7d6d 100644 --- a/Sources/Intramodular/Core/_ChatItemConfiguration.swift +++ b/Sources/Intramodular/Core/_ChatItemConfiguration.swift @@ -2,8 +2,8 @@ // Copyright (c) Vatsal Manot // - import Foundation +import SwiftUIZ struct _ChatItemConfiguration: Initiable, ExpressibleByNilLiteral { var onEdit: ((AnyChatItemContent) -> Void)? diff --git a/Sources/Intramodular/Message List/_ChatMessageListB.swift b/Sources/Intramodular/Message List/_ChatMessageListB.swift index 6d85f47..8e045cc 100644 --- a/Sources/Intramodular/Message List/_ChatMessageListB.swift +++ b/Sources/Intramodular/Message List/_ChatMessageListB.swift @@ -62,6 +62,7 @@ public struct _ChatMessageListB: View { .modifier(_ChatMessageListB_ScrollBehavior(scrollView: scrollView, lastItem: $lastItem)) } } + ._SwiftUIX_defaultScrollAnchor(.bottom) } } diff --git a/Sources/module.swift b/Sources/module.swift index e32f524..021ab6e 100644 --- a/Sources/module.swift +++ b/Sources/module.swift @@ -3,4 +3,3 @@ // @_exported import SwiftUIX -@_exported import SwiftUIZ