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

Fix inputContainer position when presenting BaseChatViewController as child #338

Merged
merged 2 commits into from
Jul 26, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Chatto/Source/ChatController/BaseChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,15 @@ open class BaseChatViewController: UIViewController, UICollectionViewDataSource,
// If we have been pushed on nav controller and hidesBottomBarWhenPushed = true, then ignore bottomLayoutMargin
// because it has incorrect value when we actually have a bottom bar (tabbar)

if self.hidesBottomBarWhenPushed && (navigationController?.viewControllers.count ?? 0) > 1 && navigationController?.viewControllers.last == self {
// Also if instance of BaseChatViewController is added as childViewController to another view controller, we had to check all this stuf on parent instance instead of self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KaterinaPetrova Thank you for your changes!

May I ask you to move this code to a separate function setupInputContainerBottomConstraint? This method becomes too big now

Also, can you replace Ctrl with Controller. We are trying to avoid shorthand writing in this repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of coarse, thanks for review. I've put this function near inputContainerBottomConstraint variable declaration, is it okay?

let navigatedCtrl: UIViewController
if let parent = self.parent, !(parent is UINavigationController || parent is UITabBarController) {
navigatedCtrl = parent
} else {
navigatedCtrl = self
}

if navigatedCtrl.hidesBottomBarWhenPushed && (navigationController?.viewControllers.count ?? 0) > 1 && navigationController?.viewControllers.last == navigatedCtrl {
self.inputContainerBottomConstraint.constant = 0
} else {
self.inputContainerBottomConstraint.constant = self.bottomLayoutGuide.length
Expand Down