boronotes/pages/note_page/note_page.gd

39 lines
880 B
GDScript

class_name NotePage
extends PanelContainer
signal edit_pressed()
signal back_pressed()
signal note_pressed(note: Note)
const NOTE_ITEM = preload("res://components/note_item/note_item.tscn")
@onready var back_button: Button = %BackButton
@onready var page_title: Label = %PageTitle
@onready var notes_container: VBoxContainer = %NotesContainer
func display(title: String, notes: Array[Note]) -> void:
page_title.text = title
for child in notes_container.get_children():
notes_container.remove_child(child)
for note in notes:
var note_item = NOTE_ITEM.instantiate()
note_item.note = note
notes_container.add_child(note_item)
note_item.pressed.connect(_on_note_item_pressed)
func _on_note_item_pressed(note: Note) -> void:
note_pressed.emit(note)
func _on_back_button_pressed():
back_pressed.emit()
func _on_edit_button_pressed():
edit_pressed.emit()