Skip to content

Commit

Permalink
🐛 検索履歴が正常に更新できていなかった問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
tasuwo committed May 4, 2021
1 parent 04f7056 commit a20c0de
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 58 deletions.
12 changes: 8 additions & 4 deletions TBox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
2CDD81132640EBE700DAEE93 /* ThumbnailPresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CDD81122640EBE700DAEE93 /* ThumbnailPresentable.swift */; };
2CDD811526410DAC00DAEE93 /* ClipCollectionPreLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CDD811426410DAC00DAEE93 /* ClipCollectionPreLoader.swift */; };
2CDD811726410FE500DAEE93 /* ThumbnailPrefetchObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CDD811626410FE500DAEE93 /* ThumbnailPrefetchObserver.swift */; };
2CDD811926415E4C00DAEE93 /* ClipSearchHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CDD811826415E4C00DAEE93 /* ClipSearchHistory.swift */; };
2CF798E9AA8CD17482922B52 /* TextEditAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB8EB73E5E48D51233A69439 /* TextEditAlert.swift */; };
2D5E35E175AC1E89520B7CE6 /* ClipItemImageShareItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1517EBB9B3F8FAC048B006C4 /* ClipItemImageShareItem.swift */; };
2D682CD34D73E65064CB9092 /* ClipMergeImageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1E4266439A54DC2A1BD5771A /* ClipMergeImageCell.xib */; };
Expand Down Expand Up @@ -570,7 +571,7 @@
FB999E5A9B4C9A68FED90DCE /* Domain.AutoDefaultValue.generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28F3962B4D6757D6C7EE8EE /* Domain.AutoDefaultValue.generated.swift */; };
FBF1B91A314A25A03FB3DFF9 /* TransferringClip.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCEC3CCBF4581FD7E8603E6F /* TransferringClip.swift */; };
FC50C39641DB672E4DE41C81 /* Persistence.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E62DA54F7E7544BDEFAFC1F2 /* Persistence.framework */; };
FCC7776563B264DFB217850B /* ClipSearchHistoryListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8196DA03917B8218A381F618 /* ClipSearchHistoryListCell.swift */; };
FCC7776563B264DFB217850B /* ClipSearchHistoryContentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8196DA03917B8218A381F618 /* ClipSearchHistoryContentCell.swift */; };
FCEC7EC4073BEF150965494E /* AlbumSelectionModalAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96135E777415B15AE45BB131 /* AlbumSelectionModalAction.swift */; };
FDD82070AFF49D368C1690A5 /* DependencyContainer+Router.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDFBB7EFBB72AF7E0C379F47 /* DependencyContainer+Router.swift */; };
FE5C0346748096C8B0AB37E1 /* AlbumListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A75570DD7FB01C634043477 /* AlbumListViewController.swift */; };
Expand Down Expand Up @@ -1035,6 +1036,7 @@
2CDD81122640EBE700DAEE93 /* ThumbnailPresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailPresentable.swift; sourceTree = "<group>"; };
2CDD811426410DAC00DAEE93 /* ClipCollectionPreLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipCollectionPreLoader.swift; sourceTree = "<group>"; };
2CDD811626410FE500DAEE93 /* ThumbnailPrefetchObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThumbnailPrefetchObserver.swift; sourceTree = "<group>"; };
2CDD811826415E4C00DAEE93 /* ClipSearchHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipSearchHistory.swift; sourceTree = "<group>"; };
2D77435F6E8E115402226FFD /* ClipSearchHistoryService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipSearchHistoryService.swift; sourceTree = "<group>"; };
2EA95B1E82FA0198AB863F37 /* ClipCollectionMenuBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipCollectionMenuBuilder.swift; sourceTree = "<group>"; };
2F09E79C19111463EBFBAD62 /* EmptyMessageView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = EmptyMessageView.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1215,7 +1217,7 @@
80D8F5CFD66244BD80528960 /* ClipCollectionViewLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipCollectionViewLayout.swift; sourceTree = "<group>"; };
80DF6BC653CC7924402EA55B /* ShareNavigationRootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareNavigationRootViewController.swift; sourceTree = "<group>"; };
810474F40EFD8CCE4E42F449 /* Array+Indexed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Indexed.swift"; sourceTree = "<group>"; };
8196DA03917B8218A381F618 /* ClipSearchHistoryListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipSearchHistoryListCell.swift; sourceTree = "<group>"; };
8196DA03917B8218A381F618 /* ClipSearchHistoryContentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipSearchHistoryContentCell.swift; sourceTree = "<group>"; };
81D36E5B34039C00183839FC /* TemporaryClipStorage_Configuration+Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TemporaryClipStorage_Configuration+Constants.swift"; sourceTree = "<group>"; };
823BCEB98141B32977A43111 /* HasUserSettingStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HasUserSettingStorage.swift; sourceTree = "<group>"; };
84A9023F8DF190A30687493B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3031,13 +3033,14 @@
98CEC6A1BE9DCE7B31EFC1CF /* ClipSearchEntry */ = {
isa = PBXGroup;
children = (
2CDD811826415E4C00DAEE93 /* ClipSearchHistory.swift */,
8196DA03917B8218A381F618 /* ClipSearchHistoryContentCell.swift */,
A1BC9F3CA3583DB730E49E4F /* ClipSearchHistoryContentConfiguration.swift */,
E27BDF539AA736E5753EA0E8 /* ClipSearchHistoryContentView.swift */,
F2502317EED048A55EE41318 /* ClipSearchHistoryContentView.xib */,
4316C5253929032F024C109E /* ClipSearchHistoryHeaderCell.swift */,
6C686F1B724DBAFCC62BACCB /* ClipSearchHistoryHeaderConfiguration.swift */,
9EC0F5CF61A1D69919757C5B /* ClipSearchHistoryHeaderContentView.swift */,
8196DA03917B8218A381F618 /* ClipSearchHistoryListCell.swift */,
6D10BA8859EA3DAD25772067 /* SearchEntrySectionFooterView.swift */,
);
path = ClipSearchEntry;
Expand Down Expand Up @@ -4689,6 +4692,7 @@
E1D58875CAC9613923295216 /* AlbumListCollectionView.swift in Sources */,
EC1036B9962D97899CD3F083 /* AlbumListCollectionViewCell.swift in Sources */,
C2F9CD6719A2262D86F305F9 /* AlbumSelectionCell.swift in Sources */,
2CDD811926415E4C00DAEE93 /* ClipSearchHistory.swift in Sources */,
8BD77C3988316E4C9731A1C0 /* AlbumSelectionTableView.swift in Sources */,
492134C769A12030E01C7393 /* AssetCatalog.swift in Sources */,
39250701FA4547A22064CA40 /* ButtonCell.swift in Sources */,
Expand Down Expand Up @@ -4729,7 +4733,7 @@
57A69CD57AE89E330C3FD841 /* ClipSearchHistoryHeaderCell.swift in Sources */,
CD6B622911CEC366CF236C8F /* ClipSearchHistoryHeaderConfiguration.swift in Sources */,
577A71E99922A50B9FFDA7BB /* ClipSearchHistoryHeaderContentView.swift in Sources */,
FCC7776563B264DFB217850B /* ClipSearchHistoryListCell.swift in Sources */,
FCC7776563B264DFB217850B /* ClipSearchHistoryContentCell.swift in Sources */,
C67CD8F6BAD11CFDA2F6A7A8 /* ClipSelectionCollectionViewCell.swift in Sources */,
1D054A593E51A35B3C6471F0 /* EmptyMessageView.swift in Sources */,
84129DF2521938FFDC0F6A21 /* FadeTransitionAnimator.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum SearchEntryViewLayout {

struct SearchHistoryWrapper: Hashable {
let isSomeItemsHidden: Bool
let original: ClipSearchHistory
let original: Domain.ClipSearchHistory

var query: ClipSearchQuery { original.query }
}
Expand Down Expand Up @@ -119,25 +119,21 @@ extension SearchEntryViewLayout {
private static func configureHistoryHeader(removeAllHistoriesHandler: @escaping () -> Void) -> UICollectionView.CellRegistration<ClipSearchHistoryHeaderCell, Bool>
{
return .init { cell, _, isEnabled in
var contentConfiguration = ClipSearchHistoryHeaderConfiguration()
contentConfiguration.isRemoveAllButtonEnabled = isEnabled
contentConfiguration.removeAllHistoriesHandler = removeAllHistoriesHandler
cell.contentConfiguration = contentConfiguration
cell.removeAllHistoriesHandler = removeAllHistoriesHandler
cell.isRemoveAllButtonEnabled = isEnabled

var backgroundConfiguration = UIBackgroundConfiguration.listPlainHeaderFooter()
backgroundConfiguration.backgroundColor = .clear
cell.backgroundConfiguration = backgroundConfiguration
}
}

private static func configureHistoryCell() -> UICollectionView.CellRegistration<ClipSearchHistoryListCell, SearchHistoryWrapper> {
private static func configureHistoryCell() -> UICollectionView.CellRegistration<ClipSearchHistoryContentCell, SearchHistoryWrapper> {
return .init { cell, _, history in
var contentConfiguration = ClipSearchHistoryContentConfiguration()
contentConfiguration.queryConfiguration = .init(title: history.query.displayTitle,
sortName: history.query.sort.displayTitle,
displaySettingName: history.query.displaySettingDisplayTitle,
isDisplaySettingHidden: history.isSomeItemsHidden)
cell.contentConfiguration = contentConfiguration
cell.searchHistory = .init(title: history.query.displayTitle,
sortName: history.query.sort.displayTitle,
displaySettingName: history.query.displaySettingDisplayTitle,
isDisplaySettingHidden: history.isSomeItemsHidden)

var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell()
backgroundConfiguration.backgroundColor = Asset.Color.secondaryBackgroundClient.color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension SearchResultViewController {
store.execute(.entryViewDidAppear)
}

func entrySelected(_ history: ClipSearchHistory) {
func entrySelected(_ history: Domain.ClipSearchHistory) {
searchController.searchBar.becomeFirstResponder()
store.execute(.selectedHistory(history))

Expand Down
17 changes: 17 additions & 0 deletions TBoxUIKit/View/ClipSearchEntry/ClipSearchHistory.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Copyright © 2021 Tasuku Tozawa. All rights reserved.
//

public struct ClipSearchHistory {
public let title: String
public let sortName: String
public let displaySettingName: String
public let isDisplaySettingHidden: Bool

public init(title: String, sortName: String, displaySettingName: String, isDisplaySettingHidden: Bool) {
self.title = title
self.sortName = sortName
self.displaySettingName = displaySettingName
self.isDisplaySettingHidden = isDisplaySettingHidden
}
}
16 changes: 16 additions & 0 deletions TBoxUIKit/View/ClipSearchEntry/ClipSearchHistoryContentCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright © 2021 Tasuku Tozawa. All rights reserved.
//

import Domain
import UIKit

public class ClipSearchHistoryContentCell: UICollectionViewListCell {
public var searchHistory: ClipSearchHistory?

override public func updateConfiguration(using state: UICellConfigurationState) {
var newConfiguration = ClipSearchHistoryContentConfiguration().updated(for: state)
newConfiguration.clipSearchHistory = searchHistory
contentConfiguration = newConfiguration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,10 @@
import UIKit

public struct ClipSearchHistoryContentConfiguration {
public struct QueryConfiguration {
public let title: String
public let sortName: String
public let displaySettingName: String
public let isDisplaySettingHidden: Bool

public init(title: String, sortName: String, displaySettingName: String, isDisplaySettingHidden: Bool) {
self.title = title
self.sortName = sortName
self.displaySettingName = displaySettingName
self.isDisplaySettingHidden = isDisplaySettingHidden
}
}

public var queryConfiguration: QueryConfiguration?
public var clipSearchHistory: ClipSearchHistory?

public init() {
self.queryConfiguration = nil
self.clipSearchHistory = nil
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ extension ClipSearchHistoryContentView {
private func apply(_ configuration: ClipSearchHistoryContentConfiguration) {
_configuration = configuration

guard let configuration = configuration.queryConfiguration else {
guard let history = configuration.clipSearchHistory else {
titleLabel.text = nil
secondaryTitleLabel.text = nil
return
}

titleLabel.text = configuration.title
titleLabel.text = history.title
secondaryTitleLabel.text = [
configuration.isDisplaySettingHidden ? nil : configuration.displaySettingName,
configuration.sortName
history.isDisplaySettingHidden ? nil : history.displaySettingName,
history.sortName
].compactMap { $0 }.joined(separator: " / ")
}
}
10 changes: 6 additions & 4 deletions TBoxUIKit/View/ClipSearchEntry/ClipSearchHistoryHeaderCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import Domain
import UIKit

public class ClipSearchHistoryHeaderCell: UICollectionViewListCell {
private var _contentConfiguration: ClipSearchHistoryHeaderConfiguration {
return (contentConfiguration as? ClipSearchHistoryHeaderConfiguration) ?? ClipSearchHistoryHeaderConfiguration()
}
public var isRemoveAllButtonEnabled: Bool = false
public var removeAllHistoriesHandler: (() -> Void)?

override public func updateConfiguration(using state: UICellConfigurationState) {
contentConfiguration = _contentConfiguration.updated(for: state)
var newConfiguration = ClipSearchHistoryHeaderConfiguration().updated(for: state)
newConfiguration.isRemoveAllButtonEnabled = isRemoveAllButtonEnabled
newConfiguration.removeAllHistoriesHandler = removeAllHistoriesHandler
contentConfiguration = newConfiguration
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import UIKit

public struct ClipSearchHistoryHeaderConfiguration {
public var title: String = ""
public var isRemoveAllButtonEnabled = false
public var removeAllHistoriesHandler: (() -> Void)?

Expand Down
16 changes: 0 additions & 16 deletions TBoxUIKit/View/ClipSearchEntry/ClipSearchHistoryListCell.swift

This file was deleted.

0 comments on commit a20c0de

Please sign in to comment.