Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6708 : [Today Widget] Update current widget strings/colours #6750

Merged
merged 3 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Client/Configuration/Fennec.enterprise.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ LEANPLUM_KEY =

ENABLE_BITCODE = NO
CLANG_MODULES_AUTOLINK = NO

// Today Widget - Search
MOZ_TODAY_WIDGET_SEARCH_DISPLAY_NAME = Firefox - Search
3 changes: 3 additions & 0 deletions Client/Configuration/Fennec.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ LEANPLUM_KEY =

ENABLE_BITCODE = NO
CLANG_MODULES_AUTOLINK = NO

// Today Widget - Search
MOZ_TODAY_WIDGET_SEARCH_DISPLAY_NAME = Firefox - Search
3 changes: 3 additions & 0 deletions Client/Configuration/Firefox.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ LEANPLUM_KEY =

ENABLE_BITCODE = NO
CLANG_MODULES_AUTOLINK = NO

// Today Widget - Search
MOZ_TODAY_WIDGET_SEARCH_DISPLAY_NAME = Firefox - Search
6 changes: 6 additions & 0 deletions Extensions/Today/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "privatebrowsing.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
15 changes: 15 additions & 0 deletions Extensions/Today/Images.xcassets/search.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "search.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion Extensions/Today/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>$(MOZ_BUNDLE_DISPLAY_NAME)</string>
<string>$(MOZ_TODAY_WIDGET_SEARCH_DISPLAY_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down
60 changes: 43 additions & 17 deletions Extensions/Today/TodayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import XCGLogger
private let log = Logger.browserLogger

struct TodayStrings {
static let NewPrivateTabButtonLabel = NSLocalizedString("TodayWidget.NewPrivateTabButtonLabel", tableName: "Today", value: "New Private Tab", comment: "New Private Tab button label")
static let NewTabButtonLabel = NSLocalizedString("TodayWidget.NewTabButtonLabel", tableName: "Today", value: "New Tab", comment: "New Tab button label")
static let NewPrivateTabButtonLabel = NSLocalizedString("TodayWidget.NewPrivateTabButtonLabel", tableName: "Today", value: "Private Search", comment: "New Private Tab button label")
static let NewTabButtonLabel = NSLocalizedString("TodayWidget.NewTabButtonLabel", tableName: "Today", value: "New Search", comment: "New Tab button label")
static let GoToCopiedLinkLabel = NSLocalizedString("TodayWidget.GoToCopiedLinkLabel", tableName: "Today", value: "Go to copied link", comment: "Go to link on clipboard")
}

Expand All @@ -25,6 +25,9 @@ private struct TodayUX {
static let copyLinkImageWidth: CGFloat = 23
static let margin: CGFloat = 8
static let buttonsHorizontalMarginPercentage: CGFloat = 0.1
static let privateSearchButtonColorThree = UIColor(red: 117.0/255.0, green: 41.0/255.0, blue: 167.0/255.0, alpha: 1.0)
nbhasin2 marked this conversation as resolved.
Show resolved Hide resolved
static let privateSearchButtonColorTwo = UIColor(red: 73.0/255.0, green: 46.0/255.0, blue: 133.0/255.0, alpha: 1.0)
static let privateSearchButtonColorOne = UIColor(red: 56.0/255.0, green: 51.0/255.0, blue: 114.0/255.0, alpha: 1.0)
}

@objc (TodayViewController)
Expand All @@ -38,11 +41,14 @@ class TodayViewController: UIViewController, NCWidgetProviding {
imageButton.label.text = TodayStrings.NewTabButtonLabel

let button = imageButton.button

button.setImage(UIImage(named: "new_tab_button_normal")?.withRenderingMode(.alwaysTemplate), for: .normal)
button.setImage(UIImage(named: "new_tab_button_highlight")?.withRenderingMode(.alwaysTemplate), for: .highlighted)

button.frame = CGRect(width: 60.0, height: 60.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this tested on smaller and larger devices, does it look fine on iPad, iPhone5, iPhone 11 Pro Max?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's tested on all devices and it looked fine.

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.tintColor = UIColor(named: "widgetLabelColors")
label.textColor = UIColor(named: "widgetLabelColors")
label.font = UIFont.systemFont(ofSize: TodayUX.imageButtonTextSize)

imageButton.sizeToFit()
Expand All @@ -53,14 +59,17 @@ class TodayViewController: UIViewController, NCWidgetProviding {
let imageButton = ImageButtonWithLabel()
imageButton.addTarget(self, action: #selector(onPressNewPrivateTab), forControlEvents: .touchUpInside)
imageButton.label.text = TodayStrings.NewPrivateTabButtonLabel

let button = imageButton.button
button.setImage(UIImage(named: "new_private_tab_button_normal"), for: .normal)
button.setImage(UIImage(named: "new_private_tab_button_highlight"), for: .highlighted)
button.frame = CGRect(width: 60.0, height: 60.0)
button.performGradient(colorOne: TodayUX.privateSearchButtonColorOne, colorTwo: TodayUX.privateSearchButtonColorTwo, colorThree: TodayUX.privateSearchButtonColorThree)
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.tintColor = TodayUX.privateBrowsingColor
label.textColor = TodayUX.privateBrowsingColor
label.tintColor = UIColor(named: "widgetLabelColors")
label.textColor = UIColor(named: "widgetLabelColors")
label.font = UIFont.systemFont(ofSize: TodayUX.imageButtonTextSize)
imageButton.sizeToFit()
return imageButton
Expand Down Expand Up @@ -97,16 +106,16 @@ class TodayViewController: UIViewController, NCWidgetProviding {
fileprivate lazy var buttonStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .horizontal
stackView.alignment = .fill
stackView.spacing = 0
stackView.alignment = .center
stackView.spacing = 30
stackView.distribution = UIStackView.Distribution.fillEqually
return stackView
}()

fileprivate var scheme: String {
guard let string = Bundle.main.object(forInfoDictionaryKey: "MozInternalURLScheme") as? String else {
// Something went wrong/weird, but we should fallback to the public one.
return "firefox"
return "Firefox"
nbhasin2 marked this conversation as resolved.
Show resolved Hide resolved
}
return string
}
Expand Down Expand Up @@ -208,6 +217,20 @@ extension UIButton {
}
}

extension UIButton {
func performGradient(colorOne: UIColor, colorTwo: UIColor, colorThree : UIColor) {
let gradientLayer = CAGradientLayer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we can put this in a separate file
Ex. UIButtonExtension.swift

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - this can be addressed later and doesn't need to go in this PR

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()
Expand All @@ -227,18 +250,21 @@ class ImageButtonWithLabel: UIView {
addSubview(label)

button.snp.makeConstraints { make in
make.top.left.centerX.equalTo(self)
make.centerX.equalTo(self)
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)
make.top.equalTo(button.snp.bottom).offset(10)
make.leading.trailing.bottom.equalTo(self)
}

label.numberOfLines = 1
label.lineBreakMode = .byWordWrapping
label.textAlignment = .center
label.textColor = UIColor.white
}

func addTarget(_ target: AnyObject?, action: Selector, forControlEvents events: UIControl.Event) {
Expand Down