Skip to content

Commit

Permalink
Merge pull request TeamSparker#427 from yangsubinn/feature/TeamSparke…
Browse files Browse the repository at this point in the history
…r#425

[Feat] TeamSparker#425 - 습관 시작 후 습관방 이동 플로우 적용
  • Loading branch information
yangsubinn authored Mar 23, 2022
2 parents 44d0e99 + cdeca61 commit 5b45d25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions Spark-iOS/Spark-iOS/Resource/Constants/Notification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ extension Notification.Name {
static let leaveRoom = Notification.Name("leaveRoom")
static let feedReport = Notification.Name("feedReport")
static let updateHome = Notification.Name("updateHome")
static let startHabitRoom = Notification.Name("startHabitRoom")
}
10 changes: 10 additions & 0 deletions Spark-iOS/Spark-iOS/Source/ViewControllers/TabBar/HomeVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ extension HomeVC {
private func setNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(setToastMessage(_:)), name: .leaveRoom, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateHome), name: .updateHome, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(enterHabitRoomVC(_:)), name: .startHabitRoom, object: nil)
}

// MARK: - Screen Change
Expand Down Expand Up @@ -280,6 +281,15 @@ extension HomeVC {
}
}
}

@objc
private func enterHabitRoomVC(_ notification: NSNotification) {
guard let nextVC = UIStoryboard(name: Const.Storyboard.Name.habitRoom, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.habitRoom) as? HabitRoomVC else { return }
guard let roomID: Int = notification.userInfo?["roomID"] as? Int else { return }
nextVC.roomID = roomID

navigationController?.pushViewController(nextVC, animated: true)
}
}

// MARK: - UICollectionViewDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,19 @@ extension WaitingVC {
print("fromeWhereStatus 를 지정해주세요.")
}
}
self.postStartHabitNotification()
}

self.present(nextVC, animated: true, completion: nil)
}

private func postNotification() {
private func postLeaveNotification() {
NotificationCenter.default.post(name: .leaveRoom, object: nil, userInfo: ["roomName": "\(roomName ?? "")", "waitingRoom": true])
}

private func postStartHabitNotification() {
NotificationCenter.default.post(name: .startHabitRoom, object: nil, userInfo: ["roomID": roomId ?? 0])
}
}

// MARK: - Network
Expand Down Expand Up @@ -564,7 +569,7 @@ extension WaitingVC {
case .none:
print("fromeWhereStatus 를 지정해주세요.")
}
self.postNotification()
self.postLeaveNotification()
print("deleteWaitingRoomWithAPI - success: \(message)")
case .requestErr(let message):
print("deleteWaitingRoomWithAPI - requestErr: \(message)")
Expand Down Expand Up @@ -593,7 +598,7 @@ extension WaitingVC {
case .none:
print("fromeWhereStatus 를 지정해주세요.")
}
self.postNotification()
self.postLeaveNotification()
print("deleteWaitingRoomWithAPI - success: \(message)")
case .requestErr(let message):
print("deleteWaitingRoomWithAPI - requestErr: \(message)")
Expand Down

0 comments on commit 5b45d25

Please sign in to comment.