Fix view controller popping animation bug

This commit is contained in:
Niels Andriesse 2021-02-12 15:52:14 +11:00
parent 2fd1707cba
commit c1d9270f1b
5 changed files with 49 additions and 31 deletions

View File

@ -220,6 +220,7 @@
B821494F25D4E163009C0F2A /* BodyTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B821494E25D4E163009C0F2A /* BodyTextView.swift */; };
B82149B825D60393009C0F2A /* BlockedModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82149B725D60393009C0F2A /* BlockedModal.swift */; };
B82149C125D605C6009C0F2A /* InfoBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B82149C025D605C6009C0F2A /* InfoBanner.swift */; };
B8214A2B25D63EB9009C0F2A /* MessagesTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8214A2A25D63EB9009C0F2A /* MessagesTableView.swift */; };
B8269D2925C7A4B400488AB4 /* InputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8269D2825C7A4B400488AB4 /* InputView.swift */; };
B8269D3325C7A8C600488AB4 /* InputViewButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8269D3225C7A8C600488AB4 /* InputViewButton.swift */; };
B8269D3D25C7B34D00488AB4 /* InputTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8269D3C25C7B34D00488AB4 /* InputTextView.swift */; };
@ -1269,6 +1270,7 @@
B821494E25D4E163009C0F2A /* BodyTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BodyTextView.swift; sourceTree = "<group>"; };
B82149B725D60393009C0F2A /* BlockedModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockedModal.swift; sourceTree = "<group>"; };
B82149C025D605C6009C0F2A /* InfoBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoBanner.swift; sourceTree = "<group>"; };
B8214A2A25D63EB9009C0F2A /* MessagesTableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagesTableView.swift; sourceTree = "<group>"; };
B8269D2825C7A4B400488AB4 /* InputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputView.swift; sourceTree = "<group>"; };
B8269D3225C7A8C600488AB4 /* InputViewButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputViewButton.swift; sourceTree = "<group>"; };
B8269D3C25C7B34D00488AB4 /* InputTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputTextView.swift; sourceTree = "<group>"; };
@ -2245,6 +2247,7 @@
B821494E25D4E163009C0F2A /* BodyTextView.swift */,
B82149B725D60393009C0F2A /* BlockedModal.swift */,
B82149C025D605C6009C0F2A /* InfoBanner.swift */,
B8214A2A25D63EB9009C0F2A /* MessagesTableView.swift */,
);
path = "Views & Modals";
sourceTree = "<group>";
@ -5047,6 +5050,7 @@
45A6DAD61EBBF85500893231 /* ReminderView.swift in Sources */,
34D1F0881F8678AA0066283D /* ConversationViewLayout.m in Sources */,
B82B408E239DC00D00A248E7 /* DisplayNameVC.swift in Sources */,
B8214A2B25D63EB9009C0F2A /* MessagesTableView.swift in Sources */,
B835246E25C38ABF0089A44F /* ConversationVC.swift in Sources */,
B821494625D4D6FF009C0F2A /* URLModal.swift in Sources */,
4CA485BB2232339F004B9E7D /* PhotoCaptureViewController.swift in Sources */,

View File

