Skip to content

Commit d98a483

Browse files
committed
Adjust chat panel UI
1 parent bd5064e commit d98a483

6 files changed

Lines changed: 71 additions & 8 deletions

File tree

Core/Sources/ChatGPTChatTab/ChatPanel.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct ChatPanel: View {
1818
Divider()
1919
ChatPanelInputArea(chat: chat)
2020
}
21-
.background(.regularMaterial)
21+
.background(.clear)
2222
.onAppear { chat.send(.appear) }
2323
}
2424
}
@@ -86,13 +86,23 @@ struct ChatPanelMessages: View {
8686
}
8787
.modify { view in
8888
if #available(macOS 13.0, *) {
89-
view.listRowSeparator(.hidden).listSectionSeparator(.hidden)
89+
view
90+
.listRowSeparator(.hidden)
91+
.listSectionSeparator(.hidden)
9092
} else {
9193
view
9294
}
9395
}
9496
}
9597
.listStyle(.plain)
98+
.listRowBackground(EmptyView())
99+
.modify { view in
100+
if #available(macOS 13.0, *) {
101+
view.scrollContentBackground(.hidden)
102+
} else {
103+
view
104+
}
105+
}
96106
.coordinateSpace(name: scrollSpace)
97107
.preference(
98108
key: ListHeightPreferenceKey.self,

Core/Sources/ChatGPTChatTab/Styles.swift

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extension Color {
99
if appearance.isDarkMode {
1010
return #colorLiteral(red: 0.1580096483, green: 0.1730263829, blue: 0.2026666105, alpha: 1)
1111
}
12-
return .white
12+
return #colorLiteral(red: 0.9896564803, green: 0.9896564803, blue: 0.9896564803, alpha: 1)
1313
}))
1414
}
1515

@@ -18,7 +18,7 @@ extension Color {
1818
if appearance.isDarkMode {
1919
return #colorLiteral(red: 0.2284317913, green: 0.2145925438, blue: 0.3214019983, alpha: 1)
2020
}
21-
return #colorLiteral(red: 0.896820749, green: 0.8709097223, blue: 0.9766687925, alpha: 1)
21+
return #colorLiteral(red: 0.957824412, green: 0.947133649, blue: 0.9906365955, alpha: 1)
2222
}))
2323
}
2424
}
@@ -92,6 +92,60 @@ extension MarkdownUI.Theme {
9292
}
9393
}
9494

95+
static func instruction(fontSize: Double) -> MarkdownUI.Theme {
96+
.gitHub.text {
97+
ForegroundColor(.primary)
98+
BackgroundColor(Color.clear)
99+
FontSize(fontSize)
100+
}
101+
.code {
102+
FontFamilyVariant(.monospaced)
103+
FontSize(.em(0.85))
104+
BackgroundColor(Color.secondary.opacity(0.2))
105+
}
106+
.codeBlock { configuration in
107+
let wrapCode = UserDefaults.shared.value(for: \.wrapCodeInChatCodeBlock)
108+
109+
if wrapCode {
110+
configuration.label
111+
.codeBlockLabelStyle()
112+
.codeBlockStyle(configuration)
113+
} else {
114+
ScrollView(.horizontal) {
115+
configuration.label
116+
.codeBlockLabelStyle()
117+
}
118+
.workaroundForVerticalScrollingBugInMacOS()
119+
.codeBlockStyle(configuration)
120+
}
121+
}
122+
.table { configuration in
123+
configuration.label
124+
.fixedSize(horizontal: false, vertical: true)
125+
.markdownTableBorderStyle(.init(
126+
color: .init(nsColor: .separatorColor),
127+
strokeStyle: .init(lineWidth: 1)
128+
))
129+
.markdownTableBackgroundStyle(
130+
.alternatingRows(Color.secondary.opacity(0.1), Color.secondary.opacity(0.2))
131+
)
132+
.markdownMargin(top: 0, bottom: 16)
133+
}
134+
.tableCell { configuration in
135+
configuration.label
136+
.markdownTextStyle {
137+
if configuration.row == 0 {
138+
FontWeight(.semibold)
139+
}
140+
BackgroundColor(nil)
141+
}
142+
.fixedSize(horizontal: false, vertical: true)
143+
.padding(.vertical, 6)
144+
.padding(.horizontal, 13)
145+
.relativeLineSpacing(.em(0.25))
146+
}
147+
}
148+
95149
static func functionCall(fontSize: Double) -> MarkdownUI.Theme {
96150
.gitHub.text {
97151
ForegroundColor(.secondary)

Core/Sources/ChatGPTChatTab/Views/BotMessage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct BotMessage: View {
6666
.stroke(Color(nsColor: .separatorColor), lineWidth: 1)
6767
}
6868
.padding(.leading, 8)
69-
.shadow(color: .black.opacity(0.1), radius: 2)
69+
.shadow(color: .black.opacity(0.05), radius: 6)
7070
.contextMenu {
7171
Button("Copy") {
7272
NSPasteboard.general.clearContents()

Core/Sources/ChatGPTChatTab/Views/Instructions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct Instruction: View {
7171
func body(content: Content) -> some View {
7272
content
7373
.textSelection(.enabled)
74-
.markdownTheme(.custom(fontSize: chatFontSize))
74+
.markdownTheme(.instruction(fontSize: chatFontSize))
7575
.opacity(0.8)
7676
.frame(maxWidth: .infinity, alignment: .leading)
7777
.padding()

Core/Sources/ChatGPTChatTab/Views/UserMessage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct UserMessage: View {
3434
}
3535
.padding(.leading)
3636
.padding(.trailing, 8)
37-
.shadow(color: .black.opacity(0.1), radius: 2)
37+
.shadow(color: .black.opacity(0.05), radius: 6)
3838
.frame(maxWidth: .infinity, alignment: .trailing)
3939
.contextMenu {
4040
Button("Copy") {

Core/Sources/SuggestionWidget/ChatWindowView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct ChatWindowView: View {
4343
}
4444
.xcodeStyleFrame(cornerRadius: 10)
4545
.ignoresSafeArea(edges: .top)
46-
.background(.regularMaterial)
4746
.onChange(of: viewStore.state.isPanelDisplayed) { isDisplayed in
4847
toggleVisibility(isDisplayed)
4948
}

0 commit comments

Comments
 (0)