diff --git a/Signal/Images.xcassets/NavBarBackWithShadow.imageset/Contents.json b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/Contents.json new file mode 100644 index 000000000..82a078d60 --- /dev/null +++ b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "chevron-left-shadow-24@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "chevron-left-shadow-24@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "chevron-left-shadow-24@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@1x.png b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@1x.png new file mode 100644 index 000000000..373826d47 Binary files /dev/null and b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@1x.png differ diff --git a/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@2x.png b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@2x.png new file mode 100644 index 000000000..a9c856d50 Binary files /dev/null and b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@2x.png differ diff --git a/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@3x.png b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@3x.png new file mode 100644 index 000000000..556f10a10 Binary files /dev/null and b/Signal/Images.xcassets/NavBarBackWithShadow.imageset/chevron-left-shadow-24@3x.png differ diff --git a/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/Contents.json b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/Contents.json new file mode 100644 index 000000000..d52bbbebb --- /dev/null +++ b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "chevron-right-shadow-24@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "chevron-right-shadow-24@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "chevron-right-shadow-24@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@1x.png b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@1x.png new file mode 100644 index 000000000..a10fac00b Binary files /dev/null and b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@1x.png differ diff --git a/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@2x.png b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@2x.png new file mode 100644 index 000000000..24002aa78 Binary files /dev/null and b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@2x.png differ diff --git a/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@3x.png b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@3x.png new file mode 100644 index 000000000..f4cc5f6b4 Binary files /dev/null and b/Signal/Images.xcassets/NavBarBackWithShadowRTL.imageset/chevron-right-shadow-24@3x.png differ diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift index 690d044ed..2606edf99 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift @@ -190,13 +190,67 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC let hasCancel = (mode != .sharedNavigation) if hasCancel { - let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel, - target: self, action: #selector(cancelPressed)) - cancelButton.tintColor = .white - self.navigationItem.leftBarButtonItem = cancelButton + // Mimic a UIBarButtonItem of type .cancel, but with a shadow. + let cancelButton = OWSButton(title: CommonStrings.cancelButton) { [weak self] in + self?.cancelPressed() + } + cancelButton.setTitleColor(.white, for: .normal) + if let titleLabel = cancelButton.titleLabel { + titleLabel.font = UIFont.systemFont(ofSize: 18.0) + titleLabel.layer.shadowColor = UIColor.black.cgColor + titleLabel.layer.shadowRadius = 2.0 + titleLabel.layer.shadowOpacity = 0.66 + titleLabel.layer.shadowOffset = .zero + } else { + owsFailDebug("Missing titleLabel.") + } + cancelButton.sizeToFit() + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: cancelButton) } else { + // Mimic a conventional back button, but with a shadow. + let isRTL = CurrentAppContext().isRTL + let imageName = isRTL ? "NavBarBackRTL" : "NavBarBack" + let backButton = OWSButton(imageName: imageName, tintColor: .white) { [weak self] in + self?.navigationController?.popViewController(animated: true) + } + + // Nudge closer to the left edge to match default back button item. + let kExtraLeftPadding: CGFloat = isRTL ? +0 : -8 + + // Give some extra hit area to the back button. This is a little smaller + // than the default back button, but makes sense for our left aligned title + // view in the MessagesViewController + let kExtraRightPadding: CGFloat = isRTL ? -0 : +10 + + // Extra hit area above/below + let kExtraHeightPadding: CGFloat = 4 + + // Matching the default backbutton placement is tricky. + // We can't just adjust the imageEdgeInsets on a UIBarButtonItem directly, + // so we adjust the imageEdgeInsets on a UIButton, then wrap that + // in a UIBarButtonItem. + + backButton.contentHorizontalAlignment = .left + + // Default back button is 1.5 pixel lower than our extracted image. + let kTopInsetPadding: CGFloat = 1.5 + backButton.imageEdgeInsets = UIEdgeInsets(top: kTopInsetPadding, left: kExtraLeftPadding, bottom: 0, right: 0) + + var backImageSize = CGSize.zero + if let backImage = UIImage(named: imageName) { + backImageSize = backImage.size + } else { + owsFailDebug("Missing backImage.") + } + backButton.frame = CGRect(origin: .zero, size: CGSize(width: backImageSize.width + kExtraRightPadding, + height: backImageSize.height + kExtraHeightPadding)) + + backButton.layer.shadowColor = UIColor.black.cgColor + backButton.layer.shadowRadius = 2.0 + backButton.layer.shadowOpacity = 0.66 + backButton.layer.shadowOffset = .zero // Note: using a custom leftBarButtonItem breaks the interactive pop gesture. - self.navigationItem.leftBarButtonItem = self.createOWSBackButton() + navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton) } } @@ -507,7 +561,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC // MARK: - Event Handlers - @objc func cancelPressed(sender: UIButton) { + private func cancelPressed() { self.approvalDelegate?.attachmentApproval(self, didCancelAttachments: attachments) } } diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift index 1e273776a..46527237a 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentPrepViewController.swift @@ -140,16 +140,6 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD } #endif - if isZoomable { - // Add top and bottom gradients to ensure toolbar controls are legible - // when placed over image/video preview which may be a clashing color. - let topGradient = GradientView(from: backgroundColor, to: UIColor.clear) - self.view.addSubview(topGradient) - topGradient.autoPinWidthToSuperview() - topGradient.autoPinEdge(toSuperviewEdge: .top) - topGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(60)) - } - // Hide the play button embedded in the MediaView and replace it with our own. // This allows us to zoom in on the media view without zooming in on the button if attachment.isVideo {