Skip to content

Commit

Permalink
Adicionando interface para navigationService
Browse files Browse the repository at this point in the history
  • Loading branch information
ozielguimaraes committed Aug 24, 2024
1 parent 6b6c590 commit e57d1b4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 18 deletions.
53 changes: 36 additions & 17 deletions EscolaBiblicaDominical/Ebd.Mobile/Ebd.MobileApp/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,50 @@
using Ebd.Mobile.Views;
using Ebd.Mobile.Views.Aluno;
using Ebd.Mobile.Views.Chamada;
using Ebd.MobileApp.Services.Navigation;
using Ebd.MobileApp.Views.Perfil;

namespace Ebd.Mobile
namespace Ebd.MobileApp;

public partial class AppShell : Shell
{
public partial class AppShell : Shell
private readonly INavigationService _navigationService;

public AppShell(INavigationService navigationService)
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(ItemDetailPage), typeof(ItemDetailPage));
Routing.RegisterRoute(nameof(NewItemPage), typeof(NewItemPage));
Routing.RegisterRoute(nameof(HomePage), typeof(HomePage));
Routing.RegisterRoute(nameof(EfetuarChamadaPage), typeof(EfetuarChamadaPage));
_navigationService = navigationService;
InitializeRouting();

Routing.RegisterRoute(PageConstant.Aluno.Novo, typeof(NovoAlunoPage));
Routing.RegisterRoute(PageConstant.Aluno.Lista, typeof(ListaAlunoPage));
Routing.RegisterRoute(PageConstant.Aluno.ResponsavelAluno.Adicionar, typeof(AdicionarResponsavelPage));
InitializeComponent();
}

Routing.RegisterRoute(PageConstant.Perfil.Detalhes, typeof(PerfilPage));
}
private static void InitializeRouting()
{
Routing.RegisterRoute(nameof(ItemDetailPage), typeof(ItemDetailPage));
Routing.RegisterRoute(nameof(NewItemPage), typeof(NewItemPage));
Routing.RegisterRoute(nameof(HomePage), typeof(HomePage));
Routing.RegisterRoute(nameof(EfetuarChamadaPage), typeof(EfetuarChamadaPage));

Routing.RegisterRoute(PageConstant.Aluno.Novo, typeof(NovoAlunoPage));
Routing.RegisterRoute(PageConstant.Aluno.Lista, typeof(ListaAlunoPage));
Routing.RegisterRoute(PageConstant.Aluno.ResponsavelAluno.Adicionar, typeof(AdicionarResponsavelPage));

private async void OnMenuItemClicked(object sender, EventArgs e)
Routing.RegisterRoute(PageConstant.Perfil.Detalhes, typeof(PerfilPage));
}

protected override async void OnHandlerChanged()
{
base.OnHandlerChanged();

if (Handler is not null)
{
Shell.Current.FlyoutIsPresented = false;
await Shell.Current.GoToAsync("//LoginPage");
await _navigationService.InitializeAsync();
}
}

private async void OnMenuItemClicked(object sender, EventArgs e)
{
Shell.Current.FlyoutIsPresented = false;
await Shell.Current.GoToAsync("//LoginPage");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Ebd.MobileApp.Services.Implementations.Analytics;
using Ebd.MobileApp.Services.Implementations.BottomSheets;
using Ebd.MobileApp.Services.Interfaces.BottomSheets;
using Ebd.MobileApp.Services.Navigation;
using Ebd.MobileApp.ViewModels.Home;
using Ebd.MobileApp.ViewModels.Perfil;
using Ebd.MobileApp.ViewModels.Turma;
Expand Down Expand Up @@ -65,6 +66,7 @@ public static IServiceCollection ConfigureServices(this IServiceCollection servi
services.AddSingleton<IAnalyticsService, AnalyticsService>();
services.AddSingleton<IDialogService, DialogService>();
services.AddSingleton<INetworkService, NetworkService>();
services.AddSingleton<INavigationService, NavigationService>();
services.AddSingleton(Connectivity.Current);

services.AddSingleton<IAlunoService, AlunoService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Ebd.MobileApp.ViewModels;

namespace Ebd.MobileApp.Services.Navigation;

public interface INavigationService
{
Task Navigate<TViewModel>(object? parameter = null, bool animated = true)
where TViewModel : BasePageViewModel;

void Initialize(object? parameters = null);
Task InitializeAsync();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Ebd.MobileApp.Services.Navigation;

internal sealed class NavigationService
internal sealed class NavigationService : INavigationService
{
static readonly Lazy<NavigationService> _Lazy = new(() => new());

Expand Down Expand Up @@ -119,4 +119,9 @@ private Page CreateAndBindPage(Type viewModelType)

return page;
}

public async Task InitializeAsync()
{
await Task.CompletedTask;
}
}

0 comments on commit e57d1b4

Please sign in to comment.