Skip to content

Commit

Permalink
Merge pull request TeamNADA#263 from TeamNADA/release1.0/TeamNADA#266
Browse files Browse the repository at this point in the history
[FIX] TeamNADA#262 - 명함 모음 리로드 로직 수정
  • Loading branch information
hyun99999 authored Dec 29, 2021
2 parents ded11cd + 814b9d9 commit 0c7093d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,11 @@ class SelectGroupBottomSheetViewController: CommonBottomSheetViewController {
@objc func presentCardInfoViewController() {
switch status {
case .detail:
NotificationCenter.default.post(name: .reloadGroupViewController, object: nil)
changeGroupWithAPI(request: ChangeGroupRequest(cardID: cardDataModel?.cardID ?? "",
userID: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "",
groupID: groupId ?? 0,
newGroupID: selectedGroup))
case .add, .addWithQR:
NotificationCenter.default.post(name: .reloadGroupViewController, object: nil)
cardAddInGroupWithAPI(cardRequest: CardAddInGroupRequest(cardId: cardDataModel?.cardID ?? "",
userId: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "",
groupId: selectedGroup))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ class CardDetailViewController: UIViewController {
case .group:
self.navigationController?.popViewController(animated: true)
case .add:
NotificationCenter.default.post(name: .reloadGroupViewController, object: nil)
self.dismiss(animated: true, completion: nil)
case .addWithQR:
NotificationCenter.default.post(name: .reloadGroupViewController, object: nil)
self.presentingViewController?.presentingViewController?.dismiss(animated: true, completion: nil)

case .detail:
Expand All @@ -28,7 +30,6 @@ class CardDetailViewController: UIViewController {
@IBAction func presentHarmonyViewController(_ sender: Any) {
cardHarmonyFetchWithAPI(myCard: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.firstCardID) ?? "",
yourCard: cardDataModel?.cardID ?? "")

}

@IBOutlet weak var optionButton: UIButton!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ class GroupViewController: UIViewController {
registerCell()
setNotification()
setUI()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

offset = 0
frontCards?.removeAll()
groupListFetchWithAPI(userID: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "")
}
}
Expand All @@ -99,22 +106,28 @@ extension GroupViewController {

private func setNotification() {
NotificationCenter.default.addObserver(self, selector: #selector(didRecieveDataNotification(_:)), name: Notification.Name.passDataToGroup, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(scrollToTop), name: .reloadGroupViewController, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(relaodCardCollection), name: .reloadGroupViewController, object: nil)
}
// FIXME: - 스크롤탑
private func scrollToTop(completion: () -> Void) {
groupListFetchWithAPI(userID: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "")
completion()
}

@objc func didRecieveDataNotification(_ notification: Notification) {
selectedRow = notification.object as? Int ?? 0
}

@objc
private func scrollToTop() {
private func relaodCardCollection() {
offset = 0
frontCards?.removeAll()
groupListFetchWithAPI(userID: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "")

// FIXME: - 스크롤 탑
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.cardsCollectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .top, animated: false)
}
// scrollToTop {
// self.cardsCollectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .top, animated: false)
// }
groupListFetchWithAPI(userID: UserDefaults.standard.string(forKey: Const.UserDefaultsKey.userID) ?? "")
// cardsCollectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .top, animated: false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class QRScanViewController: UIViewController {

extension QRScanViewController {
@objc func dismissQRScanViewController() {
NotificationCenter.default.post(name: .reloadGroupViewController, object: nil)
self.dismiss(animated: true, completion: nil)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class GroupEditViewController: UIViewController {

// MARK: - @IBAction Properties
@IBAction func dismissToPreviousView(_ sender: UIButton) {
NotificationCenter.default.post(name: .reloadGroupViewController, object: nil)
self.navigationController?.popViewController(animated: true)
}

Expand Down

0 comments on commit 0c7093d

Please sign in to comment.