using WorkFlowCheck.MAUI.Services.Interfaces;

namespace WorkFlowCheck.MAUI.Pages.System;

public partial class SyncPage : ContentPage
{
    private ISyncService _syncService;
    public SyncPage()
    {
        InitializeComponent();
        _syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
    }

    private async void OnSyncClicked(object sender, EventArgs e)
    {
        LoadingIndicator.IsRunning = true;
        LoadingIndicator.IsVisible = true;
        try
        {
            await _syncService.SyncDatas();
        }
        catch (Exception)
        {

            throw;
        }
        LoadingIndicator.IsVisible = false;
        LoadingIndicator.IsRunning = false;
        
    }


    protected override bool OnBackButtonPressed()
    {
        Shell.Current.GoToAsync("//MainPage");
        return true;
    }
}