I'm pulling down a list of Gif images from Firebase and displaying them using a WebView. I loop through my Set<URL>
of Gif images and throw them into the WebView sitting inside a Scroller. Here's the function:
private func gifGallery() -> some View {
ScrollView(.horizontal, showsIndicators: false) {
//LazyHGrid(rows: [GridItem(.flexible())], spacing: 4) {
HStack(spacing: 6) {
ForEach(Array(gifImages.gifListUrls)) { gifImageUrl in
Button(action: {
// Button Action
}){
WebView(url: gifImageUrl)
}
}
.frame(width: 300, height: 165)
}
}
}
I'm stuck with the "Button" functionality I'd like to incoporate. While each Gif is now tappable as a button, When the user taps an image, I'd like to update that image's border color and background color to be green or something, indicating it has been selected.
Given that these images are URL data types, I'm having trouble comparing them and thus updating the border and background coloring. If they were strings, it would be cake.
How can I get them to add border coloring when tapped?