| 151 | } |
| 152 | |
| 153 | void View::updatePeerList() { |
| 154 | lv_obj_clean(peers_list); |
| 155 | |
| 156 | // Enable on boot row |
| 157 | auto* enable_on_boot_wrapper = lv_obj_create(peers_list); |
| 158 | lv_obj_set_size(enable_on_boot_wrapper, LV_PCT(100), LV_SIZE_CONTENT); |
| 159 | lv_obj_set_style_pad_all(enable_on_boot_wrapper, 0, LV_STATE_DEFAULT); |
| 160 | lv_obj_set_style_border_width(enable_on_boot_wrapper, 0, LV_STATE_DEFAULT); |
| 161 | |
| 162 | auto* enable_label = lv_label_create(enable_on_boot_wrapper); |
| 163 | lv_label_set_text(enable_label, "Enable on boot"); |
| 164 | lv_obj_align(enable_label, LV_ALIGN_LEFT_MID, 0, 0); |
| 165 | |
| 166 | enable_on_boot_switch = lv_switch_create(enable_on_boot_wrapper); |
| 167 | lv_obj_align(enable_on_boot_switch, LV_ALIGN_RIGHT_MID, 0, 0); |
| 168 | lv_obj_add_event_cb(enable_on_boot_switch, onEnableOnBootSwitchChanged, LV_EVENT_VALUE_CHANGED, nullptr); |
| 169 | lv_obj_add_event_cb(enable_on_boot_wrapper, onEnableOnBootParentClicked, LV_EVENT_SHORT_CLICKED, enable_on_boot_switch); |
| 170 | |
| 171 | if (lvgl_get_ui_density() == LVGL_UI_DENSITY_COMPACT) { |
| 172 | lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 2, LV_STATE_DEFAULT); |
| 173 | } else { |
| 174 | lv_obj_set_style_pad_ver(enable_on_boot_wrapper, 8, LV_STATE_DEFAULT); |
| 175 | } |
| 176 | |
| 177 | updateEnableOnBootToggle(); |
| 178 | |
| 179 | using enum bluetooth::RadioState; |
| 180 | if (state->getRadioState() == On) { |
| 181 | // Paired peers section |
| 182 | auto paired = state->getPairedPeers(); |
| 183 | if (!paired.empty()) { |
| 184 | lv_list_add_text(peers_list, "Paired"); |
| 185 | for (size_t i = 0; i < paired.size(); ++i) { |
| 186 | createPeerListItem(paired[i], true, i); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | // Scan results section |
| 191 | auto scan_results = state->getScanResults(); |
| 192 | lv_list_add_text(peers_list, "Available"); |
| 193 | if (!scan_results.empty()) { |
| 194 | for (size_t i = 0; i < scan_results.size(); ++i) { |
| 195 | createPeerListItem(scan_results[i], false, i); |
| 196 | } |
| 197 | } else if (!state->isScanning()) { |
| 198 | auto* no_devices_label = lv_label_create(peers_list); |
| 199 | lv_label_set_text(no_devices_label, "No devices found."); |
| 200 | } |
| 201 | // Never hide peers_list: it always contains the "Enable on boot" row. |
| 202 | // While scanning with no results the spinner in the toolbar provides feedback. |
| 203 | |
| 204 | // Scan button |
| 205 | auto* scan_button = lv_button_create(peers_list); |
| 206 | lv_obj_set_width(scan_button, LV_PCT(100)); |
| 207 | lv_obj_set_style_margin_ver(scan_button, 4, LV_STATE_DEFAULT); |
| 208 | auto* scan_label = lv_label_create(scan_button); |
| 209 | lv_label_set_text(scan_label, state->isScanning() ? "Stop scan" : "Scan"); |
| 210 | lv_obj_add_event_cb(scan_button, onScanButtonClicked, LV_EVENT_SHORT_CLICKED, nullptr); |
nothing calls this directly
no test coverage detected