using System;
using Billing.Themes;
using Xamarin.Forms;

namespace Billing.UI
{
    public abstract class BillingPage : ContentPage
    {
        public event EventHandler Loaded;

        private bool loaded;

        public BillingPage()
        {
            SetDynamicResource(BackgroundColorProperty, BaseTheme.WindowBackgroundColor);
            Shell.SetTabBarIsVisible(this, false);
        }

        public virtual void OnLoaded()
        {
            Loaded?.Invoke(this, EventArgs.Empty);
        }

        public void TriggerLoad()
        {
            if (!loaded)
            {
                loaded = true;
                OnLoaded();
            }
        }
    }
}