75 lines
2.9 KiB
C#
75 lines
2.9 KiB
C#
using FrontendPlatformUno.Views;
|
|
using FrontendPlatformUno.ViewModels;
|
|
using FrontendPlatformUno.Services.Api;
|
|
|
|
namespace FrontendPlatformUno
|
|
{
|
|
public class App : Application
|
|
{
|
|
private static Window? _window;
|
|
public static IHost? Host { get; private set; }
|
|
|
|
protected async override void OnLaunched(LaunchActivatedEventArgs args)
|
|
{
|
|
var builder = this.CreateBuilder(args)
|
|
|
|
// Add navigation support for toolkit controls such as TabBar and NavigationView
|
|
.UseToolkitNavigation()
|
|
.Configure(host => host
|
|
#if DEBUG
|
|
// Switch to Development environment when running in DEBUG
|
|
.UseEnvironment(Environments.Development)
|
|
#endif
|
|
.UseLogging(configure: (context, logBuilder) =>
|
|
{
|
|
// Configure log levels for different categories of logging
|
|
logBuilder.SetMinimumLevel(
|
|
context.HostingEnvironment.IsDevelopment() ?
|
|
LogLevel.Information :
|
|
LogLevel.Warning);
|
|
}, enableUnoLogging: true)
|
|
.UseConfiguration(configure: configBuilder =>
|
|
configBuilder
|
|
.EmbeddedSource<App>()
|
|
.Section<AppConfig>()
|
|
)
|
|
// Enable localization (see appsettings.json for supported languages)
|
|
.UseLocalization()
|
|
.ConfigureServices((context, services) =>
|
|
{
|
|
// TODO: Register your services
|
|
//services.AddSingleton<IMyService, MyService>();
|
|
services.AddSingleton<IDefaultApi>(_ => new DefaultApi("http://localhost:8080"));
|
|
})
|
|
.UseNavigation(RegisterRoutes)
|
|
);
|
|
_window = builder.Window;
|
|
|
|
UnhandledException += (sender, e) =>
|
|
{
|
|
Console.WriteLine(e.ToString());
|
|
};
|
|
|
|
Host = await builder.NavigateAsync<Shell>();
|
|
}
|
|
|
|
private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
|
|
{
|
|
views.Register(
|
|
new ViewMap(ViewModel: typeof(ShellViewModel)),
|
|
new ViewMap<GamenightsPage, GamenightsViewModel>(),
|
|
new ViewMap<LoginPage, LoginViewModel>()
|
|
);
|
|
|
|
routes.Register(
|
|
new RouteMap("", View: views.FindByViewModel<ShellViewModel>(),
|
|
Nested: new RouteMap[]
|
|
{
|
|
new RouteMap("Gamenights", View: views.FindByViewModel<GamenightsViewModel>()),
|
|
new RouteMap("Login", View: views.FindByViewModel<LoginViewModel>()),
|
|
}
|
|
)
|
|
);
|
|
}
|
|
}
|
|
} |