using LSFE.MobApp.Pages.Authentication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LSFE.MobApp.Services
{
    public interface INavigationService
    {
        Task NavigateToMainPageAsync();
        Task NavigateToForgotPasswordAsync();
        Task NavigateToLoginPageAsync();
        Task<bool> NavigateBackAsync();
    }

    public class NavigationService : INavigationService
    {
        public async Task NavigateToMainPageAsync()
        {
            // Navigate to main tabs after successful login
            await Shell.Current.GoToAsync("//DoctorsPage");
        }

        public async Task NavigateToForgotPasswordAsync()
        {
            await Shell.Current.GoToAsync(nameof(ForgotPasswordPage));
        }

        public async Task NavigateToLoginPageAsync()
        {
            // Clear secure storage
            SecureStorage.RemoveAll();

            // Navigate back to login
            await Shell.Current.GoToAsync("//LoginPage");
        }

        public async Task<bool> NavigateBackAsync()
        {
            if (Shell.Current.Navigation.NavigationStack.Count > 1)
            {
                await Shell.Current.GoToAsync("..");
                return true;
            }
            return false;
        }
    }
}
