Skip to content

Commit

Permalink
Merge branch 'develop' into feature/89_MypageViewModel
Browse files Browse the repository at this point in the history
  • Loading branch information
jangseoyoung committed Dec 1, 2021
2 parents 71efeda + 753ddf0 commit 27ce922
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
generate:
tuist generate
arch -x86_64 pod install
3 changes: 0 additions & 3 deletions Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ let project = Project(
outputPaths: [Path.init("$SRCROOT/Supporting Files/R.generated.swift")],
outputFileListPaths: []
)
],
dependencies: [
.cocoapods(path: ".")
]
)
],
Expand Down
13 changes: 13 additions & 0 deletions Sources/Model/Networking/EmptyModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// EmptyModel.swift
// SSGP
//
// Created by 장서영 on 2021/11/29.
// Copyright © 2021 com.ssgp. All rights reserved.
//

import Foundation

struct EmptyModel: Codable {

}
12 changes: 11 additions & 1 deletion Sources/Model/Networking/SSGPAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ extension SSGPAPI: TargetType {

var headers: [String: String]? {
switch self {
case .login, .signUp, .findNearbyStore:
case .login, .signUp:
return ["Content-Type": "application/json"]
case .tokenRefresh:
return [
Expand Down Expand Up @@ -149,4 +149,14 @@ extension SSGPAPI: TargetType {
return keychain.get("REFRESH-TOKEN") ?? ""
}

private var id: String {
let keychain = KeychainSwift()
return keychain.get("ID") ?? ""
}

private var password: String {
let keychain = KeychainSwift()
return keychain.get("PASSWORD") ?? ""
}

}
7 changes: 5 additions & 2 deletions Sources/View/Map/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import CoreLocation
import RxSwift
import RxCocoa
import FloatingPanel
import RxViewController

class MapViewController: UIViewController {

Expand Down Expand Up @@ -74,6 +75,7 @@ class MapViewController: UIViewController {

private func bind() {
let input = MapViewModel.Input(
viewWillApear: self.rx.viewWillAppear.map { _ in () }.asDriver(onErrorJustReturn: ()),
userLocationIsEnabled: self.locationManager.userLocation(),
mapViewDidFinishLoadingMap: mapViewDidFinishLoadingMap.asDriver(onErrorJustReturn: ()),
annotaationIsSelected: annotaationIsSelected.asDriver(onErrorJustReturn: nil),
Expand All @@ -83,8 +85,9 @@ class MapViewController: UIViewController {
)
let output = viewModel.transform(input)

output.setAnnotataion.subscribe(onNext: { [weak self] annotations in
self?.mapView.addAnnotations(annotations)
output.setAnnotataion.subscribe(onNext: { annotations in
self.mapView.removeAnnotations(self.mapView.annotations)
self.mapView.addAnnotations(annotations)
})
.disposed(by: disposeBag)

Expand Down
2 changes: 2 additions & 0 deletions Sources/ViewModel/Auth/LoginViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class LoginViewModel: ViewModel {
).subscribe(onSuccess: { token in
self.keychain.set(token.access_token, forKey: "ACCESS-TOKEN")
self.keychain.set(token.refresh_token, forKey: "REFRESH-TOKEN")
self.keychain.set(id, forKey: "ID")
self.keychain.set(pwd, forKey: "PASSWORD")
self.output.loginResult.accept(true)
}, onFailure: { _ in
self.output.loginResult.accept(false)
Expand Down
9 changes: 8 additions & 1 deletion Sources/ViewModel/Map/MapViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MapViewModel: ViewModel {
private var isMapFirstLoad = true

struct Input {
let viewWillApear: Driver<Void>
let userLocationIsEnabled: Single<CLLocationCoordinate2D>
let mapViewDidFinishLoadingMap: Driver<Void>
let annotaationIsSelected: Driver<MKAnnotationView?>
Expand All @@ -39,7 +40,13 @@ class MapViewModel: ViewModel {

func transform(_ input: Input) -> Output {

input.userLocationIsEnabled.subscribe(onSuccess: {
Observable.combineLatest(
input.userLocationIsEnabled.asObservable(),
input.viewWillApear.asObservable(),
resultSelector: { location, _ in
return location
}
).subscribe(onNext: {
HTTPClient.shared.networking(api: .findNearbyStore(
String($0.longitude),
String($0.latitude)
Expand Down

0 comments on commit 27ce922

Please sign in to comment.