diff --git a/Extensions/Today/Images.xcassets/close-private-tabs.imageset/Contents.json b/Extensions/Today/Images.xcassets/close-private-tabs.imageset/Contents.json deleted file mode 100644 index 5dc3dae06cce..000000000000 --- a/Extensions/Today/Images.xcassets/close-private-tabs.imageset/Contents.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "images" : [ - { - "filename" : "close-private-tabs.pdf", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Extensions/Today/Images.xcassets/close-private-tabs.imageset/close-private-tabs.pdf b/Extensions/Today/Images.xcassets/close-private-tabs.imageset/close-private-tabs.pdf deleted file mode 100644 index 7b9007f3ee23..000000000000 Binary files a/Extensions/Today/Images.xcassets/close-private-tabs.imageset/close-private-tabs.pdf and /dev/null differ diff --git a/Extensions/Today/Images.xcassets/private-search.imageset/Contents.json b/Extensions/Today/Images.xcassets/private-search.imageset/Contents.json deleted file mode 100644 index 6f7724f0c188..000000000000 --- a/Extensions/Today/Images.xcassets/private-search.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "private-search.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "original" - } -} diff --git a/Extensions/Today/Images.xcassets/private-search.imageset/private-search.pdf b/Extensions/Today/Images.xcassets/private-search.imageset/private-search.pdf deleted file mode 100644 index 94136507917b..000000000000 Binary files a/Extensions/Today/Images.xcassets/private-search.imageset/private-search.pdf and /dev/null differ diff --git a/Extensions/Today/Images.xcassets/search-button.imageset/Contents.json b/Extensions/Today/Images.xcassets/search-button.imageset/Contents.json deleted file mode 100644 index 047e396b13b0..000000000000 --- a/Extensions/Today/Images.xcassets/search-button.imageset/Contents.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "images" : [ - { - "filename" : "search.pdf", - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "light" - } - ], - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "template-rendering-intent" : "original" - } -} diff --git a/Extensions/Today/Images.xcassets/search-button.imageset/search.pdf b/Extensions/Today/Images.xcassets/search-button.imageset/search.pdf deleted file mode 100644 index 9c689589b338..000000000000 Binary files a/Extensions/Today/Images.xcassets/search-button.imageset/search.pdf and /dev/null differ diff --git a/Extensions/Today/Images.xcassets/subtitleLableColor.colorset/Contents.json b/Extensions/Today/Images.xcassets/subtitleLableColor.colorset/Contents.json deleted file mode 100644 index 014c01ebf5b2..000000000000 --- a/Extensions/Today/Images.xcassets/subtitleLableColor.colorset/Contents.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "light" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.235", - "green" : "0.220", - "red" : "0.220" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.702", - "green" : "0.694", - "red" : "0.694" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Extensions/Today/Images.xcassets/widgetLabelColors.colorset/Contents.json b/Extensions/Today/Images.xcassets/widgetLabelColors.colorset/Contents.json deleted file mode 100644 index a9cb0b1df4db..000000000000 --- a/Extensions/Today/Images.xcassets/widgetLabelColors.colorset/Contents.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "light" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.153", - "green" : "0.137", - "red" : "0.141" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "0.980", - "green" : "0.976", - "red" : "0.976" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Extensions/Today/TodayViewController.swift b/Extensions/Today/TodayViewController.swift index 02d4d3ce5809..20ba1311304b 100644 --- a/Extensions/Today/TodayViewController.swift +++ b/Extensions/Today/TodayViewController.swift @@ -17,44 +17,40 @@ struct TodayStrings { } private struct TodayUX { + static let privateBrowsingColor = UIColor(rgb: 0xcf68ff) static let backgroundHightlightColor = UIColor(white: 216.0/255.0, alpha: 44.0/255.0) - static let linkTextSize: CGFloat = 9.0 - static let labelTextSize: CGFloat = 12.0 - static let imageButtonTextSize: CGFloat = 13.0 - static let copyLinkImageWidth: CGFloat = 20 + static let linkTextSize: CGFloat = 10.0 + static let labelTextSize: CGFloat = 14.0 + static let imageButtonTextSize: CGFloat = 14.0 + static let copyLinkImageWidth: CGFloat = 23 static let margin: CGFloat = 8 static let buttonsHorizontalMarginPercentage: CGFloat = 0.1 - static let buttonStackViewSpacing: CGFloat = 30.0 - static var labelColor: UIColor { - if #available(iOS 13, *) { - return UIColor(named: "widgetLabelColors") ?? UIColor(rgb: 0x242327) - } else { - return UIColor(rgb: 0x242327) - } - } - static var subtitleLabelColor: UIColor { - if #available(iOS 13, *) { - return UIColor(named: "subtitleLableColor") ?? UIColor(rgb: 0x38383C) - } else { - return UIColor(rgb: 0x38383C) - } - } + static let privateSearchButtonColorBrightPurple = UIColor(red: 117.0/255.0, green: 41.0/255.0, blue: 167.0/255.0, alpha: 1.0) + static let privateSearchButtonColorDarkPurple = UIColor(red: 73.0/255.0, green: 46.0/255.0, blue: 133.0/255.0, alpha: 1.0) + static let privateSearchButtonColorFaintDarkPurple = UIColor(red: 56.0/255.0, green: 51.0/255.0, blue: 114.0/255.0, alpha: 1.0) } @objc (TodayViewController) class TodayViewController: UIViewController, NCWidgetProviding { + var copiedURL: URL? fileprivate lazy var newTabButton: ImageButtonWithLabel = { let imageButton = ImageButtonWithLabel() imageButton.addTarget(self, action: #selector(onPressNewTab), forControlEvents: .touchUpInside) imageButton.label.text = TodayStrings.NewTabButtonLabel + let button = imageButton.button - button.setImage(UIImage(named: "search-button")?.withRenderingMode(.alwaysOriginal), for: .normal) + button.frame = CGRect(width: 60.0, height: 60.0) + button.backgroundColor = UIColor.white + button.layer.cornerRadius = button.frame.size.width/2 + button.clipsToBounds = true + button.setImage(UIImage(named: "search"), for: .normal) let label = imageButton.label - label.textColor = TodayUX.labelColor - label.tintColor = TodayUX.labelColor + label.tintColor = UIColor(named: "widgetLabelColors") + label.textColor = UIColor(named: "widgetLabelColors") label.font = UIFont.systemFont(ofSize: TodayUX.imageButtonTextSize) + imageButton.sizeToFit() return imageButton }() @@ -64,10 +60,16 @@ class TodayViewController: UIViewController, NCWidgetProviding { imageButton.addTarget(self, action: #selector(onPressNewPrivateTab), forControlEvents: .touchUpInside) imageButton.label.text = TodayStrings.NewPrivateTabButtonLabel let button = imageButton.button - button.setImage(UIImage(named: "private-search")?.withRenderingMode(.alwaysOriginal), for: .normal) + button.frame = CGRect(width: 60.0, height: 60.0) + button.performGradient(colorOne: TodayUX.privateSearchButtonColorFaintDarkPurple, colorTwo: TodayUX.privateSearchButtonColorDarkPurple, colorThree: TodayUX.privateSearchButtonColorBrightPurple) + button.layer.cornerRadius = button.frame.size.width/2 + button.clipsToBounds = true + button.setImage(UIImage(named: "quick_action_new_private_tab")?.withRenderingMode(.alwaysTemplate), for: .normal) + button.tintColor = UIColor.white + let label = imageButton.label - label.textColor = TodayUX.labelColor - label.tintColor = TodayUX.labelColor + label.tintColor = UIColor(named: "widgetLabelColors") + label.textColor = UIColor(named: "widgetLabelColors") label.font = UIFont.systemFont(ofSize: TodayUX.imageButtonTextSize) imageButton.sizeToFit() return imageButton @@ -75,18 +77,18 @@ class TodayViewController: UIViewController, NCWidgetProviding { fileprivate lazy var openCopiedLinkButton: ButtonWithSublabel = { let button = ButtonWithSublabel() + button.setTitle(TodayStrings.GoToCopiedLinkLabel, for: .normal) button.addTarget(self, action: #selector(onPressOpenClibpoard), for: .touchUpInside) + // We need to set the background image/color for .Normal, so the whole button is tappable. button.setBackgroundColor(UIColor.clear, forState: .normal) button.setBackgroundColor(TodayUX.backgroundHightlightColor, forState: .highlighted) - button.setImage(UIImage(named: "copy_link_icon")?.withRenderingMode(.alwaysOriginal), for: .normal) + + button.setImage(UIImage(named: "copy_link_icon")?.withRenderingMode(.alwaysTemplate), for: .normal) + button.label.font = UIFont.systemFont(ofSize: TodayUX.labelTextSize) button.subtitleLabel.font = UIFont.systemFont(ofSize: TodayUX.linkTextSize) - button.label.textColor = TodayUX.labelColor - button.label.tintColor = TodayUX.labelColor - button.subtitleLabel.textColor = TodayUX.subtitleLabelColor - button.subtitleLabel.tintColor = TodayUX.subtitleLabelColor return button }() @@ -95,7 +97,9 @@ class TodayViewController: UIViewController, NCWidgetProviding { stackView.axis = .vertical stackView.alignment = .fill stackView.spacing = TodayUX.margin / 2 - stackView.distribution = UIStackView.Distribution.fillProportionally + stackView.distribution = UIStackView.Distribution.fill + stackView.layoutMargins = UIEdgeInsets(top: TodayUX.margin, left: TodayUX.margin, bottom: TodayUX.margin, right: TodayUX.margin) + stackView.isLayoutMarginsRelativeArrangement = true return stackView }() @@ -103,7 +107,7 @@ class TodayViewController: UIViewController, NCWidgetProviding { let stackView = UIStackView() stackView.axis = .horizontal stackView.alignment = .center - stackView.spacing = TodayUX.buttonStackViewSpacing + stackView.spacing = 30 stackView.distribution = UIStackView.Distribution.fillEqually return stackView }() @@ -118,17 +122,15 @@ class TodayViewController: UIViewController, NCWidgetProviding { override func viewDidLoad() { super.viewDidLoad() + let widgetView: UIView! self.extensionContext?.widgetLargestAvailableDisplayMode = .compact - let effectView: UIVisualEffectView - if #available(iOS 13, *) { effectView = UIVisualEffectView(effect: UIVibrancyEffect.widgetEffect(forVibrancyStyle: .label)) } else { - effectView = UIVisualEffectView(effect: .none) + effectView = UIVisualEffectView(effect: UIVibrancyEffect.widgetPrimary()) } - self.view.addSubview(effectView) effectView.snp.makeConstraints { make in make.edges.equalTo(self.view) @@ -215,6 +217,20 @@ extension UIButton { } } +extension UIButton { + func performGradient(colorOne: UIColor, colorTwo: UIColor, colorThree: UIColor) { + let gradientLayer = CAGradientLayer() + gradientLayer.frame = self.frame + gradientLayer.colors = [colorOne.cgColor, colorTwo.cgColor, colorThree.cgColor] + gradientLayer.startPoint = CGPoint(x: 1.0, y: 0.0) + gradientLayer.endPoint = CGPoint(x: 0.0, y: 1.0) + gradientLayer.locations = [0.0, 0.5, 1.0] + gradientLayer.cornerRadius = self.frame.size.width/2 + layer.masksToBounds = true + layer.insertSublayer(gradientLayer, below: self.imageView?.layer) + } +} + class ImageButtonWithLabel: UIView { lazy var button = UIButton() @@ -232,20 +248,18 @@ class ImageButtonWithLabel: UIView { func performLayout() { addSubview(button) addSubview(label) - button.imageView?.contentMode = .scaleAspectFit button.snp.makeConstraints { make in make.centerX.equalTo(self) - make.top.equalTo(self.safeAreaLayoutGuide).offset(5) - make.right.greaterThanOrEqualTo(self.safeAreaLayoutGuide).offset(40) - make.left.greaterThanOrEqualTo(self.safeAreaLayoutGuide).inset(40) - make.height.greaterThanOrEqualTo(60) + make.top.equalTo(self.safeAreaLayoutGuide) + make.right.greaterThanOrEqualTo(self.safeAreaLayoutGuide).offset(30) + make.left.greaterThanOrEqualTo(self.safeAreaLayoutGuide).inset(30) + make.height.width.equalTo(60) } label.snp.makeConstraints { make in make.top.equalTo(button.snp.bottom).offset(10) make.leading.trailing.bottom.equalTo(self) - make.height.equalTo(10) } label.numberOfLines = 1 @@ -277,30 +291,30 @@ class ButtonWithSublabel: UIButton { fileprivate func performLayout() { let titleLabel = self.label + self.titleLabel?.removeFromSuperview() addSubview(titleLabel) let imageView = self.imageView! let subtitleLabel = self.subtitleLabel + subtitleLabel.textColor = UIColor.lightGray self.addSubview(subtitleLabel) imageView.snp.makeConstraints { make in - make.centerY.left.equalTo(10) + make.centerY.left.equalTo(self) make.width.equalTo(TodayUX.copyLinkImageWidth) } titleLabel.snp.makeConstraints { make in - make.left.equalTo(imageView.snp.right).offset(10) + make.left.equalTo(imageView.snp.right).offset(TodayUX.margin) make.trailing.top.equalTo(self) - make.height.greaterThanOrEqualTo(12) } subtitleLabel.lineBreakMode = .byTruncatingTail subtitleLabel.snp.makeConstraints { make in - make.bottom.equalTo(self).inset(10) + make.bottom.equalTo(self) make.top.equalTo(titleLabel.snp.bottom) make.leading.trailing.equalTo(titleLabel) - make.height.greaterThanOrEqualTo(10) } }