Skip to content

Commit 47cd569

Browse files
committed
refactor(ui): use theme paddings for dialog spacing
1 parent 58a2d8d commit 47cd569

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

main/ui/dialog.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ void dialog_show_error_timeout(const char *message,
196196
lv_obj_center(ctx->modal);
197197
theme_apply_frame(ctx->modal);
198198

199+
int32_t gap = theme_get_small_padding();
200+
199201
lv_obj_t *title = theme_create_label(ctx->modal, "Error", false);
200202
theme_apply_label(title, true);
201-
lv_obj_align(title, LV_ALIGN_TOP_MID, 0, 10);
203+
lv_obj_align(title, LV_ALIGN_TOP_MID, 0, gap);
202204

203205
lv_obj_t *error = theme_create_label(ctx->modal, message, false);
204206
theme_apply_label(error, false);
@@ -210,7 +212,7 @@ void dialog_show_error_timeout(const char *message,
210212

211213
lv_obj_t *hint = theme_create_label(ctx->modal, "Returning...", false);
212214
theme_apply_label(hint, false);
213-
lv_obj_align(hint, LV_ALIGN_BOTTOM_MID, 0, -10);
215+
lv_obj_align(hint, LV_ALIGN_BOTTOM_MID, 0, -gap);
214216

215217
lv_timer_t *timer = lv_timer_create(error_timer_cb, timeout_ms, ctx);
216218
lv_timer_set_repeat_count(timer, 1);
@@ -248,15 +250,16 @@ static void show_confirm_internal(const char *message,
248250
if (danger && style == DIALOG_STYLE_OVERLAY)
249251
lv_obj_set_style_border_color(dialog, error_color(), 0);
250252

251-
int32_t msg_y = 10;
253+
int32_t gap = theme_get_small_padding();
254+
int32_t msg_y = gap;
252255
if (danger) {
253256
lv_obj_t *icon = lv_label_create(dialog);
254257
lv_obj_set_style_text_font(icon, theme_font_medium(), 0);
255258
lv_obj_set_style_text_color(icon, error_color(), 0);
256259
lv_label_set_text(icon, LV_SYMBOL_WARNING);
257260
lv_obj_align(icon, LV_ALIGN_TOP_MID, 0, 0);
258261
lv_obj_update_layout(icon);
259-
msg_y = lv_obj_get_height(icon) + 6;
262+
msg_y = lv_obj_get_height(icon) + gap;
260263
}
261264

262265
lv_obj_t *msg_label = make_message_label(dialog, message, 90);
@@ -269,7 +272,8 @@ static void show_confirm_internal(const char *message,
269272
danger ? no_color() : yes_color(), confirm_yes_cb, ctx);
270273

271274
dialog_fit_overlay(dialog, style, message,
272-
msg_y + theme_get_button_height() + 20);
275+
msg_y + theme_get_button_height() +
276+
theme_get_button_spacing());
273277
}
274278

275279
void dialog_show_confirm(const char *message,
@@ -289,13 +293,14 @@ lv_obj_t *dialog_show_progress(const char *title, const char *message,
289293
lv_obj_t *root;
290294
lv_obj_t *dialog = create_dialog_container(style, &root);
291295

292-
int32_t msg_y = title ? add_dialog_title(dialog, title) + 10 : 5;
296+
int32_t gap = theme_get_small_padding();
297+
int32_t msg_y = title ? add_dialog_title(dialog, title) + gap : gap / 2;
293298

294299
if (message)
295300
lv_obj_align(make_message_label(dialog, message, 90), LV_ALIGN_TOP_MID, 0,
296301
msg_y);
297302

298-
dialog_fit_overlay(dialog, style, message ? message : "", msg_y + 5);
303+
dialog_fit_overlay(dialog, style, message ? message : "", msg_y + gap / 2);
299304

300305
return root;
301306
}

0 commit comments

Comments
 (0)