Skip to content

Enhancement Image Background #124

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

Closed
fred-bowker opened this issue Jan 23, 2025 · 10 comments
Closed

Enhancement Image Background #124

fred-bowker opened this issue Jan 23, 2025 · 10 comments

Comments

@fred-bowker
Copy link
Contributor

I can't find a current way to set an image background to be the background of the message view, pretty sure this would be simple enough to implement and I think it would be part of the .chatTheme(
ChatTheme(

I'm happy to have a go at making the change and putting up a pull request but want to check to see if there is already a way of doing this and I'm just missing something.

Image
Image

@btoms20
Copy link
Contributor

btoms20 commented Jan 24, 2025

Hey @fred-bowker, you could set the ChatThemes mainBG to .clear and place an Image in the ChatViews .background() modifier.

ChatView( ... )
    .chatTheme(colors: .init(mainBG: .clear))
    .background { AsyncImage(url: URL(string: "https://...")) }

Let me know if that lets you achieve the effect you're after.

@fred-bowker
Copy link
Contributor Author

Hi @btoms20, this is working, the only issue is that when the keyboard appears, it squashes the background up. The chat looks pretty good with a background included, I'll put up a pull request with the backgrounds included on one of the examples, I think this would be useful to other people.

@btoms20
Copy link
Contributor

btoms20 commented Jan 24, 2025

Hey @fred-bowker, I'm not by my computer at the moment, so I don't know the correct syntax but you could prevent the squishing of the Image by either placing the AsyncImage behind the ChatView in its own element or by applying an .ignoresSafeArea(.keyboard) modifier to the AsyncImage? Hope that helps 👍

@fred-bowker
Copy link
Contributor Author

Hi @btoms20 that works great thanks, I'll maybe put a pull request up for including this as an option in .chatTheme(, and add it to an example. I have a fairly large pull request up for adding giphy functionality, so I'll wait till that get's reviewed and merged first

@btoms20
Copy link
Contributor

btoms20 commented Mar 30, 2025

@fred-bowker, congrats on merging this in #157.

I noticed a couple small things that you might want to fix:

  • The reply view uses the themes background color so setting it to .clear makes the reply pretty difficult to read, especially in dark mode.
  • The background images don't extend beyond the safe area like the ChatView does, this results in an awkward space at the bottom of the screen while in portrait mode and along the edges when in landscape mode.

Image

  • Also, in landscape mode, the image is distorted pretty bad, you should consider extending the image structure to accept landscape versions of images as well as the current portrait ones then apply them appropriately for the user depending on device orientation.

Image

Otherwise it looks great 👍

@fred-bowker
Copy link
Contributor Author

Hi @btoms20 thanks for this feedback,

The reply view background and adding images for landscape should be easy changes.

Can you show me an example of with and without for "The background images don't extend beyond the safe area like the ChatView does", as I can't see what you are meaning here.

Thanks Fred

@f3dm76
Copy link
Collaborator

f3dm76 commented Apr 3, 2025

Hey @fred-bowker, I think @btoms20 means this part.
Image

@fred-bowker
Copy link
Contributor Author

Thanks @f3dm76, I'll see what i can do for getting this fixed

@fred-bowker
Copy link
Contributor Author

@btoms20 Hi, I've made the changes in pull request #183

@fred-bowker
Copy link
Contributor Author

@btoms20 @f3dm76 I think this issue can be closed now

@f3dm76 f3dm76 closed this as completed May 29, 2025
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