using Billing.UI;
using System;
using Xamarin.Forms;

namespace Billing.Views
{
    public partial class BillPage : BillingPage
    {
        private static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(nameof(SelectedDate), typeof(DateTime), typeof(BillPage));

        public DateTime SelectedDate
        {
            get => (DateTime)GetValue(SelectedDateProperty);
            set => SetValue(SelectedDateProperty, value);
        }

        public Command AddBilling { get; }

        public BillPage()
        {
            AddBilling = new Command(OnAddBilling);

            InitializeComponent();

            billingDate.SetDateTime(DateTime.Now);
        }

        private void OnDateSelected(object sender, DateEventArgs e)
        {
            SelectedDate = e.Date;

            // TODO: while selecting date
        }

        private void OnTitleDateLongPressed(object sender, EventArgs e)
        {
            billingDate.SetDateTime(DateTime.Now);
        }

        private async void OnAddBilling()
        {
            await Navigation.PushAsync(new AddBillPage());
        }
    }
}