@tool
extends Main
class_name MainMobile

@onready var _reservation_repo : AbstractReservationRepo = $Repos/Reservation

@export var current_page : Pages:
	set(value):
		current_page = value
		load_page(value, false)

@onready var _pages := {
	Pages.Board: $Pages/Board,
	Pages.ReservationCreation: $Pages/ReservationCreation,
	Pages.TimeSetting: $Pages/TimeSetting
}

var _current_page := Pages.Board
var _previous_page : Pages

func get_current_page():
	return _current_page

func load_page(value, with_update=true):
	_pages[_current_page].visible = false

	if _previous_page != _current_page:
		_previous_page = _current_page

	_current_page = value
	if with_update:
		_pages[_current_page].update()
	_pages[_current_page].visible = true

	return _pages[_current_page]

func go_to_previous_page(with_update=true):
	if _previous_page != null:
		load_page(_previous_page, with_update)

func get_reservation_repo() -> AbstractReservationRepo:
	return _reservation_repo
