Skip to content

Commit

Permalink
✅[CHORE] #119 - 검색결과가 비었을 때 화면 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jumining committed May 11, 2022
1 parent d1f9482 commit 3a176ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ internal enum Asset {
internal static let iosStatusbar = ImageAsset(name: "iosStatusbar")
internal static let loginLogo = ImageAsset(name: "loginLogo")
internal static let logo = ImageAsset(name: "logo")
internal static let noSearch = ImageAsset(name: "noSearch")
internal static let photoInsert = ImageAsset(name: "photo_insert")
internal static let profile = ImageAsset(name: "profile")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class StudioMapSearchViewController: UIViewController {
let searchPlaceTextField = UITextField() // searchBar
let tableView = UITableView()
let dividerView = UIView()
let noSearchImageView = UIImageView()
let navigationBar = FilinNavigationBar()
let searchController = UISearchController(searchResultsController: nil)

Expand Down Expand Up @@ -133,12 +134,27 @@ class StudioMapSearchViewController: UIViewController {
func setUpTextField() { /// 수정
searchPlaceTextField.becomeFirstResponder()
}

func changeEmptySearchView() {
print("call")
view.add(noSearchImageView) {
$0.image = UIImage(named: "noSearch")
$0.snp.makeConstraints {
$0.top.equalTo(self.searchPlaceTextField.snp.bottom).offset(135)
$0.centerX.equalTo(self.view.snp.centerX)
$0.height.equalTo(223)
$0.width.equalTo(246)
}
}
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}

@objc func touchSearchButton(_ sender: UIButton) {
self.view.endEditing(true)
changeEmptySearchView() /// (임시로 실행) 토큰 나오면 이 줄 삭제하기
searchStudiosWithAPI(keyword: searchPlaceTextField.text ?? "")
}
}
Expand Down Expand Up @@ -199,7 +215,11 @@ extension StudioMapSearchViewController {
case .success(let data):
if let search = data as? StudioSearchResponse {
self.serverSearchStudios = search
self.tableView.reloadData()
if ((self.serverSearchStudios?.studios.isEmpty) != nil) {
self.changeEmptySearchView()
} else {
self.tableView.reloadData()
}
}
case .requestErr(let message):
print("searchStudioWithAPI - requestErr: \(message)")
Expand Down

0 comments on commit 3a176ba

Please sign in to comment.