Last active
September 20, 2024 22:20
-
-
Save apatronl/d2264c81ee3c655612c0b38b12d34a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ChatView: View { | |
@Bindable private var viewModel: ChatViewModel = ChatViewModel() | |
var body: some View { | |
NavigationStack { | |
VStack { | |
ChatMessagesList(viewModel: viewModel) | |
HStack { | |
MessageTextField(draftMessage: $viewModel.draftMessage) | |
SendMessageButton { | |
viewModel.sendMessage() | |
} | |
.disabled(!viewModel.canSendMessage) | |
} | |
.padding(8) | |
} | |
.navigationTitle("Chat") | |
.toolbar { | |
Button( | |
action: { | |
// Trigger translation | |
viewModel.triggerTranslation() | |
}, | |
label: { | |
Image(systemName: "translate") | |
} | |
) | |
} | |
} | |
.translationTask(viewModel.translationConfiguration) { session in | |
// Translate all messages | |
await viewModel.translateAllMessages(using: session) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment