Skip to content

Commit

Permalink
[Fix/#108] Challenge - 삭제 시 alert구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-seonwoo committed Jan 18, 2024
1 parent 74e91e4 commit 0cadae9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions HMH_iOS/HMH_iOS/Global/Protocols/AlertDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ protocol AlertDelegate: AnyObject {
func enabledButtonTapped()
func alertDismissTapped()
func confirmButtonTapped()
func deleteButtonTapped()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import SnapKit
import Then

final class ChallengeViewController: UIViewController {

var isCreatedChallenge = false
var decodedIndex: Int = 0
func updateChallengeStatus(isCreatedChallenge: Bool) {
self.isCreatedChallenge = isCreatedChallenge
configureTabBar(isCreatedChallenge: isCreatedChallenge)
Expand All @@ -27,7 +27,7 @@ final class ChallengeViewController: UIViewController {

let challengeView = ChallengeView(frame: .zero, appAddButtonViewModel: BlockingApplicationModel.shared)

private var selectedIndex = IndexPath()
var selectedIndex = IndexPath()

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Expand Down Expand Up @@ -79,6 +79,10 @@ final class ChallengeViewController: UIViewController {
let nextViewController = CreatePeriodController()
self.navigationController?.pushViewController(nextViewController, animated: false)
}

func deleteTap() {
challengeView.deleteCell()
}
}


Expand All @@ -93,6 +97,8 @@ extension ChallengeViewController: UICollectionViewDelegate {
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
self.decodedIndex = indexPath.item
print(decodedIndex)
if selectedIndex == [] {
selectedIndex = [1,0]
}
Expand All @@ -102,14 +108,17 @@ extension ChallengeViewController: UICollectionViewDelegate {
}
if let currentSelectedCell = collectionView.cellForItem(at: indexPath) as? AppListCollectionViewCell {
currentSelectedCell.isSelectedCell = true

self.selectedIndex = indexPath
let alertController = AlertViewController()
alertController.setAlertType(.delete)
alertController.modalPresentationStyle = .overFullScreen
self.present(alertController, animated: false, completion: nil)
}

}
}

}



Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import Then
import FamilyControls

final class ChallengeView: UIView {

private var appAddButtonViewModel: BlockingApplicationModel = BlockingApplicationModel.shared
private var cancellables: Set<AnyCancellable> = []
var isChallengeComplete: Bool = true

private let goalTime: Int = 3
private var days: Int = 7
private var appList: [AppModel] = [AppModel(appIcon: "", appName: "Instagram", appUseTime: "1시간 20분"),
var appList: [AppModel] = [AppModel(appIcon: "", appName: "Instagram", appUseTime: "1시간 20분"),
AppModel(appIcon: "", appName: "Youtube", appUseTime: "1시간")]
var isDeleteMode: Bool = false {
didSet {
Expand Down Expand Up @@ -95,6 +94,11 @@ final class ChallengeView: UIView {
@objc private func deleteButtonTapped() {
isDeleteMode.toggle()
}

func deleteCell() {
print("tap")
}

}

extension ChallengeView: UICollectionViewDataSource {
Expand Down Expand Up @@ -273,3 +277,4 @@ extension ChallengeView {
return nil
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ final class AlertViewController: UIViewController {
}

extension AlertViewController: AlertDelegate {
func deleteButtonTapped() {
let challengeController = ChallengeViewController()
challengeController.deleteTap()
dismiss(animated: false) {
(self.okAction ?? self.emptyActions)()
}
}
func confirmButtonTapped() {
setRootViewController(TabBarController())
}
Expand All @@ -139,7 +146,7 @@ extension AlertViewController: AlertDelegate {
UserManager.shared.clearAll()
}
}

dismiss(animated: false) {
let loginViewController = LoginViewController()
if let window = UIApplication.shared.windows.first {
Expand All @@ -157,3 +164,4 @@ extension AlertViewController: AlertDelegate {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ final class HMHDeleteAlert: UIView {
}

private func setAddTarget() {
cancelButton.addTarget(self, action: #selector(cancelButtonTapped), for: .touchUpInside)
confirmButton.addTarget(self, action: #selector(confirmButtonTapped), for: .touchUpInside)
cancelButton.addTarget(self, action: #selector(deleteButtonTapped), for: .touchUpInside)
confirmButton.addTarget(self, action: #selector(cancelButtonTapped), for: .touchUpInside)
}

private func configureView() {
Expand All @@ -98,8 +98,8 @@ final class HMHDeleteAlert: UIView {
delegate?.alertDismissTapped()
}

@objc func confirmButtonTapped() {
delegate?.alertDismissTapped()
@objc func deleteButtonTapped() {
delegate?.deleteButtonTapped()
}
}

0 comments on commit 0cadae9

Please sign in to comment.