Preserve scroll state across conversation view layout changes, if possible.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent eaa1f4f318
commit 7d32491968

@ -5,8 +5,8 @@ target 'Signal' do
pod 'ATAppUpdater' pod 'ATAppUpdater'
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
#pod 'AxolotlKit', path: '../SignalProtocolKit' #pod 'AxolotlKit', path: '../SignalProtocolKit'
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'signal-master' #pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'signal-master'
#pod 'JSQMessagesViewController', path: '../JSQMessagesViewController' pod 'JSQMessagesViewController', path: '../JSQMessagesViewController'
pod 'PureLayout' pod 'PureLayout'
pod 'OpenSSL', git: 'https://github.com/WhisperSystems/OpenSSL-Pod' pod 'OpenSSL', git: 'https://github.com/WhisperSystems/OpenSSL-Pod'
pod 'Reachability' pod 'Reachability'

@ -114,7 +114,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- ATAppUpdater - ATAppUpdater
- AxolotlKit (from `https://github.com/WhisperSystems/SignalProtocolKit.git`) - AxolotlKit (from `https://github.com/WhisperSystems/SignalProtocolKit.git`)
- JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController.git`, branch `signal-master`) - JSQMessagesViewController (from `../JSQMessagesViewController`)
- OpenSSL (from `https://github.com/WhisperSystems/OpenSSL-Pod`) - OpenSSL (from `https://github.com/WhisperSystems/OpenSSL-Pod`)
- PureLayout - PureLayout
- Reachability - Reachability
@ -125,8 +125,7 @@ EXTERNAL SOURCES:
AxolotlKit: AxolotlKit:
:git: https://github.com/WhisperSystems/SignalProtocolKit.git :git: https://github.com/WhisperSystems/SignalProtocolKit.git
JSQMessagesViewController: JSQMessagesViewController:
:branch: signal-master :path: ../JSQMessagesViewController
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
OpenSSL: OpenSSL:
:git: https://github.com/WhisperSystems/OpenSSL-Pod :git: https://github.com/WhisperSystems/OpenSSL-Pod
SignalServiceKit: SignalServiceKit:
@ -138,9 +137,6 @@ CHECKOUT OPTIONS:
AxolotlKit: AxolotlKit:
:commit: 6e9d5e8c3dc87e397b4b7485172507b0990a22dd :commit: 6e9d5e8c3dc87e397b4b7485172507b0990a22dd
:git: https://github.com/WhisperSystems/SignalProtocolKit.git :git: https://github.com/WhisperSystems/SignalProtocolKit.git
JSQMessagesViewController:
:commit: 868cf70fae0f3b54c3cfa7773ef03578d209b668
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git
OpenSSL: OpenSSL:
:commit: b2d3c149102032a09aefbfb470885db4aa83efad :commit: b2d3c149102032a09aefbfb470885db4aa83efad
:git: https://github.com/WhisperSystems/OpenSSL-Pod :git: https://github.com/WhisperSystems/OpenSSL-Pod
@ -171,6 +167,6 @@ SPEC CHECKSUMS:
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266
PODFILE CHECKSUM: 2f847bb25e70d1d376f38cf21ae08624fa6ed67d PODFILE CHECKSUM: 4a6db311736b5ab36b660af813dcdf0af62da48c
COCOAPODS: 1.2.1 COCOAPODS: 1.2.1

@ -169,7 +169,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
UIDocumentPickerDelegate, UIDocumentPickerDelegate,
UIImagePickerControllerDelegate, UIImagePickerControllerDelegate,
UINavigationControllerDelegate, UINavigationControllerDelegate,
UITextViewDelegate> UITextViewDelegate,
JSQLayoutDelegate>
@property (nonatomic) TSThread *thread; @property (nonatomic) TSThread *thread;
@property (nonatomic) TSMessageAdapter *lastDeliveredMessage; @property (nonatomic) TSMessageAdapter *lastDeliveredMessage;
@ -245,6 +246,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
@property (nonatomic) BOOL shouldObserveDBModifications; @property (nonatomic) BOOL shouldObserveDBModifications;
@property (nonatomic) BOOL viewHasEverAppeared; @property (nonatomic) BOOL viewHasEverAppeared;
@property (nonatomic) BOOL wasScrolledToBottomBeforeKeyboardShow; @property (nonatomic) BOOL wasScrolledToBottomBeforeKeyboardShow;
@property (nonatomic) BOOL wasScrolledToBottomBeforeLayoutChange;
@end @end
@ -404,7 +406,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
// We only want to update scroll state for non-empty show events. // We only want to update scroll state for non-empty show events.
BOOL isPresenting = endValue.size.height > 0.f; BOOL isPresenting = endValue.size.height > 0.f;
if (isPresenting) { if (isPresenting && self.wasScrolledToBottomBeforeKeyboardShow) {
[self scrollToBottomImmediately]; [self scrollToBottomImmediately];
} }
} }
@ -543,6 +545,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
- (void)viewDidLoad - (void)viewDidLoad
{ {
self.collectionView.layoutDelegate = self;
[super viewDidLoad]; [super viewDidLoad];
[self.navigationController.navigationBar setTranslucent:NO]; [self.navigationController.navigationBar setTranslucent:NO];
@ -4461,6 +4465,24 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
[self updateNavigationBarSubtitleLabel]; [self updateNavigationBarSubtitleLabel];
} }
#pragma mark - JSQLayoutDelegate
- (void)jsqWillChangeLayout
{
OWSAssert([NSThread isMainThread]);
self.wasScrolledToBottomBeforeLayoutChange = [self isScrolledToBottom];
}
- (void)jsqDidChangeLayout
{
OWSAssert([NSThread isMainThread]);
if (self.wasScrolledToBottomBeforeLayoutChange) {
[self scrollToBottomImmediately];
}
}
#pragma mark - Class methods #pragma mark - Class methods
+ (UINib *)nib + (UINib *)nib

Loading…
Cancel
Save