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

Reactions does not show up in presented view controller #18

Open
mzeeshanid opened this issue Jan 16, 2021 · 3 comments
Open

Reactions does not show up in presented view controller #18

mzeeshanid opened this issue Jan 16, 2021 · 3 comments

Comments

@mzeeshanid
Copy link

Here is the reproducible example.

Screen.Recording.2021-01-16.at.11.14.02.AM.mov

ReactionButton.zip

@mzeeshanid
Copy link
Author

I think this is happening mainly because of this:

private var rootView: UIView? {
        UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.view
    }

@mzeeshanid
Copy link
Author

Replace the above getter with the following fix this problem
Stackoverflow

private var rootView: UIView? {
        var currentVc = UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController
        while let presentedVc = currentVc?.presentedViewController {
            if let navVc = (presentedVc as? UINavigationController)?.viewControllers.last {
                currentVc = navVc
            } else if let tabVc = (presentedVc as? UITabBarController)?.selectedViewController {
                currentVc = tabVc
            } else {
                currentVc = presentedVc
            }
        }
        return currentVc?.view
    }

However, I think the reactions view should be shown up from the centre of reaction button instead of showing from the centre of view. Like in my case i have to show only 2 reactions and the reaction view show up in the centre of the screen which look ugly.

@mzeeshanid
Copy link
Author

If any one wants to show the reactions view from the targeted view then replace the extension:

extension ReactionButton.Config {
    
    func rect(items: Int, originalPos: CGPoint, trait: UITraitCollection) -> CGRect {
        let originalPos = CGPoint(x: originalPos.x, y: originalPos.y - heightForSize - 10)
        let option = CGFloat(items)
        let width = (option + 1) * spacing + self.size * option
        
        return CGRect(origin: originalPos, size: CGSize(width: width, height: heightForSize))
    }
    
}

I am not creating pull request for this one ;)
Thanks

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

1 participant