Skip to content

Commit

Permalink
fix: [Settings] BT Pair footer flashes #2081 (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
priyonto authored Aug 1, 2024
1 parent 5033730 commit 878fabe
Showing 1 changed file with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,8 @@ extension TagSettingsViewController {
tableView.reloadSections(section, with: .fade)
}

// swiftlint:disable:next function_body_length
private func reloadSection(identifier: TagSettingsSectionIdentifier) {
switch identifier {
case .btPair:
let section = configureBluetoothSection()
updateSection(
with: identifier,
newSection: section
)
case .offsetCorrection:
if showOffsetCorrection() {
let section = configureOffsetCorrectionSection()
Expand Down Expand Up @@ -601,6 +594,25 @@ extension TagSettingsViewController {
}, completion: nil)
UIView.setAnimationsEnabled(true)
}
case .btPair:
if let currentSection = tableViewSections.first(where: {
$0.identifier == section
}) {
let btPairItem = tagPairSettingItem()
let sectionIndex = indexOfSection(section: section)
let indexPath = IndexPath(row: 0, section: sectionIndex)

UIView.setAnimationsEnabled(false)
tableView.performBatchUpdates({
if currentSection.cells.count > 0 {
currentSection.cells.remove(at: 0)
currentSection.cells.insert(btPairItem, at: 0)
tableView.deleteRows(at: [indexPath], with: .none)
tableView.insertRows(at: [indexPath], with: .none)
}
}, completion: nil)
UIView.setAnimationsEnabled(true)
}
default:
break
}
Expand Down Expand Up @@ -872,7 +884,7 @@ extension TagSettingsViewController: TagSettingsSwitchCellDelegate {
cell.configure(title: self?.unpairedString)
cell.configurePairingAnimation(start: false)
}
self?.reloadSection(identifier: .btPair)
self?.reloadCellsFor(section: .btPair)
}

let isConnected = viewModel.isConnected
Expand All @@ -893,7 +905,7 @@ extension TagSettingsViewController: TagSettingsSwitchCellDelegate {
cell.configure(title: self?.unpairedString)
cell.configurePairingAnimation(start: false)
}
self?.reloadSection(identifier: .btPair)
self?.reloadCellsFor(section: .btPair)
}
}
}
Expand Down

0 comments on commit 878fabe

Please sign in to comment.