Merge pull request #1116 from mastodon/ios-141-search-flow-fixes

Search Flow QA (IOS-141)
This commit is contained in:
Nathan Mattes 2023-09-20 21:34:20 +02:00 committed by GitHub
commit b9ca2e59ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 63 deletions

View File

@ -44,7 +44,6 @@
2A72812E297EA9D8004138C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2A72812D297EA9D8004138C5 /* Assets.xcassets */; };
2A728134297EA9D8004138C5 /* WidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A728120297EA9D7004138C5 /* WidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
2A72813F297EC762004138C5 /* WidgetExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A72813E297EC762004138C5 /* WidgetExtension.swift */; };
2A76F75C2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */; };
2A82294F29262EE000D2A1F7 /* AppContext+NextAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */; };
2A86A14629892944007F1062 /* MultiFollowersCountIntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14529892944007F1062 /* MultiFollowersCountIntentHandler.swift */; };
2A86A14929892B3A007F1062 /* MultiFollowersCountWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14829892B3A007F1062 /* MultiFollowersCountWidget.swift */; };
@ -639,7 +638,6 @@
2A72812D297EA9D8004138C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2A72812F297EA9D8004138C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2A72813E297EC762004138C5 /* WidgetExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetExtension.swift; sourceTree = "<group>"; };
2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineHeaderViewActionButton.swift; sourceTree = "<group>"; };
2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppContext+NextAccount.swift"; sourceTree = "<group>"; };
2A86A14529892944007F1062 /* MultiFollowersCountIntentHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountIntentHandler.swift; sourceTree = "<group>"; };
2A86A14829892B3A007F1062 /* MultiFollowersCountWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountWidget.swift; sourceTree = "<group>"; };
@ -1323,7 +1321,6 @@
0F20220626134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift */,
0F20222C261457EE000C64BF /* HashtagTimelineViewModel+State.swift */,
2A506CF5292D040100059C37 /* HashtagTimelineHeaderView.swift */,
2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */,
);
path = HashtagTimeline;
sourceTree = "<group>";
@ -3881,7 +3878,6 @@
DBCC3B30261440A50045B23D /* UITabBarController.swift in Sources */,
DB3E6FE42806A5B800B035AE /* DiscoverySection.swift in Sources */,
DB8190C62601FF0400020C08 /* AttachmentContainerView.swift in Sources */,
2A76F75C2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift in Sources */,
DB697DDB278F4DE3004EF2F7 /* DataSourceProvider+StatusTableViewCellDelegate.swift in Sources */,
DB87D4512609CF1E00D12C0D /* ComposeStatusPollOptionAppendEntryCollectionViewCell.swift in Sources */,
DBB45B5627B39FC9002DC5A7 /* MediaPreviewVideoViewController.swift in Sources */,

View File

@ -69,10 +69,13 @@ final class HashtagTimelineHeaderView: UIView {
var onButtonTapped: (() -> Void)?
let followButton: UIButton = {
let button = HashtagTimelineHeaderViewActionButton()
button.cornerRadius = 10
button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 16, bottom: 5, right: 16) // set 28pt height
button.titleLabel?.font = .systemFont(ofSize: 14, weight: .bold)
let button = UIButton(configuration: .tinted())
button.configuration?.background.cornerRadius = 10
button.configuration?.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer({ incoming in
var outgoing = incoming
outgoing.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .boldSystemFont(ofSize: 15))
return outgoing
})
return button
}()
@ -153,14 +156,18 @@ private extension HashtagTimelineHeaderView {
extension HashtagTimelineHeaderView {
func update(_ entity: HashtagTimelineHeaderView.Data) {
titleLabel.text = "#\(entity.name)"
followButton.setTitle(entity.following == true ? L10n.Scene.FollowedTags.Actions.unfollow : L10n.Scene.FollowedTags.Actions.follow, for: .normal)
followButton.backgroundColor = entity.following == true ? Asset.Colors.Button.tagUnfollow.color : Asset.Colors.Button.tagFollow.color
followButton.setTitleColor(
entity.following == true ? Asset.Colors.Button.tagFollow.color : Asset.Colors.Button.tagUnfollow.color,
for: .normal
)
if entity.following {
followButton.configuration?.background.backgroundColor = Asset.Colors.Button.userFollowing.color
followButton.configuration?.baseForegroundColor = Asset.Colors.Button.userFollowingTitle.color
followButton.configuration?.title = L10n.Scene.FollowedTags.Actions.unfollow
} else {
followButton.configuration?.background.backgroundColor = Asset.Colors.Button.userFollow.color
followButton.configuration?.baseForegroundColor = .white
followButton.configuration?.title = L10n.Scene.FollowedTags.Actions.follow
}
followButton.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 6, leading: 16, bottom: 5, trailing: 16)
postCountLabel.text = String(entity.postCount)
participantsLabel.text = String(entity.participantsCount)

View File

@ -1,47 +0,0 @@
//
// HashtagTimelineHeaderViewActionButton.swift
// Mastodon
//
// Created by Marcus Kida on 25.11.22.
//
import UIKit
import MastodonUI
import MastodonAsset
class HashtagTimelineHeaderViewActionButton: RoundedEdgesButton {
init() {
super.init(frame: .zero)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func layoutSubviews() {
super.layoutSubviews()
let shadowColor: UIColor = {
switch traitCollection.userInterfaceStyle {
case .dark:
return .darkGray
default:
return .lightGray
}
}()
layer.setupShadow(
color: shadowColor,
alpha: 1,
x: 0,
y: 1,
blur: 2,
spread: 0,
roundedRect: bounds,
byRoundingCorners: .allCorners,
cornerRadii: CGSize(width: cornerRadius, height: cornerRadius)
)
}
}

View File

@ -34,6 +34,7 @@ class SearchResultsOverviewTableViewController: UIViewController, NeedsDependenc
self.coordinator = sceneCoordinator
tableView = UITableView(frame: .zero, style: .insetGrouped)
tableView.keyboardDismissMode = .onDrag
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.backgroundColor = .systemGroupedBackground
tableView.separatorInset.left = 62

View File

@ -265,7 +265,12 @@ extension SearchDetailViewController: UISearchBarDelegate {
}
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
guard let searchText = searchBar.text, searchText.isNotEmpty else { return }
searchBar.resignFirstResponder()
let searchResultViewModel = SearchResultViewModel(context: context, authContext: viewModel.authContext, searchScope: .all, searchText: searchText)
coordinator.present(scene: .searchResult(viewModel: searchResultViewModel), transition: .show)
}
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {

View File

@ -78,7 +78,13 @@ extension SearchResultViewModel.State {
return
}
offset = viewModel.items.count
offset = viewModel.items.filter({ item in
if case .bottomLoader(_) = item {
return false
} else {
return true
}
}).count
// not set offset for all case
// and assert other cases the items are all the same type elements