Skip to content

Commit

Permalink
Domains Dashboard Card: Card UI v2 (#20570)
Browse files Browse the repository at this point in the history
* Create a decorative search view for DomainDashboardCard

- A placeholder view for a search bar that suggests searching a domain
- A view adapts to light and dark mode and fades out
- Accessibility is turned off since it serves the same purpose as an image

* Integrate search view in DashboardDomainsCardCell

* Fix typo with DashboardDomainsCardSearchView name
  • Loading branch information
staskus authored Apr 21, 2023
1 parent 5b7ed12 commit cffe8d4
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,23 @@ class DashboardDomainsCardCell: DashboardCollectionViewCell {
return label
}()

private lazy var dashboardDomainsCardSearchView: UIView = {
let searchView = UIView.embedSwiftUIView(DashboardDomainsCardSearchView())
searchView.translatesAutoresizingMaskIntoConstraints = false
return searchView
}()

private lazy var containerStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [dashboardIconView, descriptionLabel])
stackView.axis = .horizontal
let stackView = UIStackView(arrangedSubviews: [dashboardDomainsCardSearchView, descriptionLabel])
stackView.axis = .vertical
stackView.spacing = Metrics.stackViewSpacing
stackView.alignment = .center
stackView.alignment = .fill
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.directionalLayoutMargins = Metrics.contentDirectionalLayoutMargins
stackView.isLayoutMarginsRelativeArrangement = true
return stackView
}()

private lazy var dashboardIconView: UIView = {
let circleView = UIView(frame: .zero)
circleView.backgroundColor = .jetpackGreen
circleView.layer.cornerRadius = Metrics.iconSize / 2
circleView.layer.masksToBounds = true
circleView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
circleView.widthAnchor.constraint(equalToConstant: Metrics.iconSize),
circleView.heightAnchor.constraint(equalToConstant: Metrics.iconSize)
])

circleView.addSubview(dashboardIcon)
NSLayoutConstraint.activate([
dashboardIcon.centerXAnchor.constraint(equalTo: circleView.centerXAnchor),
dashboardIcon.centerYAnchor.constraint(equalTo: circleView.centerYAnchor)
])
return circleView
}()

