using GMCabsDriverAssistantSolution.ViewModels;

namespace GMCabsDriverAssistantSolution.Views;

public partial class ImeiNumberInstallPage : ContentPage
{
    #region Fields
    private readonly ImeiNumberInstallViewModel _viewModel;
    #endregion

    #region Constructor
    public ImeiNumberInstallPage()
    {
        InitializeComponent();
        BindingContext = _viewModel = new ImeiNumberInstallViewModel();
    }
    #endregion

    #region System Events
    private void EntryTextChanged(object sender, TextChangedEventArgs e)
    {
        _viewModel.GetImeiDetails(e.NewTextValue);
    }

    private void CompleteImeiInstallation_Clicked(object sender, EventArgs e)
    {
        _viewModel.CompleteInstallation();
        (App.Current as App).MainPage = new AppShell();
    }
    #endregion

    private void ClearImeiButton_Clicked(object sender, EventArgs e)
    {
        Preferences.Set("imeiNumber", null);
        _viewModel.InstalledImeiExists = false;
        _viewModel.InstalledImei = "NOT INSTALLED";
        (App.Current as App).MainPage = new AppShell();
    }
}