This commit is contained in:
67
BimAI.UI.Mobile/MauiProgram.cs
Normal file
67
BimAI.UI.Mobile/MauiProgram.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Reflection;
|
||||
using BimAI.UI.Mobile.Services;
|
||||
using BimAI.UI.Shared.Extensions;
|
||||
using BimAI.UI.Shared.Interfaces;
|
||||
using BimAI.UI.Shared.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Maui.Controls.Hosting;
|
||||
using Microsoft.Maui.Devices;
|
||||
using Microsoft.Maui.Hosting;
|
||||
using MudBlazor.Services;
|
||||
using ZXing.Net.Maui.Controls;
|
||||
|
||||
namespace BimAI.UI.Mobile;
|
||||
|
||||
public static class MauiProgram
|
||||
{
|
||||
public static MauiApp CreateMauiApp()
|
||||
{
|
||||
var builder = MauiApp.CreateBuilder();
|
||||
builder
|
||||
.UseMauiApp<App>()
|
||||
.UseBarcodeReader()
|
||||
.ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); });
|
||||
|
||||
builder.Configuration
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
||||
.AddJsonFile($"appsettings.Development.json", optional: true, reloadOnChange: false)
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
builder.Services.AddMauiBlazorWebView();
|
||||
builder.Services.AddMudServices();
|
||||
|
||||
if (DeviceInfo.Platform == DevicePlatform.iOS)
|
||||
{
|
||||
builder.Services.AddSingleton<IScannerService, ScannerService>();
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Services.AddSingleton<IScannerService, NoOpScannerService>();
|
||||
}
|
||||
|
||||
builder.Services.AddScoped<AuthService>();
|
||||
|
||||
var baseUrl = GetApiBaseUrl();
|
||||
builder.Services.AddSharedServices(baseUrl);
|
||||
|
||||
|
||||
#if DEBUG
|
||||
builder.Services.AddBlazorWebViewDeveloperTools();
|
||||
builder.Logging.AddDebug();
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Debug);
|
||||
#endif
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
private static string GetApiBaseUrl()
|
||||
{
|
||||
#if IOS
|
||||
// iOS symulator
|
||||
return "http://192.168.29.140:7142/";
|
||||
#else
|
||||
return "https://localhost:7142/";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user