[settings] Bug fix in code options controller

This commit is contained in:
Laury
2021-10-27 19:29:09 +02:00
parent c4ed8f84d3
commit f6e937a927
2 changed files with 9 additions and 11 deletions

View File

@@ -10,12 +10,8 @@ CodeOptionsController::CodeOptionsController(Responder * parentResponder) :
GenericSubController(parentResponder),
m_preferencesController(this)
{
for (int i = 0; i < k_totalNumberOfCell; i++) {
m_cells[i].setMessageFont(KDFont::LargeFont);
}
for (int i = 0; i < k_totalNumberOfSwitchCells; i++) {
m_switchCells[i].setMessageFont(KDFont::LargeFont);
}
m_chevronCell.setMessageFont(KDFont::LargeFont);
m_switchCell.setMessageFont(KDFont::LargeFont);
}
bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
@@ -44,7 +40,10 @@ bool CodeOptionsController::handleEvent(Ion::Events::Event event) {
HighlightCell * CodeOptionsController::reusableCell(int index, int type) {
assert(type == 0);
assert(index >= 0 && index < k_totalNumberOfCell);
return &m_cells[index];
if (index == 0) {
return &m_chevronCell;
}
return &m_switchCell;
}
int CodeOptionsController::reusableCellCount(int type) {

View File

@@ -14,11 +14,10 @@ public:
int reusableCellCount(int type) override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
private:
constexpr static int k_totalNumberOfCell = 1;
constexpr static int k_totalNumberOfSwitchCells = 1;
constexpr static int k_totalNumberOfCell = 2;
PreferencesController m_preferencesController;
MessageTableCellWithChevronAndMessage m_cells[k_totalNumberOfCell];
MessageTableCellWithSwitch m_switchCells[k_totalNumberOfCell];
MessageTableCellWithChevronAndMessage m_chevronCell;
MessageTableCellWithSwitch m_switchCell;
};
}