-
Notifications
You must be signed in to change notification settings - Fork 593
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
Allowing storyboard layout & custom main view class for BaseChatViewController #323
Conversation
…ChatViewControllerView. Allows using storyboards and customize view class.
…iew in BaseChatViewController subclass.
Codecov Report
@@ Coverage Diff @@
## master #323 +/- ##
=========================================
Coverage ? 63.46%
=========================================
Files ? 63
Lines ? 3525
Branches ? 0
=========================================
Hits ? 2237
Misses ? 1288
Partials ? 0
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Can you apply requested changes?
@@ -167,7 +176,13 @@ open class BaseChatViewController: UIViewController, UICollectionViewDataSource, | |||
sSelf.isAdjustingInputContainer = false | |||
} | |||
self.keyboardTracker = KeyboardTracker(viewController: self, inputContainer: self.inputContainer, layoutBlock: layoutBlock, notificationCenter: self.notificationCenter) | |||
(self.view as? BaseChatViewControllerView)?.bmaInputAccessoryView = self.keyboardTracker?.trackingView | |||
|
|||
// Compiler can't understand this cast inline. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because protocol is not restricted for classes only. Value types can implement it as well. Compiler doesn't allow to modify value type declared with let
keyword. Can you fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip. Fixed.
// Compiler can't understand this cast inline. | ||
// Although we are only setting a property on a constant, it believes that we change reference to it. | ||
// We do not. | ||
if var customView = (self.view as? BaseChatViewControllerViewProtocol) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, remove parentheses
…ned up setting bmaAccessoryInputView
I've faced a problem trying to subclass an already existing VC from BaseChatViewController.
It had some storyboard layout, and its view was of a custom class with some presentation logic.
However loadView() in BaseChatViewController replaced VC's main view with BaseChatViewControllerView & setupKeyboardTracker() didn't set bmaInputAccessoryView unless it stayed that way.
Now we can work with custom view taken from storyboard:
_
var bmaInputAccessoryView: UIView?
override var inputAccessoryView: UIView? {
return self.bmaInputAccessoryView
}
_