-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Conversation
…ternal inconsistency exception on UIDictation private API 🙏
[skip ci]
|
||
- (SLKTypingIndicatorView *)typingIndicatorView | ||
{ | ||
return (SLKTypingIndicatorView *)self.typingIndicatorProxyView; |
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 will probably crash if you try to do something with the returned value, and it isn't really a kind of SLKTypingIndicatorView
. You may want to return nil
in this case?
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.
Good point! Will fix that. Thanks for all your feedback!
… nil for `typingIndicatorView` property
…tocol`. Updates doc and sample project too.
@sveinhal I've made some fixes, considering all your feedback. Mind having a look once more? |
SLKTextViewController uses Auto-Layout internally, so this API is the most appropriate way to update the view dimensions dynamically. | ||
You can return UIViewNoIntrinsicMetric for any intrinsic size of a given dimension. | ||
*/ | ||
- (CGSize)intrinsicContentSize; |
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.
Why specify this? The typing indicator class is already required to be a kind of UIView
and this class already conforms to this protocol. Also, SLKTextViewController
uses - [UIView systemLayoutSizeFittingSize:]
internally, so it is not calling this method directly. It is not necessary for correct behavior. In my specific example, I'm also using auto-layout inside the custom typing indicator view, and it works perfectly without supplying an implementation of intrinsicContentSize
, since all of it's subviews either do implement it, or have explicit size constraints (and explicit margins to the superview).
I have a view that has two subviews. Both of these have explicit height and width constraints, as well as explicit margins to the superview, and inter spacing between them. Therefore, systemLayoutSizeFittingSize:
is able to deterministically deduce a size, without any of the views implementing intrinsicContentSize
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.
Anyways: Having this requirement here does nothing (except maybe set expectations to the developer). Leaving an implementation out keeps the compiler silent, since the UIView
implements 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.
You're right! I totally forgot we were using systemLayoutSizeFittingSize:
now, which is way better for dynamic sizes. I'll remove that required method from the protocol.
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.
You're right! I totally forgot we were using systemLayoutSizeFittingSize:
now, which is way better for dynamic sizes. I'll remove that required method from the protocol.
I'm satisfied with this, but I think the quirks of implementing a custom protocol-conforming class in Swift justifies a note somewhere in the Anyways, you get my 👍 for merging this! |
Contra: I discovered a bug: If the scroll view is scrolled up when setting |
I don't understand this requirement: // Don't show if the content offset is not at top (when inverted) or at bottom (when not inverted)
if ((self.isInverted && ![self.scrollViewProxy slk_isAtTop]) || (!self.isInverted && ![self.scrollViewProxy slk_isAtBottom])) {
return NO;
} Maybe that should be configurable. Also, it behaves different when showing/hiding. |
…rotocol`. No really needed since we're using `systemLayoutSizeFittingSize:` internally.
About |
I guess I can override the method in my subclass of |
But when leaving it on, it still had a bug. The typing indicator would display, but not hide when scrolled up. (I didn't try to see if it would hide if I scrolled up while it was visible, but that's another issue) |
Anyways: If you clean up the protocol, and preferably add a note about Swift in the read me, I think this is production quality :-) Great work! |
Sounds good! What do you mean by "clean up the protocol"? |
Remove the
Sure, but calling It may be some quirks in the frame calculations again. I'm not displaying my VC full screen ¯_(ツ)_/¯ I've also confirmed that this isn't a regression, so it is unrelated to this pull request. |
That's done in 52c201e
Are you overriding
|
Now I am (or rather — the Swift equivalent). So that solved my problem. Now it's always displayed or hidden with a nice animation whenever I set the However, before I added this, and just let the However, this is also the current behavior for my particular view hierarchy in master as well, so I suggest we close this discussion, and perhaps open another issue for it, if needed :-) |
👍 |
Adds custom typing indicator support
Over at appear.in we usually give each other a cake when something is ready to be merged. 🍰 |
Thanks for all your input @sveinhal ! 🙌 |
Thank you for creating a great open source component, and also a great product which we use every day both on iOS and the desktop. And: Which has great integration with the stuff I'm working on every day: https://appear.in (shameless plug) |
Do you have an example of this in Swift? |
Inspired from @sveinhal's implementation in #202.
It now uses KVO internally, observing the
visible
propery's changes to properly update the view constraints constants and animately present the typing indicator view.By simply conforming to
SLKTypingIndicatorProtocol
required methods, it should be very easy to add any sort of custom typing indicator view.I have added a custom typing indicator view to the sample project:

PS: Thanks @sveinhal for taking the initiative to do this! I felt the need to refactor your implementation for a more friendly approach. Observing the
hidden
property wasn't enough, since it would force the view to hide when dismissing the typing indicator. I have also taken the time to refactor and improve other related to logic to the default typing indicator view.This update should be backwards compatible, but might still need some testing before merging.