-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Added condition to not show toast for when user is in private mode - Fixed issue with tabs showing no imageview
- Loading branch information
Showing
6 changed files
with
204 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import UIKit | ||
import SnapKit | ||
import Foundation | ||
|
||
struct EmptyPrivateTabsViewUX { | ||
static let TitleFont = UIFont.systemFont(ofSize: 22, weight: UIFont.Weight.medium) | ||
static let DescriptionFont = UIFont.systemFont(ofSize: 17) | ||
static let LearnMoreFont = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.medium) | ||
static let TextMargin: CGFloat = 18 | ||
static let LearnMoreMargin: CGFloat = 30 | ||
static let MaxDescriptionWidth: CGFloat = 250 | ||
static let MinBottomMargin: CGFloat = 10 | ||
} | ||
|
||
// View we display when there are no private tabs created | ||
class EmptyPrivateTabsView: UIView { | ||
lazy var titleLabel: UILabel = { | ||
let label = UILabel() | ||
label.textColor = UIColor.Photon.White100 | ||
label.font = EmptyPrivateTabsViewUX.TitleFont | ||
label.textAlignment = .center | ||
return label | ||
}() | ||
|
||
var descriptionLabel: UILabel = { | ||
let label = UILabel() | ||
label.textColor = UIColor.Photon.White100 | ||
label.font = EmptyPrivateTabsViewUX.DescriptionFont | ||
label.textAlignment = .center | ||
label.numberOfLines = 0 | ||
label.preferredMaxLayoutWidth = EmptyPrivateTabsViewUX.MaxDescriptionWidth | ||
return label | ||
}() | ||
|
||
var learnMoreButton: UIButton = { | ||
let button = UIButton(type: .system) | ||
button.setTitle( | ||
NSLocalizedString("Learn More", tableName: "PrivateBrowsing", comment: "Text button displayed when there are no tabs open while in private mode"), | ||
for: []) | ||
button.setTitleColor(UIColor.theme.tabTray.privateModeLearnMore, for: []) | ||
button.titleLabel?.font = EmptyPrivateTabsViewUX.LearnMoreFont | ||
return button | ||
}() | ||
|
||
fileprivate var iconImageView: UIImageView = { | ||
let imageView = UIImageView(image: UIImage.templateImageNamed("largePrivateMask")) | ||
imageView.tintColor = UIColor.Photon.Grey60 | ||
return imageView | ||
}() | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
titleLabel.text = NSLocalizedString("Private Browsing", | ||
tableName: "PrivateBrowsing", comment: "Title displayed for when there are no open tabs while in private mode") | ||
descriptionLabel.text = NSLocalizedString("Firefox won’t remember any of your history or cookies, but new bookmarks will be saved.", | ||
tableName: "PrivateBrowsing", comment: "Description text displayed when there are no open tabs while in private mode") | ||
|
||
addSubview(titleLabel) | ||
addSubview(descriptionLabel) | ||
addSubview(iconImageView) | ||
addSubview(learnMoreButton) | ||
|
||
titleLabel.snp.makeConstraints { make in | ||
make.center.equalTo(self) | ||
} | ||
|
||
iconImageView.snp.makeConstraints { make in | ||
make.bottom.equalTo(titleLabel.snp.top) | ||
make.height.width.equalTo(120) | ||
make.centerX.equalTo(self) | ||
} | ||
|
||
descriptionLabel.snp.makeConstraints { make in | ||
make.top.equalTo(titleLabel.snp.bottom).offset(EmptyPrivateTabsViewUX.TextMargin) | ||
make.centerX.equalTo(self) | ||
} | ||
|
||
learnMoreButton.snp.makeConstraints { (make) -> Void in | ||
make.top.equalTo(descriptionLabel.snp.bottom).offset(EmptyPrivateTabsViewUX.LearnMoreMargin).priority(10) | ||
make.bottom.lessThanOrEqualTo(self).offset(-EmptyPrivateTabsViewUX.MinBottomMargin).priority(1000) | ||
make.centerX.equalTo(self) | ||
} | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.