@@ -143,8 +143,45 @@ open class GravityTableManager: BaseTableManager {
143143
144144 open func replace( oldGenerator: CellGeneratorType ,
145145 on newGenerator: CellGeneratorType ,
146- removeAnimation: UITableView . RowAnimation = . automatic,
147- insertAnimation: UITableView . RowAnimation = . automatic) {
146+ removeInsertAnimation: TableRowAnimationGroup = . animated( . automatic, . automatic) ) {
147+ guard let index = self . findGenerator ( oldGenerator) else { return }
148+
149+ generators [ index. sectionIndex] . remove ( at: index. generatorIndex)
150+ generators [ index. sectionIndex] . insert ( newGenerator, at: index. generatorIndex)
151+
152+ let indexPath = IndexPath ( row: index. generatorIndex, section: index. sectionIndex)
153+
154+ modifier? . replace ( at: indexPath, with: removeInsertAnimation. value)
155+ }
156+
157+ open func replace( header: HeaderGeneratorType , with animation: TableRowAnimation = . animated( . fade) ) {
158+ guard let indexOfHeader = self . sections. firstIndex ( where: { $0 === header } ) else {
159+ self . addSectionHeaderGenerator ( header)
160+ return
161+ }
162+
163+ self . sections [ indexOfHeader] = header
164+ modifier? . reloadSections ( at: [ indexOfHeader] , with: animation. value)
165+ }
166+
167+ open func remove( _ generator: CellGeneratorType ,
168+ with animation: TableRowAnimation = . animated( . automatic) ,
169+ needScrollAt scrollPosition: UITableView . ScrollPosition ? = nil ,
170+ needRemoveEmptySection: Bool = false ) {
171+ guard let index = self . findGenerator ( generator) else { return }
172+ self . removeGenerator ( with: index,
173+ with: animation,
174+ needScrollAt: scrollPosition,
175+ needRemoveEmptySection: needRemoveEmptySection)
176+ }
177+
178+ // MARK: - Depcrecated
179+
180+ @available ( * , deprecated, message: " Please use method with a new `TableRowAnimationGroup` parameters " )
181+ open func replace( oldGenerator: CellGeneratorType ,
182+ on newGenerator: CellGeneratorType ,
183+ removeAnimation: UITableView . RowAnimation ,
184+ insertAnimation: UITableView . RowAnimation ) {
148185 guard let index = self . findGenerator ( oldGenerator) else { return }
149186
150187 generators [ index. sectionIndex] . remove ( at: index. generatorIndex)
@@ -154,7 +191,8 @@ open class GravityTableManager: BaseTableManager {
154191 modifier? . replace ( at: indexPath, with: ( remove: removeAnimation, insert: insertAnimation) )
155192 }
156193
157- open func replace( header: HeaderGeneratorType , with animation: UITableView . RowAnimation = . fade) {
194+ @available ( * , deprecated, message: " Please use method with a new `TableRowAnimation` parameter " )
195+ open func replace( header: HeaderGeneratorType , with animation: UITableView . RowAnimation ) {
158196 guard let indexOfHeader = self . sections. firstIndex ( where: { $0 === header } ) else {
159197 self . addSectionHeaderGenerator ( header)
160198 return
@@ -164,13 +202,14 @@ open class GravityTableManager: BaseTableManager {
164202 modifier? . reloadSections ( at: [ indexOfHeader] , with: animation)
165203 }
166204
205+ @available ( * , deprecated, message: " Please use method with a new `TableRowAnimation` parameter " )
167206 open func remove( _ generator: CellGeneratorType ,
168- with animation: UITableView . RowAnimation = . automatic ,
207+ with animation: UITableView . RowAnimation ,
169208 needScrollAt scrollPosition: UITableView . ScrollPosition ? = nil ,
170209 needRemoveEmptySection: Bool = false ) {
171210 guard let index = self . findGenerator ( generator) else { return }
172211 self . removeGenerator ( with: index,
173- with: animation,
212+ with: . animated ( animation) ,
174213 needScrollAt: scrollPosition,
175214 needRemoveEmptySection: needRemoveEmptySection)
176215 }
0 commit comments