45 lines
1.8 KiB
GDScript
45 lines
1.8 KiB
GDScript
class_name LegalDocumentBuilder
|
|
extends RefCounted
|
|
|
|
const Brand := preload("res://scripts/ui/medmind_style.gd")
|
|
|
|
|
|
static func populate(container: VBoxContainer, document: Dictionary) -> void:
|
|
for child in container.get_children():
|
|
child.queue_free()
|
|
var title := Label.new()
|
|
title.text = str(document.get("title", "Legal document"))
|
|
title.add_theme_font_override("font", Brand.font)
|
|
title.add_theme_font_size_override("font_size", 30)
|
|
container.add_child(title)
|
|
var metadata := Label.new()
|
|
metadata.text = "Effective %s | Version %s" % [document.get("effectiveDate", ""), document.get("version", "")]
|
|
metadata.add_theme_font_override("font", Brand.font)
|
|
metadata.add_theme_font_size_override("font_size", 14)
|
|
metadata.add_theme_color_override("font_color", Brand.muted_color(UIThemeService.is_dark_mode()))
|
|
container.add_child(metadata)
|
|
var summary := _paragraph(str(document.get("summary", "")))
|
|
container.add_child(summary)
|
|
for section_value in document.get("sections", []):
|
|
if typeof(section_value) != TYPE_DICTIONARY:
|
|
continue
|
|
var section: Dictionary = section_value
|
|
var heading := Label.new()
|
|
heading.text = str(section.get("heading", ""))
|
|
heading.add_theme_font_override("font", Brand.font)
|
|
heading.add_theme_font_size_override("font_size", 20)
|
|
container.add_child(heading)
|
|
for paragraph_value in section.get("paragraphs", []):
|
|
container.add_child(_paragraph(str(paragraph_value)))
|
|
|
|
|
|
static func _paragraph(value: String) -> Label:
|
|
var label := Label.new()
|
|
label.text = value
|
|
label.add_theme_font_override("font", Brand.font)
|
|
label.add_theme_font_size_override("font_size", 16)
|
|
label.add_theme_color_override("font_color", Brand.muted_color(UIThemeService.is_dark_mode()))
|
|
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
label.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
|
return label
|