extends Control const Brand := preload("res://scripts/ui/medmind_style.gd") var days: Array = [] var dark := true func set_days(next_days: Array, dark_mode: bool) -> void: days = next_days.duplicate(true) dark = dark_mode queue_redraw() func _draw() -> void: if days.is_empty(): return var bottom := size.y - 24.0 var top := 20.0 var slot: float = size.x / float(days.size()) var maximum := 1 for day in days: maximum = maxi(maximum, int(day.get("studyTimeSeconds", 0))) for index in range(days.size()): var day: Dictionary = days[index] var seconds := int(day.get("studyTimeSeconds", 0)) var bar_height: float = (bottom - top) * float(seconds) / float(maximum) var width: float = minf(30.0, slot * 0.48) var rect := Rect2(index * slot + (slot - width) * 0.5, bottom - bar_height, width, maxf(2.0, bar_height)) draw_rect(rect, Brand.ROYAL_BLUE, true) var label := _weekday(str(day.get("dateUtc", ""))) draw_string(Brand.font, Vector2(index * slot, size.y - 5), label, HORIZONTAL_ALIGNMENT_CENTER, slot, 11, Brand.muted_color(dark)) func _weekday(iso_date: String) -> String: if iso_date.length() < 10: return "" var unix := Time.get_unix_time_from_datetime_string(iso_date.left(10) + "T00:00:00") var date := Time.get_date_dict_from_unix_time(unix) return ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][int(date.get("weekday", 0))]