-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] #136 - 마이페이지 러닝 기록 상세뷰 UI와 삭제 api 연결 #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] #136 - 마이페이지 러닝 기록 상세뷰 UI와 삭제 api 연결 #138
The head ref may contain hidden characters: "feat/#136-\uB9C8\uC774\uD398\uC774\uC9C0-\uB7EC\uB2DD-\uAE30\uB85D-\uC0C1\uC138\uBDF0-UI\uC640-\uC11C\uBC84-\uC5F0\uACB0"
Conversation
맨 아래에 추가된 뷰의 바텀 레이아웃을 안 잡아서.. 그랬어요..
lsj8706
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다~!
- 삭제 이후 테이블뷰가 reload되지 않는 이유 -> 테이블 뷰는 이미 가지고 있는 모델 어레이를 바탕으로 뷰를 그리고 있습니다. -> 모델이 들어있는 어레이가 바뀌지 않으면 UI는 바뀌지 않습니다. -> 즉, 삭제 이후 서버 통신을 다시 해서 모델들을 새로 받아와야합니다.
- 탭바가 없어지는건 view가 사라질 때 다시 탭바를 보여주는 방식으로 해결할 수 있습니다! viewWillDissappear에서 탭바를 보여주도록 바꿔보실래요~?
| var rightButtonTapAction: (() -> Void)? | ||
|
|
||
| var deleteRecordDelegate: deleteRecordDelegate? | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rightButtonTapAction 이라는 클로저로 터치 이벤트 발생 시 처리할 액션을 지정해줄 수 있도록 했는데 delegate를 추가로 구현하셨네요..?
rightButtonTapAction으로 전체 검색해서 사용 예시 한번 확인해보세요
하위뷰에서 이벤트 발생시 처리할 동작을 지정해줄 때에는 늘 하던대로 delegate-protocol을 사용할 수도 있지만 이렇게 클로저로 액션일 미리 지정해줄 수도 있습니다.
둘 다 사용할 줄 알아야해요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delegate-protocol을 쓴 이유가 deleteVC에서 버튼이 눌렸을 때, ActivityRecordVC에 있는 테이블뷰 -> 선택된 셀들을 가져와야 하는데, rightButtonTapAction 클로저 안에서 이 ActivityRecordVC 테이블뷰에 접근하는 법을 모르겠어서 였어요..! 제가 클로저에 대한 이해가 낮아서 그런 것 같은데.. 잘 모르겠어서 일단은 수정하지 말아볼게요...!
| @discardableResult | ||
| func setButtonTitle(_ leftButtonTitle: String, _ rightButtonTitle: String) -> Self { | ||
| self.yesButton.setTitle(rightButtonTitle, for: .normal) | ||
| self.noButton.setTitle(leftButtonTitle, for: .normal) | ||
| return self | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| case .getActivityRecordInfo: | ||
| return .requestPlain | ||
| case .deleteRecord(let recordIdList): | ||
| return .requestParameters(parameters: ["recordIdList": recordIdList], encoding: JSONEncoding.default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
| func setRecordId(recordId: Int?) { | ||
| self.recordId = recordId | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 작업을 외부 VC에서 실행시키고 있는 것 같은데 그냥 바로 빝에 있는 setData함수에서 어차피 ActivityRecord 모델을 받아오고 있고 이 모델에 Id가 있기 때문에 함수를 분리한 것은 좋지만 호출은 바로 밑에 있는 setData에서 하면 될 거 같아요~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정하겠습니다!
|
|
||
| private var deleteRecordList = [Int]() | ||
|
|
||
| weak var delegate: deleteRecordDelegate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 친구는 어디에 쓰이고 있는 걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삭제할 record들의 id값만 넣어주기 위한 리스트입니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlwogus0128 앗 delegate를 물어본 거였어요! ㅎㅎ
| self.activityRecordTableView.reloadData() | ||
| self.editButton.setTitle("편집", for: .normal) | ||
| self.deleteRecordButton.isHidden = true | ||
| self.totalNumOfRecordlabel.text = "총 기록 \(self.activityRecordList.count)개" | ||
| if let selectedRows = activityRecordTableView.indexPathsForSelectedRows { | ||
| for indexPath in selectedRows { | ||
| activityRecordTableView.deselectRow(at: indexPath, animated: true) | ||
| } | ||
| } | ||
| self.deleteRecordButton.isEnabled = false | ||
| self.deleteRecordButton.setTitle(title: "삭제하기") | ||
| self.activityRecordTableView.reloadData() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.activityRecordTableView.reloadData()를 두번 호출한 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그러게요..ㅋ 수정하겠습니다
| protocol deleteRecordDelegate: AnyObject { | ||
| func wantsToDelete() | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이게 RNAlertVC의 버튼 터치시 발생할 delegate라면 위치가 RNAlertVC가 있는 파일이어야 합니다.
그런데 앞선 리뷰에 딜리게이트 말고 클로저로 액션을 전달하는 방법을 이야기했으니 아예 없애고 클로저로 해봐도 좋을 거에요!
| @objc func deleteRecordButtonDidTap() { | ||
| let deleteVC = RNAlertVC(description: "러닝 기록을 정말로 삭제하시겠어요?").setButtonTitle("취소", "삭제하기") | ||
| deleteVC.modalPresentationStyle = .overFullScreen | ||
| deleteVC.deleteRecordDelegate = self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleteVC.rightButtonTapAction = {
// 원하는 액션
}그리고 deleteVC보다는 deleteAlertVC 처럼 더 구체적인 네이밍을 사용합시다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정했습니닷
| let activityRecordList = activityRecordList[indexPath.item] | ||
| //ActivityRecordDetailVC.setCourseId(courseId: <#T##Int?#>, publicCourseId: <#T##Int?#>) | ||
|
|
||
| let activityRecordDetailVC = ActivityRecordDetailVC() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 줄은 isEditMode가 false일때만 필요한거니까 아래의 else블록 안에 있으면 좋을 거 같아요!
isEditMode가 true일때 불필요하게 변수를 메모리에 할당하는 것을 방지합시다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
옹 감사합니다!
| let status = result.statusCode | ||
| if 200..<300 ~= status { | ||
| print("삭제 성공") | ||
| self.reloadActivityRecordInfoVC() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 함수가 아니라 서버 통신 함수를 실행시켜야 할거에요~!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감사합니닷
|
궁금증 리뷰 달아놓은 것 제외하고 리뷰 반영했습니다! |
@dlwogus0128 푸시 해주세요! |
|
be22beb <- 이게 최신 커밋으로 보이는데 맞나요? |
ad7638c 이거요...! |
@dlwogus0128 이 브랜치가 아니라 139번에서 반영한 것 같아요..! 그럼 우선 이거 머지하고 139번도 PR 올려주세요~! |
🌱 작업한 내용
🌱 PR Point
📸 스크린샷
📮 관련 이슈