using Autofac; using Autofac.Extensions.DependencyInjection; //using Microsoft.Extensions.Hosting; // <- critical for .Host using FFImageLoading.Maui; // For FFImageLoading.Maui.Helpers.Init() using Microsoft.Extensions.Logging; using Microsoft.Maui.Handlers; using Microsoft.Maui.LifecycleEvents; using NLog.Extensions.Logging; // For .AddNLog() using SkiaSharp.Views.Maui.Controls.Hosting; //using Xamarin.Forms.Clinical6.Android.Renderers; using Xamarin.Forms.Clinical6.UI.Controls; using Xamarin.Forms.Clinical6.UI.Effects; using Xamarin.Forms.Clinical6.UI.Views; using Xamarin.Forms.Clinical6.UI.Views.VideoConsult; using Xamarin.Forms.Clinical6.Views; using ZXing.Net.Maui.Controls; // For .UseZXingNetMaui() using Plugin.Firebase.Auth; using Plugin.Firebase.Bundled.Shared; using Plugin.Firebase.Crashlytics; using Microsoft.Maui.LifecycleEvents; using Plugin.Firebase.CloudMessaging; using Plugin.Firebase.CloudMessaging.EventArgs; using System.Diagnostics; #if IOS using Plugin.Firebase.Bundled.Platforms.iOS; using MAUI.Clinical6.iOS; using Xamarin.Forms.Clinical6.Core.Services; using MAUI.Clinical6.Platforms.iOS.PageRender; using Xamarin.Forms.Clinical6.iOS.Renders; using MAUI.Clinical6.Platforms.iOS.Services; using Xamarin.Forms.Clinical6.Services; using CommunityToolkit.Maui; #else using Plugin.Firebase.Bundled.Platforms.Android; #endif #if ANDROID using Xamarin.Forms.Clinical6.Android.Renderers; using MAUI.Clinical6.Platforms.Android.Renders; using Xamarin.Forms.Clinical6.Handlers; using MAUI.Clinical6.Platforms.Android.Controls; using MAUI.Clinical6.Platforms.Android.Handlers; using MAUI.Clinical6.Platforms.Android.PageRenderer; using clinical6Ui.sample.Platforms.Android.Handlers; using Xamarin.Forms.Clinical6.Services; using MAUI.Clinical6.Android.Services; using Xamarin.Forms.Clinical6.Android.Effects; using Xamarin.Forms.Clinical6.Maui.Handlers; using Xamarin.Forms.Clinical6.Helpers; using FaceIDTest.Droid.Services.FingerprintAuth; using CommunityToolkit.Maui; #endif #if IOS using MAUI.Clinical6.Platforms.iOS.Controls; #endif namespace Inventiva { public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .UseBarcodeReader() // ZXing.Net.Maui .UseSkiaSharp() // SkiaSharp.Views.Maui.Controls .UseFFImageLoading() .RegisterFirebaseServices() .UseMauiCommunityToolkit() //.UseServiceProviderFactory(new AutofacServiceProviderFactory()) // swap container //.ConfigureContainer(containerBuilder => //{ // // Call your Autofac registrations here // Xamarin.Forms.Clinical6.UI.DependencyConfig.Configure(containerBuilder); //}) .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); fonts.AddFont("Roboto-Bold.ttf", "Roboto-Bold"); fonts.AddFont("Roboto-Light.ttf", "Roboto-Light"); fonts.AddFont("Roboto-Medium.ttf", "Roboto-Medium"); fonts.AddFont("Roboto-Regular.ttf", "Roboto-Regular"); }); builder.ConfigureMauiHandlers(handlers => { #if ANDROID // Remove default Frame/BorderHandler mapping if necessary //handlers.AddHandler(); #endif }); // Register your custom handler here: builder.ConfigureMauiHandlers(handlers => { #if ANDROID //Controls handlers.AddHandler(typeof(MaterialTextbox), typeof(MaterialTextboxHandler)); handlers.AddHandler(typeof(Ellipse), typeof(EllipseHandler)); handlers.AddHandler(typeof(HtmlLabel), typeof(HtmlLabelHandler)); //handlers.AddHandler(typeof(MaterialFrame), typeof(MaterialFrameHandler)); handlers.AddHandler(typeof(ExtendedCheckBox), typeof(ExtendedCheckBoxHandler)); handlers.AddHandler(typeof(VideoPlayer), typeof(VideoPlayerHandler)); handlers.AddHandler(typeof(CircleView), typeof(CircleViewHandler)); handlers.AddHandler(typeof(AccessibilityLabel), typeof(AccessibilityLabelHandler)); handlers.AddHandler(typeof(BorderLessDatePicker), typeof(BorderLessDatePickerHandler)); handlers.AddHandler(typeof(BorderLessTimePicker), typeof(BorderLessTimePickerHandler)); handlers.AddHandler(typeof(StepSlider), typeof(StepSliderHandler)); handlers.AddHandler(typeof(VideoConsultRoomPage), typeof(VideoConsultRoomPageHandler)); handlers.AddHandler(typeof(VerticalStepSlider), typeof(VerticalStepSliderHandler)); handlers.AddHandler(typeof(DashboardTabPage), typeof(DashboardTabbedHandler)); //PageRenderer handlers.AddHandler(typeof(SwipeableListView), typeof(SwipeableListViewHandler)); handlers.AddHandler(typeof(FlyoutPage), typeof(DashboardFlyoutPageHandler)); handlers.AddHandler(typeof(NavigationPage), typeof(ExtendedNavigationPageHandler)); handlers.AddHandler(typeof(CustomWebView), typeof(CustomWebViewHandler)); //Renders handlers.AddHandler(typeof(BorderLessPicker), typeof(BorderLessPickerHandler)); handlers.AddHandler(typeof(LocalHtmlWebViewer), typeof(LocalHtmlWebViewerHandler)); handlers.AddHandler(typeof(PdfWebViewer), typeof(PdfWebViewerHandler)); handlers.AddHandler(typeof(BorderLessEntry), typeof(BorderLessEntryHandler)); #endif #if IOS //Controls handlers.AddHandler(typeof(ViewCell), typeof(BaseLineViewCellRenderer)); handlers.AddHandler(typeof(BorderLessDatePicker), typeof(BorderLessDatePickerHandler)); handlers.AddHandler(typeof(BorderLessEntry), typeof(BorderLessEntryHandler)); handlers.AddHandler(typeof(BorderLessTimePicker), typeof(BorderLessTimePickerHandler)); handlers.AddHandler(typeof(CircleView), typeof(CircleViewHandler)); handlers.AddHandler(typeof(CustomWebView), typeof(CustomWebViewHandler)); handlers.AddHandler(typeof(DashboardTabPage), typeof(DashboardTabbedPageHandler)); handlers.AddHandler(typeof(Ellipse), typeof(EllipseHandler)); handlers.AddHandler(typeof(ExtendedCheckBox), typeof(ExtendedCheckBoxHandler)); handlers.AddHandler(typeof(HtmlLabel), typeof(HtmlLabelHandler)); handlers.AddHandler(typeof(MaterialTextbox), typeof(MaterialTextboxHandler)); handlers.AddHandler(typeof(NoSelectViewCell), typeof(NoSelectViewCellRenderer)); handlers.AddHandler(typeof(StepSlider), typeof(StepSliderHandler)); handlers.AddHandler(typeof(VerticalStepSlider), typeof(VerticalStepSliderHandler)); handlers.AddHandler(typeof(VideoPlayer), typeof(VideoPlayerHandler)); //Pagerenderer handlers.AddHandler(typeof(BasePage), typeof(BasePageHandler)); handlers.AddHandler(typeof(SwipeableListView), typeof(CustomListViewHandler)); handlers.AddHandler(typeof(FlyoutPage), typeof(MasterDetailHandler)); handlers.AddHandler(typeof(NavigationPage), typeof(ExtendedNavigationHandler)); handlers.AddHandler(typeof(ViewCell), typeof(StandardViewCellRenderer)); handlers.AddHandler(); //Renderers handlers.AddHandler(); handlers.AddHandler(); handlers.AddHandler(); #endif }); builder.ConfigureEffects(effects => { #if ANDROID effects.Add(); #endif }); // Autofac initialization if replacing default DI container (optional) // Akavache initialization (early in startup) Akavache.Registrations.Start("inventiva"); #if DEBUG builder.Logging.AddDebug(); #endif builder.Logging.AddNLog(); #if ANDROID builder.Services.AddSingleton(); builder.Services.AddSingleton(); #endif #if IOS builder.Services.AddSingleton(); builder.Services.AddSingleton(); #endif return builder.Build(); } private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder) { builder.ConfigureLifecycleEvents(events => { #if IOS events.AddiOS(iOS => iOS.WillFinishLaunching((app, launchOptions) => { CrossFirebase.Initialize(CreateCrossFirebaseSettings()); CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(false); return false; })); #else events.AddAndroid(android => android.OnCreate((activity, _) => CrossFirebase.Initialize(activity, CreateCrossFirebaseSettings()))); CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true); #endif }); builder.Services.AddSingleton(_ => CrossFirebaseAuth.Current); return builder; } private static CrossFirebaseSettings CreateCrossFirebaseSettings() { return new CrossFirebaseSettings( isAuthEnabled: true, isCloudMessagingEnabled: true, isAnalyticsEnabled: true); } } }