Skip to content

Commit 37c101d

Browse files
committed
feat : 테스트 커밋 (#89)
2 parents 4a86afd + 94a94f9 commit 37c101d

31 files changed

+620
-124
lines changed

KCS/.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ excluded:
99
- KCS/Application
1010

1111
line_length: 140
12+
file_length: 600

KCS/KCS.xcodeproj/project.pbxproj

Lines changed: 80 additions & 7 deletions
Large diffs are not rendered by default.

KCS/KCS/Domain/UseCase/FetchRefreshStoresUseCaseImpl.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ struct FetchRefreshStoresUseCaseImpl: FetchRefreshStoresUseCase {
1515
requestLocation: RequestLocation
1616
) -> Observable<[Store]> {
1717
let newLocation = parallelTranslate(requestLocation: requestLocation)
18-
1918
return repository.fetchRefreshStores(requestLocation: newLocation)
2019
}
2120

21+
}
22+
23+
private extension FetchRefreshStoresUseCaseImpl {
24+
2225
func parallelTranslate (requestLocation: RequestLocation) -> RequestLocation {
2326
let distance1 = sqrt(
2427
pow(requestLocation.northWest.longitude - requestLocation.southWest.longitude, 2)
@@ -42,7 +45,7 @@ struct FetchRefreshStoresUseCaseImpl: FetchRefreshStoresUseCase {
4245
center: center
4346
)
4447
if distance2 > 0.07 {
45-
return translateHeightLocations(
48+
newLocation = translateHeightLocations(
4649
loc1: newLocation.northEast,
4750
loc2: newLocation.southEast,
4851
center: center
@@ -69,20 +72,20 @@ struct FetchRefreshStoresUseCaseImpl: FetchRefreshStoresUseCase {
6972
southEast: Location(longitude: center.longitude - 0.035, latitude: loc2.latitude),
7073
northEast: Location(longitude: center.longitude + 0.035, latitude: loc2.latitude)
7174
)
72-
7375
}
7476

7577
let slope = (loc2.latitude - loc1.latitude) / (loc2.longitude - loc1.longitude)
7678
let constant1 = 0.035 * sqrt(pow(slope, 2) + 1) - slope * center.longitude + center.latitude
7779
let constant2 = (-0.035) * sqrt(pow(slope, 2) + 1) - slope * center.longitude + center.latitude
78-
80+
7981
return RequestLocation(
8082
northWest: getNewLocation(location: loc1, slope: slope, constant: constant1),
8183
southWest: getNewLocation(location: loc1, slope: slope, constant: constant2),
8284
southEast: getNewLocation(location: loc2, slope: slope, constant: constant2),
8385
northEast: getNewLocation(location: loc2, slope: slope, constant: constant1)
8486
)
8587
}
88+
8689
func getNewLocation(location: Location, slope: Double, constant: Double) -> Location {
8790
return Location(
8891
longitude: (location.latitude + (location.longitude / slope) - constant) / (slope + 1 / slope),
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// UIFont+.swift
3+
// KCS
4+
//
5+
// Created by 김영현 on 1/21/24.
6+
//
7+
8+
import UIKit
9+
10+
extension UIFont {
11+
12+
static func pretendard(size fontSize: CGFloat, weight: UIFont.Weight) -> UIFont {
13+
let familyName = "Pretendard"
14+
15+
var weightString: String
16+
switch weight {
17+
case .black:
18+
weightString = "Black"
19+
case .bold:
20+
weightString = "Blod"
21+
case .heavy:
22+
weightString = "ExtraBold"
23+
case .ultraLight:
24+
weightString = "ExtraLight"
25+
case .light:
26+
weightString = "Light"
27+
case .medium:
28+
weightString = "Medium"
29+
case .regular:
30+
weightString = "Regular"
31+
case .semibold:
32+
weightString = "SemiBold"
33+
case .thin:
34+
weightString = "Thin"
35+
default:
36+
weightString = "Regular"
37+
}
38+
39+
return UIFont(name: "\(familyName)-\(weightString)", size: fontSize) ?? .systemFont(ofSize: fontSize, weight: weight)
40+
}
41+
42+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// UILabel+.swift
3+
// KCS
4+
//
5+
// Created by 김영현 on 1/21/24.
6+
//
7+
8+
import UIKit
9+
10+
extension UILabel {
11+
12+
var numberOfVisibleLines: Int {
13+
layoutIfNeeded()
14+
let textSize = CGSize(width: frame.size.width, height: CGFloat(Float.infinity))
15+
let textHeight = lroundf(Float(sizeThatFits(textSize).height))
16+
let lineHeight = lroundf(Float(font.lineHeight))
17+
18+
return textHeight/lineHeight
19+
}
20+
21+
}

KCS/KCS/Presentation/Home/View/CertificationLabel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class CertificationLabel: UIView {
1414
private lazy var certificationLabel: UILabel = {
1515
let label = UILabel()
1616
label.translatesAutoresizingMaskIntoConstraints = false
17-
label.font = UIFont.systemFont(ofSize: 9)
17+
label.font = UIFont.pretendard(size: 9, weight: .medium)
1818
label.textColor = UIColor.certificationLabelText
1919
label.text = certificationType.description
2020

KCS/KCS/Presentation/Home/View/FilterButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private extension FilterButton {
3737

3838
func setContents(type: CertificationType) {
3939
var titleAttribute = AttributedString.init(type.description)
40-
titleAttribute.font = .systemFont(ofSize: 10)
40+
titleAttribute.font = UIFont.pretendard(size: 12, weight: .medium)
4141

4242
guard var config = configuration else { return }
4343
config.attributedTitle = titleAttribute

KCS/KCS/Presentation/Home/View/HomeViewController.swift

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ final class HomeViewController: UIViewController {
175175

176176
private var storeInformationViewController: StoreInformationViewController?
177177

178+
private let dismissObserver = PublishRelay<Void>()
179+
178180
private let viewModel: HomeViewModel
179181

180182
init(viewModel: HomeViewModel) {
@@ -210,14 +212,13 @@ private extension HomeViewController {
210212
self.setMarker(marker: Marker(certificationType: filteredStore.type, position: location), tag: UInt($0.id))
211213
}
212214
}
213-
markerCancel()
215+
storeInformationViewController?.dismiss(animated: true)
214216
}
215217
.disposed(by: disposeBag)
216218

217219
viewModel.getStoreInformationOutput
218220
.bind { [weak self] store in
219221
guard let self = self else { return }
220-
markerClicked()
221222
presentStoreView()
222223
storeInformationViewController?.setUIContents(store: store)
223224
}
@@ -262,56 +263,71 @@ private extension HomeViewController {
262263

263264
func markerTouchHandler(marker: Marker) {
264265
marker.touchHandler = { [weak self] (_: NMFOverlay) -> Bool in
265-
guard let self = self else { return true }
266-
markerCancel()
267-
if clickedMarker != marker {
268-
clickedMarker?.isSelected = false
269-
}
270-
marker.isSelected.toggle()
271-
if marker.isSelected {
272-
viewModel.action(input: .markerTapped(tag: marker.tag))
266+
if let clickedMarker = self?.clickedMarker {
267+
if clickedMarker == marker { return true }
268+
if clickedMarker.isSelected {
269+
self?.storeInformationViewController?.dismiss(animated: true) { [weak self] in
270+
self?.markerSelected(marker: marker)
271+
}
272+
} else {
273+
self?.markerSelected(marker: marker)
274+
}
275+
} else {
276+
self?.markerSelected(marker: marker)
273277
}
274-
clickedMarker = marker
275278

276279
return true
277280
}
278281
}
279282

280-
func markerClicked() {
281-
locationBottomConstraint.constant = -240
282-
refreshBottomConstraint.constant = -240
283-
UIView.animate(withDuration: 0.3) {
284-
self.view.layoutIfNeeded()
283+
func markerSelected(marker: Marker) {
284+
marker.isSelected.toggle()
285+
if marker.isSelected {
286+
viewModel.action(input: .markerTapped(tag: marker.tag))
285287
}
288+
clickedMarker = marker
286289
}
287290

288-
func markerCancel() {
289-
locationBottomConstraint.constant = -16
290-
refreshBottomConstraint.constant = -17
291+
func markerClicked(height: CGFloat) {
292+
mapView.mapView.logoMargin = UIEdgeInsets(top: 0, left: 0, bottom: height, right: 0)
293+
locationBottomConstraint.constant = -height
294+
refreshBottomConstraint.constant = -height
291295
UIView.animate(withDuration: 0.3) {
292296
self.view.layoutIfNeeded()
293297
}
294-
storeInformationViewController?.dismiss(animated: true)
295298
}
296299

297300
func presentStoreView() {
298301
let storeViewModel = StoreInformationViewModelImpl(
299302
getOpenClosedUseCase: GetOpenClosedUseCaseImpl(),
300303
fetchImageUseCase: FetchImageUseCaseImpl(repository: ImageRepositoryImpl())
301304
)
302-
storeInformationViewController = StoreInformationViewController(viewModel: storeViewModel)
305+
let contentHeightObserver = PublishRelay<CGFloat>()
306+
storeInformationViewController = StoreInformationViewController(
307+
viewModel: storeViewModel,
308+
contentHeightObserver: contentHeightObserver,
309+
dismissObserver: dismissObserver
310+
)
303311
storeInformationViewController?.transitioningDelegate = self
304-
312+
305313
if let viewController = storeInformationViewController {
306-
if let sheet = viewController.sheetPresentationController {
307-
let detentIdentifier = UISheetPresentationController.Detent.Identifier("detent")
308-
let detent = UISheetPresentationController.Detent.custom(identifier: detentIdentifier) { _ in
309-
return 224
314+
contentHeightObserver
315+
.bind { [weak self] contentHeight in
316+
guard let self = self else { return }
317+
let bottomSafeArea: CGFloat = 34
318+
let height = contentHeight - bottomSafeArea
319+
if let sheet = viewController.sheetPresentationController {
320+
let detentIdentifier = UISheetPresentationController.Detent.Identifier("detent")
321+
let detent = UISheetPresentationController.Detent.custom(identifier: detentIdentifier) { _ in
322+
return height
323+
}
324+
sheet.detents = [detent]
325+
sheet.largestUndimmedDetentIdentifier = detentIdentifier
326+
sheet.preferredCornerRadius = 15
327+
}
328+
markerClicked(height: contentHeight - bottomSafeArea + 16)
310329
}
311-
sheet.detents = [detent]
312-
sheet.largestUndimmedDetentIdentifier = detentIdentifier
313-
sheet.preferredCornerRadius = 15
314-
}
330+
.disposed(by: disposeBag)
315331
present(viewController, animated: true)
316332
}
317333
}
@@ -438,21 +454,26 @@ extension HomeViewController: NMFMapViewCameraDelegate {
438454
extension HomeViewController: NMFMapViewTouchDelegate {
439455

440456
func mapView(_ mapView: NMFMapView, didTapMap latlng: NMGLatLng, point: CGPoint) {
441-
clickedMarker?.isSelected = false
442-
markerCancel()
457+
storeInformationViewController?.dismiss(animated: true)
443458
}
444459

445460
}
446461

447462
extension HomeViewController: UIViewControllerTransitioningDelegate {
448463

449464
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
450-
clickedMarker?.isSelected = false
451-
locationBottomConstraint.constant = -16
452-
refreshBottomConstraint.constant = -17
453-
UIView.animate(withDuration: 0.3) {
454-
self.view.layoutIfNeeded()
455-
}
465+
dismissObserver
466+
.bind { [weak self] in
467+
guard let self = self else { return }
468+
clickedMarker?.isSelected = false
469+
mapView.mapView.logoMargin = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
470+
locationBottomConstraint.constant = -16
471+
refreshBottomConstraint.constant = -17
472+
UIView.animate(withDuration: 0.3) {
473+
self.view.layoutIfNeeded()
474+
}
475+
}
476+
.disposed(by: disposeBag)
456477

457478
return nil
458479
}

KCS/KCS/Presentation/Home/View/Marker.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Marker: NMFMarker {
1616
setUI(type: certificationType)
1717
}
1818
}
19-
19+
private lazy var unselectedGlobalZIndex: Int = self.globalZIndex
2020
private let certificationType: CertificationType
2121

2222
init(certificationType: CertificationType, position: NMGLatLng? = nil) {
@@ -43,6 +43,7 @@ private extension Marker {
4343
case .safe:
4444
icon = NMFOverlayImage(image: UIImage.markerSafeSelected)
4545
}
46+
self.globalZIndex = 250000
4647
} else {
4748
switch type {
4849
case .goodPrice:
@@ -52,6 +53,7 @@ private extension Marker {
5253
case .safe:
5354
icon = NMFOverlayImage(image: UIImage.markerSafeNormal)
5455
}
56+
self.globalZIndex = unselectedGlobalZIndex
5557
}
5658
self.iconImage = icon
5759
}

KCS/KCS/Presentation/Home/View/RefreshButton.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ private extension RefreshButton {
2525

2626
func setUI() {
2727
var titleAttribute = AttributedString("현 지도에서 검색")
28-
titleAttribute.font = .systemFont(ofSize: 10)
28+
titleAttribute.font = UIFont.pretendard(size: 10, weight: .medium)
2929

3030
var config = UIButton.Configuration.filled()
3131
config.attributedTitle = titleAttribute
3232
config.baseBackgroundColor = .white
33-
config.baseForegroundColor = .label
33+
config.baseForegroundColor = .black
3434
config.image = SystemImage.refresh?.withTintColor(.primary3, renderingMode: .alwaysOriginal)
3535
config.preferredSymbolConfigurationForImage = UIImage.SymbolConfiguration(pointSize: 10)
3636
config.imagePlacement = .leading

0 commit comments

Comments
 (0)