Replace battery bar with low-battery icon

Remove the full-width bottom bar. Instead draw a small battery icon in the
bottom-right corner only when charge drops below 20%.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-23 17:32:31 +02:00
parent 92dfcfabcd
commit ebca07666e
+13 -6
View File
@@ -46,14 +46,21 @@ static void bar_draw(Layer *layer, GContext *ctx) {
static void battery_draw(Layer *layer, GContext *ctx) {
GRect bounds = layer_get_bounds(layer);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_fill_rect(ctx, bounds, 0, GCornerNone);
int fill_w = (s_battery_level * bounds.size.w) / 100;
if (s_battery_level >= 20) return;
// Body outline
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_draw_rect(ctx, GRect(0, 1, 19, 10));
// Terminal nub
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_fill_rect(ctx, GRect(19, 4, 3, 4), 0, GCornerNone);
// Charge fill
int fill_w = (s_battery_level * 15) / 100;
if (fill_w > 0) {
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_fill_rect(ctx, GRect(0, 0, fill_w, bounds.size.h), 0, GCornerNone);
graphics_fill_rect(ctx, GRect(2, 3, fill_w, 6), 0, GCornerNone);
}
}
@@ -115,8 +122,8 @@ static void main_window_load(Window *window) {
text_layer_set_text(s_date_layer, "01/01");
layer_add_child(root, text_layer_get_layer(s_date_layer));
// Battery — thin strip at the very bottom
s_battery_layer = layer_create(GRect(0, bounds.size.h - 4, bounds.size.w, 4));
// Battery icon — bottom right, only visible below 20%
s_battery_layer = layer_create(GRect(bounds.size.w - 26, bounds.size.h - 16, 23, 12));
layer_set_update_proc(s_battery_layer, battery_draw);
layer_add_child(root, s_battery_layer);
}