Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Runnect-iOS/Runnect-iOS/Global/UIComponents/RNAlertVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ final class RNAlertVC: UIViewController {
// MARK: - Properties

var rightButtonTapAction: (() -> Void)?

var deleteRecordDelegate: deleteRecordDelegate?


// MARK: - UI Components

private let containerView = UIView().then {
Expand Down Expand Up @@ -98,7 +96,6 @@ extension RNAlertVC {

@objc private func touchYesButton() {
self.rightButtonTapAction?()
deleteRecordDelegate?.wantsToDelete()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import SnapKit
import Then
import Moya

protocol deleteRecordDelegate: AnyObject {
func wantsToDelete()
}

final class ActivityRecordInfoVC: UIViewController, deleteRecordDelegate {
final class ActivityRecordInfoVC: UIViewController {

// MARK: - Properties

Expand All @@ -24,9 +20,7 @@ final class ActivityRecordInfoVC: UIViewController, deleteRecordDelegate {
private var activityRecordList = [ActivityRecord]()

private var deleteRecordList = [Int]()

weak var delegate: deleteRecordDelegate?


private var isEditMode: Bool = false

// MARK: - UI Components
Expand Down Expand Up @@ -127,14 +121,11 @@ extension ActivityRecordInfoVC {

extension ActivityRecordInfoVC {
func wantsToDelete() {
print("삭제 실행")

guard let selectedRecords = activityRecordTableView.indexPathsForSelectedRows else { return }
self.deleteRecordList = activityRecordTableView.indexPathsForSelectedRows?.map { activityRecordList[$0.row].id } ?? []

for indexPath in selectedRecords {
self.deleteRecordList.append(activityRecordList[indexPath.row].id)
}
print("삭제 실행")

self.isEditMode.toggle()
deleteRecord()
}
}
Expand All @@ -143,6 +134,7 @@ extension ActivityRecordInfoVC {

extension ActivityRecordInfoVC {
@objc func editButtonDidTap() {
print(isEditMode)
if isEditMode {
self.totalNumOfRecordlabel.text = "총 기록 \(self.activityRecordList.count)개"
self.editButton.setTitle("편집", for: .normal)
Expand All @@ -164,10 +156,12 @@ extension ActivityRecordInfoVC {
@objc func deleteRecordButtonDidTap() {
let deleteAlertVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기")
deleteAlertVC.modalPresentationStyle = .overFullScreen
deleteAlertVC.deleteRecordDelegate = self
self.present(deleteAlertVC, animated: false, completion: nil)
deleteAlertVC.rightButtonTapAction = { [weak self] in
deleteAlertVC.dismiss(animated: false)
self?.wantsToDelete()
self?.isEditMode = false
return
Comment on lines +162 to +164
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
}
}
Expand Down