Skip to content

Commit 15156bd

Browse files
committed
make forwarded new methods in deprecated calls
1 parent 23673d4 commit 15156bd

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

Source/Table/Manager/ManualTableManager.swift

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ public class ManualTableManager: BaseTableManager {
336336
new sectionHeader: TableHeaderGenerator,
337337
generators: [TableCellGenerator],
338338
with animation: UITableView.RowAnimation) {
339-
340339
self.insertSection(after: headerGenerator,
341340
new: sectionHeader,
342341
generators: generators,
@@ -354,78 +353,52 @@ public class ManualTableManager: BaseTableManager {
354353
open func insert(before generator: TableCellGenerator,
355354
new newGenerators: [TableCellGenerator],
356355
with animation: UITableView.RowAnimation) {
357-
guard let index = self.findGenerator(generator) else { return }
358-
let elements = newGenerators.enumerated().map { item in
359-
(item.element, index.sectionIndex, index.generatorIndex + item.offset)
360-
}
361-
self.insert(elements: elements, with: .animated(animation))
356+
self.insert(before: generator, new: newGenerators, with: .animated(animation))
362357
}
363358

364359
@available(*, deprecated, message: "Please use method with a new `TableRowAnimation` parameter")
365360
open func insert(after generator: TableCellGenerator,
366361
new newGenerator: TableCellGenerator,
367362
with animation: UITableView.RowAnimation) {
368-
guard let index = self.findGenerator(generator) else { return }
369-
self.insert(elements: [(newGenerator, index.sectionIndex, index.generatorIndex + 1)], with: .animated(animation))
363+
self.insert(after: generator, new: [newGenerator], with: .animated(animation))
370364
}
371365

372366
@available(*, deprecated, message: "Please use method with a new `TableRowAnimation` parameter")
373367
open func insert(before generator: TableCellGenerator,
374368
new newGenerator: TableCellGenerator,
375369
with animation: UITableView.RowAnimation) {
376-
guard let index = self.findGenerator(generator) else { return }
377-
self.insert(elements: [(newGenerator, index.sectionIndex, index.generatorIndex)], with: .animated(animation))
370+
self.insert(before: generator, new: [newGenerator], with: .animated(animation))
378371
}
379372

380373
@available(*, deprecated, message: "Please use method with a new `TableRowAnimation` parameter")
381374
open func insert(to headerGenerator: TableHeaderGenerator,
382375
new generator: TableCellGenerator,
383376
with animation: UITableView.RowAnimation) {
384-
guard let headerIndex = self.sections.firstIndex(where: { $0 === headerGenerator }) else {
385-
return
386-
}
387-
self.insert(elements: [(generator, headerIndex, 0)], with: .animated(animation))
377+
self.insert(to: headerGenerator, new: generator, with: .animated(animation))
388378
}
389379

390380
@available(*, deprecated, message: "Please use method with a new `TableRowAnimation` parameter")
391381
open func insertAtBeginning(to headerGenerator: TableHeaderGenerator,
392382
new generators: [TableCellGenerator],
393383
with animation: UITableView.RowAnimation) {
394-
guard let headerIndex = self.sections.firstIndex(where: { $0 === headerGenerator }) else {
395-
return
396-
}
397-
let elements = generators.enumerated().map { item in
398-
(item.element, headerIndex, item.offset)
399-
}
400-
self.insert(elements: elements, with: .animated(animation))
384+
self.insertAtBeginning(to: headerGenerator, new: generators, with: .animated(animation))
401385
}
402386

403387
@available(*, deprecated, message: "Please use method with a new `TableRowAnimation` parameter")
404388
open func insertAtEnd(to headerGenerator: TableHeaderGenerator,
405389
new generators: [TableCellGenerator],
406390
with animation: UITableView.RowAnimation) {
407-
guard let headerIndex = self.sections.firstIndex(where: { $0 === headerGenerator }) else {
408-
return
409-
}
410-
let base = self.generators[headerIndex].count
411-
let elements = generators.enumerated().map { item in
412-
(item.element, headerIndex, base + item.offset)
413-
}
414-
self.insert(elements: elements, with: .animated(animation))
391+
self.insertAtEnd(to: headerGenerator, new: generators, with: .animated(animation))
415392
}
416393

417394
@available(*, deprecated, message: "Please use method with a new `TableRowAnimationGroup` parameter")
418395
open func replace(oldGenerator: TableCellGenerator,
419396
on newGenerator: TableCellGenerator,
420397
removeAnimation: UITableView.RowAnimation,
421398
insertAnimation: UITableView.RowAnimation) {
422-
guard let index = self.findGenerator(oldGenerator) else { return }
423-
424-
generators[index.sectionIndex].remove(at: index.generatorIndex)
425-
generators[index.sectionIndex].insert(newGenerator, at: index.generatorIndex)
426-
let indexPath = IndexPath(row: index.generatorIndex, section: index.sectionIndex)
427-
428-
modifier?.replace(at: indexPath, with: (remove: removeAnimation, insert: insertAnimation))
399+
self.replace(oldGenerator: oldGenerator,
400+
on: newGenerator,
401+
removeInsertAnimation: .animated(removeAnimation, insertAnimation))
429402
}
430403

431404
}

0 commit comments

Comments
 (0)