Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
6002_SihamFiqow/MauiProgram.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
86 lines (68 sloc)
2.84 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Logging; | |
using MauiApp1.ViewModel; | |
using MauiApp1.Page; | |
using MauiApp1.Services; | |
using MauiApp1.Interface; | |
using MauiApp1.Models; | |
using CommunityToolkit.Maui; | |
using Supabase; | |
namespace MauiApp1 | |
{ | |
public static class MauiProgram | |
{ | |
public static MauiApp CreateMauiApp() | |
{ | |
var builder = MauiApp.CreateBuilder(); | |
builder | |
.UseMauiApp<App>() | |
.UseMauiCommunityToolkit() | |
.ConfigureFonts(fonts => | |
{ | |
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); | |
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); | |
}); | |
// Configure Supabase | |
var url = AppConfig.SUPABASE_URL; | |
var key = AppConfig.SUPABASE_KEY; | |
builder.Services.AddSingleton(provider => new Supabase.Client(url, key)); | |
// Add ViewModels | |
builder.Services.AddSingleton<OrganisationsListingViewModel>(); | |
builder.Services.AddTransient<AddOrganisationViewModel>(); | |
builder.Services.AddTransient<UpdateOrganisationViewModel>(); | |
builder.Services.AddTransient<LoginViewModel>(); | |
builder.Services.AddTransient<SignupViewModel>(); | |
// Add Views | |
builder.Services.AddSingleton<OrganisationsListingPage>(); | |
builder.Services.AddTransient<AddOrganisationPage>(); | |
builder.Services.AddTransient<UpdateOrganisationPage>(); | |
builder.Services.AddTransient<ProfilePage>(); | |
builder.Services.AddTransient<LoginPage>(); | |
builder.Services.AddTransient<SignupPage>(); | |
// Add Data Service | |
builder.Services.AddSingleton<IDataService, DataService>(); | |
builder.Services.AddSingleton<IUserService, UserService>(); | |
builder.Services.AddTransient<MainPage>(); | |
builder.Services.AddTransient<MainViewModel>(); | |
#if DEBUG | |
builder.Logging.AddDebug(); | |
#endif | |
AddCharityServices(builder.Services); | |
builder.Services.AddTransient<UserService>(); | |
builder.Services.AddTransient<LoadingPage>(); | |
// builder.Services.AddTransient<LoginPage>(); | |
builder.Services.AddTransient<SignupPage>(); | |
return builder.Build(); | |
} | |
private static IServiceCollection AddCharityServices(IServiceCollection services) | |
{ | |
services.AddSingleton<CharityService>(); | |
services.AddTransient<DetailPage>(); | |
services.AddTransient<DetailViewModel>(); | |
services.AddTransient<Charity1Page>(); | |
services.AddTransient<Charity1ViewModel>(); | |
services.AddTransient<BasketPage>(); | |
services.AddSingleton<BasketViewModel>(); | |
return services; | |
} | |
} | |
} |