Skip to content

Commit c271e88

Browse files
authored
Merge pull request #311 from Atcha-Project/bugfix/#310
[BUGFIX] 말풍선 기능 오류 수정
2 parents ffedff7 + e483e3b commit c271e88

7 files changed

Lines changed: 326 additions & 557 deletions

File tree

Atcha-iOS/DesignSource/AtchaBallon/AtchaBallon.swift

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import UIKit
99
import SnapKit
1010

1111
final class AtchaBallon: UIView {
12-
private let topLabel: AtcahaInsetLabel = AtcahaInsetLabel()
13-
private let bottomLabel: AtcahaInsetLabel = AtcahaInsetLabel()
12+
var topLabel: AtcahaInsetLabel = AtcahaInsetLabel()
13+
var bottomLabel: AtcahaInsetLabel = AtcahaInsetLabel()
1414
private let triangeImageView: UIImageView = UIImageView()
1515
private lazy var containerStackView: UIStackView = {
1616
let stackView = UIStackView(arrangedSubviews: [topLabel, bottomLabel])
@@ -184,3 +184,38 @@ final class AtchaBallon: UIView {
184184
}
185185
}
186186

187+
extension AtchaBallon {
188+
// 내부 뷰를 초기화 (모두 투명하게)
189+
func resetAndHideAll() {
190+
self.layer.removeAllAnimations()
191+
self.topLabel.alpha = 0
192+
self.bottomLabel.alpha = 0
193+
self.triangeImageView.alpha = 0
194+
self.isHidden = false
195+
}
196+
197+
// Top 라벨 서서히 표시/숨김
198+
func setTopVisible(_ isVisible: Bool, duration: TimeInterval = 0.3) {
199+
self.topLabel.isHidden = false
200+
UIView.animate(withDuration: duration) {
201+
self.topLabel.alpha = isVisible ? 1 : 0
202+
}
203+
}
204+
205+
// Bottom 라벨(과 삼각형) 서서히 표시/숨김
206+
func setBottomVisible(_ isVisible: Bool, duration: TimeInterval = 0.3) {
207+
self.bottomLabel.isHidden = false
208+
UIView.animate(withDuration: duration) {
209+
self.bottomLabel.alpha = isVisible ? 1 : 0
210+
self.triangeImageView.alpha = isVisible ? 1 : 0
211+
}
212+
}
213+
214+
// 택시비 AttributedString 생성 헬퍼
215+
static func makeFareAttributedString(fareStr: String) -> NSAttributedString {
216+
let gray = NSMutableAttributedString(string: "여기서 막차 놓치면 택시비 ", attributes: [.foregroundColor: UIColor.gray100])
217+
let white = NSMutableAttributedString(string: "\(fareStr)", attributes: [.foregroundColor: UIColor.white])
218+
gray.append(white)
219+
return gray
220+
}
221+
}

Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ final class DetailRouteViewController: BaseViewController<DetailRouteViewModel>,
567567

568568
// 2. 좌표가 있다면 '애니메이션 없이' 즉시 현위치로 이동
569569
if let currentCoord = viewModel.currentLocation {
570-
mapContainerView.setupCenter(location: currentCoord) // setupZoomCenter 대신 setupCenter(이동만)
571570
mapContainerView.setupZoomCenter(location: currentCoord) // 필요 시 줌까지
572571
}
573572
} else {
@@ -604,6 +603,8 @@ extension DetailRouteViewController {
604603
@objc private func didTapLocationButton() {
605604
ensureLocationPermissionOrShowToast()
606605

606+
viewModel.forceLocationSnap()
607+
607608
isFollowingUser = true
608609
shouldCenterToCurrentLocationOnce = true
609610
viewModel.startHeading()
@@ -645,7 +646,6 @@ extension DetailRouteViewController {
645646
if isAlarmFired {
646647
if let currentCoord = viewModel.currentLocation {
647648
// 애니메이션 없이 즉시 이동하여 '깜빡임' 방지
648-
mapContainerView.setupCenter(location: currentCoord)
649649
mapContainerView.setupZoomCenter(location: currentCoord)
650650
}
651651
}

Atcha-iOS/Presentation/Location/DetailRoute/DetailRouteViewModel.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ final class DetailRouteViewModel: BaseViewModel {
5555
@Published var isRefreshing: Bool = false
5656

5757
private var lastValidTime: Date? = nil
58-
private var consecutiveValidCount = 0
58+
private var didSendInitialLocation = false
5959

60+
private var consecutiveValidCount = 0
61+
func forceLocationSnap() {
62+
self.didSendInitialLocation = false
63+
self.lastValidTime = nil
64+
self.consecutiveValidCount = 0
65+
}
6066
//#if DEBUG
6167
//@Published var mockLocation: CLLocationCoordinate2D? = nil
6268
//#endif
@@ -204,6 +210,9 @@ final class DetailRouteViewModel: BaseViewModel {
204210
streamTask = Task {
205211
for await location in streamUseCase.startUpdate() {
206212
let now = Date()
213+
214+
let isInitialTracking = !self.didSendInitialLocation
215+
207216
let timeGap = self.lastValidTime != nil ? now.timeIntervalSince(self.lastValidTime!) : 999.0
208217
let isRecovering = timeGap > 60.0
209218

@@ -218,7 +227,9 @@ final class DetailRouteViewModel: BaseViewModel {
218227
// 지상 탈출이 의심될 때: 바로 안 믿고 카운터를 올립니다.
219228
self.consecutiveValidCount += 1
220229

221-
if self.consecutiveValidCount >= 3 {
230+
let requiredCount = isInitialTracking ? 1 : 3
231+
232+
if self.consecutiveValidCount >= requiredCount {
222233
// 3번 연속(약 3초) 정상 신호가 들어왔다? 이건 100% 진짜 지상이다!
223234
smoother.reset(location.coordinate)
224235

@@ -252,6 +263,9 @@ final class DetailRouteViewModel: BaseViewModel {
252263

253264
await MainActor.run {
254265
self.currentLocation = capturedCoord
266+
if !self.didSendInitialLocation {
267+
self.didSendInitialLocation = true
268+
}
255269
HomeArrivalManager.shared.checkHomeArrival(currentCoord: capturedCoord)
256270
}
257271

0 commit comments

Comments
 (0)