Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to indicate other user is typing with a (...) message? #90

Open
jkanalakis opened this issue Sep 12, 2024 · 4 comments
Open

How to indicate other user is typing with a (...) message? #90

jkanalakis opened this issue Sep 12, 2024 · 4 comments

Comments

@jkanalakis
Copy link

jkanalakis commented Sep 12, 2024

I came across this request and have a very similar question. I don't have multiple users in a chat, only one. But the same question, how can I show a "..." message bubble to indicate that the other user is typing a response? Right now, I present a full-screen "Thinking..." overlay but it is not very satisfying. I would love to present a "..." that is ideally animated (lottie, gif, etc.) to show that a response is coming. Here's how my app looks today for some context.

Can you offer any advice?

Thank you,

John K.

@f3dm76
Copy link
Collaborator

f3dm76 commented Sep 12, 2024

Hey @jkanalakis, unfortunately we do not have time for open source right now. You are most welcome to support this library by submitting a PR adding this functionality

@jkanalakis
Copy link
Author

@f3dm76 Thank you, Alisa. I completely understand. I am a big fan of the ExyteChat library and all of the open source work that your team has done.
Best wishes,
John K.

@floriangbh
Copy link

Hello,

I think you can use betweenListAndInputViewBuilder modifier to add a bubble, like this :

struct ContentView: View {
    @StateObject var viewModel = ChatViewModel()
    
    var body: some View {
        NavigationStack {
            VStack {
                ChatView(messages: viewModel.messages) { draft in
                    viewModel.send(draft: draft)
                }
                .setAvailableInput(.textOnly)
                .betweenListAndInputViewBuilder {
                    VStack {
                        if viewModel.isLoading {
                            HStack {
                                LottieView(animation: .named("message-typing"))
                                    .looping()
                                    .frame(width: 120)
                                Spacer()
                            }
                            .frame(height: 120)
                        } else {
                            EmptyView()
                        }
                    }
                }
            }
        }
    }
}

Not perfect, but it do the job !

@jkanalakis
Copy link
Author

@floriangbh Thank you for the great idea! I ended up just posting an empty message with "..." and then removing it when the response arrives. I love your solution and am going to give it a try today!
John K.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants