chore: rename file name and code format

This commit is contained in:
sunxiaojian 2021-04-02 12:10:12 +08:00
parent 458ab6bcda
commit f24aee739e
6 changed files with 34 additions and 59 deletions

View File

@ -30,7 +30,7 @@
2D32EAAC25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D32EAAB25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift */; }; 2D32EAAC25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D32EAAB25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift */; };
2D32EABA25CB9B0500C9ED86 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D32EAB925CB9B0500C9ED86 /* UIView.swift */; }; 2D32EABA25CB9B0500C9ED86 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D32EAB925CB9B0500C9ED86 /* UIView.swift */; };
2D32EADA25CBCC3300C9ED86 /* PublicTimelineViewModel+LoadMiddleState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D32EAD925CBCC3300C9ED86 /* PublicTimelineViewModel+LoadMiddleState.swift */; }; 2D32EADA25CBCC3300C9ED86 /* PublicTimelineViewModel+LoadMiddleState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D32EAD925CBCC3300C9ED86 /* PublicTimelineViewModel+LoadMiddleState.swift */; };
2D34D9CB261489930081BFC0 /* SearchViewController+recomendView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9CA261489930081BFC0 /* SearchViewController+recomendView.swift */; }; 2D34D9CB261489930081BFC0 /* SearchViewController+RecomendView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9CA261489930081BFC0 /* SearchViewController+RecomendView.swift */; };
2D34D9D126148D9E0081BFC0 /* APIService+Recommend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9D026148D9E0081BFC0 /* APIService+Recommend.swift */; }; 2D34D9D126148D9E0081BFC0 /* APIService+Recommend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9D026148D9E0081BFC0 /* APIService+Recommend.swift */; };
2D34D9DB261494120081BFC0 /* APIService+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9DA261494120081BFC0 /* APIService+Search.swift */; }; 2D34D9DB261494120081BFC0 /* APIService+Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9DA261494120081BFC0 /* APIService+Search.swift */; };
2D34D9E226149C920081BFC0 /* SearchRecommendTagsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9E126149C920081BFC0 /* SearchRecommendTagsCollectionViewCell.swift */; }; 2D34D9E226149C920081BFC0 /* SearchRecommendTagsCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D34D9E126149C920081BFC0 /* SearchRecommendTagsCollectionViewCell.swift */; };
@ -344,7 +344,7 @@
2D32EAAB25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineMiddleLoaderTableViewCell.swift; sourceTree = "<group>"; }; 2D32EAAB25CB96DC00C9ED86 /* TimelineMiddleLoaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineMiddleLoaderTableViewCell.swift; sourceTree = "<group>"; };
2D32EAB925CB9B0500C9ED86 /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; }; 2D32EAB925CB9B0500C9ED86 /* UIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
2D32EAD925CBCC3300C9ED86 /* PublicTimelineViewModel+LoadMiddleState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PublicTimelineViewModel+LoadMiddleState.swift"; sourceTree = "<group>"; }; 2D32EAD925CBCC3300C9ED86 /* PublicTimelineViewModel+LoadMiddleState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PublicTimelineViewModel+LoadMiddleState.swift"; sourceTree = "<group>"; };
2D34D9CA261489930081BFC0 /* SearchViewController+recomendView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchViewController+recomendView.swift"; sourceTree = "<group>"; }; 2D34D9CA261489930081BFC0 /* SearchViewController+RecomendView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchViewController+RecomendView.swift"; sourceTree = "<group>"; };
2D34D9D026148D9E0081BFC0 /* APIService+Recommend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+Recommend.swift"; sourceTree = "<group>"; }; 2D34D9D026148D9E0081BFC0 /* APIService+Recommend.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+Recommend.swift"; sourceTree = "<group>"; };
2D34D9DA261494120081BFC0 /* APIService+Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+Search.swift"; sourceTree = "<group>"; }; 2D34D9DA261494120081BFC0 /* APIService+Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIService+Search.swift"; sourceTree = "<group>"; };
2D34D9E126149C920081BFC0 /* SearchRecommendTagsCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchRecommendTagsCollectionViewCell.swift; sourceTree = "<group>"; }; 2D34D9E126149C920081BFC0 /* SearchRecommendTagsCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchRecommendTagsCollectionViewCell.swift; sourceTree = "<group>"; };
@ -1439,7 +1439,7 @@
children = ( children = (
2DE0FAC62615F5D200CDF649 /* View */, 2DE0FAC62615F5D200CDF649 /* View */,
DB9D6BE825E4F5340051B173 /* SearchViewController.swift */, DB9D6BE825E4F5340051B173 /* SearchViewController.swift */,
2D34D9CA261489930081BFC0 /* SearchViewController+recomendView.swift */, 2D34D9CA261489930081BFC0 /* SearchViewController+RecomendView.swift */,
2D6DE3FF26141DF600A63F6A /* SearchViewModel.swift */, 2D6DE3FF26141DF600A63F6A /* SearchViewModel.swift */,
2D34D9E026149C550081BFC0 /* CollectionViewCell */, 2D34D9E026149C550081BFC0 /* CollectionViewCell */,
); );
@ -2021,7 +2021,7 @@
DB49A63D25FF609300B98345 /* PlayerContainerView+MediaTypeIndicotorView.swift in Sources */, DB49A63D25FF609300B98345 /* PlayerContainerView+MediaTypeIndicotorView.swift in Sources */,
DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */, DB0140CF25C42AEE00F9F3CF /* OSLog.swift in Sources */,
DB44384F25E8C1FA008912A2 /* CALayer.swift in Sources */, DB44384F25E8C1FA008912A2 /* CALayer.swift in Sources */,
2D34D9CB261489930081BFC0 /* SearchViewController+recomendView.swift in Sources */, 2D34D9CB261489930081BFC0 /* SearchViewController+RecomendView.swift in Sources */,
2D206B8625F5FB0900143C56 /* Double.swift in Sources */, 2D206B8625F5FB0900143C56 /* Double.swift in Sources */,
DB9A485C2603010E008B817C /* PHPickerResultLoader.swift in Sources */, DB9A485C2603010E008B817C /* PHPickerResultLoader.swift in Sources */,
2D76319F25C1521200929FB9 /* StatusSection.swift in Sources */, 2D76319F25C1521200929FB9 /* StatusSection.swift in Sources */,

