-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Design] #3 - 검색 UI 구현 #27
Conversation
뒤로가기 버튼 + 지우기 버튼
최근 검색어 tableView 구현
final class로 변경
SearchVC 하나 파일에 구현
Realm: add & delete 사용
1. 최근순으로 정렬되도록 수정 2. textField 빈 경우 return 키 비활성화
textField 비었을 땐 최근 검색어 / 글자 있으면 자동 완성어 ( x 버튼 숨기기 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 ^___^
|
||
import SnapKit | ||
|
||
protocol SearchRecentTVCDelegate: AnyObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p5; 여기에 AnyObject 타입 붙인 디테일 좋네여 ^_^
|
||
weak var delegate: SearchRecentTVCDelegate? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p5;
나중에 한번 여기서 줄 지워주세여!
import SnapKit | ||
|
||
protocol SearchRecentTVCDelegate: AnyObject { | ||
func SearchRecentTVCDelete(index: Int) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3;
메서드명은 소문자로 시작해주세요 !
감사합니다 ^_^
extension SearchVC: UITextFieldDelegate { | ||
func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
textField.resignFirstResponder() | ||
addSearchRecent(title: textField.text ?? "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p4; 빈 경우에 추가하면 안될것 같아서 여기서 옵셔널 바인딩으로 textField.text가 있는지 체크하고 addSearrchRecent 호출하면 좋을것 같아요!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Realm이랑 Snapkit으로 깔끔하게 구현해주셨네요~~! 수고 많으셨습니다! 코드 스타일이 점 비슷한건 착각인가.. 코드리뷰 반영하시고 나면 어프루브하겠습니다~
// MARK: - @objc Methods | ||
|
||
@objc func deleteSearch() { | ||
delegate?.SearchRecentTVCDelete(index: index) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p4;
여기도 그냥 익스텐션으로 빼주세요~ 안쪽에는 프로퍼티, 컴포넌트, 라이프 사이클 관련만 있으면 될 것 같습니당!
|
||
let realm = try? Realm() | ||
|
||
var searchFlag: Bool = false { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p4;
searchFlag보다 조금 더 구체적으로 이름을 바꿀 수 있을 것 같아요! searchStarted 라던가... Flag라는 말이 조금 모호하다는 느낌이 있네용~~
isEmptyTextField() | ||
} else { | ||
searchTextField.rightViewMode = .always | ||
searchTableView.tableHeaderView = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p5;
👍 👍
SearchRecentTVC.register(target: searchTableView) | ||
SearchTVC.register(target: searchTableView) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p4;
사실 중요한 부분은 아니지만 컨벤션 만들었으니까 이부분 registerCell에 넣어주세요~
searchTextField.rightViewMode = .never | ||
topLabel.text = "최근 검색어" | ||
searchTableView.tableHeaderView = topView | ||
searchFlag = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q;
검색어가 없을 경우 최근검색어가 자동으로 뜨도록 구현하기로 정해졌나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
없는 경우가 "텍스트를 입력하다가 다시 지워서 텍스트 필드가 비워진 상태"를 뜻하는 거 맞나요 ?
당연하게 이렇게 구현했는데 기디 선생님들께 다시 여쭤보겠습니다 ..
if searchFlag { | ||
guard let cell = tableView.dequeueReusableCell(withIdentifier: SearchTVC.className, for: indexPath) as? SearchTVC else { return UITableViewCell() } | ||
cell.setData(data: searchRecentList[indexPath.row]) | ||
return cell | ||
} else { | ||
guard let cell = tableView.dequeueReusableCell(withIdentifier: SearchRecentTVC.className, for: indexPath) as? SearchRecentTVC else { return UITableViewCell() } | ||
cell.setData(data: searchRecentList[indexPath.row]) | ||
cell.index = indexPath.row | ||
cell.delegate = self | ||
return cell | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p5;
셀 두개 사용해서 잘 구현해 주셨습니다! 다른 방법으로 하나의 셀에 boolFlag를 두고 재사용할 수 있는 방법도 있는데, 뭐가 더 좋은 방법인지는 저도 잘 모르겠네용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 그런 방법도 있겠네요 ! 감사합니다 ㅎ ㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
🔥 Pull requests
⛳️ 작업한 브랜치
👷 작업한 내용
🚨 참고 사항
Realm 구현한 부분 좀 봐주세용 ..
최근검색어의 경우에 0번째 리스트에 추가하는 식으로 했습니다.
📸 스크린샷
📟 관련 이슈