Skip to content

Reaction Snapshot Overlay Mispositioned. #805

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

Open
kylelol opened this issue Apr 15, 2025 · 7 comments
Open

Reaction Snapshot Overlay Mispositioned. #805

kylelol opened this issue Apr 15, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@kylelol
Copy link

kylelol commented Apr 15, 2025

Actual behaviour

I have a SwiftUI view with the following structure. On iPad I was to show the list of channels of the left 25% of the screen and the selected channel conversion on the right 75% of the screen:

    var body: some View {
        stackView
    }
    
    private var stackView: some View {
        GeometryReader { geometry in
            HStack(spacing: 0) {
                channelListView
                    .frame(width: geometry.size.width * 0.25)
                if let channel {
                    channelView(channel: channel)
                        .frame(width: geometry.size.width * 0.75)
                } else {
                    Text("No Conversation Selected")
                }
            }
        }
    }
    
    var channelListView: some View {
        StaffChatChannelListView(
            channelListController: chatClient.channelListController(
                query: ChannelListQuery(
                    filter: .and([
                        .containMembers(userIds: [chatClient.currentUserId ?? ""]),
                        .equal("student_status", to: true)
                    ])
                )
            )
        ) { channel in
            self.channel = channel
        }        
    }
    
    func channelView(channel: ChatChannel) -> some View {
        ChatChannelView(
            channelController: chatClient.channelController(
                for: channel.cid,
                messageOrdering: .topToBottom
            )
        )
        .id(channel.cid.rawValue)
    }

That renders the following screenshot:

Image

However, whenever I hold to read on a message the snapshot and overlay get completely mispositioned:

Image Image

Expected behaviour

I would expect the snapshot and overlays to be positioned correctly.

Steps to reproduce

1. Go to '...'
2. Tap on '...'
3. Scroll down to '...'
...

Which packages are you using?

No response

Which SDK version are you using?

4.76.0

Which iOS version is the issue reproducible?

iOS 18.4

Which iPhone Device is the issue reproducible?

iPad simulator

Which Xcode version are you using?

Xcode 16.2

@nuno-vieira
Copy link
Member

Hello @kylelol,

Unfortunately, this is a known limitation at the moment. The context view is quite coupled with the view hierarchy. So, for now, you will need to replace and customize this view.

In order to properly fix this on our side without breaking change, it will most likely involve re-writing this view, so we don't have an ETA at the moment.

We will keep you posted once we have more details.

Best,
Nuno

@nuno-vieira nuno-vieira added the bug Something isn't working label Apr 15, 2025
@kylelol
Copy link
Author

kylelol commented Apr 16, 2025

@nuno-vieira When you say replace and customize this view which part are you referring to specifically from the SDK?

@nuno-vieira
Copy link
Member

nuno-vieira commented Apr 16, 2025

Hi @kylelol,

You will need to provide your own view for ViewFactory.makeReactionsOverlayView()

Best,
Nuno

@kylelol
Copy link
Author

kylelol commented Apr 17, 2025

@nuno-vieira Thanks, I assume that will include having to provide a view for the list of reactions / message actions?

Image

@nuno-vieira
Copy link
Member

Hi @kylelol,

Yes, exactly, unfortunately it will require rebuilding the whole view at the moment. Maybe you can try using the native contextMenu.

Please do let us know if you have any difficulties.

Best,
Nuno

@martinmitrevski
Copy link
Contributor

You might also try changing the background:

public func makeReactionsBackgroundView(
        currentSnapshot: UIImage,
        popInAnimationInProgress: Bool
    ) -> some View {
          Color.black.opacity(0.3)
    }

Basically, instead of using the snapshot, to provide a transparent background.

Alternatively, you can even do an empty view that shows a menu or presentation detent, sth like this:

struct CustomReactionsContainer: View {
    
    @State var showDetent: Bool = false
    
    let messageDisplayInfo: MessageDisplayInfo
    var snapshot: UIImage
    var onBackgroundTap: () -> Void
    
    var body: some View {
        Color.clear.onAppear {
            showDetent = true
        }
        .sheet(isPresented: $showDetent, onDismiss: {
            onBackgroundTap()
        }, content: {
            CustomReactionOverlay(
                messageDisplayInfo: messageDisplayInfo,
                snapshot: snapshot,
                onBackgroundTap: onBackgroundTap
            )
            .presentationDetents([.height(height)])
        })
    }
    
    var height: CGFloat {
        if messageDisplayInfo.showsBottomContainer && !messageDisplayInfo.showsMessageActions {
            return 230
        } else {
            return 300
        }
    }
}

And then in the View Factory:

func makeReactionsOverlayView(
        channel: ChatChannel,
        currentSnapshot: UIImage,
        messageDisplayInfo: MessageDisplayInfo,
        onBackgroundTap: @escaping () -> Void,
        onActionExecuted: @escaping (MessageActionInfo) -> Void
    ) -> some View {
        CustomReactionsContainer(
            messageDisplayInfo: messageDisplayInfo,
            snapshot: currentSnapshot,
            onBackgroundTap: onBackgroundTap
        )
    }

Hope that helps, Martin

@kylelol
Copy link
Author

kylelol commented Apr 18, 2025

Thanks I will give that a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants