-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 additions
and
139 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
36 changes: 0 additions & 36 deletions
36
WordPress/Classes/ViewRelated/Post/Search/PostSearchSuggestionsService.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
37 changes: 37 additions & 0 deletions
37
WordPress/Classes/ViewRelated/Post/Search/PostSearchToken.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,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 } | ||
} |
34 changes: 34 additions & 0 deletions
34
WordPress/Classes/ViewRelated/Post/Search/PostSearchTokenTableCell.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,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 | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
WordPress/Resources/AppImages.xcassets/block-tag-cloud.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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "block-tag-cloud.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+2.13 KB
WordPress/Resources/AppImages.xcassets/block-tag-cloud.imageset/block-tag-cloud.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
WordPress/Resources/AppImages.xcassets/comment-author-gravatar.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,15 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "comment-author-gravatar.pdf", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"template-rendering-intent" : "template" | ||
} | ||
} |
Binary file added
BIN
+1.98 KB
...Resources/AppImages.xcassets/comment-author-gravatar.imageset/comment-author-gravatar.pdf
Binary file not shown.
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