From 713c5fa15ea92d12975e367783ed762f87f6370f Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 9 Dec 2019 16:47:13 +1100 Subject: [PATCH] WIP --- .../Loki/Redesign/Style Guide/Colors.swift | 2 + .../Loki/Redesign/Style Guide/Values.swift | 3 + .../Redesign/View Controllers/HomeVC.swift | 6 +- .../ConversationInputTextView.m | 23 ++++--- .../ConversationInputToolbar.m | 67 +++++++------------ .../ConversationViewController.m | 2 +- .../translations/en.lproj/Localizable.strings | 1 + 7 files changed, 46 insertions(+), 58 deletions(-) diff --git a/Signal/src/Loki/Redesign/Style Guide/Colors.swift b/Signal/src/Loki/Redesign/Style Guide/Colors.swift index c1316fd02..916725218 100644 --- a/Signal/src/Loki/Redesign/Style Guide/Colors.swift +++ b/Signal/src/Loki/Redesign/Style Guide/Colors.swift @@ -31,4 +31,6 @@ final class Colors : NSObject { @objc static let modalBorder = UIColor(hex: 0x212121) @objc static let fakeChatBubbleBackground = UIColor(hex: 0x3F4146) @objc static let fakeChatBubbleText = UIColor(hex: 0x000000) + @objc static let composeViewBackground = UIColor(hex: 0x1B1B1B) + @objc static let composeViewTextFieldBackground = UIColor(hex: 0x141414) } diff --git a/Signal/src/Loki/Redesign/Style Guide/Values.swift b/Signal/src/Loki/Redesign/Style Guide/Values.swift index 86b33cf56..88e0ea2ae 100644 --- a/Signal/src/Loki/Redesign/Style Guide/Values.swift +++ b/Signal/src/Loki/Redesign/Style Guide/Values.swift @@ -7,6 +7,8 @@ final class Values : NSObject { @objc static let conversationCellTimestampOpacity = CGFloat(0.4) @objc static let textFieldBorderOpacity = CGFloat(0.4) @objc static let modalBackgroundOpacity = CGFloat(0.75) + @objc static let composeViewTextFieldBorderOpacity = CGFloat(0.12) + @objc static let composeViewTextFieldPlaceholderOpacity = CGFloat(0.4) // MARK: - Font Sizes @objc static let verySmallFontSize = CGFloat(10) @@ -39,6 +41,7 @@ final class Values : NSObject { @objc static let fakeChatBubbleWidth = CGFloat(224) @objc static let fakeChatBubbleCornerRadius = CGFloat(10) @objc static let fakeChatViewHeight = CGFloat(234) + @objc static var composeViewTextFieldBorderThickness: CGFloat { return 1 / UIScreen.main.scale } // MARK: - Distances @objc static let verySmallSpacing = CGFloat(4) diff --git a/Signal/src/Loki/Redesign/View Controllers/HomeVC.swift b/Signal/src/Loki/Redesign/View Controllers/HomeVC.swift index 9afcbbfe7..7b5c688e6 100644 --- a/Signal/src/Loki/Redesign/View Controllers/HomeVC.swift +++ b/Signal/src/Loki/Redesign/View Controllers/HomeVC.swift @@ -211,11 +211,11 @@ final class HomeVC : UIViewController, UITableViewDataSource, UITableViewDelegat let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(openSettings)) profilePictureView.addGestureRecognizer(tapGestureRecognizer) navigationItem.leftBarButtonItem = UIBarButtonItem(customView: profilePictureView) - let createPrivateGroupChatButton = UIBarButtonItem(image: #imageLiteral(resourceName: "People"), style: .plain, target: self, action: #selector(createPrivateGroupChat)) - createPrivateGroupChatButton.tintColor = Colors.text +// let createPrivateGroupChatButton = UIBarButtonItem(image: #imageLiteral(resourceName: "People"), style: .plain, target: self, action: #selector(createPrivateGroupChat)) +// createPrivateGroupChatButton.tintColor = Colors.text let joinPublicChatButton = UIBarButtonItem(image: #imageLiteral(resourceName: "Globe"), style: .plain, target: self, action: #selector(joinPublicChat)) joinPublicChatButton.tintColor = Colors.text - navigationItem.rightBarButtonItems = [ createPrivateGroupChatButton, joinPublicChatButton ] + navigationItem.rightBarButtonItems = [ /*createPrivateGroupChatButton,*/ joinPublicChatButton ] } // MARK: Interaction diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m b/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m index 48607b7d1..ce3840210 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m @@ -28,16 +28,17 @@ NS_ASSUME_NONNULL_BEGIN self.delegate = self; self.backgroundColor = nil; - self.scrollIndicatorInsets = UIEdgeInsetsMake(4, 4, 4, 4); + self.showsHorizontalScrollIndicator = NO; + self.showsVerticalScrollIndicator = NO; self.scrollEnabled = YES; self.scrollsToTop = NO; self.userInteractionEnabled = YES; - self.font = [UIFont ows_dynamicTypeBodyFont]; - self.textColor = Theme.primaryColor; + self.font = [UIFont systemFontOfSize:LKValues.mediumFontSize]; + self.textColor = LKColors.text; self.textAlignment = NSTextAlignmentNatural; - self.tintColor = UIColor.lokiGreen; + self.tintColor = LKColors.accent; self.contentMode = UIViewContentModeRedraw; self.dataDetectorTypes = UIDataDetectorTypeNone; @@ -45,18 +46,18 @@ NS_ASSUME_NONNULL_BEGIN self.text = nil; self.placeholderView = [UILabel new]; - self.placeholderView.text = NSLocalizedString(@"New Message", @""); - self.placeholderView.textColor = Theme.placeholderColor; + self.placeholderView.text = NSLocalizedString(@"Message", @""); + self.placeholderView.textColor = [LKColors.text colorWithAlphaComponent:LKValues.composeViewTextFieldPlaceholderOpacity]; self.placeholderView.userInteractionEnabled = NO; [self addSubview:self.placeholderView]; // We need to do these steps _after_ placeholderView is configured. - self.font = [UIFont ows_dynamicTypeBodyFont]; - CGFloat hMarginLeading = 12.f; - CGFloat hMarginTrailing = 24.f; - self.textContainerInset = UIEdgeInsetsMake(7.f, + self.font = [UIFont systemFontOfSize:LKValues.mediumFontSize]; + CGFloat hMarginLeading = 16.f; + CGFloat hMarginTrailing = 16.f; + self.textContainerInset = UIEdgeInsetsMake(11.f, CurrentAppContext().isRTL ? hMarginTrailing : hMarginLeading, - 7.f, + 11.f, CurrentAppContext().isRTL ? hMarginLeading : hMarginTrailing); self.textContainer.lineFragmentPadding = 0; self.contentInset = UIEdgeInsetsZero; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index 434a07316..4ff4109ea 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -28,8 +28,8 @@ typedef NS_CLOSED_ENUM(NSUInteger, VoiceMemoRecordingState){ static void *kConversationInputTextViewObservingContext = &kConversationInputTextViewObservingContext; -const CGFloat kMinTextViewHeight = 36; -const CGFloat kMaxTextViewHeight = 98; +const CGFloat kMinTextViewHeight = 40; +const CGFloat kMaxTextViewHeight = 120; #pragma mark - @@ -119,25 +119,15 @@ const CGFloat kMaxTextViewHeight = 98; - (void)createContents { self.layoutMargins = UIEdgeInsetsZero; - - if (UIAccessibilityIsReduceTransparencyEnabled()) { - self.backgroundColor = Theme.toolbarBackgroundColor; - } else { - CGFloat alpha = OWSNavigationBar.backgroundBlurMutingFactor; - self.backgroundColor = [UIColor.lokiDarkerGray colorWithAlphaComponent:alpha]; - - UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:Theme.barBlurEffect]; - blurEffectView.layer.zPosition = -1; - [self addSubview:blurEffectView]; - [blurEffectView autoPinEdgesToSuperviewEdges]; - } - self.autoresizingMask = UIViewAutoresizingFlexibleHeight; + + self.backgroundColor = LKColors.composeViewBackground; _inputTextView = [ConversationInputTextView new]; self.inputTextView.textViewToolbarDelegate = self; - self.inputTextView.font = [UIFont ows_dynamicTypeBodyFont]; - self.inputTextView.backgroundColor = Theme.toolbarBackgroundColor; + self.inputTextView.textColor = LKColors.text; + self.inputTextView.font = [UIFont systemFontOfSize:LKValues.mediumFontSize]; + self.inputTextView.backgroundColor = LKColors.composeViewTextFieldBackground; [self.inputTextView setContentHuggingLow]; [self.inputTextView setCompressionResistanceLow]; SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _inputTextView); @@ -145,43 +135,34 @@ const CGFloat kMaxTextViewHeight = 98; _textViewHeightConstraint = [self.inputTextView autoSetDimension:ALDimensionHeight toSize:kMinTextViewHeight]; _attachmentButton = [[UIButton alloc] init]; - self.attachmentButton.accessibilityLabel - = NSLocalizedString(@"ATTACHMENT_LABEL", @"Accessibility label for attaching photos"); - self.attachmentButton.accessibilityHint = NSLocalizedString( - @"ATTACHMENT_HINT", @"Accessibility hint describing what you can do with the attachment button"); - [self.attachmentButton addTarget:self - action:@selector(attachmentButtonPressed) - forControlEvents:UIControlEventTouchUpInside]; - UIImage *attachmentImage = [UIImage imageNamed:@"ic_circled_plus"]; - [self.attachmentButton setImage:[attachmentImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - forState:UIControlStateNormal]; - self.attachmentButton.tintColor = Theme.navbarIconColor; + self.attachmentButton.accessibilityLabel = NSLocalizedString(@"ATTACHMENT_LABEL", @"Accessibility label for attaching photos"); + self.attachmentButton.accessibilityHint = NSLocalizedString(@"ATTACHMENT_HINT", @"Accessibility hint describing what you can do with the attachment button"); + [self.attachmentButton addTarget:self action:@selector(attachmentButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + UIImage *attachmentImage = [UIImage imageNamed:@"CirclePlus"]; + [self.attachmentButton setImage:attachmentImage forState:UIControlStateNormal]; [self.attachmentButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)]; SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _attachmentButton); _sendButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.sendButton setTitle:MessageStrings.sendButton forState:UIControlStateNormal]; - [self.sendButton setTitleColor:UIColor.lokiGreen forState:UIControlStateNormal]; + [self.sendButton setTitleColor:LKColors.text forState:UIControlStateNormal]; self.sendButton.titleLabel.textAlignment = NSTextAlignmentCenter; - self.sendButton.titleLabel.font = [UIFont ows_mediumFontWithSize:17.f]; + self.sendButton.titleLabel.font = [UIFont boldSystemFontOfSize:LKValues.mediumFontSize]; self.sendButton.contentEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 4); [self.sendButton autoSetDimension:ALDimensionHeight toSize:kMinTextViewHeight]; [self.sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside]; SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _sendButton); - UIImage *voiceMemoIcon = [UIImage imageNamed:@"voice-memo-button"]; + UIImage *voiceMemoIcon = [UIImage imageNamed:@"Microphone"]; OWSAssertDebug(voiceMemoIcon); _voiceMemoButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [self.voiceMemoButton setImage:[voiceMemoIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] - forState:UIControlStateNormal]; - self.voiceMemoButton.imageView.tintColor = Theme.navbarIconColor; + [self.voiceMemoButton setImage:voiceMemoIcon forState:UIControlStateNormal]; [self.voiceMemoButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)]; SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _voiceMemoButton); // We want to be permissive about the voice message gesture, so we hang // the long press GR on the button's wrapper, not the button itself. - UILongPressGestureRecognizer *longPressGestureRecognizer = - [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; + UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; longPressGestureRecognizer.minimumPressDuration = 0; self.voiceMemoGestureRecognizer = longPressGestureRecognizer; [self.voiceMemoButton addGestureRecognizer:longPressGestureRecognizer]; @@ -201,8 +182,7 @@ const CGFloat kMaxTextViewHeight = 98; SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _linkPreviewWrapper); // V Stack - UIStackView *vStack = [[UIStackView alloc] - initWithArrangedSubviews:@[ self.quotedReplyWrapper, self.linkPreviewWrapper, self.inputTextView ]]; + UIStackView *vStack = [[UIStackView alloc] initWithArrangedSubviews:@[ self.quotedReplyWrapper, self.linkPreviewWrapper, self.inputTextView ]]; vStack.axis = UILayoutConstraintAxisVertical; [vStack setContentHuggingHorizontalLow]; [vStack setCompressionResistanceHorizontalLow]; @@ -213,7 +193,7 @@ const CGFloat kMaxTextViewHeight = 98; } // V Stack Wrapper - const CGFloat vStackRounding = 18.f; + const CGFloat vStackRounding = kMinTextViewHeight / 2; UIView *vStackWrapper = [UIView containerView]; vStackWrapper.layer.cornerRadius = vStackRounding; vStackWrapper.clipsToBounds = YES; @@ -235,9 +215,9 @@ const CGFloat kMaxTextViewHeight = 98; initWithArrangedSubviews:@[ self.attachmentButton, vStackWrapper, self.voiceMemoButton, self.sendButton ]]; self.hStack.axis = UILayoutConstraintAxisHorizontal; self.hStack.layoutMarginsRelativeArrangement = YES; - self.hStack.layoutMargins = UIEdgeInsetsMake(6, 6, 6, 6); + self.hStack.layoutMargins = UIEdgeInsetsMake(LKValues.smallSpacing, LKValues.smallSpacing, LKValues.smallSpacing, LKValues.smallSpacing); self.hStack.alignment = UIStackViewAlignmentBottom; - self.hStack.spacing = 8; + self.hStack.spacing = LKValues.smallSpacing; [self addSubview:self.hStack]; [self.hStack autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.mentionCandidateSelectionView]; @@ -266,8 +246,9 @@ const CGFloat kMaxTextViewHeight = 98; self.borderView.userInteractionEnabled = NO; self.borderView.backgroundColor = UIColor.clearColor; self.borderView.opaque = NO; - self.borderView.layer.borderColor = Theme.secondaryColor.CGColor; - self.borderView.layer.borderWidth = CGHairlineWidth(); + self.borderView.layer.borderColor = LKColors.text.CGColor; + self.borderView.layer.opacity = LKValues.composeViewTextFieldBorderOpacity; + self.borderView.layer.borderWidth = LKValues.composeViewTextFieldBorderThickness; self.borderView.layer.cornerRadius = vStackRounding; [self addSubview:self.borderView]; [self.borderView autoPinToEdgesOfView:vStackWrapper]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 9fba95d52..dfa12b237 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1560,7 +1560,7 @@ typedef enum : NSUInteger { isAttachmentButtonHidden = false; } [self.inputToolbar setUserInteractionEnabled:isEnabled]; - NSString *placeholderText = isEnabled ? NSLocalizedString(@"New Message", "") : NSLocalizedString(@"Pending Friend Request...", ""); + NSString *placeholderText = isEnabled ? NSLocalizedString(@"Message", "") : NSLocalizedString(@"Pending Friend Request...", ""); [self.inputToolbar setPlaceholderText:placeholderText]; [self.inputToolbar setAttachmentButtonHidden:isAttachmentButtonHidden]; } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 8145b5a85..8f10ff6e3 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2738,3 +2738,4 @@ "Enter a display name" = "Enter a display name"; "Restore your account using your seed" = "Restore your account using your seed"; "Enter your seed" = "Enter your seed"; +"Message" = "Message";