using GMCabsDriverAssistantSolution.ViewModels;

namespace GMCabsDriverAssistantSolution.Views;

public partial class BookingsPage : ContentPage
{
    #region Fields
    private readonly BookingsViewModel _viewModel;
    #endregion

    #region Properties

    #endregion

    #region Constructor
    public BookingsPage(double? lat, double? lng)
    {
        InitializeComponent();
        BindingContext = _viewModel = new BookingsViewModel();
        if (lat == null)
        {
            var currentLocation = Geolocation.GetLastKnownLocationAsync();
            lat = currentLocation.Result.Latitude;
            lng = currentLocation.Result.Longitude;
        }
        _viewModel.CurrentLat = lat.Value;
        _viewModel.CurrentLng = lng.Value;
    }
    #endregion

    #region Methods
    protected override void OnAppearing()
    {
        base.OnAppearing();
        _viewModel.OnAppearing();
    }
    private async void OnBookingViewClicked(object sender, EventArgs e)
    {
        await Navigation.PushAsync(new BookingDetailsPage(), true);
    }
    #endregion
}