Skip to content

Commit

Permalink
feat: 카테고리 편집 UI 구현
Browse files Browse the repository at this point in the history
Kyxxn committed Nov 20, 2024
1 parent 8ddf694 commit abad439
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ final class CategoryViewController: UIViewController {
color: .mhTitle
) { [weak self] in
// TODO: 편집하기
self?.categoryTableView.setEditing(true, animated: true)
}

// 우측 추가 버튼
@@ -93,7 +94,7 @@ extension CategoryViewController: UITableViewDelegate {
_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath
) {

// TODO: 카테고리 선택 시 로직 필요
}

func tableView(
@@ -102,6 +103,36 @@ extension CategoryViewController: UITableViewDelegate {
) -> CGFloat {
CategoryTableViewCell.height
}

func tableView(
_ tableView: UITableView,
canEditRowAt indexPath: IndexPath
) -> Bool {
indexPath.row >= 2
}

func tableView(
_ tableView: UITableView,
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath
) -> UISwipeActionsConfiguration? {
let editAction = UIContextualAction(
style: .normal,
title: "수정"
) { [weak self] _, _, completion in
// TODO: 수정 로직
}

let deleteAction = UIContextualAction(
style: .destructive,
title: "삭제"
) { [weak self] _, _, completion in
// TODO: 삭제 로직
}

return UISwipeActionsConfiguration(
actions: [deleteAction, editAction]
)
}
}

extension CategoryViewController: UITableViewDataSource {

0 comments on commit abad439

Please sign in to comment.