From b0ce60a38d92ac0e309b50e695b5b771434ad8b4 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 7 Nov 2017 17:34:12 -0500 Subject: [PATCH 1/6] Fix layout of registration page for iPhoneX // FREEBIE --- .../RegistrationViewController.m | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Signal/src/ViewControllers/RegistrationViewController.m b/Signal/src/ViewControllers/RegistrationViewController.m index 3b88cb736..134cfab14 100644 --- a/Signal/src/ViewControllers/RegistrationViewController.m +++ b/Signal/src/ViewControllers/RegistrationViewController.m @@ -61,41 +61,46 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi - (void)createViews { - self.view.backgroundColor = [UIColor ows_signalBrandBlueColor]; + self.view.backgroundColor = [UIColor whiteColor]; self.view.userInteractionEnabled = YES; [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundTapped:)]]; - UIView *header = [UIView new]; - header.backgroundColor = [UIColor ows_signalBrandBlueColor]; - [self.view addSubview:header]; - [header autoPinToTopLayoutGuideOfViewController:self withInset:0]; - [header autoPinWidthToSuperview]; + UIView *headerWrapper = [UIView containerView]; + [self.view addSubview:headerWrapper]; + headerWrapper.backgroundColor = UIColor.ows_signalBrandBlueColor; + + UIView *headerContent = [UIView new]; + [headerWrapper addSubview:headerContent]; + [headerWrapper autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeBottom]; + [headerContent autoPinEdgeToSuperviewEdge:ALEdgeBottom]; + [headerContent autoPinToTopLayoutGuideOfViewController:self withInset:0]; + [headerContent autoPinWidthToSuperview]; UILabel *headerLabel = [UILabel new]; headerLabel.text = NSLocalizedString(@"REGISTRATION_TITLE_LABEL", @""); headerLabel.textColor = [UIColor whiteColor]; headerLabel.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(20.f, 24.f)]; - [header addSubview:headerLabel]; + [headerContent addSubview:headerLabel]; [headerLabel autoHCenterInSuperview]; [headerLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:14.f]; CGFloat screenHeight = MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height); if (screenHeight < 568) { // iPhone 4s or smaller. - [header autoSetDimension:ALDimensionHeight toSize:20]; + [headerContent autoSetDimension:ALDimensionHeight toSize:20]; headerLabel.hidden = YES; } else if (screenHeight < 667) { // iPhone 5 or smaller. - [header autoSetDimension:ALDimensionHeight toSize:80]; + [headerContent autoSetDimension:ALDimensionHeight toSize:80]; } else { - [header autoSetDimension:ALDimensionHeight toSize:220]; + [headerContent autoSetDimension:ALDimensionHeight toSize:220]; UIImage *logo = [UIImage imageNamed:@"logoSignal"]; OWSAssert(logo); UIImageView *logoView = [UIImageView new]; logoView.image = logo; - [header addSubview:logoView]; + [headerContent addSubview:logoView]; [logoView autoHCenterInSuperview]; [logoView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:headerLabel withOffset:-14.f]; } @@ -112,7 +117,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi [self.view addSubview:contentView]; [contentView autoPinToBottomLayoutGuideOfViewController:self withInset:0]; [contentView autoPinWidthToSuperview]; - [contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:header]; + [contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:headerContent]; // Country UIView *countryRow = [UIView containerView]; From a3153d29d0d5d279192b1d24008f170ffb3df656 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 7 Nov 2017 18:36:29 -0500 Subject: [PATCH 2/6] Fix callscreen for iPhoneX // FREEBIE --- .../ViewControllers/CallViewController.swift | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/Signal/src/ViewControllers/CallViewController.swift b/Signal/src/ViewControllers/CallViewController.swift index 9c419d4be..21a3984e5 100644 --- a/Signal/src/ViewControllers/CallViewController.swift +++ b/Signal/src/ViewControllers/CallViewController.swift @@ -33,6 +33,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver { var contactNameLabel: MarqueeLabel! var contactAvatarView: AvatarImageView! + var contactAvatarContainerView: UIView! var callStatusLabel: UILabel! var callDurationTimer: Timer? @@ -270,8 +271,10 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver { callStatusLabel.layer.shadowRadius = 4 self.view.addSubview(callStatusLabel) + contactAvatarContainerView = UIView.container() + self.view.addSubview(contactAvatarContainerView) contactAvatarView = AvatarImageView() - self.view.addSubview(contactAvatarView) + contactAvatarContainerView.addSubview(contactAvatarView) } func createSettingsNagViews() { @@ -340,25 +343,25 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver { action:#selector(didPressAudioSource)) audioSourceButton.accessibilityLabel = NSLocalizedString("CALL_VIEW_AUDIO_SOURCE_LABEL", comment: "Accessibility label for selection the audio source") - + hangUpButton = createButton(imageName:"hangup-active-wide", action:#selector(didPressHangup)) hangUpButton.accessibilityLabel = NSLocalizedString("CALL_VIEW_HANGUP_LABEL", comment: "Accessibility label for hang up call") - + audioModeMuteButton = createButton(imageName:"audio-call-mute-inactive", action:#selector(didPressMute)) audioModeMuteButton.accessibilityLabel = NSLocalizedString("CALL_VIEW_MUTE_LABEL", comment: "Accessibility label for muting the microphone") - + videoModeMuteButton = createButton(imageName:"video-mute-unselected", action:#selector(didPressMute)) videoModeMuteButton.accessibilityLabel = NSLocalizedString("CALL_VIEW_MUTE_LABEL", comment: "Accessibility label for muting the microphone") - + audioModeVideoButton = createButton(imageName:"audio-call-video-inactive", action:#selector(didPressVideo)) audioModeVideoButton.accessibilityLabel = NSLocalizedString("CALL_VIEW_SWITCH_TO_VIDEO_LABEL", comment: "Accessibility label to switch to video call") - + videoModeVideoButton = createButton(imageName:"video-video-unselected", action:#selector(didPressVideo)) videoModeVideoButton.accessibilityLabel = NSLocalizedString("CALL_VIEW_SWITCH_TO_AUDIO_LABEL", comment: "Accessibility label to switch to audio only") @@ -569,19 +572,29 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver { contactNameLabel.autoPinEdge(toSuperviewEdge:.top, withInset:topMargin) contactNameLabel.autoPinLeadingToSuperview(withMargin: contactHMargin) contactNameLabel.setContentHuggingVerticalHigh() + contactNameLabel.setCompressionResistanceHigh() callStatusLabel.autoPinEdge(.top, to:.bottom, of:contactNameLabel, withOffset:contactVSpacing) callStatusLabel.autoPinLeadingToSuperview(withMargin: contactHMargin) callStatusLabel.setContentHuggingVerticalHigh() - - contactAvatarView.autoPinEdge(.top, to:.bottom, of:callStatusLabel, withOffset:+avatarTopSpacing) - contactAvatarView.autoPinEdge(.bottom, to:.top, of:ongoingCallView, withOffset:-avatarBottomSpacing) - contactAvatarView.autoHCenterInSuperview() - // Stretch that avatar to fill the available space. - contactAvatarView.setContentHuggingLow() - contactAvatarView.setCompressionResistanceLow() - // Preserve square aspect ratio of contact avatar. - contactAvatarView.autoMatch(.width, to:.height, of:contactAvatarView) + callStatusLabel.setCompressionResistanceHigh() + + contactAvatarContainerView.autoPinEdge(.top, to:.bottom, of:callStatusLabel, withOffset:+avatarTopSpacing) + contactAvatarContainerView.autoPinEdge(.bottom, to:.top, of:ongoingCallView, withOffset:-avatarBottomSpacing) + contactAvatarContainerView.autoPinWidthToSuperview(withMargin: avatarTopSpacing) + + contactAvatarView.autoCenterInSuperview() + + // Ensure ContacAvatarView gets as close as possible to it's superview edges while maintaining + // aspect ratio. + contactAvatarView.autoPinToSquareAspectRatio() + contactAvatarView.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual) + contactAvatarView.autoPinEdge(toSuperviewEdge: .right, withInset: 0, relation: .greaterThanOrEqual) + contactAvatarView.autoPinEdge(toSuperviewEdge: .bottom, withInset: 0, relation: .greaterThanOrEqual) + contactAvatarView.autoPinEdge(toSuperviewEdge: .left, withInset: 0, relation: .greaterThanOrEqual) + NSLayoutConstraint.autoSetPriority(UILayoutPriorityDefaultLow) { + contactAvatarView.autoPinEdgesToSuperviewMargins() + } // Ongoing call controls ongoingCallView.autoPinEdge(toSuperviewEdge:.bottom, withInset:ongoingBottomMargin) From 8c69e00a3f2917f6fed468e6464f56de463f617c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 7 Nov 2017 18:36:57 -0500 Subject: [PATCH 3/6] Adapt ConversationViewController to iPhoneX // FREEBIE --- Signal/src/UIColor+OWS.h | 1 + Signal/src/UIColor+OWS.m | 5 +++++ .../ConversationView/ConversationInputToolbar.m | 2 +- .../ConversationView/ConversationViewController.m | 7 +++++++ .../src/ViewControllers/NewContactThreadViewController.m | 1 + Signal/src/ViewControllers/OWSViewController.m | 3 ++- 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Signal/src/UIColor+OWS.h b/Signal/src/UIColor+OWS.h index f4c8e9046..b80bde873 100644 --- a/Signal/src/UIColor+OWS.h +++ b/Signal/src/UIColor+OWS.h @@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN + (UIColor *)ows_blackColor; + (UIColor *)ows_errorMessageBorderColor; + (UIColor *)ows_infoMessageBorderColor; ++ (UIColor *)ows_inputToolbarBackgroundColor; + (UIColor *)backgroundColorForContact:(NSString *)contactIdentifier; + (UIColor *)colorWithRGBHex:(unsigned long)value; diff --git a/Signal/src/UIColor+OWS.m b/Signal/src/UIColor+OWS.m index 7693f3750..562888057 100644 --- a/Signal/src/UIColor+OWS.m +++ b/Signal/src/UIColor+OWS.m @@ -86,6 +86,11 @@ NS_ASSUME_NONNULL_BEGIN return [UIColor colorWithRed:239.f / 255.f green:189.f / 255.f blue:88.f / 255.f alpha:1.0f]; } ++ (UIColor *)ows_inputToolbarBackgroundColor +{ + return [self colorWithWhite:245 / 255.f alpha:1.f]; +} + + (UIColor *)ows_lightBackgroundColor { return [UIColor colorWithRed:242.f / 255.f green:242.f / 255.f blue:242.f / 255.f alpha:1.f]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index 15195bcc0..4a1bf392f 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -72,7 +72,7 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex { self.layoutMargins = UIEdgeInsetsZero; - self.backgroundColor = [UIColor colorWithWhite:245 / 255.f alpha:1.f]; + self.backgroundColor = [UIColor ows_inputToolbarBackgroundColor]; UIView *borderView = [UIView new]; borderView.backgroundColor = [UIColor colorWithWhite:238 / 255.f alpha:1.f]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 156b1e948..42996a9ef 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -479,6 +479,13 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { [self loadDraftInCompose]; } +- (void)loadView +{ + [super loadView]; + + self.view.backgroundColor = [UIColor ows_inputToolbarBackgroundColor]; +} + - (void)createContents { _layout = [ConversationViewLayout new]; diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index 9bfdd1313..e9d540269 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -75,6 +75,7 @@ NS_ASSUME_NONNULL_BEGIN { [super loadView]; + self.view.backgroundColor = UIColor.whiteColor; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _nonContactAccountSet = [NSMutableSet set]; _collation = [UILocalizedIndexedCollation currentCollation]; diff --git a/Signal/src/ViewControllers/OWSViewController.m b/Signal/src/ViewControllers/OWSViewController.m index 96792b1ca..c2f2b66aa 100644 --- a/Signal/src/ViewControllers/OWSViewController.m +++ b/Signal/src/ViewControllers/OWSViewController.m @@ -110,7 +110,8 @@ NS_ASSUME_NONNULL_BEGIN CGRect keyboardEndFrameConverted = [self.view convertRect:keyboardEndFrame fromView:nil]; // Adjust the position of the bottom view to account for the keyboard's // intrusion into the view. - CGFloat offset = -MAX(0, (self.view.height - keyboardEndFrameConverted.origin.y)); + // We offset by the bottomLayoutGuide for iPhoneX users, else there is an unnecessary gap between the keyboard and input bar. + CGFloat offset = -MAX(0, (self.view.height - keyboardEndFrameConverted.origin.y - self.bottomLayoutGuide.length)); // There's no need to use: [UIView animateWithDuration:...]. // Any layout changes made during these notifications are From b40d2afc051c47f0f6c82386b827c473ae1d5dba Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 7 Nov 2017 18:43:02 -0500 Subject: [PATCH 4/6] Scanner view for iPhoneX // FREEBIE --- Signal/src/ViewControllers/FingerprintViewScanController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/FingerprintViewScanController.m b/Signal/src/ViewControllers/FingerprintViewScanController.m index 64ad54225..e106224b6 100644 --- a/Signal/src/ViewControllers/FingerprintViewScanController.m +++ b/Signal/src/ViewControllers/FingerprintViewScanController.m @@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN footer.backgroundColor = darkGrey; [self.view addSubview:footer]; [footer autoPinWidthToSuperview]; - [footer autoPinToBottomLayoutGuideOfViewController:self withInset:0]; + [footer autoPinEdgeToSuperviewEdge:ALEdgeBottom]; [footer autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.qrScanningController.view]; UILabel *cameraInstructionLabel = [UILabel new]; @@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN [footer addSubview:cameraInstructionLabel]; [cameraInstructionLabel autoPinWidthToSuperviewWithMargin:ScaleFromIPhone5To7Plus(16.f, 30.f)]; CGFloat instructionsVMargin = ScaleFromIPhone5To7Plus(10.f, 20.f); - [cameraInstructionLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:instructionsVMargin]; + [cameraInstructionLabel autoPinToBottomLayoutGuideOfViewController:self withInset:instructionsVMargin]; [cameraInstructionLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:instructionsVMargin]; } From e5263dcf0ed72bc9e97375c816a1f825730c8bfb Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 14 Nov 2017 09:13:04 -0500 Subject: [PATCH 5/6] Clarify comment // FREEBIE --- Signal/src/ViewControllers/OWSViewController.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/OWSViewController.m b/Signal/src/ViewControllers/OWSViewController.m index c2f2b66aa..27e282531 100644 --- a/Signal/src/ViewControllers/OWSViewController.m +++ b/Signal/src/ViewControllers/OWSViewController.m @@ -110,8 +110,12 @@ NS_ASSUME_NONNULL_BEGIN CGRect keyboardEndFrameConverted = [self.view convertRect:keyboardEndFrame fromView:nil]; // Adjust the position of the bottom view to account for the keyboard's // intrusion into the view. - // We offset by the bottomLayoutGuide for iPhoneX users, else there is an unnecessary gap between the keyboard and input bar. - CGFloat offset = -MAX(0, (self.view.height - keyboardEndFrameConverted.origin.y - self.bottomLayoutGuide.length)); + // + // On iPhoneX, when no keyboard is present, we include a buffer at the bottom of the screen so the bottom view + // clears the floating "home button". But because the keyboard includes it's own buffer, we subtract the length + // (height) of the bottomLayoutGuide, else we'd have an unnecessary buffer between the popped keyboard and the input + // bar. + CGFloat offset = -MAX(0, (self.view.height - self.bottomLayoutGuide.length - keyboardEndFrameConverted.origin.y)); // There's no need to use: [UIView animateWithDuration:...]. // Any layout changes made during these notifications are From a27b0340902f67bb979e21ba8aa383eaa0b54b8b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 14 Nov 2017 12:48:12 -0500 Subject: [PATCH 6/6] Fix GIF picker footer for iPhoneX // FREEBIE --- .../GifPicker/GifPickerViewController.swift | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift index 0094d6599..c5fc7c584 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift @@ -172,11 +172,19 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect self.collectionView.autoPinWidthToSuperview() self.collectionView.autoPinEdge(.top, to: .bottom, of: searchBar) + // for iPhoneX devices, extends the black background to the bottom edge of the view. + let bottomBannerContainer = UIView() + bottomBannerContainer.backgroundColor = UIColor.black + self.view.addSubview(bottomBannerContainer) + bottomBannerContainer.autoPinWidthToSuperview() + bottomBannerContainer.autoPinEdge(.top, to: .bottom, of: self.collectionView) + bottomBannerContainer.autoPinEdge(toSuperviewEdge: .bottom) + let bottomBanner = UIView() - bottomBanner.backgroundColor = UIColor.black - self.view.addSubview(bottomBanner) + bottomBannerContainer.addSubview(bottomBanner) + + bottomBanner.autoPinEdge(toSuperviewEdge: .top) bottomBanner.autoPinWidthToSuperview() - bottomBanner.autoPinEdge(.top, to: .bottom, of: self.collectionView) self.autoPinView(toBottomGuideOrKeyboard:bottomBanner) // The Giphy API requires us to "show their trademark prominently" in our GIF experience.