Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Settings] BT Pair footer flashes #2081 #2105

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading