diff --git a/Localization/StringsConvertor/input/Base.lproj/app.json b/Localization/StringsConvertor/input/Base.lproj/app.json index 739573267..f22ec3098 100644 --- a/Localization/StringsConvertor/input/Base.lproj/app.json +++ b/Localization/StringsConvertor/input/Base.lproj/app.json @@ -661,6 +661,7 @@ "no_results": "No results" }, "recent_search": "Recent searches", + "clear_all": "Clear all", "clear": "Clear" } }, diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index e8c01abdd..40a6befb6 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -252,7 +252,6 @@ DB4AA6B327BA34B6009EC082 /* CellFrameCacheContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4AA6B227BA34B6009EC082 /* CellFrameCacheContainer.swift */; }; DB4F0963269ED06300D62E92 /* SearchResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4F0962269ED06300D62E92 /* SearchResultViewController.swift */; }; DB4F0966269ED52200D62E92 /* SearchResultViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4F0965269ED52200D62E92 /* SearchResultViewModel.swift */; }; - DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4F0967269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift */; }; DB4F096A269EDAD200D62E92 /* SearchResultViewModel+State.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4F0969269EDAD200D62E92 /* SearchResultViewModel+State.swift */; }; DB4F097526A037F500D62E92 /* SearchHistoryViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4F097426A037F500D62E92 /* SearchHistoryViewModel.swift */; }; DB4F097B26A039FF00D62E92 /* SearchHistorySection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB4F097A26A039FF00D62E92 /* SearchHistorySection.swift */; }; @@ -927,7 +926,6 @@ DB4B779626CA50BA00B087B3 /* th */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = th; path = th.lproj/Intents.stringsdict; sourceTree = ""; }; DB4F0962269ED06300D62E92 /* SearchResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultViewController.swift; sourceTree = ""; }; DB4F0965269ED52200D62E92 /* SearchResultViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchResultViewModel.swift; sourceTree = ""; }; - DB4F0967269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHistoryTableHeaderView.swift; sourceTree = ""; }; DB4F0969269EDAD200D62E92 /* SearchResultViewModel+State.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SearchResultViewModel+State.swift"; sourceTree = ""; }; DB4F097426A037F500D62E92 /* SearchHistoryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHistoryViewModel.swift; sourceTree = ""; }; DB4F097A26A039FF00D62E92 /* SearchHistorySection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHistorySection.swift; sourceTree = ""; }; @@ -2099,6 +2097,8 @@ DB4F0965269ED52200D62E92 /* SearchResultViewModel.swift */, DB0FCB932797E2B0006C02E2 /* SearchResultViewModel+Diffable.swift */, DB4F0969269EDAD200D62E92 /* SearchResultViewModel+State.swift */, + 2D198648261C0B8500F0B013 /* SearchResultSection.swift */, + 2D198642261BF09500F0B013 /* SearchResultItem.swift */, ); path = SearchResult; sourceTree = ""; @@ -2108,10 +2108,6 @@ children = ( DB0FCB852796BDA1006C02E2 /* SearchSection.swift */, DB0FCB872796BDA9006C02E2 /* SearchItem.swift */, - 2D198648261C0B8500F0B013 /* SearchResultSection.swift */, - 2D198642261BF09500F0B013 /* SearchResultItem.swift */, - DB4F097A26A039FF00D62E92 /* SearchHistorySection.swift */, - DB4F097C26A03A5B00D62E92 /* SearchHistoryItem.swift */, ); path = Search; sourceTree = ""; @@ -2137,7 +2133,6 @@ DB4F098026A0475500D62E92 /* View */ = { isa = PBXGroup; children = ( - DB4F0967269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift */, ); path = View; sourceTree = ""; @@ -2920,6 +2915,8 @@ DB63F76127996B6600455B82 /* SearchHistoryViewController+DataSourceProvider.swift */, DB4F097426A037F500D62E92 /* SearchHistoryViewModel.swift */, DB63F74E2799405600455B82 /* SearchHistoryViewModel+Diffable.swift */, + DB4F097A26A039FF00D62E92 /* SearchHistorySection.swift */, + DB4F097C26A03A5B00D62E92 /* SearchHistoryItem.swift */, ); path = SearchHistory; sourceTree = ""; @@ -3694,7 +3691,6 @@ 2D84350525FF858100EECE90 /* UIScrollView.swift in Sources */, 6213AF5A28939C8400BCADB6 /* BookmarkViewModel.swift in Sources */, 5B24BBDB262DB14800A9381B /* ReportStatusViewModel+Diffable.swift in Sources */, - DB4F0968269ED8AD00D62E92 /* SearchHistoryTableHeaderView.swift in Sources */, 5DA732CC2629CEF500A92342 /* UIView+Remove.swift in Sources */, 2A506CF4292CD85800059C37 /* FollowedTagsViewController.swift in Sources */, DB1D843026566512000346B3 /* KeyboardPreference.swift in Sources */, diff --git a/Mastodon/Scene/Search/Search/SearchViewController.swift b/Mastodon/Scene/Search/Search/SearchViewController.swift index e1505121d..41bc55ee0 100644 --- a/Mastodon/Scene/Search/Search/SearchViewController.swift +++ b/Mastodon/Scene/Search/Search/SearchViewController.swift @@ -171,7 +171,6 @@ extension SearchViewController { // MARK: - UISearchBarDelegate extension SearchViewController: UISearchBarDelegate { func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) searchBarTapPublisher.send("") return false } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift index 84a0aedb2..09889fc2d 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift @@ -315,8 +315,6 @@ extension SearchDetailViewController: UISearchBarDelegate { } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - // dismiss or pop if isModal { dismiss(animated: true, completion: nil) diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift index 170f59934..ecab554e1 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistorySectionHeaderCollectionReusableView.swift @@ -30,8 +30,9 @@ final class SearchHistorySectionHeaderCollectionReusableView: UICollectionReusab let clearButton: UIButton = { let button = UIButton(type: .system) - button.setImage(UIImage(systemName: "xmark.circle.fill"), for: .normal) - button.tintColor = Asset.Colors.Label.secondary.color + + button.setTitle(L10n.Scene.Search.Searching.clearAll, for: .normal) + button.tintColor = Asset.Colors.Brand.blurple.color button.accessibilityLabel = L10n.Scene.Search.Searching.clear return button @@ -47,9 +48,6 @@ final class SearchHistorySectionHeaderCollectionReusableView: UICollectionReusab _init() } -} - -extension SearchHistorySectionHeaderCollectionReusableView { private func _init() { primaryLabel.translatesAutoresizingMaskIntoConstraints = false addSubview(primaryLabel) @@ -72,9 +70,7 @@ extension SearchHistorySectionHeaderCollectionReusableView { clearButton.addTarget(self, action: #selector(SearchHistorySectionHeaderCollectionReusableView.clearButtonDidPressed(_:)), for: .touchUpInside) } -} -extension SearchHistorySectionHeaderCollectionReusableView { @objc private func clearButtonDidPressed(_ sender: UIButton) { delegate?.searchHistorySectionHeaderCollectionReusableView(self, clearButtonDidPressed: sender) } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift index e31f050bd..31350811d 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/Cell/SearchHistoryUserCollectionViewCell+ViewModel.swift @@ -31,7 +31,7 @@ extension SearchHistoryUserCollectionViewCell { func configure( me: MastodonUser?, viewModel: ViewModel, - delegate: UserViewDelegate? + delegate: SearchHistorySectionHeaderCollectionReusableViewDelegate? ) { let user = viewModel.value diff --git a/Mastodon/Diffable/Search/SearchHistoryItem.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryItem.swift similarity index 100% rename from Mastodon/Diffable/Search/SearchHistoryItem.swift rename to Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryItem.swift diff --git a/Mastodon/Diffable/Search/SearchHistorySection.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift similarity index 92% rename from Mastodon/Diffable/Search/SearchHistorySection.swift rename to Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift index 813c5b59a..d0cbc05ee 100644 --- a/Mastodon/Diffable/Search/SearchHistorySection.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistorySection.swift @@ -78,13 +78,8 @@ extension SearchHistorySection { } } - let trendHeaderRegister = UICollectionView.SupplementaryRegistration(elementKind: UICollectionView.elementKindSectionHeader) { [weak dataSource] supplementaryView, elementKind, indexPath in + let trendHeaderRegister = UICollectionView.SupplementaryRegistration(elementKind: UICollectionView.elementKindSectionHeader) { supplementaryView, elementKind, indexPath in supplementaryView.delegate = configuration.searchHistorySectionHeaderCollectionReusableViewDelegate - - guard let _ = dataSource else { return } - // let sections = dataSource.snapshot().sectionIdentifiers - // guard indexPath.section < sections.count else { return } - // let section = sections[indexPath.section] } dataSource.supplementaryViewProvider = { (collectionView: UICollectionView, elementKind: String, indexPath: IndexPath) in diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift index 2ef2c8440..d55259d03 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift @@ -118,6 +118,10 @@ extension SearchHistoryViewController: SearchHistorySectionHeaderCollectionReusa try await DataSourceFacade.responseToDeleteSearchHistory( provider: self ) + + await MainActor.run { + button.isEnabled = false + } } } } diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/View/SearchHistoryTableHeaderView.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/View/SearchHistoryTableHeaderView.swift deleted file mode 100644 index d827231c0..000000000 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/View/SearchHistoryTableHeaderView.swift +++ /dev/null @@ -1,100 +0,0 @@ -// -// SearchHistoryTableHeaderView.swift -// Mastodon -// -// Created by MainasuK Cirno on 2021-7-14. -// - -import os.log -import UIKit -import Combine -import MastodonAsset -import MastodonCore -import MastodonLocalization -import MastodonUI - -protocol SearchHistoryTableHeaderViewDelegate: AnyObject { - func searchHistoryTableHeaderView(_ searchHistoryTableHeaderView: SearchHistoryTableHeaderView, clearSearchHistoryButtonDidPressed button: UIButton) -} - -final class SearchHistoryTableHeaderView: UIView { - - let logger = Logger(subsystem: "SearchHistory", category: "UI") - - weak var delegate: SearchHistoryTableHeaderViewDelegate? - var disposeBag = Set() - - let recentSearchesLabel: UILabel = { - let label = UILabel() - label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 20, weight: .semibold)) - label.textColor = Asset.Colors.Label.primary.color - label.text = L10n.Scene.Search.Searching.recentSearch - return label - }() - - let clearSearchHistoryButton: HighlightDimmableButton = { - let button = HighlightDimmableButton(type: .custom) - button.expandEdgeInsets = UIEdgeInsets(top: -10, left: -10, bottom: -10, right: -10) - button.setTitleColor(Asset.Colors.Brand.blurple.color, for: .normal) - button.setTitle(L10n.Scene.Search.Searching.clear, for: .normal) - return button - }() - - override init(frame: CGRect) { - super.init(frame: frame) - _init() - } - - required init?(coder: NSCoder) { - super.init(coder: coder) - _init() - } - -} - -extension SearchHistoryTableHeaderView { - private func _init() { - preservesSuperviewLayoutMargins = true - - recentSearchesLabel.translatesAutoresizingMaskIntoConstraints = false - addSubview(recentSearchesLabel) - NSLayoutConstraint.activate([ - recentSearchesLabel.topAnchor.constraint(equalTo: topAnchor, constant: 16), - recentSearchesLabel.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor), - bottomAnchor.constraint(equalTo: recentSearchesLabel.bottomAnchor, constant: 16), - ]) - - clearSearchHistoryButton.translatesAutoresizingMaskIntoConstraints = false - addSubview(clearSearchHistoryButton) - NSLayoutConstraint.activate([ - clearSearchHistoryButton.centerYAnchor.constraint(equalTo: recentSearchesLabel.centerYAnchor), - clearSearchHistoryButton.leadingAnchor.constraint(equalTo: recentSearchesLabel.trailingAnchor), - clearSearchHistoryButton.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor), - ]) - clearSearchHistoryButton.setContentHuggingPriority(.defaultHigh + 10, for: .horizontal) - - clearSearchHistoryButton.addTarget(self, action: #selector(SearchHistoryTableHeaderView.clearSearchHistoryButtonDidPressed(_:)), for: .touchUpInside) - - setupBackgroundColor(theme: ThemeService.shared.currentTheme.value) - ThemeService.shared.currentTheme - .receive(on: RunLoop.main) - .sink { [weak self] theme in - guard let self = self else { return } - self.setupBackgroundColor(theme: theme) - } - .store(in: &disposeBag) - } -} - -extension SearchHistoryTableHeaderView { - @objc private func clearSearchHistoryButtonDidPressed(_ sender: UIButton) { - logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public)") - delegate?.searchHistoryTableHeaderView(self, clearSearchHistoryButtonDidPressed: sender) - } -} - -extension SearchHistoryTableHeaderView { - private func setupBackgroundColor(theme: Theme) { - backgroundColor = theme.systemGroupedBackgroundColor - } -} diff --git a/Mastodon/Diffable/Search/SearchResultItem.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultItem.swift similarity index 100% rename from Mastodon/Diffable/Search/SearchResultItem.swift rename to Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultItem.swift diff --git a/Mastodon/Diffable/Search/SearchResultSection.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultSection.swift similarity index 100% rename from Mastodon/Diffable/Search/SearchResultSection.swift rename to Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultSection.swift diff --git a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift index c08673acb..bb4184bfc 100644 --- a/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift +++ b/MastodonSDK/Sources/MastodonCore/FetchedResultsController/StatusFetchedResultsController.swift @@ -90,8 +90,6 @@ extension StatusFetchedResultsController { // MARK: - NSFetchedResultsControllerDelegate extension StatusFetchedResultsController: NSFetchedResultsControllerDelegate { public func controller(_ controller: NSFetchedResultsController, didChangeContentWith snapshot: NSDiffableDataSourceSnapshotReference) { - os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) - let indexes = statusIDs let objects = fetchedResultsController.fetchedObjects ?? [] diff --git a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift index 27f3c06d0..dcc6f84f1 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift +++ b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift @@ -1277,6 +1277,8 @@ public enum L10n { public enum Searching { /// Clear public static let clear = L10n.tr("Localizable", "Scene.Search.Searching.Clear", fallback: "Clear") + /// Clear all + public static let clearAll = L10n.tr("Localizable", "Scene.Search.Searching.ClearAll", fallback: "Clear all") /// Recent searches public static let recentSearch = L10n.tr("Localizable", "Scene.Search.Searching.RecentSearch", fallback: "Recent searches") public enum EmptyState { diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings index 7f00f1cc2..7269b0c4a 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings @@ -440,6 +440,7 @@ uploaded to Mastodon."; "Scene.Search.SearchBar.Cancel" = "Cancel"; "Scene.Search.SearchBar.Placeholder" = "Search hashtags and users"; "Scene.Search.Searching.Clear" = "Clear"; +"Scene.Search.Searching.ClearAll" = "Clear all"; "Scene.Search.Searching.EmptyState.NoResults" = "No results"; "Scene.Search.Searching.RecentSearch" = "Recent searches"; "Scene.Search.Searching.Segment.All" = "All"; @@ -554,4 +555,4 @@ uploaded to Mastodon."; "Widget.MultipleFollowers.ConfigurationDescription" = "Show number of followers for multiple accounts."; "Widget.MultipleFollowers.ConfigurationDisplayName" = "Multiple followers"; "Widget.MultipleFollowers.MockUser.AccountName" = "another@follower.social"; -"Widget.MultipleFollowers.MockUser.DisplayName" = "Another follower"; \ No newline at end of file +"Widget.MultipleFollowers.MockUser.DisplayName" = "Another follower";