From 8c69e00a3f2917f6fed468e6464f56de463f617c Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 7 Nov 2017 18:36:57 -0500 Subject: [PATCH] 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 f4c8e9046a..b80bde873a 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 7693f37504..5628880575 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 15195bcc0d..4a1bf392f2 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 156b1e9489..42996a9efb 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 9bfdd13133..e9d5402696 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 96792b1ca3..c2f2b66aa5 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