extension NoticeViewController: ExpyTableViewDelegate {
func tableView(_ tableView: ExpyTableView, expyState state: ExpyState, changeForSection section: Int) {
print("NoticeViewController - ExpyTableViewDelegate - changeForSection() called - section = \(section)")
switch state {
case .willExpand:
print("펼쳐질 꺼다/ .willExpand / section: \(section)")
print("현재 섹션: \(section), tableView.expandedSections : \(tableView.expandedSections)")
// 접어야 할 섹션들
let expandedSections = tableView.expandedSections.map{ $0.key }.filter{ $0 != section }
print("willExpand 현재 들어온 섹션: \(section), 펼쳐진 섹션: expandedSections: \(expandedSections)")
case .willCollapse:
print("닫힐 꺼다 /.willCollapse / section: \(section)")
case .didExpand:
print("펼쳐짐 / .didExpand / section: \(section)")
// 접어야 할 섹션들
let expandedSections = tableView.expandedSections.map{ $0.key }.filter{ $0 != section }
if expandedSections.count > 0 {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.02, execute: {
expandedSections.forEach{ tableView.collapse($0) }
})
}
print("didExpand 현재 들어온 섹션: \(section), 펼쳐진 섹션: expandedSections: \(expandedSections)")
case .didCollapse:
print("닫힘 /.didCollapse / section: \(section)")
}
}
}