View File

@ -6,8 +6,8 @@
// //
import Foundation import Foundation
import UIKit
import MastodonSDK import MastodonSDK
import UIKit
class SearchRecommendAccountsCollectionViewCell: UICollectionViewCell { class SearchRecommendAccountsCollectionViewCell: UICollectionViewCell {
let avatarImageView: UIImageView = { let avatarImageView: UIImageView = {
@ -75,7 +75,7 @@ extension SearchRecommendAccountsCollectionViewCell {
clipsToBounds = true clipsToBounds = true
contentView.addSubview(headerImageView) contentView.addSubview(headerImageView)
headerImageView.pin(top: 16, left: 0, bottom: 0, right: 0 ) headerImageView.pin(top: 16, left: 0, bottom: 0, right: 0)
contentView.addSubview(avatarImageView) contentView.addSubview(avatarImageView)
avatarImageView.pin(toSize: CGSize(width: 88, height: 88)) avatarImageView.pin(toSize: CGSize(width: 88, height: 88))
@ -86,20 +86,20 @@ extension SearchRecommendAccountsCollectionViewCell {
contentView.addSubview(displayNameLabel) contentView.addSubview(displayNameLabel)
displayNameLabel.constrain([ displayNameLabel.constrain([
displayNameLabel.constraint(.top, toView: contentView,constant: 108), displayNameLabel.constraint(.top, toView: contentView, constant: 108),
displayNameLabel.constraint(.centerX, toView: contentView) displayNameLabel.constraint(.centerX, toView: contentView)
]) ])
contentView.addSubview(acctLabel) contentView.addSubview(acctLabel)
acctLabel.constrain([ acctLabel.constrain([
acctLabel.constraint(.top, toView: contentView,constant: 132), acctLabel.constraint(.top, toView: contentView, constant: 132),
acctLabel.constraint(.centerX, toView: contentView) acctLabel.constraint(.centerX, toView: contentView)
]) ])
contentView.addSubview(followButton) contentView.addSubview(followButton)
followButton.pin(toSize: CGSize(width: 76, height: 24)) followButton.pin(toSize: CGSize(width: 76, height: 24))
followButton.constrain([ followButton.constrain([
followButton.constraint(.top, toView: contentView,constant: 159), followButton.constraint(.top, toView: contentView, constant: 159),
followButton.constraint(.centerX, toView: contentView) followButton.constraint(.centerX, toView: contentView)
]) ])
} }
@ -124,10 +124,9 @@ extension SearchRecommendAccountsCollectionViewCell {
import SwiftUI import SwiftUI
struct SearchRecommendAccountsCollectionViewCell_Previews: PreviewProvider { struct SearchRecommendAccountsCollectionViewCell_Previews: PreviewProvider {
static var controls: some View { static var controls: some View {
Group { Group {
UIViewPreview() { UIViewPreview {
let cell = SearchRecommendAccountsCollectionViewCell() let cell = SearchRecommendAccountsCollectionViewCell()
cell.avatarImageView.backgroundColor = .white cell.avatarImageView.backgroundColor = .white
cell.headerImageView.backgroundColor = .red cell.headerImageView.backgroundColor = .red
@ -146,7 +145,6 @@ struct SearchRecommendAccountsCollectionViewCell_Previews: PreviewProvider {
} }
.background(Color.gray) .background(Color.gray)
} }
} }
#endif #endif

View File

@ -6,8 +6,8 @@
// //
import Foundation import Foundation
import UIKit
import MastodonSDK import MastodonSDK
import UIKit
class SearchRecommendTagsCollectionViewCell: UICollectionViewCell { class SearchRecommendTagsCollectionViewCell: UICollectionViewCell {
let backgroundImageView: UIImageView = { let backgroundImageView: UIImageView = {
@ -74,12 +74,11 @@ extension SearchRecommendTagsCollectionViewCell {
contentView.addSubview(flameIconView) contentView.addSubview(flameIconView)
flameIconView.pinTopRight(padding: 16) flameIconView.pinTopRight(padding: 16)
} }
func config(with tag: Mastodon.Entity.Tag) { func config(with tag: Mastodon.Entity.Tag) {
hashTagTitleLabel.text = "# " + tag.name hashTagTitleLabel.text = "# " + tag.name
if let peopleAreTalking = tag.history?.compactMap({ Int($0.uses)}).reduce(0, +) { if let peopleAreTalking = tag.history?.compactMap({ Int($0.uses) }).reduce(0, +) {
let string = L10n.Scene.Search.Recommend.HashTag.peopleTalking(String(peopleAreTalking)) let string = L10n.Scene.Search.Recommend.HashTag.peopleTalking(String(peopleAreTalking))
peopleLabel.text = string peopleLabel.text = string
} else { } else {
@ -92,10 +91,9 @@ extension SearchRecommendTagsCollectionViewCell {
import SwiftUI import SwiftUI
struct SearchRecommendTagsCollectionViewCell_Previews: PreviewProvider { struct SearchRecommendTagsCollectionViewCell_Previews: PreviewProvider {
static var controls: some View { static var controls: some View {
Group { Group {
UIViewPreview() { UIViewPreview {
let cell = SearchRecommendTagsCollectionViewCell() let cell = SearchRecommendTagsCollectionViewCell()
cell.hashTagTitleLabel.text = "# test" cell.hashTagTitleLabel.text = "# test"
cell.peopleLabel.text = "128 people are talking" cell.peopleLabel.text = "128 people are talking"
@ -112,7 +110,6 @@ struct SearchRecommendTagsCollectionViewCell_Previews: PreviewProvider {
} }
.background(Color.gray) .background(Color.gray)
} }
} }
#endif #endif

View File

@ -1,14 +1,14 @@
// //
// SearchViewController+hashTagCollectionView.swift // SearchViewController+RecomendView.swift
// Mastodon // Mastodon
// //
// Created by sxiaojian on 2021/3/31. // Created by sxiaojian on 2021/3/31.
// //
import Foundation import Foundation
import UIKit
import OSLog
import MastodonSDK import MastodonSDK
import OSLog
import UIKit
extension SearchViewController { extension SearchViewController {
func setupHashTagCollectionView() { func setupHashTagCollectionView() {
@ -17,15 +17,15 @@ extension SearchViewController {
header.descriptionLabel.text = L10n.Scene.Search.Recommend.HashTag.description header.descriptionLabel.text = L10n.Scene.Search.Recommend.HashTag.description
header.seeAllButton.addTarget(self, action: #selector(SearchViewController.hashTagSeeAllButtonPressed(_:)), for: .touchUpInside) header.seeAllButton.addTarget(self, action: #selector(SearchViewController.hashTagSeeAllButtonPressed(_:)), for: .touchUpInside)
stackView.addArrangedSubview(header) stackView.addArrangedSubview(header)
hashTagCollectionView.register(SearchRecommendTagsCollectionViewCell.self, forCellWithReuseIdentifier: String(describing: SearchRecommendTagsCollectionViewCell.self)) hashTagCollectionView.register(SearchRecommendTagsCollectionViewCell.self, forCellWithReuseIdentifier: String(describing: SearchRecommendTagsCollectionViewCell.self))
hashTagCollectionView.delegate = self hashTagCollectionView.delegate = self
stackView.addArrangedSubview(hashTagCollectionView) stackView.addArrangedSubview(hashTagCollectionView)
hashTagCollectionView.constrain([ hashTagCollectionView.constrain([
hashTagCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: 130) hashTagCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: 130)
]) ])
viewModel.requestRecommendHashTags() viewModel.requestRecommendHashTags()
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink { [weak self] _ in .sink { [weak self] _ in
@ -39,10 +39,10 @@ extension SearchViewController {
self.hashTagDiffableDataSource = dataSource self.hashTagDiffableDataSource = dataSource
} }
} receiveValue: { _ in } receiveValue: { _ in
} }
.store(in: &disposeBag) .store(in: &disposeBag)
} }
func setupAccountsCollectionView() { func setupAccountsCollectionView() {
let header = SearchRecommendCollectionHeader() let header = SearchRecommendCollectionHeader()
header.titleLabel.text = L10n.Scene.Search.Recommend.Accounts.title header.titleLabel.text = L10n.Scene.Search.Recommend.Accounts.title
@ -71,11 +71,10 @@ extension SearchViewController {
self.accountDiffableDataSource = dataSource self.accountDiffableDataSource = dataSource
} }
} receiveValue: { _ in } receiveValue: { _ in
} }
.store(in: &disposeBag) .store(in: &disposeBag)
} }
override func viewDidLayoutSubviews() { override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews() super.viewDidLayoutSubviews()
hashTagCollectionView.collectionViewLayout.invalidateLayout() hashTagCollectionView.collectionViewLayout.invalidateLayout()
@ -85,16 +84,16 @@ extension SearchViewController {
extension SearchViewController: UICollectionViewDelegate { extension SearchViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: indexPath: %s", ((#file as NSString).lastPathComponent), #line, #function, indexPath.debugDescription) os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: indexPath: %s", (#file as NSString).lastPathComponent, #line, #function, indexPath.debugDescription)
collectionView.selectItem(at: indexPath, animated: true, scrollPosition: .centeredHorizontally) collectionView.selectItem(at: indexPath, animated: true, scrollPosition: .centeredHorizontally)
} }
} }
// MARK: - UICollectionViewDelegateFlowLayout // MARK: - UICollectionViewDelegateFlowLayout
extension SearchViewController: UICollectionViewDelegateFlowLayout {
extension SearchViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
} }
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
@ -104,24 +103,18 @@ extension SearchViewController: UICollectionViewDelegateFlowLayout {
return 12 return 12
} }
} }
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
if collectionView == hashTagCollectionView { if collectionView == hashTagCollectionView {
return CGSize(width: 228, height: 130) return CGSize(width: 228, height: 130)
} else { } else {
return CGSize(width: 257, height: 202) return CGSize(width: 257, height: 202)
} }
} }
} }
extension SearchViewController { extension SearchViewController {
@objc func hashTagSeeAllButtonPressed(_ sender: UIButton) { @objc func hashTagSeeAllButtonPressed(_ sender: UIButton) {}
} @objc func accountSeeAllButtonPressed(_ sender: UIButton) {}
@objc func accountSeeAllButtonPressed(_ sender: UIButton) {
}
} }

View File

@ -5,12 +5,11 @@
// Created by sxiaojian on 2021/3/31. // Created by sxiaojian on 2021/3/31.
// //
import UIKit
import Combine import Combine
import MastodonSDK import MastodonSDK
import UIKit
final class SearchViewController: UIViewController, NeedsDependency { final class SearchViewController: UIViewController, NeedsDependency {
weak var context: AppContext! { willSet { precondition(!isViewLoaded) } } weak var context: AppContext! { willSet { precondition(!isViewLoaded) } }
weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } } weak var coordinator: SceneCoordinator! { willSet { precondition(!isViewLoaded) } }
@ -57,10 +56,10 @@ final class SearchViewController: UIViewController, NeedsDependency {
view.translatesAutoresizingMaskIntoConstraints = false view.translatesAutoresizingMaskIntoConstraints = false
return view return view
}() }()
var hashTagDiffableDataSource: UICollectionViewDiffableDataSource<RecomendHashTagSection, Mastodon.Entity.Tag>? var hashTagDiffableDataSource: UICollectionViewDiffableDataSource<RecomendHashTagSection, Mastodon.Entity.Tag>?
var accountDiffableDataSource: UICollectionViewDiffableDataSource<RecommendAccountSection, Mastodon.Entity.Account>? var accountDiffableDataSource: UICollectionViewDiffableDataSource<RecommendAccountSection, Mastodon.Entity.Account>?
let accountsCollectionView: UICollectionView = { let accountsCollectionView: UICollectionView = {
let flowLayout = UICollectionViewFlowLayout() let flowLayout = UICollectionViewFlowLayout()
flowLayout.scrollDirection = .horizontal flowLayout.scrollDirection = .horizontal
@ -75,7 +74,6 @@ final class SearchViewController: UIViewController, NeedsDependency {
} }
extension SearchViewController { extension SearchViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = Asset.Colors.Background.search.color view.backgroundColor = Asset.Colors.Background.search.color
@ -85,8 +83,8 @@ extension SearchViewController {
setupScrollView() setupScrollView()
setupHashTagCollectionView() setupHashTagCollectionView()
setupAccountsCollectionView() setupAccountsCollectionView()
} }
func setupScrollView() { func setupScrollView() {
view.addSubview(scrollView) view.addSubview(scrollView)
scrollView.constrain([ scrollView.constrain([
@ -94,7 +92,7 @@ extension SearchViewController {
scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor), scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor), scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
scrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: view.widthAnchor) scrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: view.widthAnchor),
]) ])
scrollView.addSubview(stackView) scrollView.addSubview(stackView)
@ -105,7 +103,6 @@ extension SearchViewController {
stackView.widthAnchor.constraint(equalTo: scrollView.contentLayoutGuide.widthAnchor), stackView.widthAnchor.constraint(equalTo: scrollView.contentLayoutGuide.widthAnchor),
scrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: stackView.bottomAnchor), scrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: stackView.bottomAnchor),
]) ])
} }
} }
@ -128,20 +125,13 @@ extension SearchViewController: UISearchBarDelegate {
viewModel.searchText.send(searchText) viewModel.searchText.send(searchText)
} }
func searchBarBookmarkButtonClicked(_ searchBar: UISearchBar) { func searchBarBookmarkButtonClicked(_ searchBar: UISearchBar) {}
}
}
extension SearchViewController {
} }
#if canImport(SwiftUI) && DEBUG #if canImport(SwiftUI) && DEBUG
import SwiftUI import SwiftUI
struct SearchViewController_Previews: PreviewProvider { struct SearchViewController_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
UIViewControllerPreview { UIViewControllerPreview {
let viewController = SearchViewController() let viewController = SearchViewController()
@ -149,7 +139,6 @@ struct SearchViewController_Previews: PreviewProvider {
} }
.previewLayout(.fixed(width: 375, height: 800)) .previewLayout(.fixed(width: 375, height: 800))
} }
} }
#endif #endif

View File

@ -62,10 +62,9 @@ extension SearchRecommendCollectionHeader {
import SwiftUI import SwiftUI
struct SearchRecommendCollectionHeader_Previews: PreviewProvider { struct SearchRecommendCollectionHeader_Previews: PreviewProvider {
static var controls: some View { static var controls: some View {
Group { Group {
UIViewPreview() { UIViewPreview {
let cell = SearchRecommendCollectionHeader() let cell = SearchRecommendCollectionHeader()
cell.titleLabel.text = "Trending in your timeline" cell.titleLabel.text = "Trending in your timeline"
cell.descriptionLabel.text = "Hashtags that are getting quite a bit of attention among people you follow" cell.descriptionLabel.text = "Hashtags that are getting quite a bit of attention among people you follow"
@ -83,7 +82,6 @@ struct SearchRecommendCollectionHeader_Previews: PreviewProvider {
} }
.background(Color.gray) .background(Color.gray)
} }
} }
#endif #endif