ChatUI: swiftformat fixes
parent
6652b1f4f3
commit
ca85d217ec
|
|
@ -130,14 +130,14 @@ struct ClawdisChatComposer: View {
|
||||||
.background(
|
.background(
|
||||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||||
.fill(ClawdisChatTheme.card))
|
.fill(ClawdisChatTheme.card))
|
||||||
.overlay(alignment: .topLeading) {
|
.overlay {
|
||||||
self.editorOverlay
|
VStack(alignment: .leading, spacing: 6) {
|
||||||
}
|
self.editorOverlay
|
||||||
.overlay(alignment: .bottom) {
|
HStack(alignment: .bottom, spacing: 8) {
|
||||||
HStack(alignment: .bottom, spacing: 8) {
|
self.connectionPill
|
||||||
self.connectionPill
|
Spacer(minLength: 0)
|
||||||
Spacer(minLength: 0)
|
self.sendButton
|
||||||
self.sendButton
|
}
|
||||||
}
|
}
|
||||||
.padding(8)
|
.padding(8)
|
||||||
}
|
}
|
||||||
|
|
@ -163,29 +163,26 @@ struct ClawdisChatComposer: View {
|
||||||
|
|
||||||
private var editorOverlay: some View {
|
private var editorOverlay: some View {
|
||||||
ZStack(alignment: .topLeading) {
|
ZStack(alignment: .topLeading) {
|
||||||
if self.viewModel.input.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
if self.viewModel.input.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||||
Text("Message Clawd…")
|
Text("Message Clawd…")
|
||||||
.foregroundStyle(.tertiary)
|
.foregroundStyle(.tertiary)
|
||||||
.padding(.horizontal, 8)
|
.padding(.horizontal, 6)
|
||||||
.padding(.vertical, 6)
|
.padding(.vertical, 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
ChatComposerTextView(text: self.$viewModel.input) {
|
ChatComposerTextView(text: self.$viewModel.input) {
|
||||||
self.viewModel.send()
|
self.viewModel.send()
|
||||||
}
|
}
|
||||||
.frame(minHeight: 32, idealHeight: 32, maxHeight: 72)
|
.frame(minHeight: 32, idealHeight: 32, maxHeight: 72)
|
||||||
.padding(.horizontal, 8)
|
.padding(.horizontal, 6)
|
||||||
.padding(.vertical, 5)
|
.padding(.vertical, 4)
|
||||||
.padding(.trailing, 44)
|
|
||||||
.padding(.bottom, 28)
|
|
||||||
#else
|
#else
|
||||||
TextEditor(text: self.$viewModel.input)
|
TextEditor(text: self.$viewModel.input)
|
||||||
.font(.system(size: 15))
|
.font(.system(size: 15))
|
||||||
.scrollContentBackground(.hidden)
|
.scrollContentBackground(.hidden)
|
||||||
.padding(.horizontal, 8)
|
.padding(.horizontal, 6)
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 6)
|
||||||
.padding(.bottom, 28)
|
|
||||||
.focused(self.$isFocused)
|
.focused(self.$isFocused)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,24 @@ public struct ClawdisChatView: View {
|
||||||
@State private var showSessions = false
|
@State private var showSessions = false
|
||||||
private let showsSessionSwitcher: Bool
|
private let showsSessionSwitcher: Bool
|
||||||
|
|
||||||
|
private enum Layout {
|
||||||
|
#if os(macOS)
|
||||||
|
static let outerPadding: CGFloat = 2
|
||||||
|
static let stackSpacing: CGFloat = 3
|
||||||
|
static let messageSpacing: CGFloat = 8
|
||||||
|
static let messageListPaddingTop: CGFloat = 0
|
||||||
|
static let messageListPaddingBottom: CGFloat = 2
|
||||||
|
static let messageListPaddingHorizontal: CGFloat = 4
|
||||||
|
#else
|
||||||
|
static let outerPadding: CGFloat = 6
|
||||||
|
static let stackSpacing: CGFloat = 6
|
||||||
|
static let messageSpacing: CGFloat = 12
|
||||||
|
static let messageListPaddingTop: CGFloat = 4
|
||||||
|
static let messageListPaddingBottom: CGFloat = 6
|
||||||
|
static let messageListPaddingHorizontal: CGFloat = 8
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public init(viewModel: ClawdisChatViewModel, showsSessionSwitcher: Bool = false) {
|
public init(viewModel: ClawdisChatViewModel, showsSessionSwitcher: Bool = false) {
|
||||||
self._viewModel = State(initialValue: viewModel)
|
self._viewModel = State(initialValue: viewModel)
|
||||||
self.showsSessionSwitcher = showsSessionSwitcher
|
self.showsSessionSwitcher = showsSessionSwitcher
|
||||||
|
|
@ -17,12 +35,12 @@ public struct ClawdisChatView: View {
|
||||||
ClawdisChatTheme.surface
|
ClawdisChatTheme.surface
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
|
||||||
VStack(spacing: 6) {
|
VStack(spacing: Layout.stackSpacing) {
|
||||||
self.messageList
|
self.messageList
|
||||||
ClawdisChatComposer(viewModel: self.viewModel)
|
ClawdisChatComposer(viewModel: self.viewModel)
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 6)
|
.padding(.horizontal, Layout.outerPadding)
|
||||||
.padding(.vertical, 6)
|
.padding(.vertical, Layout.outerPadding)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
||||||
|
|
@ -39,7 +57,7 @@ public struct ClawdisChatView: View {
|
||||||
private var messageList: some View {
|
private var messageList: some View {
|
||||||
ScrollViewReader { proxy in
|
ScrollViewReader { proxy in
|
||||||
ScrollView {
|
ScrollView {
|
||||||
LazyVStack(spacing: 12) {
|
LazyVStack(spacing: Layout.messageSpacing) {
|
||||||
ForEach(self.viewModel.messages) { msg in
|
ForEach(self.viewModel.messages) { msg in
|
||||||
ChatMessageBubble(message: msg)
|
ChatMessageBubble(message: msg)
|
||||||
.frame(
|
.frame(
|
||||||
|
|
@ -66,9 +84,9 @@ public struct ClawdisChatView: View {
|
||||||
.frame(height: 1)
|
.frame(height: 1)
|
||||||
.id(self.scrollerBottomID)
|
.id(self.scrollerBottomID)
|
||||||
}
|
}
|
||||||
.padding(.top, 4)
|
.padding(.top, Layout.messageListPaddingTop)
|
||||||
.padding(.bottom, 6)
|
.padding(.bottom, Layout.messageListPaddingBottom)
|
||||||
.padding(.horizontal, 8)
|
.padding(.horizontal, Layout.messageListPaddingHorizontal)
|
||||||
}
|
}
|
||||||
.background(
|
.background(
|
||||||
RoundedRectangle(cornerRadius: 16, style: .continuous)
|
RoundedRectangle(cornerRadius: 16, style: .continuous)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue