diff --git a/Fillin-iOS/Fillin-iOS.xcodeproj/project.pbxproj b/Fillin-iOS/Fillin-iOS.xcodeproj/project.pbxproj index 271b131..5bbd9f8 100644 --- a/Fillin-iOS/Fillin-iOS.xcodeproj/project.pbxproj +++ b/Fillin-iOS/Fillin-iOS.xcodeproj/project.pbxproj @@ -103,6 +103,10 @@ 6F8B71F92796F33A00F88EB3 /* StudioResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F8B71F82796F33A00F88EB3 /* StudioResponse.swift */; }; 6F8B72012797291300F88EB3 /* StudioInfoResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F8B72002797291300F88EB3 /* StudioInfoResponse.swift */; }; 6F9365872799856A0037557F /* StudioSearchResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F9365862799856A0037557F /* StudioSearchResponse.swift */; }; + 6FBCF99E2979758A00047445 /* likedStudiosViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FBCF99C2979758A00047445 /* likedStudiosViewController.swift */; }; + 6FBCF99F2979758A00047445 /* likedStudiosViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6FBCF99D2979758A00047445 /* likedStudiosViewController.xib */; }; + 6FBCF9A12979797F00047445 /* LikedStudiosCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FBCF9A02979797F00047445 /* LikedStudiosCollectionViewCell.swift */; }; + 6FBCF9A429797AF800047445 /* likedStudiosResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FBCF9A329797AF800047445 /* likedStudiosResponse.swift */; }; 770CB4632799E550006004BB /* LoginResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 770CB4622799E550006004BB /* LoginResponse.swift */; }; 775C965E278ACDE200A9BEA0 /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 775C965D278ACDE200A9BEA0 /* .swiftlint.yml */; }; 775C96AA278B2E1100A9BEA0 /* swiftgen.yml in Resources */ = {isa = PBXBuildFile; fileRef = 775C96A9278B2E1100A9BEA0 /* swiftgen.yml */; }; @@ -231,6 +235,10 @@ 6F8B71F82796F33A00F88EB3 /* StudioResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudioResponse.swift; sourceTree = ""; }; 6F8B72002797291300F88EB3 /* StudioInfoResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudioInfoResponse.swift; sourceTree = ""; }; 6F9365862799856A0037557F /* StudioSearchResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudioSearchResponse.swift; sourceTree = ""; }; + 6FBCF99C2979758A00047445 /* likedStudiosViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = likedStudiosViewController.swift; sourceTree = ""; }; + 6FBCF99D2979758A00047445 /* likedStudiosViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = likedStudiosViewController.xib; sourceTree = ""; }; + 6FBCF9A02979797F00047445 /* LikedStudiosCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LikedStudiosCollectionViewCell.swift; sourceTree = ""; }; + 6FBCF9A329797AF800047445 /* likedStudiosResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = likedStudiosResponse.swift; sourceTree = ""; }; 770CB4622799E550006004BB /* LoginResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginResponse.swift; sourceTree = ""; }; 775C9645278ACBEA00A9BEA0 /* Fillin-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Fillin-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 775C965D278ACDE200A9BEA0 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; @@ -537,6 +545,8 @@ 6F3B872827968AEB00A4BD07 /* MyPageViewController */ = { isa = PBXGroup; children = ( + 6FBCF9A229797AE600047445 /* DataModel */, + 6FBCF99B2979754400047445 /* likedStudiosViewController */, 6F3B872927968AEB00A4BD07 /* MyPagePhotoCollectionViewCell.swift */, 6F3B872A27968AEB00A4BD07 /* MyPageViewController.xib */, 6F3B872B27968AEB00A4BD07 /* MyPageViewController.swift */, @@ -768,6 +778,24 @@ path = DataModel; sourceTree = ""; }; + 6FBCF99B2979754400047445 /* likedStudiosViewController */ = { + isa = PBXGroup; + children = ( + 6FBCF99C2979758A00047445 /* likedStudiosViewController.swift */, + 6FBCF99D2979758A00047445 /* likedStudiosViewController.xib */, + 6FBCF9A02979797F00047445 /* LikedStudiosCollectionViewCell.swift */, + ); + path = likedStudiosViewController; + sourceTree = ""; + }; + 6FBCF9A229797AE600047445 /* DataModel */ = { + isa = PBXGroup; + children = ( + 6FBCF9A329797AF800047445 /* likedStudiosResponse.swift */, + ); + path = DataModel; + sourceTree = ""; + }; 775C963C278ACBEA00A9BEA0 = { isa = PBXGroup; children = ( @@ -934,6 +962,7 @@ files = ( 6F3B877E27968AEB00A4BD07 /* NotoSansKR-Medium.otf in Resources */, 6F3B87A027968AEB00A4BD07 /* SplashViewController.xib in Resources */, + 6FBCF99F2979758A00047445 /* likedStudiosViewController.xib in Resources */, 775C965E278ACDE200A9BEA0 /* .swiftlint.yml in Resources */, 6F3B87C627968AEB00A4BD07 /* PhotosTableViewCell.xib in Resources */, 6F3B87B727968AEB00A4BD07 /* FilmCurationFirstCollectionViewCell.xib in Resources */, @@ -1100,10 +1129,12 @@ 6F3B87E027968D3000A4BD07 /* StudioMapContentViewController.swift in Sources */, 6F3B87C227968AEB00A4BD07 /* PhotosCollectionViewCell.swift in Sources */, 77EB42232797D1CE00C726D8 /* FilmSelectService.swift in Sources */, + 6FBCF99E2979758A00047445 /* likedStudiosViewController.swift in Sources */, 6F3B879B27968AEB00A4BD07 /* StudioMapSearchViewController.swift in Sources */, 6F3B879327968AEB00A4BD07 /* StudioMapAPI.swift in Sources */, 6F3B877027968AEB00A4BD07 /* Assets+Generated.swift in Sources */, E89934FD27CD2BCB00DCB1A8 /* OnboardingCollectionViewCell.swift in Sources */, + 6FBCF9A429797AF800047445 /* likedStudiosResponse.swift in Sources */, 6F3B877127968AEB00A4BD07 /* Xib.swift in Sources */, 6F3B87A827968AEB00A4BD07 /* FirstAddPhotoPopUpViewController.swift in Sources */, 6F3B879027968AEB00A4BD07 /* MyPageAPI.swift in Sources */, @@ -1140,6 +1171,7 @@ 6F3B877927968AEB00A4BD07 /* UIColor+Extension.swift in Sources */, 6F3B87C827968AEB00A4BD07 /* MapTableViewCell.swift in Sources */, 6F3B87E127968D3000A4BD07 /* StudioMapCollectionViewCell.swift in Sources */, + 6FBCF9A12979797F00047445 /* LikedStudiosCollectionViewCell.swift in Sources */, 6F3B87C927968AEB00A4BD07 /* WelcomeTableViewCell.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/Contents.json b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/Contents.json new file mode 100644 index 0000000..66849cc --- /dev/null +++ b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "btnScrapActive.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "btnScrapActive@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btnScrapActive@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive.png b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive.png new file mode 100644 index 0000000..7a5374e Binary files /dev/null and b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive.png differ diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive@2x.png b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive@2x.png new file mode 100644 index 0000000..dd6f17b Binary files /dev/null and b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive@2x.png differ diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive@3x.png b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive@3x.png new file mode 100644 index 0000000..ce0849e Binary files /dev/null and b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnScrapActive.imageset/btnScrapActive@3x.png differ diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/Contents.json b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/Contents.json new file mode 100644 index 0000000..03af859 --- /dev/null +++ b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "btnUp.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "btnUp@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "btnUp@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp.png b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp.png new file mode 100644 index 0000000..d816829 Binary files /dev/null and b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp.png differ diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp@2x.png b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp@2x.png new file mode 100644 index 0000000..68a7a38 Binary files /dev/null and b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp@2x.png differ diff --git a/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp@3x.png b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp@3x.png new file mode 100644 index 0000000..748882d Binary files /dev/null and b/Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnUp.imageset/btnUp@3x.png differ diff --git a/Fillin-iOS/Fillin-iOS/Resources/Constants/Assets+Generated.swift b/Fillin-iOS/Fillin-iOS/Resources/Constants/Assets+Generated.swift index dc19357..b7b435e 100644 --- a/Fillin-iOS/Fillin-iOS/Resources/Constants/Assets+Generated.swift +++ b/Fillin-iOS/Fillin-iOS/Resources/Constants/Assets+Generated.swift @@ -35,6 +35,8 @@ internal enum Asset { internal static let btnMore = ImageAsset(name: "btnMore") internal static let btnOpen = ImageAsset(name: "btnOpen") internal static let btnScrap = ImageAsset(name: "btnScrap") + internal static let btnScrapActive = ImageAsset(name: "btnScrapActive") + internal static let btnUp = ImageAsset(name: "btnUp") internal static let btnlogin = ImageAsset(name: "btnlogin") internal static let goRightIcon = ImageAsset(name: "goRightIcon") internal static let icnAddPhotoBig = ImageAsset(name: "icnAddPhotoBig") diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/DataModel/likedStudiosResponse.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/DataModel/likedStudiosResponse.swift new file mode 100644 index 0000000..bfcedee --- /dev/null +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/DataModel/likedStudiosResponse.swift @@ -0,0 +1,18 @@ +// +// likedStudios.swift +// Fillin-iOS +// +// Created by 임주민 on 2023/01/19. +// + +import Foundation + +struct LikedStudiosResponse: Codable { + let likedStudios: [LikedStudio] +} + +// MARK: - Studio +struct LikedStudio: Codable { + let id: Int + let name, address: String +} diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/LikedStudiosCollectionViewCell.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/LikedStudiosCollectionViewCell.swift new file mode 100644 index 0000000..6ec3476 --- /dev/null +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/LikedStudiosCollectionViewCell.swift @@ -0,0 +1,88 @@ +// +// LikedStudiosCollectionViewCell.swift +// Fillin-iOS +// +// Created by 임주민 on 2023/01/19. +// + +import UIKit + +import SnapKit +import Then + +final class LikedStudiosCollectionViewCell: UICollectionViewCell { + // MARK: - Property + static let identifier = "LikedStudiosCollectionViewCell" + + // MARK: - UI Property + private let markerImageView = UIImageView().then { + $0.image = Asset.icnPlaceSmall.image + } + + private let nameLabel = UILabel().then { + $0.textColor = .white + $0.font = .subhead3 + } + + private let addressLabel = UILabel().then { + $0.textColor = .grey1 + $0.font = .body1 + } + + private let scrapButton = UIButton().then { + $0.setImage(Asset.btnScrapActive.image, for: .normal) + } + + private let borderLineView = UIView().then { + $0.backgroundColor = .darkGrey1 + } + + // MARK: - Life Cycle + override init(frame: CGRect) { + super.init(frame: frame) + + setLayout() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + // MARK: - Custom Method + + private func setLayout() { + addSubviews([markerImageView, nameLabel, addressLabel, scrapButton, borderLineView]) + + markerImageView.snp.makeConstraints { + $0.top.leading.equalToSuperview().inset(14) + $0.width.height.equalTo(22) + } + + nameLabel.snp.makeConstraints { + $0.centerY.equalTo(markerImageView) + $0.leading.equalTo(markerImageView.snp.trailing).offset(7) + } + + addressLabel.snp.makeConstraints { + $0.top.equalTo(nameLabel.snp.bottom).offset(7) + $0.leading.equalTo(nameLabel.snp.leading) + $0.trailing.equalTo(scrapButton.snp.leading).offset(-12) + } + + scrapButton.snp.makeConstraints { + $0.centerY.equalTo(markerImageView) + $0.trailing.equalToSuperview().inset(16) + $0.width.height.equalTo(32) + } + + borderLineView.snp.makeConstraints { + $0.leading.bottom.trailing.equalToSuperview() + $0.height.equalTo(1) + } + } + + func setData(studioName: String, studioAddress: String) { + nameLabel.text = studioName + addressLabel.text = studioAddress + } +} diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/likedStudiosViewController.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/likedStudiosViewController.swift new file mode 100644 index 0000000..4ff5753 --- /dev/null +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/likedStudiosViewController.swift @@ -0,0 +1,194 @@ +// +// likedStudiosViewController.swift +// Fillin-iOS +// +// Created by 임주민 on 2023/01/19. +// + +import UIKit + +import SnapKit +import Then + +final class LikedStudiosViewController: UIViewController { + // MARK: - Properties + var likedStudiosList: [LikedStudio] = [] + + // MARK: - UI Properties + private let navigationBar = FilinNavigationBar() + private let headerView = UIView() + + private lazy var studiosCollectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) + collectionView.isScrollEnabled = true + collectionView.backgroundColor = .black + + return collectionView + }() + + private let myStudioLabel = UILabel().then { + $0.text = "My Studio" + $0.font = UIFont(name: "FuturaStd-Book", size: 16) + $0.textColor = .fillinWhite + } + + private let backCircleView = UIView().then { + $0.backgroundColor = .fillinRed + $0.layer.cornerRadius = 12 + } + + private var studioCountLabel = UILabel().then { + $0.font = UIFont(name: "FuturaStd-Book", size: 12) + $0.textColor = .fillinWhite + } + + private let borderLineView = UIView().then { + $0.backgroundColor = .darkGrey1 + } + + private lazy var upButton = UIButton().then { + $0.setImage(Asset.btnUp.image, for: .normal) + $0.addTarget(self, action: #selector(upButtonDidTap), for: .touchUpInside) + } + + // MARK: - Life Cycle + override func viewDidLoad() { + super.viewDidLoad() + + setAttribute() + setLayout() + setDummyData() + } + + // MARK: - @objc + @objc func upButtonDidTap(_ sender: UIButton) { + // TODO: - 버튼 액션 처리 + } + + // MARK: - Custom Method + private func setDummyData() { + for _ in 0..<22 { + likedStudiosList.append(contentsOf: [LikedStudio(id: 0, name: "필린 사진관", address: "서울특별시 영등포구 여의도동21-3 가가가가가가가가가가가가가가가가")]) + } + studioCountLabel.text = "\(likedStudiosList.count)" + } +} + +// MARK: - Attribute +extension LikedStudiosViewController { + private func setAttribute() { + setUpNavigationBar() + registerCell() + setDelegate() + } + + private func setUpNavigationBar() { + self.navigationController?.navigationBar.isHidden = true + navigationBar.popViewController = { self.navigationController?.popViewController(animated: true) + } + } + + private func registerCell() { + studiosCollectionView.register(LikedStudiosCollectionViewCell.self, forCellWithReuseIdentifier: LikedStudiosCollectionViewCell.identifier) + } + + private func setDelegate() { + studiosCollectionView.delegate = self + studiosCollectionView.dataSource = self + } +} + +// MARK: - Layout +extension LikedStudiosViewController { + private func setLayout() { + layoutNavigaionBar() + layoutHeaderView() + layoutStudiosCollectionView() + layoutFloatingUpButton() + } + + private func layoutNavigaionBar() { + view.addSubview(navigationBar) + navigationBar.snp.makeConstraints { + $0.top.equalTo(view.safeAreaLayoutGuide) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(50) + } + } + + private func layoutHeaderView() { + view.addSubview(headerView) + headerView.addSubviews([myStudioLabel, backCircleView, studioCountLabel, borderLineView]) + headerView.snp.makeConstraints { + $0.top.equalTo(navigationBar.snp.bottom) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(50) + } + myStudioLabel.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.leading.equalToSuperview().inset(19) + } + backCircleView.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.trailing.equalToSuperview().inset(18) + $0.width.height.equalTo(24) + } + studioCountLabel.snp.makeConstraints { + $0.center.equalTo(backCircleView) + } + borderLineView.snp.makeConstraints { + $0.leading.bottom.trailing.equalToSuperview() + $0.height.equalTo(1) + } + } + + private func layoutStudiosCollectionView() { + view.addSubview(studiosCollectionView) + studiosCollectionView.snp.makeConstraints { + $0.top.equalTo(headerView.snp.bottom) + $0.leading.bottom.trailing.equalToSuperview() + } + } + + private func layoutFloatingUpButton() { + view.addSubview(upButton) + upButton.snp.makeConstraints { + $0.bottom.equalToSuperview().inset(36) + $0.trailing.equalToSuperview().inset(18) + } + } +} + +// MARK: - UICollectionViewDelegate +extension LikedStudiosViewController: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + // TODO: - 뷰 전환 + } +} + +// MARK: - UICollectionViewDataSource +extension LikedStudiosViewController: UICollectionViewDataSource { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return likedStudiosList.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: LikedStudiosCollectionViewCell.identifier, for: indexPath) as? LikedStudiosCollectionViewCell else { return UICollectionViewCell() } + let studioName = likedStudiosList[indexPath.row].name + let studioAddress = likedStudiosList[indexPath.row].address + cell.setData(studioName: studioName, studioAddress: studioAddress) + + return cell + } +} + +// MARK: - UICollectionViewDelegateFlowLayout +extension LikedStudiosViewController: UICollectionViewDelegateFlowLayout { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + let cellSize = CGSize(width: UIScreen.main.bounds.width, height: 85) + + return cellSize + } +} diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/likedStudiosViewController.xib b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/likedStudiosViewController.xib new file mode 100644 index 0000000..c2ab4de --- /dev/null +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/MyPageViewController/likedStudiosViewController/likedStudiosViewController.xib @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/OnboardingViewController/OnboardingViewController.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/OnboardingViewController/OnboardingViewController.swift index 7d25935..50e452c 100644 --- a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/OnboardingViewController/OnboardingViewController.swift +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/OnboardingViewController/OnboardingViewController.swift @@ -146,7 +146,7 @@ extension OnboardingViewController: UICollectionViewDelegate, UICollectionViewDa func scrollViewDidScroll(_ scrollView: UIScrollView) { let width = scrollView.frame.width - currentPage = lroundl(scrollView.contentOffset.x / width) + currentPage = lroundl(Float80(scrollView.contentOffset.x / width)) } } diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapBottomSheetViewController/StudioMapContentViewController/StudioMapContentViewController.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapBottomSheetViewController/StudioMapContentViewController/StudioMapContentViewController.swift index 0098d62..d66d3ad 100644 --- a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapBottomSheetViewController/StudioMapContentViewController/StudioMapContentViewController.swift +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapBottomSheetViewController/StudioMapContentViewController/StudioMapContentViewController.swift @@ -27,9 +27,12 @@ class StudioMapContentViewController: UIViewController { let timeLabel = UILabel() let callLabel = UILabel() let priceLabel = UILabel() - let linkButton = UIButton() let photoReviewLabel = UILabel() let underlineView = UIView() + var linkButton = UIButton().then { + $0.titleLabel?.font = .body1 + } + var selectedStudioInfo = StudioInfo(id: 0, name: "필린 사진관", address: "솝트시 앱잼구 필린로", price: "3000원", time: "11:00-12:00", tel: "010-0000-0000", lati: 0, long: 0, etc: "많관부~", isDeleted: false, site: "https://www.naver.com/") let studioCollectionview: UICollectionView = { let layout = UICollectionViewFlowLayout() layout.scrollDirection = .vertical @@ -42,14 +45,15 @@ class StudioMapContentViewController: UIViewController { // MARK: - View Cycle override func viewDidLoad() { super.viewDidLoad() + setupAttribute() setupUI() register() - studioPhotosWithAPI(studioID: StudioMapViewController.selectedMarkerID ?? 0) + studioPhotosWithAPI(studioID: selectedStudioInfo.id ?? 0) } override func viewDidAppear(_ animated: Bool) { - studioPhotosWithAPI(studioID: StudioMapViewController.selectedMarkerID ?? 0) + studioPhotosWithAPI(studioID: selectedStudioInfo.id ?? 0) } // MARK: - Func @@ -89,7 +93,7 @@ class StudioMapContentViewController: UIViewController { } // Label view.add(studioLabel) { - $0.text = StudioMapViewController.name + $0.text = self.selectedStudioInfo.name $0.textColor = .white $0.font = .headline $0.snp.makeConstraints { @@ -100,11 +104,13 @@ class StudioMapContentViewController: UIViewController { } view.add(scrapButton) { $0.setImage(Asset.btnScrap.image, for: .normal) + $0.setImage(Asset.btnScrapActive.image, for: .selected) $0.snp.makeConstraints { $0.top.equalTo(self.view.snp.top).offset(36) $0.trailing.equalTo(self.view.snp.trailing).offset(-18) $0.width.height.equalTo(32) } + $0.addTarget(self, action: #selector(self.scrapButtonDidTap), for: .touchUpInside) } studioScrollContainverView.add(firstdividerView) { $0.backgroundColor = .darkGrey3 @@ -117,10 +123,10 @@ class StudioMapContentViewController: UIViewController { } // Label studioScrollContainverView.add(locationLabel) { - if StudioMapViewController.address == nil { + if self.selectedStudioInfo.address == nil { $0.text = "등록된 주소가 없습니다." } else { - $0.text = StudioMapViewController.address + $0.text = self.selectedStudioInfo.address } $0.numberOfLines = 0 $0.font = .body2 @@ -133,10 +139,10 @@ class StudioMapContentViewController: UIViewController { } } studioScrollContainverView.add(timeLabel) { - if StudioMapViewController.time == nil { + if self.selectedStudioInfo.time == nil { $0.text = "등록된 운영시간이 없습니다." } else { - $0.text = StudioMapViewController.time + $0.text = self.selectedStudioInfo.time } $0.numberOfLines = 0 $0.font = .body2 @@ -149,10 +155,10 @@ class StudioMapContentViewController: UIViewController { } } studioScrollContainverView.add(callLabel) { - if StudioMapViewController.tel == nil { + if self.selectedStudioInfo.tel == nil { $0.text = "등록된 전화번호가 없습니다." } else { - $0.text = StudioMapViewController.tel + $0.text = self.selectedStudioInfo.tel } $0.numberOfLines = 0 $0.font = .body2 @@ -165,10 +171,10 @@ class StudioMapContentViewController: UIViewController { } } studioScrollContainverView.add(priceLabel) { - if StudioMapViewController.price == nil { + if self.selectedStudioInfo.price == nil { $0.text = "등록된 가격정보가 없습니다." } else { - $0.text = StudioMapViewController.price + $0.text = self.selectedStudioInfo.price } $0.numberOfLines = 0 $0.font = .body2 @@ -181,13 +187,7 @@ class StudioMapContentViewController: UIViewController { } } studioScrollContainverView.add(linkButton) { - $0.titleLabel?.font = .body1 - $0.snp.makeConstraints { - $0.top.equalTo(self.priceLabel.snp.bottom).offset(18) - $0.leading.equalTo(self.studioScrollContainverView.snp.leading).offset(48) - $0.height.equalTo(18) - } - if StudioMapViewController.site == nil { + if self.selectedStudioInfo.site == nil { $0.setTitle("웹사이트가 없습니다 ", for: .normal) $0.setTitleColor(.grey4, for: .normal) } else { @@ -195,6 +195,11 @@ class StudioMapContentViewController: UIViewController { $0.setTitleColor(.fillinRed, for: .normal) self.linkButton.addTarget(self, action: #selector(self.touchLinkButton), for: .touchUpInside) } + $0.snp.makeConstraints { + $0.top.equalTo(self.priceLabel.snp.bottom).offset(18) + $0.leading.equalTo(self.studioScrollContainverView.snp.leading).offset(48) + $0.height.equalTo(18) + } } // 아이콘 studioScrollContainverView.add(locationImageView) { @@ -244,7 +249,7 @@ class StudioMapContentViewController: UIViewController { $0.leading.equalTo(self.linkButton.snp.leading) $0.height.equalTo(1) } - if StudioMapViewController.site == nil { + if self.selectedStudioInfo.site == nil { $0.backgroundColor = .grey4 $0.snp.makeConstraints { $0.width.equalTo(106) @@ -289,13 +294,15 @@ class StudioMapContentViewController: UIViewController { // MARK: - @objc @objc func touchLinkButton() { - let studioUrl = NSURL(string: StudioMapViewController.site ?? "none site") + let studioUrl = NSURL(string: selectedStudioInfo.site ?? "none site") let studioSafariView: SFSafariViewController = SFSafariViewController(url: studioUrl! as URL) self.present(studioSafariView, animated: true, completion: nil) } - + @objc func scrapButtonDidTap(_ sender: UIButton) { + sender.isSelected.toggle() + } @objc func notiStudioPhotoswithAPI(_ notification: Notification) { - studioPhotosWithAPI(studioID: StudioMapViewController.selectedMarkerID ?? 0) + studioPhotosWithAPI(studioID: selectedStudioInfo.id ?? 0) } } diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapSearchViewController/StudioMapSearchViewController.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapSearchViewController/StudioMapSearchViewController.swift index b442e49..9b799a5 100644 --- a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapSearchViewController/StudioMapSearchViewController.swift +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapSearchViewController/StudioMapSearchViewController.swift @@ -13,7 +13,8 @@ class StudioMapSearchViewController: UIViewController { var serverSearchStudios: StudioSearchResponse? let backGroundView = UIView() let magnifyingGlassButton = UIButton() - let searchPlaceTextField = UITextField() // searchBar + let clearButton = UIButton() + let searchPlaceTextField = UITextField() let tableView = UITableView() let dividerView = UIView() let noSearchImageView = UIImageView() @@ -55,6 +56,10 @@ class StudioMapSearchViewController: UIViewController { $0.font = .body2 $0.setPlaceHolder() $0.addLeftPadding() + $0.addTarget(self, action: #selector(self.textFieldDidChange(textField:)), + for: .editingDidBegin) + $0.addTarget(self, action: #selector(self.textFieldDidChange(textField:)), + for: .editingChanged) $0.snp.makeConstraints { $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(68) $0.leading.equalTo(self.view).inset(18) @@ -72,6 +77,17 @@ class StudioMapSearchViewController: UIViewController { $0.trailing.equalTo(self.searchPlaceTextField).inset(18) } } + view.add(clearButton) { + $0.setImage(Asset.icnClear.image, for: .normal) + $0.addTarget(self, action: #selector(self.touchClearButton), for: .touchUpInside) + $0.snp.makeConstraints { + $0.top.equalTo(self.searchPlaceTextField).inset(11) + $0.leading.equalTo(self.searchPlaceTextField).inset(295) + $0.bottom.equalTo(self.searchPlaceTextField).inset(11) + $0.trailing.equalTo(self.searchPlaceTextField).inset(18) + } + } + clearButton.isHidden = true view.add(dividerView) { $0.backgroundColor = .darkGrey3 $0.snp.makeConstraints { @@ -80,13 +96,22 @@ class StudioMapSearchViewController: UIViewController { $0.height.equalTo(2) } } + 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) + } + } + noSearchImageView.isHidden = true } private func layoutNavigaionBar() { view.add(navigationBar) { switch self.status { case .originStudioVC : self.navigationBar.popViewController = { - print("버튼 누름") self.view.endEditing(true) self.dismiss(animated: true, completion: nil) } @@ -131,11 +156,12 @@ class StudioMapSearchViewController: UIViewController { tableView.register(StudioMapSearchTableViewCell.self, forCellReuseIdentifier: Const.Xib.studioSearchTableViewCell) } - func setUpTextField() { /// 수정 + func setUpTextField() { searchPlaceTextField.becomeFirstResponder() } func changeEmptySearchView() { + noSearchImageView.isHidden = false print("call") view.add(noSearchImageView) { $0.image = Asset.noSearch.image @@ -152,10 +178,28 @@ class StudioMapSearchViewController: UIViewController { self.view.endEditing(true) } + // MARK: - @objc + @objc func textFieldDidChange(textField: UITextField) { + clearButton.isHidden = (searchPlaceTextField.text?.isEmpty) ?? true + magnifyingGlassButton.isHidden = !(clearButton.isHidden) + if !(searchPlaceTextField.text?.isEmpty ?? true) { + searchStudiosWithAPI(keyword: searchPlaceTextField.text ?? "") + changeEmptySearchView() + } else { + noSearchImageView.isHidden = true + } + } + @objc func touchSearchButton(_ sender: UIButton) { self.view.endEditing(true) - changeEmptySearchView() /// (임시로 실행) 토큰 나오면 이 줄 삭제하기 - searchStudiosWithAPI(keyword: searchPlaceTextField.text ?? "") + changeEmptySearchView() + } + + @objc func touchClearButton(_ sender: UIButton) { + searchPlaceTextField.text = "" + noSearchImageView.isHidden = true + magnifyingGlassButton.isHidden = false + clearButton.isHidden = true } } @@ -215,7 +259,8 @@ extension StudioMapSearchViewController { case .success(let data): if let search = data as? StudioSearchResponse { self.serverSearchStudios = search - if ((self.serverSearchStudios?.studios.isEmpty) != nil) { + guard let isEmptyStudios = self.serverSearchStudios?.studios.isEmpty else { return } + if isEmptyStudios { self.changeEmptySearchView() } else { self.tableView.reloadData() diff --git a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapViewController/StudioMapViewController.swift b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapViewController/StudioMapViewController.swift index aeb253e..ebcf163 100644 --- a/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapViewController/StudioMapViewController.swift +++ b/Fillin-iOS/Fillin-iOS/Sources/ViewControllers/StudioMapViewController/StudioMapViewController.swift @@ -7,14 +7,14 @@ import UIKit -import NMapsMap -import CoreLocation import SnapKit import Then +import NMapsMap +import CoreLocation import MapKit class StudioMapViewController: UIViewController { - + // MARK: - Properties (BottomSheet) enum BottomSheetViewState { case expanded @@ -23,48 +23,34 @@ class StudioMapViewController: UIViewController { private let contentViewController: UIViewController private var bottomSheetViewTopConstraint: NSLayoutConstraint! - var bottomSheetPanMinTopConstant: CGFloat = 50.0 - var bottomHeight: CGFloat = UIScreen.main.bounds.size.height*(3/7) - let defaultHeight: CGFloat = UIScreen.main.bounds.size.height*(3/7) + private let bottomSheetPanMinTopConstant: CGFloat = 50.0 + private var bottomHeight: CGFloat = UIScreen.main.bounds.size.height*(3/7) + private let defaultHeight: CGFloat = UIScreen.main.bounds.size.height*(3/7) private lazy var bottomSheetPanStartingTopConstant: CGFloat = bottomSheetPanMinTopConstant - let bottomSheetView: UIView = { - let view = UIView() - view.backgroundColor = .darkGrey2 - - return view - }() + let bottomSheetView = UIView().then { + $0.backgroundColor = .darkGrey2 + } - private let dismissIndicatorView: UIView = { - let view = UIView() - view.backgroundColor = .darkGrey1 - view.layer.cornerRadius = 3 - - return view - }() + private let dismissIndicatorView = UIView().then { + $0.backgroundColor = .darkGrey1 + $0.layer.cornerRadius = 3 + } // MARK: - Properties - static var name: String? - static var address: String? - static var time: String? - static var tel: String? - static var price: String? - static var site: String? - static var selectedMarkerID: Int? - static var lati: Double? - static var long: Double? - - var serverStudioInfo: StudioInfoResponse? - var serverStudios: StudioResponse? + var serverStudioInfo = StudioInfoResponse(studio: StudioInfo(id: 0, name: "", address: "", price: "", time: "", tel: "", lati: 0, long: 0, etc: "", isDeleted: false, site: "")) + var serverStudios = StudioResponse(studios: []) + var selectedMarkerInfo = Studio(id: 0, lati: 0, long: 0) var selectedMarker: NMFMarker? - var selectedMarkerInfo: Studio? - let mapView = NMFNaverMapView(frame: .zero) - let myLocationButton = UIButton() - let dataSource = NMFInfoWindowDefaultTextSource.data() - let magnifyingGlassButton = UIButton().then { + var locationManager = CLLocationManager() + + // MARK: - UI Properties + private let navigationBar = FilinNavigationBar() + private let mapView = NMFNaverMapView(frame: .zero) + private let magnifyingGlassButton = UIButton().then { $0.setImage(Asset.icnSearch.image, for: .normal) } - let searchPlaceTextField = UITextField().then { + private lazy var searchPlaceTextField = UITextField().then { $0.backgroundColor = .darkGrey2 $0.layer.borderColor = UIColor.fillinRed.cgColor $0.layer.borderWidth = 1 @@ -72,26 +58,20 @@ class StudioMapViewController: UIViewController { $0.font = .body2 $0.setPlaceHolder() $0.addLeftPadding() + $0.addTarget(self, action: #selector(textFieldDidBeginEditing(_:)), for: .touchDown) + } + private lazy var myLocationButton = UIButton().then { + $0.setImage(Asset.icnMyLocation.image, for: .normal) + $0.addTarget(self, action: #selector(touchLocationButton), for: .touchUpInside) } - var clickCount = 0 - var locationManager = CLLocationManager() - let navigationBar = FilinNavigationBar() // MARK: - View Life Cycle override func viewDidLoad() { super.viewDidLoad() - setUpMapView() - setUpNavigationBar() - layoutMapView() - layoutMyLocationButton() - layoutSearchView() - layoutNavigaionBar() - getBottomSheetInfo() + + setAttribute() + setLayout() totalStudioWithAPI() - setLatLngNotification() - tmpSetupMarker() - setupBottomSheetUI() - setupBottomSheetGestureRecognizer() } // MARK: - init @@ -106,48 +86,33 @@ class StudioMapViewController: UIViewController { } // MARK: - Extensions + extension StudioMapViewController { + private func setAttribute() { + tmpSetupMarker() + setUpMapView() + setUpBottomSheetUI() + setUpMarkerInfo() + setUpNavigationBar() + setUpBottomSheetGestureRecognizer() + setLatLngNotification() + } - /// 서버 부활되기 전까지 현상소 관련 기능 테스트할 임시 함수 (네이버 그린팩토리에 현상소 표시해줌) - func tmpSetupMarker() { - let markertmp = NMFMarker(position: NMGLatLng(lat: 37.35940010181669, lng: 127.10475679570187)) + private func tmpSetupMarker() { + let markertmp = NMFMarker(position: NMGLatLng(lat: 37.556393, lng: 126.9716552)) markertmp.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) markertmp.mapView = self.mapView.mapView - - let secondMarkertmp = NMFMarker(position: NMGLatLng(lat: 37.36161841308457, lng: 127.10566240106306)) - secondMarkertmp.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) - secondMarkertmp.mapView = self.mapView.mapView - - secondMarkertmp.touchHandler = { [weak self] (overlay: NMFOverlay) -> Bool in - if self?.selectedMarker == nil { /// 클릭했던 현상소가 없는 경우 (지도뷰 처음 들어올 떄) - self?.selectedMarker = secondMarkertmp - self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudioSelected.image) - self?.showBottomSheet() - } else { - if self?.selectedMarker == secondMarkertmp { /// 클릭했던 현상소를 다시 클릭하는 경우 - self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) - self?.hideBottomSheetAndGoBack() - } else { /// 다른 현상소 클릭 - self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) - self?.selectedMarker = secondMarkertmp - self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudioSelected.image) - self?.showBottomSheet() - } - } - return true - } - - markertmp.touchHandler = { [weak self] (overlay: NMFOverlay) -> Bool in - if self?.selectedMarker == nil { /// 클릭했던 현상소가 없는 경우 (지도뷰 처음 들어올 떄) + markertmp.touchHandler = { [weak self] (_: NMFOverlay) -> Bool in + if self?.selectedMarker == nil { self?.selectedMarker = markertmp self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudioSelected.image) self?.showBottomSheet() } else { - if self?.selectedMarker == markertmp { /// 클릭했던 현상소를 다시 클릭하는 경우 + if self?.selectedMarker == markertmp { self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) self?.selectedMarker = nil self?.hideBottomSheetAndGoBack() - } else { /// 다른 현상소 클릭 + } else { self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) self?.selectedMarker = markertmp self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudioSelected.image) @@ -172,30 +137,29 @@ extension StudioMapViewController { locationManager.delegate = self self.locationManager.requestWhenInUseAuthorization() } - + private func setUpMarkerInfo() { self.mapView.mapView.touchDelegate = self - serverStudios?.studios.forEach { + serverStudios.studios.forEach { let marker = NMFMarker(position: NMGLatLng(lat: $0.lati, lng: $0.long)) let markerInfo = Studio(id: $0.id, lati: $0.lati, long: $0.long) marker.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) - self.selectedMarkerInfo = markerInfo - StudioMapViewController.selectedMarkerID = markerInfo.id - self.studioInfoWithAPI(studioID: markerInfo.id) + selectedMarkerInfo = markerInfo + studioInfoWithAPI(studioID: markerInfo.id) - marker.touchHandler = { [weak self] (overlay: NMFOverlay) -> Bool in - if self?.selectedMarker == nil { /// 클릭했던 현상소가 없는 경우 (지도뷰 처음 들어올 떄) + marker.touchHandler = { [weak self] (_: NMFOverlay) -> Bool in + if self?.selectedMarker == nil { self?.selectedMarker = marker self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudioSelected.image) self?.showBottomSheet() } else { - if self?.selectedMarker == marker { /// 클릭했던 현상소를 다시 클릭하는 경우 + if self?.selectedMarker == marker { self?.selectedMarker = nil self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) self?.hideBottomSheetAndGoBack() - } else { /// 다른 현상소 클릭 + } else { self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudio.image) self?.selectedMarker = marker self?.selectedMarker?.iconImage = NMFOverlayImage(image: Asset.icnStudioSelected.image) @@ -208,88 +172,67 @@ extension StudioMapViewController { } } - func getBottomSheetInfo() { - StudioMapViewController.name = "필린 현상소" - StudioMapViewController.address = "솝트시 앱잼구 필린동 아요로 12번길 13" - StudioMapViewController.time = "open 00:00-24:00" - StudioMapViewController.tel = "010-1234-5678" - StudioMapViewController.price = "컬러 5000000000원" - StudioMapViewController.site = "" - -// StudioMapViewController.name = self.serverStudioInfo?.studio.name -// StudioMapViewController.address = self.serverStudioInfo?.studio.address -// StudioMapViewController.time = self.serverStudioInfo?.studio.time -// StudioMapViewController.tel = self.serverStudioInfo?.studio.tel -// StudioMapViewController.price = self.serverStudioInfo?.studio.price -// StudioMapViewController.site = self.serverStudioInfo?.studio.site - } - private func setUpNavigationBar() { self.navigationController?.navigationBar.isHidden = true navigationBar.popViewController = { self.navigationController?.popViewController(animated: true) } } + + private func setLatLngNotification() { + NotificationCenter.default.addObserver(self, selector: #selector(getLatLng(_:)), name: Notification.Name("GetLatLng"), object: nil) + } +} + +extension StudioMapViewController { + private func setLayout() { + layoutMapView() + layoutMyLocationButton() + layoutSearchView() + layoutNavigaionBar() + view.bringSubviewToFront(bottomSheetView) + view.bringSubviewToFront(dismissIndicatorView) + } private func layoutMapView() { mapView.snp.makeConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide.snp.top) - $0.leading.equalTo(self.view.safeAreaLayoutGuide.snp.leading) - $0.bottom.equalTo(self.view.snp.bottom) - $0.trailing.equalTo(self.view.safeAreaLayoutGuide.snp.trailing) + $0.top.leading.trailing.equalTo(view.safeAreaLayoutGuide) + $0.bottom.equalToSuperview() } } private func layoutMyLocationButton() { view.addSubview(myLocationButton) - myLocationButton.setImage(Asset.icnMyLocation.image, for: .normal) myLocationButton.snp.makeConstraints { $0.trailing.equalToSuperview().offset(-20) $0.bottom.equalToSuperview().offset(-48) } - myLocationButton.addTarget(self, action: #selector(touchLocationButton), for: .touchUpInside) } private func layoutSearchView() { - view.addSubview(searchPlaceTextField) - view.addSubview(magnifyingGlassButton) + view.addSubviews([searchPlaceTextField, magnifyingGlassButton]) + searchPlaceTextField.snp.makeConstraints { + $0.top.equalTo(view.safeAreaLayoutGuide).inset(68) + $0.leading.trailing.equalToSuperview().inset(18) + $0.height.equalTo(48) + } magnifyingGlassButton.snp.makeConstraints { - $0.top.equalTo(searchPlaceTextField).inset(11) - $0.leading.equalTo(searchPlaceTextField).inset(295) - $0.bottom.equalTo(searchPlaceTextField).inset(11) + $0.centerY.equalTo(searchPlaceTextField) $0.trailing.equalTo(searchPlaceTextField).inset(18) } - searchPlaceTextField.snp.makeConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide).inset(68) - $0.leading.equalTo(self.view).inset(18) - $0.trailing.equalTo(self.view).inset(18) - $0.size.height.equalTo(48) - } - searchPlaceTextField.addTarget(self, action: #selector(textFieldDidBeginEditing(_:)), for: .touchDown) } func layoutNavigaionBar() { - view.add(navigationBar) { - self.navigationBar.popViewController = { - self.navigationController?.popViewController(animated: true) - } - $0.snp.makeConstraints { - $0.top.equalTo(self.view.safeAreaLayoutGuide.snp.top) - $0.leading.trailing.equalToSuperview() - $0.height.equalTo(50) - } + view.add(navigationBar) + navigationBar.snp.makeConstraints { + $0.top.equalTo(view.safeAreaLayoutGuide) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(50) } } - func setLatLngNotification() { - NotificationCenter.default.addObserver(self, selector: #selector(getLatLng(_:)), name: Notification.Name("GetLatLng"), object: nil) - } - // MARK: - @objc @objc func getLatLng(_ notification: Notification) { let selectedStudioId = notification.object as? Int ?? 0 studioInfoWithAPI(studioID: selectedStudioId) - - let cameraUpdate = NMFCameraUpdate(scrollTo: NMGLatLng(lat: StudioMapViewController.lati ?? 0, lng: StudioMapViewController.long ?? 0)) - mapView.mapView.moveCamera(cameraUpdate) } @objc func textFieldDidBeginEditing(_ textField: UITextField) { @@ -298,9 +241,9 @@ extension StudioMapViewController { newVC.modalPresentationStyle = .fullScreen self.present(newVC, animated: true, completion: nil) } - + @objc func touchLocationButton(_ sender: UIButton) { - sender.isSelected = !sender.isSelected + sender.isSelected.toggle() mapView.mapView.positionMode = .direction } } @@ -318,13 +261,12 @@ extension UITextField { NSAttributedString.Key.foregroundColor: UIColor.grey2, NSAttributedString.Key.font: UIFont(name: "NotoSansKR-Regular", size: 14)! ] - self.attributedPlaceholder = NSAttributedString(string: "추억을 현상할 현상소를 검색해보세요", attributes: attributes) + self.attributedPlaceholder = NSAttributedString(string: "현상소 이름 또는 주소로 검색해보세요", attributes: attributes) } } // MARK: - Extension - CLLocationManagerDelegate extension StudioMapViewController: CLLocationManagerDelegate { - func getLocationUsagePermission() { self.locationManager.requestWhenInUseAuthorization() } @@ -371,19 +313,13 @@ extension StudioMapViewController { } } } -} - -extension StudioMapViewController { func studioInfoWithAPI(studioID: Int) { StudioMapAPI.shared.infoStudio(studioID: studioID) { response in switch response { case .success(let data): if let studioinfo = data as? StudioInfoResponse { self.serverStudioInfo = studioinfo - StudioMapViewController.lati = studioinfo.studio.lati - StudioMapViewController.long = studioinfo.studio.long - - let cameraUpdate = NMFCameraUpdate(scrollTo: NMGLatLng(lat: StudioMapViewController.lati ?? 0, lng: StudioMapViewController.long ?? 0)) + let cameraUpdate = NMFCameraUpdate(scrollTo: NMGLatLng(lat: studioinfo.studio.lati ?? 0, lng: studioinfo.studio.long ?? 0)) self.mapView.mapView.moveCamera(cameraUpdate) NotificationCenter.default.post(name: Notification.Name.studioPhotoswithAPI, object: nil) self.showBottomSheet() @@ -401,31 +337,30 @@ extension StudioMapViewController { } } -// MARK: - Extension - BottomSheet +// MARK: - BottomSheet extension StudioMapViewController { - - private func setupBottomSheetUI() { + private func setUpBottomSheetUI() { addChild(contentViewController) bottomSheetView.addSubview(contentViewController.view) contentViewController.didMove(toParent: self) view.addSubviews([bottomSheetView, dismissIndicatorView]) - + let viewPan = UIPanGestureRecognizer(target: self, action: #selector(viewPanned(_:))) viewPan.delaysTouchesBegan = false viewPan.delaysTouchesEnded = false view.addGestureRecognizer(viewPan) - setupBottomSheetLayout() + setUpBottomSheetLayout() } - private func setupBottomSheetGestureRecognizer() { + private func setUpBottomSheetGestureRecognizer() { let swipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(panGesture)) swipeGesture.direction = .down view.addGestureRecognizer(swipeGesture) } - private func setupBottomSheetLayout() { + private func setUpBottomSheetLayout() { contentViewController.view.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ contentViewController.view.topAnchor.constraint(equalTo: bottomSheetView.topAnchor), @@ -454,7 +389,6 @@ extension StudioMapViewController { } private func showBottomSheet(atState: BottomSheetViewState = .normal) { - getBottomSheetInfo() if atState == .normal { changeScrollDisabled() let safeAreaHeight: CGFloat = view.safeAreaLayoutGuide.layoutFrame.height @@ -479,13 +413,13 @@ extension StudioMapViewController { self.view.layoutIfNeeded() }) } - + func nearest(to number: CGFloat, inValues values: [CGFloat]) -> CGFloat { guard let nearestVal = values.min(by: { abs(number - $0) < abs(number - $1) }) else { return number } return nearestVal } - + func changeScrollEnabled() { let contentVC = children.first as? StudioMapContentViewController contentVC?.studioScrollview.isScrollEnabled = true