-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FXIOS-9746 Bookmarks panel empty states (#23267)
- Loading branch information
1 parent
4e8df7f
commit 1322e73
Showing
9 changed files
with
195 additions
and
1 deletion.
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
12 changes: 12 additions & 0 deletions
12
firefox-ios/Client/Assets/Images.xcassets/noBookmarksInFolder.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "MobileBookmarks_folder.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+6.41 KB
...ios/Client/Assets/Images.xcassets/noBookmarksInFolder.imageset/MobileBookmarks_folder.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
firefox-ios/Client/Assets/Images.xcassets/noBookmarksInRoot.imageset/Contents.json
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,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "noBookmarks.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+13.2 KB
firefox-ios/Client/Assets/Images.xcassets/noBookmarksInRoot.imageset/noBookmarks.pdf
Binary file not shown.
95 changes: 95 additions & 0 deletions
95
firefox-ios/Client/Frontend/Library/Bookmarks/BookmarksFolderEmptyStateView.swift
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,95 @@ | ||
// 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 Foundation | ||
import Common | ||
|
||
final class BookmarksFolderEmptyStateView: UIView, ThemeApplicable { | ||
private struct UX { | ||
static let a11yTopMargin: CGFloat = 16 | ||
static let TitleTopMargin: CGFloat = 16 | ||
static let BodyTopMargin: CGFloat = 8 | ||
static let ContentLeftRightMargins: CGFloat = 16 | ||
static let StackViewWidthMultiplier: CGFloat = 0.9 | ||
static let imageWidth: CGFloat = 200 | ||
} | ||
|
||
private lazy var logoImage: UIImageView = .build { imageView in | ||
imageView.contentMode = .scaleAspectFit | ||
} | ||
|
||
private lazy var titleLabel: UILabel = .build { label in | ||
label.textAlignment = .center | ||
label.font = FXFontStyles.Bold.headline.scaledFont() | ||
label.numberOfLines = 0 | ||
label.adjustsFontForContentSizeCategory = true | ||
} | ||
|
||
private lazy var bodyLabel: UILabel = .build { label in | ||
label.textAlignment = .center | ||
label.font = FXFontStyles.Regular.body.scaledFont() | ||
label.numberOfLines = 0 | ||
label.adjustsFontForContentSizeCategory = true | ||
} | ||
|
||
private lazy var stackViewWrapper: UIStackView = .build { stackView in | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
stackView.axis = .vertical | ||
stackView.alignment = .center | ||
stackView.spacing = 0 | ||
} | ||
|
||
override init(frame: CGRect = .zero) { | ||
super.init(frame: frame) | ||
|
||
setupLayout() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
func configure(isRoot: Bool) { | ||
titleLabel.text = isRoot ? .Bookmarks.EmptyState.Root.Title : .Bookmarks.EmptyState.Nested.Title | ||
bodyLabel.text = isRoot ? .Bookmarks.EmptyState.Root.Body : .Bookmarks.EmptyState.Nested.Body | ||
logoImage.image = UIImage(named: isRoot ? ImageIdentifiers.noBookmarksInRoot : ImageIdentifiers.noBookmarksInFolder) | ||
} | ||
|
||
private func setupLayout() { | ||
stackViewWrapper.addArrangedSubview(logoImage) | ||
stackViewWrapper.setCustomSpacing(UX.TitleTopMargin, after: logoImage) | ||
stackViewWrapper.addArrangedSubview(titleLabel) | ||
stackViewWrapper.setCustomSpacing(UX.BodyTopMargin, after: titleLabel) | ||
stackViewWrapper.addArrangedSubview(bodyLabel) | ||
addSubview(stackViewWrapper) | ||
|
||
let aspectRatio = (logoImage.image?.size.height ?? 1) / (logoImage.image?.size.width ?? 1) | ||
NSLayoutConstraint.activate([ | ||
stackViewWrapper.topAnchor.constraint(greaterThanOrEqualTo: topAnchor, constant: UX.a11yTopMargin), | ||
stackViewWrapper.bottomAnchor.constraint(lessThanOrEqualTo: bottomAnchor), | ||
stackViewWrapper.centerXAnchor.constraint(equalTo: centerXAnchor), | ||
stackViewWrapper.centerYAnchor.constraint(equalTo: centerYAnchor), | ||
stackViewWrapper.widthAnchor.constraint(equalTo: widthAnchor, multiplier: UX.StackViewWidthMultiplier), | ||
|
||
titleLabel.leadingAnchor.constraint( | ||
equalTo: stackViewWrapper.leadingAnchor, constant: UX.ContentLeftRightMargins), | ||
titleLabel.trailingAnchor.constraint( | ||
equalTo: stackViewWrapper.trailingAnchor, constant: -UX.ContentLeftRightMargins), | ||
|
||
bodyLabel.leadingAnchor.constraint( | ||
equalTo: stackViewWrapper.leadingAnchor, constant: UX.ContentLeftRightMargins), | ||
bodyLabel.trailingAnchor.constraint( | ||
equalTo: stackViewWrapper.trailingAnchor, constant: -UX.ContentLeftRightMargins), | ||
|
||
logoImage.widthAnchor.constraint(equalToConstant: UX.imageWidth), | ||
logoImage.heightAnchor.constraint(equalTo: logoImage.widthAnchor, multiplier: aspectRatio) | ||
]) | ||
} | ||
|
||
// MARK: ThemeApplicable | ||
func applyTheme(theme: Theme) { | ||
titleLabel.textColor = theme.colors.textPrimary | ||
bodyLabel.textColor = theme.colors.textPrimary | ||
} | ||
} |
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