Skip to content

Commit

Permalink
Merge pull request #105 from S-FAM/hotfix/search
Browse files Browse the repository at this point in the history
[Hotfix] 검색기능관련 버그
  • Loading branch information
WhiteHyun authored Mar 1, 2023
2 parents 82ca62f + ffdd3c6 commit 07571c3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 18 deletions.
15 changes: 8 additions & 7 deletions PPAK_CVS/Sources/Scenes/Bookmark/BookmarkVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ final class BookmarkViewController: BaseViewController, View {
make.width.equalTo(165)
make.height.equalTo(107)
}

self.animationContainerView.isHidden = true
}

// MARK: - Bind
Expand Down Expand Up @@ -168,13 +166,18 @@ final class BookmarkViewController: BaseViewController, View {
.disposed(by: disposeBag)

// 서치바 텍스트 반응
header.searchBar.textField.rx.controlEvent(.editingDidEndOnExit)
.withUnretained(self)
.compactMap { $0.0.header.searchBar.textField.text }
header.searchBar.textField.rx.text
.orEmpty
.map { BookmarkViewReactor.Action.didChangeSearchBarText($0) }
.bind(to: reactor.action)
.disposed(by: disposeBag)

// 검색버튼 클릭
header.searchBar.textField.rx.controlEvent(.editingDidEndOnExit)
.map { BookmarkViewReactor.Action.didTapSearchButton }
.bind(to: reactor.action)
.disposed(by: disposeBag)

// 찜 정보 터치
/*
header.infoTouchView.rx.tapGesture()
Expand Down Expand Up @@ -269,15 +272,13 @@ final class BookmarkViewController: BaseViewController, View {
reactor.state
.map { $0.currentProducts }
.distinctUntilChanged()
.debug()
.withUnretained(self)
.bind { $0.0.collectionView.reloadData() }
.disposed(by: disposeBag)

// 서치바 텍스트
reactor.state
.map { $0.currentTarget }
.distinctUntilChanged()
.bind(to: header.searchBar.textField.rx.text)
.disposed(by: disposeBag)

Expand Down
6 changes: 4 additions & 2 deletions PPAK_CVS/Sources/Scenes/Bookmark/BookmarkViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class BookmarkViewReactor: Reactor {
case didTapDropdownCVS(CVSDropdownCase)
case didTapDropdownSort(SortType)
case didChangeSearchBarText(String)
case didTapSearchButton
case didTapProduct(Int)
}

Expand Down Expand Up @@ -133,16 +134,17 @@ final class BookmarkViewReactor: Reactor {
}

case .didChangeSearchBarText(let target):
return .just(.setTarget(target))

case .didTapSearchButton:
let updatedProducts = ProductStorage.shared.retrieve(
cvs: currentState.currentCVS,
event: currentState.currentEvent,
sort: currentState.currentSort,
target: target
target: currentState.currentTarget
)

return .concat([
.just(.setTarget(target)),
.just(.hideDropdown),
.just(.setProducts(updatedProducts))
])
Expand Down
12 changes: 9 additions & 3 deletions PPAK_CVS/Sources/Scenes/Home/HomeVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,18 @@ final class HomeViewController: BaseViewController, View {
.disposed(by: disposeBag)

// 서치바 텍스트 반응
header.searchBar.textField.rx.controlEvent(.editingDidEndOnExit)
.withUnretained(self)
.compactMap { $0.0.header.searchBar.textField.text }
header.searchBar.textField.rx.text
.orEmpty
.map { HomeViewReactor.Action.didChangeSearchBarText($0) }
.bind(to: reactor.action)
.disposed(by: disposeBag)

// 검색 버튼 반응
header.searchBar.textField.rx.controlEvent(.editingDidEndOnExit)
.map { HomeViewReactor.Action.didTapSearchButton }
.bind(to: reactor.action)
.disposed(by: disposeBag)

// CVSStorage 편의점 변경 감지
CVSStorage.shared.didChangeCVS
.distinctUntilChanged()
Expand Down Expand Up @@ -214,6 +219,7 @@ final class HomeViewController: BaseViewController, View {
// 새로운 상품 목록들로 업데이트
reactor.state
.map { $0.products }
.distinctUntilChanged()
.map { _ in Void() }
.withUnretained(self)
.map { $0.0 }
Expand Down
8 changes: 5 additions & 3 deletions PPAK_CVS/Sources/Scenes/Home/HomeViewReactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class HomeViewReactor: Reactor {
case didTapDropdownCVS(CVSDropdownCase)
case didTapDropdownSort(SortType)
case didChangeSearchBarText(String)
case didTapSearchButton
case didSelectItemAt(ProductModel)
case fetchMoreData
}
Expand Down Expand Up @@ -107,7 +108,6 @@ final class HomeViewReactor: Reactor {
])

case .didTapBookmarkButton:
// guard currentState.showsBookmarkVC == false else { return .empty() }
return .concat([
.just(.hideDropdown),
.just(.setBookmarkVC(true)),
Expand Down Expand Up @@ -171,17 +171,19 @@ final class HomeViewReactor: Reactor {
])

case .didChangeSearchBarText(let target):
return .just(.setTarget(target))

case .didTapSearchButton:
return .concat([
.just(.setLoading(true)),
.just(.resetProducts),
.just(.resetOffset),
.just(.setTarget(target)),
.just(.hideDropdown),
requestProducts(
cvs: currentState.currentCVSType,
event: currentState.currentEventType,
sort: currentState.currentSortType,
name: target
name: currentState.currentTarget
)
])

Expand Down
6 changes: 3 additions & 3 deletions PPAK_CVS/Sources/Scenes/Setting/SettingConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
import Foundation

enum Message {

static let sendMailFail = "메일을 보낼 수 없습니다."
static let retry = "메일을 보내려면 'Mail' 앱이 필요합니다.\nApp Store에서 해당 앱을 복원하거나 이메일 설정을 확인하고 다시 시도해주세요."
static let email = "[email protected]"

static let cancel = "취소"
static let moveAppStore = "App Store로 이동"
}

struct Configs {

static let appID = "id1665633509"
static let appStoreMailURL = "https://apps.apple.com/kr/app/mail/id1108187098"
}

0 comments on commit 07571c3

Please sign in to comment.