Skip to content

Commit

Permalink
Update design of token cells
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Oct 19, 2023
1 parent e26f2be commit bac6644
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 139 deletions.
90 changes: 0 additions & 90 deletions WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,87 +1,6 @@
{
"object": {
"pins": [
{
"package": "AutomatticAbout",
"repositoryURL": "https://github.com/automattic/AutomatticAbout-swift",
"state": {
"branch": null,
"revision": "0f784591b324e5d3ddc5771808ef8eca923e3de2",
"version": "1.1.2"
}
},
{
"package": "Charts",
"repositoryURL": "https://github.com/danielgindi/Charts",
"state": {
"branch": null,
"revision": "07b23476ad52b926be772f317d8f1d4511ee8d02",
"version": "4.1.0"
}
},
{
"package": "CwlCatchException",
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "35f9e770f54ce62dd8526470f14c6e137cef3eea",
"version": "2.1.1"
}
},
{
"package": "CwlPreconditionTesting",
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688",
"version": "2.1.0"
}
},
{
"package": "Lottie",
"repositoryURL": "https://github.com/airbnb/lottie-ios.git",
"state": {
"branch": null,
"revision": "4ca8023b820b7d5d5ae1e2637c046e3dab0f45d0",
"version": "3.4.2"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble",
"state": {
"branch": null,
"revision": "1f3bde57bde12f5e7b07909848c071e9b73d6edc",
"version": "10.0.0"
}
},
{
"package": "ScreenObject",
"repositoryURL": "https://github.com/Automattic/ScreenObject",
"state": {
"branch": null,
"revision": "328db56c62aab91440ec5e07cc9f7eef6e26a26e",
"version": "0.2.3"
}
},
{
"package": "swift-algorithms",
"repositoryURL": "https://github.com/apple/swift-algorithms",
"state": {
"branch": null,
"revision": "b14b7f4c528c942f121c8b860b9410b2bf57825e",
"version": "1.0.0"
}
},
{
"package": "swift-numerics",
"repositoryURL": "https://github.com/apple/swift-numerics",
"state": {
"branch": null,
"revision": "0a5bc04095a675662cf24757cc0640aa2204253b",
"version": "1.0.2"
}
},
{
"package": "BuildkiteTestCollector",
"repositoryURL": "https://github.com/buildkite/test-collector-swift",
Expand All @@ -90,15 +9,6 @@
"revision": "77c7f492f5c1c9ca159f73d18f56bbd1186390b0",
"version": "0.3.0"
}
},
{
"package": "XCUITestHelpers",
"repositoryURL": "https://github.com/Automattic/XCUITestHelpers",
"state": {
"branch": null,
"revision": "5179cb69d58b90761cc713bdee7740c4889d3295",
"version": "0.4.0"
}
}
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,5 @@
import UIKit

protocol PostSearchToken {
var icon: UIImage? { get }
var value: String { get }
var id: AnyHashable { get }
}

extension PostSearchToken {
func asSearchToken() -> UISearchToken {
let token = UISearchToken(icon: icon, text: value)
token.representedObject = self
return token
}
}

struct PostSearchAuthorToken: Hashable, PostSearchToken {
let authorID: NSNumber
let displayName: String?

var icon: UIImage? { UIImage(systemName: "person.circle") }
var value: String { displayName ?? "" }
var id: AnyHashable { self }

init(author: BlogAuthor) {
self.authorID = author.userID
self.displayName = author.displayName
}
}

struct PostSearchTagToken: Hashable, PostSearchToken {
let tag: String

var icon: UIImage? { UIImage(systemName: "number.circle") }
var value: String { tag }
var id: AnyHashable { self }
}

/// Suggests search token for the given input and context. Performs all of the
/// work in the background.
actor PostSearchSuggestionsService {
Expand Down
37 changes: 37 additions & 0 deletions WordPress/Classes/ViewRelated/Post/Search/PostSearchToken.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import Foundation

protocol PostSearchToken {
var icon: UIImage? { get }
var value: String { get }
var id: AnyHashable { get }
}

extension PostSearchToken {
func asSearchToken() -> UISearchToken {
let token = UISearchToken(icon: icon, text: value)
token.representedObject = self
return token
}
}

struct PostSearchAuthorToken: Hashable, PostSearchToken {
let authorID: NSNumber
let displayName: String?

var icon: UIImage? { UIImage(named: "comment-author-gravatar") }
var value: String { displayName ?? "" }
var id: AnyHashable { self }

init(author: BlogAuthor) {
self.authorID = author.userID
self.displayName = author.displayName
}
}

struct PostSearchTagToken: Hashable, PostSearchToken {
let tag: String

var icon: UIImage? { UIImage(named: "block-tag-cloud") }
var value: String { tag }
var id: AnyHashable { self }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import UIKit

final class PostSearchTokenTableCell: UITableViewCell {
private let iconView = UIImageView()
private let titleLabel = UILabel()
private lazy var stackView = UIStackView(arrangedSubviews: [
iconView, titleLabel, UIView()
])

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

iconView.tintColor = .secondaryLabel

stackView.spacing = 8
stackView.alignment = .center
stackView.isLayoutMarginsRelativeArrangement = true
stackView.layoutMargins = UIEdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
stackView.translatesAutoresizingMaskIntoConstraints = false

contentView.addSubview(stackView)
contentView.pinSubviewToAllEdges(stackView)
}

required init?(coder: NSCoder) {
fatalError("Not implemented")
}

func configure(with token: any PostSearchToken, isLast: Bool) {
iconView.image = token.icon
titleLabel.text = token.value
stackView.layoutMargins.bottom = isLast ? 16 : 8
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class PostSearchViewController: UIViewController, UITableViewDelegate, UIS
tableView.translatesAutoresizingMaskIntoConstraints = false
view.pinSubviewToAllEdges(tableView)

tableView.register(UITableViewCell.self, forCellReuseIdentifier: Constants.tokenCellID)
tableView.register(PostSearchTokenTableCell.self, forCellReuseIdentifier: Constants.tokenCellID)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: Constants.postCellID)

tableView.dataSource = dataSource
Expand Down Expand Up @@ -103,18 +103,11 @@ final class PostSearchViewController: UIViewController, UITableViewDelegate, UIS
private func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch SectionID(rawValue: indexPath.section)! {
case .tokens:
let cell = tableView.dequeueReusableCell(withIdentifier: Constants.tokenCellID, for: indexPath)
let cell = tableView.dequeueReusableCell(withIdentifier: Constants.tokenCellID, for: indexPath) as! PostSearchTokenTableCell
let token = viewModel.suggestedTokens[indexPath.row]
var configuration = cell.defaultContentConfiguration()
configuration.text = token.value
configuration.image = token.icon
configuration.imageProperties.tintColor = .secondaryLabel
cell.contentConfiguration = configuration
if indexPath.row == viewModel.suggestedTokens.count - 1 {
cell.separatorInset = UIEdgeInsets.zero
} else {
cell.separatorInset = UIEdgeInsets(top: 0, left: view.bounds.size.width, bottom: 0, right: 0)
}
let isLast = indexPath.row == viewModel.suggestedTokens.count - 1
cell.configure(with: token, isLast: isLast)
cell.separatorInset = UIEdgeInsets(top: 0, left: isLast ? 0 : view.bounds.size.width, bottom: 0, right: 0)
return cell
case .posts:
// TODO: Update the cell design
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "block-tag-cloud.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "comment-author-gravatar.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Binary file not shown.
14 changes: 13 additions & 1 deletion WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@
0CB4057E29C8DF84008EED0A /* BlogDashboardPersonalizeCardCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB4057B29C8DEE1008EED0A /* BlogDashboardPersonalizeCardCell.swift */; };
0CB424F62AE0416D0080B807 /* SolidColorActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB424F52AE0416D0080B807 /* SolidColorActivityIndicator.swift */; };
0CB424F72AE0416D0080B807 /* SolidColorActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB424F52AE0416D0080B807 /* SolidColorActivityIndicator.swift */; };
0CB424EE2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB424ED2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift */; };
0CB424EF2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB424ED2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift */; };
0CB424F12ADEE52A0080B807 /* PostSearchToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB424F02ADEE52A0080B807 /* PostSearchToken.swift */; };
0CB424F22ADEE52A0080B807 /* PostSearchToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB424F02ADEE52A0080B807 /* PostSearchToken.swift */; };
0CD223DF2AA8ADFD002BD761 /* DashboardQuickActionsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CD223DE2AA8ADFD002BD761 /* DashboardQuickActionsViewModel.swift */; };
0CD223E02AA8ADFD002BD761 /* DashboardQuickActionsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CD223DE2AA8ADFD002BD761 /* DashboardQuickActionsViewModel.swift */; };
0CD382832A4B699E00612173 /* DashboardBlazeCardCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CD382822A4B699E00612173 /* DashboardBlazeCardCellViewModel.swift */; };
Expand Down Expand Up @@ -6161,6 +6165,8 @@
0CB4057229C8DD01008EED0A /* BlogDashboardPersonalizationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogDashboardPersonalizationView.swift; sourceTree = "<group>"; };
0CB4057B29C8DEE1008EED0A /* BlogDashboardPersonalizeCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlogDashboardPersonalizeCardCell.swift; sourceTree = "<group>"; };
0CB424F52AE0416D0080B807 /* SolidColorActivityIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SolidColorActivityIndicator.swift; sourceTree = "<group>"; };
0CB424ED2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostSearchTokenTableCell.swift; sourceTree = "<group>"; };
0CB424F02ADEE52A0080B807 /* PostSearchToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostSearchToken.swift; sourceTree = "<group>"; };
0CD223DE2AA8ADFD002BD761 /* DashboardQuickActionsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardQuickActionsViewModel.swift; sourceTree = "<group>"; };
0CD382822A4B699E00612173 /* DashboardBlazeCardCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardBlazeCardCellViewModel.swift; sourceTree = "<group>"; };
0CD382852A4B6FCE00612173 /* DashboardBlazeCardCellViewModelTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardBlazeCardCellViewModelTest.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10267,8 +10273,10 @@
isa = PBXGroup;
children = (
0CD9CC9E2AD73A560044A33C /* PostSearchViewController.swift */,
0CA10F6C2ADAE86D00CE75AC /* PostSearchSuggestionsService.swift */,
0CD9CCA22AD831590044A33C /* PostSearchViewModel.swift */,
0CB424ED2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift */,
0CB424F02ADEE52A0080B807 /* PostSearchToken.swift */,
0CA10F6C2ADAE86D00CE75AC /* PostSearchSuggestionsService.swift */,
0CA10FA62ADB76ED00CE75AC /* PostSearchService.swift */,
);
path = Search;
Expand Down Expand Up @@ -22309,6 +22317,7 @@
8261B4CC1EA8E13700668298 /* SVProgressHUD+Dismiss.m in Sources */,
329F8E5624DDAC61002A5311 /* DynamicHeightCollectionView.swift in Sources */,
FECA442F28350B7800D01F15 /* PromptRemindersScheduler.swift in Sources */,
0CB424EE2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift in Sources */,
436D56242117312700CEAA33 /* RegisterDomainDetailsViewModel+RowList.swift in Sources */,
C81CCD65243AECA200A83E27 /* TenorGIF.swift in Sources */,
596C035E1B84F21D00899EEB /* ThemeBrowserViewController.swift in Sources */,
Expand Down Expand Up @@ -22777,6 +22786,7 @@
836498CE281735CC00A2C170 /* BloggingPromptsHeaderView.swift in Sources */,
3F43703F2893201400475B6E /* JetpackOverlayViewController.swift in Sources */,
319D6E8519E44F7F0013871C /* SuggestionsTableViewCell.m in Sources */,
0CB424F12ADEE52A0080B807 /* PostSearchToken.swift in Sources */,
98AA6D1126B8CE7200920C8B /* Comment+CoreDataClass.swift in Sources */,
7E4A773720F802A8001C706D /* ActivityRangesFactory.swift in Sources */,
E1AC282D18282423004D394C /* SFHFKeychainUtils.m in Sources */,
Expand Down Expand Up @@ -24263,6 +24273,7 @@
FABB223D2602FC2C00C8785C /* ThisWeekWidgetStats.swift in Sources */,
FABB223E2602FC2C00C8785C /* PostAutoUploadMessageProvider.swift in Sources */,
FABB223F2602FC2C00C8785C /* GutenbergMediaPickerHelper.swift in Sources */,
0CB424EF2ADEE3CD0080B807 /* PostSearchTokenTableCell.swift in Sources */,
FABB22402602FC2C00C8785C /* FeatureFlag.swift in Sources */,
3F170E252655917400F6F670 /* UIView+SwiftUI.swift in Sources */,
80EF929128105CFA0064A971 /* QuickStartFactory.swift in Sources */,
Expand Down Expand Up @@ -24819,6 +24830,7 @@
FABB23D22602FC2C00C8785C /* PostServiceOptions.m in Sources */,
FABB23D32602FC2C00C8785C /* DiffTitleValue.swift in Sources */,
FABB23D42602FC2C00C8785C /* ReaderCommentsViewController.swift in Sources */,
0CB424F22ADEE52A0080B807 /* PostSearchToken.swift in Sources */,
FABB23D52602FC2C00C8785C /* SiteCreationRequest+Validation.swift in Sources */,
FABB23D62602FC2C00C8785C /* FormattableContentGroup.swift in Sources */,
FABB23D72602FC2C00C8785C /* MenuItemSourceViewController.m in Sources */,
Expand Down

0 comments on commit bac6644

Please sign in to comment.