Skip to content

Commit

Permalink
improvements to menu, show recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
ctate committed May 22, 2024
1 parent bf33464 commit 7aca213
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
21 changes: 11 additions & 10 deletions platforms/apple/Crystal/Chat/ChatToolbarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ struct ChatToolbarView: ToolbarContent {
.keyboardShortcut("/", modifiers: .command)
}
ToolbarItem(placement: .principal) {
HStack {
Image(findProviderByModelId(selectedModelId)?.image ?? "")
.resizable()
.scaledToFit()
.frame(width: 16, height: 16)
Text(selectedModelId)
}
}
ToolbarItem(placement: .confirmationAction) {
Button(action: {
showPopover = true
}) {
Image(systemName: showPopover ? "chevron.down" : "chevron.right")
HStack(alignment: .center) {
Image(findProviderByModelId(selectedModelId)?.image ?? "")
.resizable()
.scaledToFit()
.frame(width: 16, height: 16)

Text(selectedModelId)
.foregroundColor(.white)

Image(systemName: showPopover ? "chevron.down" : "chevron.right")
}
}
.popover(isPresented: $showPopover, arrowEdge: .bottom) {
ScrollView {
Expand Down
25 changes: 18 additions & 7 deletions platforms/apple/Crystal/Chat/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ struct ChatContentView: View {
Spacer()

Button(action: {
viewModel.sendMessage(
userInput,
conversationManager: conversationManager,
modelContext: modelContext
)
userInput = ""
if userInput.isEmpty {
showRecorder.toggle()
} else {
viewModel.sendMessage(
userInput,
conversationManager: conversationManager,
modelContext: modelContext
)
userInput = ""
}
}) {
Image(systemName: "arrow.up")
Image(systemName: userInput.isEmpty ? "mic" : "arrow.up")
.imageScale(.large)
.foregroundColor(.white)
}
Expand Down Expand Up @@ -286,6 +290,13 @@ struct ChatView: View {
dragOffset = isSidebarVisible ? sidebarWidth : 0
}
)
.onChange(of: isSidebarVisible) {
if isSidebarVisible {
let generator = UINotificationFeedbackGenerator()
generator.prepare()
generator.notificationOccurred(.success)
}
}
}
#endif
}
Expand Down

0 comments on commit 7aca213

Please sign in to comment.