@ -5,9 +5,8 @@
// Remaining send logic
// Subtitle
// Resending failed messages
// Tapping links in link previews
// Link previews
// Animation glitch when leaving conversation (probably because vc is resigning first responder)
// Slight paging glitch
final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewDataSource, UITableViewDelegate {
let thread: TSThread
@ -47,19 +46,10 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewD
}()
// MARK: UI Components
lazy var messagesTableView: UITableView = {
let result = UITableView()
lazy var messagesTableView: MessagesTableView = {
let result = MessagesTableView()
result.dataSource = self
result.delegate = self
result.register(VisibleMessageCell.self, forCellReuseIdentifier: VisibleMessageCell.identifier)
result.register(InfoMessageCell.self, forCellReuseIdentifier: InfoMessageCell.identifier)
result.register(TypingIndicatorCellV2.self, forCellReuseIdentifier: TypingIndicatorCellV2.identifier)
result.separatorStyle = .none
result.backgroundColor = .clear
result.contentInset = UIEdgeInsets(top: 0, leading: 0, bottom: ConversationVC.bottomInset, trailing: 0)
result.showsVerticalScrollIndicator = false
result.contentInsetAdjustmentBehavior = .never
result.keyboardDismissMode = .interactive
return result
}()
@ -189,14 +179,14 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewD
didConstrainScrollButton = true
}
UIView.animate(withDuration: 0.25) {
self.messagesTableView.contentInset = UIEdgeInsets(top: 0, leading: 0, bottom: newHeight + ConversationVC.bottomInset, trailing: 0)
self.messagesTableView.keyboardHeight = newHeight
self.scrollButton.alpha = 0
}
}
@objc private func handleKeyboardWillHideNotification(_ notification: Notification) {
UIView.animate(withDuration: 0.25) {
self.messagesTableView.contentInset = UIEdgeInsets(top: 0, leading: 0, bottom: ConversationVC.bottomInset, trailing: 0)
self.messagesTableView.keyboardHeight = 0
self.scrollButton.alpha = self.getScrollButtonOpacity()
}
}

View File

@ -361,8 +361,6 @@ final class VisibleMessageCell : MessageCell, UITextViewDelegate, BodyTextViewDe
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
if let panGestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
let locationInBubbleView = panGestureRecognizer.location(in: bubbleView)
guard bubbleView.bounds.contains(locationInBubbleView) else { return false }
let v = panGestureRecognizer.velocity(in: self)
guard v.x < 0 else { return false }
return abs(v.x) > abs(v.y)

View File

@ -0,0 +1,37 @@
final class MessagesTableView : UITableView {
var keyboardHeight: CGFloat = 0
override var contentInset: UIEdgeInsets {
get { UIEdgeInsets(top: 0, leading: 0, bottom: MessagesTableView.baselineContentInset + keyboardHeight, trailing: 0) }
set { }
}
override var adjustedContentInset: UIEdgeInsets {
get { UIEdgeInsets(top: 0, leading: 0, bottom: MessagesTableView.baselineContentInset + keyboardHeight, trailing: 0) }
set { }
}
private static let baselineContentInset = Values.mediumSpacing
override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style)
initialize()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
initialize()
}
private func initialize() {
register(VisibleMessageCell.self, forCellReuseIdentifier: VisibleMessageCell.identifier)
register(InfoMessageCell.self, forCellReuseIdentifier: InfoMessageCell.identifier)
register(TypingIndicatorCellV2.self, forCellReuseIdentifier: TypingIndicatorCellV2.identifier)
separatorStyle = .none
backgroundColor = .clear
showsVerticalScrollIndicator = false
contentInsetAdjustmentBehavior = .never
keyboardDismissMode = .interactive
}
}

View File

@ -255,20 +255,9 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
- (void)didToggleLinkPreviewsEnabled:(UISwitch *)sender
{
BOOL isOn = sender.isOn;
if (isOn) {
NSString *title = @"Enable Link Previews?";
NSString *message = @"You will not have full metadata protection when sending or receiving link previews.";
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[sender setOn:NO animated:YES];
SSKPreferences.areLinkPreviewsEnabled = NO;
}]];
[self presentViewController:alert animated:YES completion:nil];
}
OWSLogInfo(@"toggled to: %@", (sender.isOn ? @"ON" : @"OFF"));
SSKPreferences.areLinkPreviewsEnabled = sender.isOn;
BOOL enabled = sender.isOn;
OWSLogInfo(@"toggled to: %@", (enabled ? @"ON" : @"OFF"));
SSKPreferences.areLinkPreviewsEnabled = enabled;
}
- (void)isScreenLockEnabledDidChange:(UISwitch *)sender