-
Notifications
You must be signed in to change notification settings - Fork 2
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
DiaryEditViewController 구성 / Location 흐름 구축 #176
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7636b9f
#166 feat: imagePicker 추가
LEEYOONJONG 456dcf0
refactor: textField, textView active 시 키보드로 인해 안보이는 이슈로 인한 로직 수정
LEEYOONJONG eb43ef0
#168 feat: 태그 추가 시 적절한 UI 형태로 반환
LEEYOONJONG 2c1ed1c
feat: textView에 패딩 부여
LEEYOONJONG f7346a3
feat: UI 컴포넌트 색상 및 레이아웃 변경
LEEYOONJONG cf8ab4c
#171 feat: 위치 버튼을 눌렀을 때 현재 위치의 좌표를 받아오는 일련의 흐름 구축
LEEYOONJONG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// LocationSession.swift | ||
// Segno | ||
// | ||
// Created by YOONJONG on 2022/12/08. | ||
// | ||
|
||
import CoreLocation | ||
import Foundation | ||
|
||
import RxSwift | ||
|
||
protocol LocationRepository { | ||
var locationSubject: PublishSubject<Location> { get set } | ||
var addressSubject: PublishSubject<String> { get set } | ||
func getLocation() | ||
func stopLocation() | ||
} | ||
|
||
final class LocationRepositoryImpl: NSObject, LocationRepository { | ||
var locationSubject = PublishSubject<Location>() | ||
var addressSubject = PublishSubject<String>() | ||
private var locationManager = CLLocationManager() | ||
|
||
override init() { | ||
|
||
} | ||
|
||
func getLocation() { | ||
locationManager.delegate = self | ||
locationManager.desiredAccuracy = kCLLocationAccuracyBest | ||
locationManager.requestWhenInUseAuthorization() | ||
DispatchQueue.global().async { | ||
if CLLocationManager.locationServicesEnabled() { | ||
debugPrint("위치 서비스 on") | ||
self.locationManager.startUpdatingLocation() | ||
} else { | ||
print("위치 서비스 off 상태") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그냥 보다가 궁금해진건데, 다른 부분들은 debugPrint() 쓰시다 여기는 print()군요..?! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅋ.ㅋ 이런,,,,, |
||
} | ||
} | ||
} | ||
|
||
func stopLocation() { | ||
DispatchQueue.global().async { | ||
self.locationManager.stopUpdatingLocation() | ||
} | ||
} | ||
|
||
func getAddress(location: CLLocation) { | ||
let geocoder = CLGeocoder() | ||
let locale = Locale(identifier: "Ko-kr") | ||
geocoder.reverseGeocodeLocation(location, preferredLocale: locale) { placemarks, error in | ||
guard let placemarks = placemarks, | ||
let address = placemarks.last else { return } | ||
// debugPrint("description : ", address.description) | ||
let fullAddress = address.description.components(separatedBy: ", ")[1] | ||
let array = Array(fullAddress.components(separatedBy: " ").dropFirst()) | ||
let refinedAddress = array.joined(separator: " ") | ||
debugPrint("full : ", refinedAddress) | ||
|
||
self.addressSubject.onNext(refinedAddress) | ||
} | ||
} | ||
} | ||
|
||
extension LocationRepositoryImpl: CLLocationManagerDelegate { | ||
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { | ||
debugPrint("didUpdateLocations") | ||
if let cllocation = locations.first { | ||
print("위도 : \(cllocation.coordinate.latitude)") | ||
print("경도 : \(cllocation.coordinate.longitude)") | ||
let location = Location(latitude: cllocation.coordinate.latitude, longitude: cllocation.coordinate.longitude) | ||
getAddress(location: cllocation) | ||
locationSubject.onNext(location) | ||
} | ||
} | ||
|
||
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { | ||
debugPrint("didFailWithError") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// LocationUseCase.swift | ||
// Segno | ||
// | ||
// Created by YOONJONG on 2022/12/08. | ||
// | ||
|
||
import Foundation | ||
|
||
import RxSwift | ||
|
||
protocol LocationUseCase { | ||
var locationSubject: PublishSubject<Location> { get set } | ||
var addressSubject: PublishSubject<String> { get set } | ||
func getLocation() | ||
func stopLocation() | ||
} | ||
|
||
final class LocationUseCaseImpl: LocationUseCase { | ||
var locationSubject = PublishSubject<Location>() | ||
var addressSubject = PublishSubject<String>() | ||
let repository: LocationRepository | ||
private let disposeBag = DisposeBag() | ||
|
||
init(repository: LocationRepository = LocationRepositoryImpl()) { | ||
self.repository = repository | ||
subscribeResults() | ||
} | ||
|
||
func getLocation() { | ||
repository.getLocation() | ||
} | ||
|
||
func stopLocation() { | ||
repository.stopLocation() | ||
} | ||
|
||
private func subscribeResults() { | ||
repository.addressSubject | ||
.bind(to: addressSubject) | ||
.disposed(by: disposeBag) | ||
|
||
repository.locationSubject | ||
.bind(to: locationSubject) | ||
.disposed(by: disposeBag) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Segno/Segno/Presentation/Utility/DeleteTapGestureRecognizer.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// DeleteTapGestureRecognizer.swift | ||
// Segno | ||
// | ||
// Created by YOONJONG on 2022/12/07. | ||
// | ||
|
||
import UIKit | ||
|
||
class DeleteGestureRecognizer: UITapGestureRecognizer { | ||
var title: String? | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
subject에 대한 고민이 정말.. 사람 미치게 하죠ㅎㅎㅋㅋ 이 주제에 대해서 오늘내일 이야기를 나눠 보고, 이번 주 칼럼에 실어 봅시다.