diff --git a/iBox/Sources/BoxList/BoxListView.swift b/iBox/Sources/BoxList/BoxListView.swift index a492c96..5403162 100644 --- a/iBox/Sources/BoxList/BoxListView.swift +++ b/iBox/Sources/BoxList/BoxListView.swift @@ -43,6 +43,9 @@ class BoxListView: UIView { $0.backgroundColor = .clear $0.separatorColor = .clear $0.rowHeight = 50 + $0.estimatedSectionHeaderHeight = 0 + $0.estimatedSectionFooterHeight = 0 + $0.estimatedRowHeight = 0 } private let emptyStackView = UIStackView().then { @@ -150,6 +153,7 @@ class BoxListView: UIView { return cell } + boxListDataSource.defaultRowAnimation = .top boxListDataSource.delegate = self } @@ -184,6 +188,13 @@ class BoxListView: UIView { guard var snapshot = self?.boxListDataSource.snapshot() else { return } snapshot.reloadItems(idArray) self?.boxListDataSource.apply(snapshot) + case .openCloseFolder(boxList: let boxList, section: let section, isEmpty: let isEmpty): + self?.applySnapshot(with: boxList) + self?.tableView.layoutIfNeeded() + if !isEmpty { + let indexPath = IndexPath(row: NSNotFound, section: section) + self?.tableView.scrollToRow(at: indexPath, at: .top, animated: true) + } } }.store(in: &cancellables) } @@ -422,7 +433,6 @@ class BoxListDataSource: UITableViewDiffableDataSource() + var rowsToReload = Set() var isEditing = false var favoriteId: UUID? = nil @@ -37,6 +38,7 @@ class BoxListViewModel { case reloadSections(idArray: [BoxListSectionViewModel.ID]) case reloadRows(idArray: [BoxListCellViewModel.ID]) case editStatus(isEditing: Bool) + case openCloseFolder(boxList: [BoxListSectionViewModel], section: Int, isEmpty: Bool) } let input = PassthroughSubject() @@ -62,7 +64,7 @@ class BoxListViewModel { } case let .folderTapped(section): boxList[section].isOpened.toggle() - output.send(.sendBoxList(boxList: boxList)) + output.send(.openCloseFolder(boxList: boxList, section: section, isEmpty: boxList[section].boxListCellViewModelsWithStatus.isEmpty)) case let .deleteBookmark(indexPath): deleteBookmark(at: indexPath) case let .toggleFavorite(indexPath): diff --git a/iBox/Sources/Favorite/FavoriteView.swift b/iBox/Sources/Favorite/FavoriteView.swift index f4834e0..0963419 100644 --- a/iBox/Sources/Favorite/FavoriteView.swift +++ b/iBox/Sources/Favorite/FavoriteView.swift @@ -40,7 +40,6 @@ class FavoriteView: UIView { // MARK: - Setup Methods private func setupProperty() { - guard let webView else { return } backgroundColor = .backgroundColor }