private lazy var dashboardIcon: UIImageView = {
let image = UIImage.gridicon(.domains).withTintColor(.white).withRenderingMode(.alwaysOriginal)
let imageView = UIImageView(image: image)
Expand Down Expand Up @@ -148,23 +135,21 @@ extension DashboardDomainsCardCell {
}

private enum Style {
static let titleLabelFont = WPStyleGuide.fontForTextStyle(.subheadline, fontWeight: .semibold)
static let descriptionLabelFont = WPStyleGuide.fontForTextStyle(.subheadline)
static let hideThisImage = UIImage(systemName: "minus.circle")
}

private enum Metrics {
static let stackViewSpacing = 16.0
static let iconSize = 40.0
static let stackViewSpacing: CGFloat = -20 // Negative since the views should overlap
static let contentDirectionalLayoutMargins = NSDirectionalEdgeInsets(top: 8.0,
leading: 16.0,
bottom: 8.0,
trailing: 16.0)
}

private enum Strings {
static let title = NSLocalizedString("domain.dashboard.card.title",
value: "Own your online identity with a custom domain",
static let title = NSLocalizedString("domain.dashboard.card.shortTitle",
value: "Find a custom domain",
comment: "Title for the Domains dashboard card.")
static let description = NSLocalizedString("domain.dashboard.card.description",
value: "Stake your claim on your corner of the web with a site address that’s easy to find, share and follow.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import SwiftUI

struct DashboardDomainsCardSearchView: View {
@SwiftUI.Environment(\.colorScheme) var colorScheme: ColorScheme

var body: some View {
VStack(alignment: .center) {
HStack {
Image(systemName: Constants.iconName)
.foregroundColor(Colors.icon)
.font(.system(size: Metrics.iconSize))
Text(Constants.searchBarPlaceholder)
.foregroundColor(Colors.text)
.font(.system(size: Metrics.fontSize))
Spacer()
}
.padding(.horizontal, Metrics.padding)
.frame(height: Metrics.searchBarHeight)
.background(
RoundedRectangle(cornerRadius: Metrics.containerCornerRadius)
.foregroundColor(Colors.containerBackground)
)
Spacer()
RoundedRectangle(cornerRadius: Metrics.containerCornerRadius)
.foregroundColor(Colors.containerBackground)
}
.padding([.leading, .trailing, .top], Metrics.padding)
.frame(height: Metrics.height)
.background(
ZStack {
LinearGradient(
gradient: Gradient(
colors: [
colorScheme == .light ? Colors.gradientTopLight : Colors.gradientTopDark,
Color.clear
]
),
startPoint: .top,
endPoint: .bottom
)
}
)
.cornerRadius(Metrics.cornerRadius)
.accessibilityHidden(true)
}
}

private extension DashboardDomainsCardSearchView {
enum Metrics {
static let padding: CGFloat = 8
static let cornerRadius: CGFloat = 16
static let containerCornerRadius: CGFloat = 8
static let iconSize: CGFloat = 20
static let fontSize: CGFloat = 15 // fixed .footnote style size
static let height: CGFloat = 110
static let searchBarHeight: CGFloat = 40
}

enum Constants {
static let iconName = "globe"
static let searchBarPlaceholder = "domain.blog"
}

enum Colors {
static let gradientTopLight = Color(UIColor.secondarySystemBackground)
static let gradientTopDark = Color(UIColor.tertiarySystemBackground)
static let containerBackground = Color(UIColor.secondarySystemGroupedBackground)
static let icon = Color(UIColor.jetpackGreen)
static let text = Color(UIColor.textSubtle)
}
}
6 changes: 6 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@
01CE5015290A890F00A9C2E0 /* TracksConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CE5010290A890300A9C2E0 /* TracksConfiguration.swift */; };
01DBFD8729BDCBF200F3720F /* JetpackNativeConnectionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DBFD8629BDCBF200F3720F /* JetpackNativeConnectionService.swift */; };
01DBFD8829BDCBF200F3720F /* JetpackNativeConnectionService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DBFD8629BDCBF200F3720F /* JetpackNativeConnectionService.swift */; };
01E61E5A29F03DEC002E544E /* DashboardDomainsCardSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01E61E5929F03DEC002E544E /* DashboardDomainsCardSearchView.swift */; };
01E61E5B29F03DEC002E544E /* DashboardDomainsCardSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01E61E5929F03DEC002E544E /* DashboardDomainsCardSearchView.swift */; };
01E78D1D296EA54F00FB6863 /* StatsPeriodHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01E78D1C296EA54F00FB6863 /* StatsPeriodHelperTests.swift */; };
02761EC02270072F009BAF0F /* BlogDetailsViewController+SectionHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02761EBF2270072F009BAF0F /* BlogDetailsViewController+SectionHelpers.swift */; };
02761EC222700A9C009BAF0F /* BlogDetailsSubsectionToSectionCategoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02761EC122700A9C009BAF0F /* BlogDetailsSubsectionToSectionCategoryTests.swift */; };
Expand Down Expand Up @@ -5756,6 +5758,7 @@
01CE5006290A889F00A9C2E0 /* TracksConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TracksConfiguration.swift; sourceTree = "<group>"; };
01CE5010290A890300A9C2E0 /* TracksConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TracksConfiguration.swift; sourceTree = "<group>"; };
01DBFD8629BDCBF200F3720F /* JetpackNativeConnectionService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JetpackNativeConnectionService.swift; sourceTree = "<group>"; };
01E61E5929F03DEC002E544E /* DashboardDomainsCardSearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardDomainsCardSearchView.swift; sourceTree = "<group>"; };
01E78D1C296EA54F00FB6863 /* StatsPeriodHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsPeriodHelperTests.swift; sourceTree = "<group>"; };
02761EBF2270072F009BAF0F /* BlogDetailsViewController+SectionHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlogDetailsViewController+SectionHelpers.swift"; sourceTree = "<group>"; };
02761EC122700A9C009BAF0F /* BlogDetailsSubsectionToSectionCategoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogDetailsSubsectionToSectionCategoryTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -9605,6 +9608,7 @@
DCFC097229D3549C00277ECB /* DashboardDomainsCardCell.swift */,
0118968E29D1EB5E00D34BA9 /* DomainsDashboardCardHelper.swift */,
0118969E29D30CAD00D34BA9 /* DomainsDashboardCardTracker.swift */,
01E61E5929F03DEC002E544E /* DashboardDomainsCardSearchView.swift */,
);
path = Domains;
sourceTree = "<group>";
Expand Down Expand Up @@ -21559,6 +21563,7 @@
931F312C2714302A0075433B /* PublicizeServicesState.swift in Sources */,
8BDA5A75247C63F300AB124C /* ReaderDetailCoordinator.swift in Sources */,
FE39C136269C37C900EFB827 /* ListTableViewCell.swift in Sources */,
01E61E5A29F03DEC002E544E /* DashboardDomainsCardSearchView.swift in Sources */,
803C493B283A7C0C00003E9B /* QuickStartChecklistHeader.swift in Sources */,
93C1147F18EC5DD500DAC95C /* AccountService.m in Sources */,
FF945F701B28242300FB8AC4 /* MediaLibraryPickerDataSource.m in Sources */,
Expand Down Expand Up @@ -25269,6 +25274,7 @@
FABB26012602FC2C00C8785C /* ReaderShareAction.swift in Sources */,
C7124E4F2638528F00929318 /* JetpackPrologueViewController.swift in Sources */,
FE341706275FA157005D5CA7 /* RichCommentContentRenderer.swift in Sources */,
01E61E5B29F03DEC002E544E /* DashboardDomainsCardSearchView.swift in Sources */,
FABB26022602FC2C00C8785C /* PostingActivityMonth.swift in Sources */,
0107E15D28FFE99300DE87DB /* WidgetConfiguration.swift in Sources */,
FABB26032602FC2C00C8785C /* StreakStatsRecordValue+CoreDataClass.swift in Sources */,
Expand Down

0 comments on commit cffe8d4

Please sign in to comment.