fix: search scene UI update
This commit is contained in:
parent
7d24b389d7
commit
f84fb723df
|
@ -83,7 +83,6 @@ extension SearchRecommendTagsCollectionViewCell {
|
||||||
let containerStackView = UIStackView()
|
let containerStackView = UIStackView()
|
||||||
containerStackView.axis = .vertical
|
containerStackView.axis = .vertical
|
||||||
containerStackView.distribution = .fill
|
containerStackView.distribution = .fill
|
||||||
containerStackView.spacing = 6
|
|
||||||
containerStackView.layoutMargins = UIEdgeInsets(top: 16, left: 16, bottom: 0, right: 16)
|
containerStackView.layoutMargins = UIEdgeInsets(top: 16, left: 16, bottom: 0, right: 16)
|
||||||
containerStackView.isLayoutMarginsRelativeArrangement = true
|
containerStackView.isLayoutMarginsRelativeArrangement = true
|
||||||
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
containerStackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -113,6 +112,7 @@ extension SearchRecommendTagsCollectionViewCell {
|
||||||
peopleLabel.translatesAutoresizingMaskIntoConstraints = false
|
peopleLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||||
peopleLabel.setContentHuggingPriority(.defaultLow - 1, for: .vertical)
|
peopleLabel.setContentHuggingPriority(.defaultLow - 1, for: .vertical)
|
||||||
containerStackView.addArrangedSubview(peopleLabel)
|
containerStackView.addArrangedSubview(peopleLabel)
|
||||||
|
containerStackView.setCustomSpacing(SearchViewController.hashtagPeopleTalkingLabelTop, after: horizontalStackView)
|
||||||
}
|
}
|
||||||
|
|
||||||
func config(with tag: Mastodon.Entity.Tag) {
|
func config(with tag: Mastodon.Entity.Tag) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ extension SearchViewController {
|
||||||
hashtagCollectionView.translatesAutoresizingMaskIntoConstraints = false
|
hashtagCollectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
stackView.addArrangedSubview(hashtagCollectionView)
|
stackView.addArrangedSubview(hashtagCollectionView)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
hashtagCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: 130)
|
hashtagCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: CGFloat(SearchViewController.hashtagCardHeight))
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ extension SearchViewController {
|
||||||
accountsCollectionView.translatesAutoresizingMaskIntoConstraints = false
|
accountsCollectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
stackView.addArrangedSubview(accountsCollectionView)
|
stackView.addArrangedSubview(accountsCollectionView)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
accountsCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: 202)
|
accountsCollectionView.frameLayoutGuide.heightAnchor.constraint(equalToConstant: CGFloat(SearchViewController.accountCardHeight))
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ extension SearchViewController: UICollectionViewDelegateFlowLayout {
|
||||||
|
|
||||||
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: SearchViewController.hashtagCardHeight)
|
||||||
} else {
|
} else {
|
||||||
return CGSize(width: 257, height: 202)
|
return CGSize(width: 257, height: SearchViewController.accountCardHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,26 @@ import MastodonSDK
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
final class SearchViewController: UIViewController, NeedsDependency {
|
final class SearchViewController: UIViewController, NeedsDependency {
|
||||||
|
|
||||||
|
public static var hashtagCardHeight: CGFloat {
|
||||||
|
get {
|
||||||
|
if UIScreen.main.bounds.size.height > 736 {
|
||||||
|
return 186
|
||||||
|
}
|
||||||
|
return 130
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static var hashtagPeopleTalkingLabelTop: CGFloat {
|
||||||
|
get {
|
||||||
|
if UIScreen.main.bounds.size.height > 736 {
|
||||||
|
return 18
|
||||||
|
}
|
||||||
|
return 6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static let accountCardHeight = 202
|
||||||
|
|
||||||
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) } }
|
||||||
|
|
||||||
|
@ -49,9 +69,6 @@ final class SearchViewController: UIViewController, NeedsDependency {
|
||||||
let stackView = UIStackView()
|
let stackView = UIStackView()
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.distribution = .fill
|
stackView.distribution = .fill
|
||||||
stackView.spacing = 0
|
|
||||||
stackView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 68, right: 0)
|
|
||||||
stackView.isLayoutMarginsRelativeArrangement = true
|
|
||||||
return stackView
|
return stackView
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -130,6 +147,8 @@ extension SearchViewController {
|
||||||
setupSearchingTableView()
|
setupSearchingTableView()
|
||||||
setupDataSource()
|
setupDataSource()
|
||||||
setupSearchHeader()
|
setupSearchHeader()
|
||||||
|
view.bringSubviewToFront(searchBar)
|
||||||
|
view.bringSubviewToFront(statusBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupSearchBar() {
|
func setupSearchBar() {
|
||||||
|
@ -148,23 +167,27 @@ extension SearchViewController {
|
||||||
statusBar.topAnchor.constraint(equalTo: view.topAnchor),
|
statusBar.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
statusBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
statusBar.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
statusBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
statusBar.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
statusBar.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 3),
|
statusBar.bottomAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 3),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupScrollView() {
|
func setupScrollView() {
|
||||||
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
scrollView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
||||||
|
// scrollView
|
||||||
view.addSubview(scrollView)
|
view.addSubview(scrollView)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
scrollView.frameLayoutGuide.topAnchor.constraint(equalTo: searchBar.bottomAnchor),
|
scrollView.frameLayoutGuide.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: searchBar.frame.height),
|
||||||
scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
|
scrollView.frameLayoutGuide.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
|
view.trailingAnchor.constraint(equalTo: scrollView.frameLayoutGuide.trailingAnchor),
|
||||||
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
|
scrollView.frameLayoutGuide.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
scrollView.contentLayoutGuide.widthAnchor.constraint(equalTo: view.widthAnchor),
|
scrollView.frameLayoutGuide.widthAnchor.constraint(equalTo: scrollView.contentLayoutGuide.widthAnchor),
|
||||||
])
|
])
|
||||||
|
|
||||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
// stackview
|
||||||
scrollView.addSubview(stackView)
|
scrollView.addSubview(stackView)
|
||||||
|
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
stackView.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor),
|
stackView.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor),
|
||||||
stackView.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor),
|
stackView.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor),
|
||||||
|
|
Loading…
Reference in New Issue