#region Includes
using UnityEngine;
using UnityEngine.Events;
#endregion
///
/// This class represents a view or page within a paginated view system.
/// It provides events to signal changes in the active state of the page.
///
public class PageView : MonoBehaviour
{
#region Variables
[Header("Events")]
///
/// UnityEvent that is invoked when the page is about to transition to the active state.
///
[Tooltip("Invoked when the page is about to transition to the active state")]
public UnityEvent OnChangingToActiveState;
///
/// UnityEvent that is invoked when the page is about to transition to the inactive state.
///
[Tooltip("Invoked when the page is about to transition to the inactive state")]
public UnityEvent OnChangingToInactiveState;
///
/// UnityEvent with a boolean parameter that is invoked when the active state of the page changes.
/// The parameter is True if the page becomes active, False if it becomes inactive.
///
[Tooltip("Invoked when the active state of the page changes: True when active and False when inactive")]
public UnityEvent OnActiveStateChanged;
#endregion
///
/// Invokes the OnChangingToActiveState event to signal that the page is about to become active.
///
public void ChangingToActiveState()
{
OnChangingToActiveState?.Invoke();
}
///
/// Invokes the OnChangingToInactiveState event to signal that the page is about to become inactive.
///
public void ChangingToInactiveState()
{
OnChangingToInactiveState?.Invoke();
}
///
/// Invokes the OnActiveStateChanged event with the provided active state.
///
/// True to signal the page becoming active, False for inactive.
public void ChangeActiveState(bool active)
{
OnActiveStateChanged?.Invoke(active);
}
}