diff --git a/NethereumExplorer.Maui/App.xaml.cs b/NethereumExplorer.Maui/App.xaml.cs index 6c8cc1d..dfce5b1 100644 --- a/NethereumExplorer.Maui/App.xaml.cs +++ b/NethereumExplorer.Maui/App.xaml.cs @@ -1,17 +1,11 @@ -using Microsoft.Maui; -using Microsoft.Maui.Controls; -using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific; -using Application = Microsoft.Maui.Controls.Application; +namespace NethereumExplorer.Maui; -namespace NethereumExplorer.Maui +public partial class App : Application { - public partial class App : Application - { - public App() - { - InitializeComponent(); + public App() + { + InitializeComponent(); - MainPage = new MainPage(); - } - } + MainPage = new MainPage(); + } } diff --git a/NethereumExplorer.Maui/GlobalUsings.cs b/NethereumExplorer.Maui/GlobalUsings.cs new file mode 100644 index 0000000..f25dc10 --- /dev/null +++ b/NethereumExplorer.Maui/GlobalUsings.cs @@ -0,0 +1,9 @@ +global using System; +global using Microsoft.Maui; +global using Microsoft.Maui.Controls; +global using Microsoft.Maui.Hosting; +global using Microsoft.Maui.Controls.Hosting; +global using Blazor.FlexGrid; +global using Microsoft.Extensions.DependencyInjection; +global using NethereumExplorer.Services; +global using NethereumExplorer.ViewModels; \ No newline at end of file diff --git a/NethereumExplorer.Maui/MainPage.xaml.cs b/NethereumExplorer.Maui/MainPage.xaml.cs index 8bb820e..4bcdcaf 100644 --- a/NethereumExplorer.Maui/MainPage.xaml.cs +++ b/NethereumExplorer.Maui/MainPage.xaml.cs @@ -1,13 +1,9 @@ -using System; -using Microsoft.Maui.Controls; +namespace NethereumExplorer.Maui; -namespace NethereumExplorer.Maui +public partial class MainPage : ContentPage { - public partial class MainPage : ContentPage + public MainPage() { - public MainPage() - { - InitializeComponent(); - } + InitializeComponent(); } } diff --git a/NethereumExplorer.Maui/MauiProgram.cs b/NethereumExplorer.Maui/MauiProgram.cs index cb14556..c1a885e 100644 --- a/NethereumExplorer.Maui/MauiProgram.cs +++ b/NethereumExplorer.Maui/MauiProgram.cs @@ -1,66 +1,19 @@ -using Microsoft.AspNetCore.Components.WebView.Maui; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Maui; -using Microsoft.Maui.Hosting; -using Microsoft.Maui.Controls.Compatibility; -using Microsoft.Maui.Controls.Hosting; -using NethereumExplorer.Services; -using NethereumExplorer.ViewModels; -using Blazor.FlexGrid; -using System.Net.Http; +namespace NethereumExplorer.Maui; -namespace NethereumExplorer.Maui +public static class MauiProgram { - public static class MauiProgram - { - public static MauiApp CreateMauiApp() - { - - var builder = MauiApp.CreateBuilder(); - builder - .RegisterBlazorMauiWebView() - .UseMauiApp() - .ConfigureFonts(fonts => - { - fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); - }); + public static MauiApp CreateMauiApp() + { - builder.Services.AddBlazorWebView(); - - var services = builder.Services; - - var web3ServiceProvider = new Web3ProviderService(); - var accountsService = new AccountsService(web3ServiceProvider); - var newBlockProcessingService = new NewBlockProcessingService(web3ServiceProvider); - var toastsViewModel = new ToastsViewModel(); - var blocksViewModel = new BlocksViewModel(newBlockProcessingService); - var latestBlockTransactionsViewModel = new LatestBlockTransactionsViewModel(web3ServiceProvider); - var newAccountPrivateKeyViewModel = new NewAccountPrivateKeyViewModel(); - var accountsViewModel = new AccountsViewModel(accountsService, newAccountPrivateKeyViewModel); - var accountsTransactionMonitoringService = new AccountsTransactionMonitoringService(accountsService, web3ServiceProvider); - - services.AddSingleton((x) => web3ServiceProvider); - services.AddSingleton((x) => accountsService); - services.AddSingleton(newBlockProcessingService); - services.AddSingleton(toastsViewModel); - services.AddSingleton(blocksViewModel); - services.AddSingleton(latestBlockTransactionsViewModel); - services.AddTransient(); - services.AddSingleton(accountsViewModel); - services.AddSingleton(newAccountPrivateKeyViewModel); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(accountsTransactionMonitoringService); - services.AddSingleton(); - services.AddSingleton(); - - - services.AddFlexGrid(cfg => + var builder = MauiApp.CreateBuilder(); + builder + .UseMauiApp() + .ConfigureFonts(fonts => { - cfg.ApplyConfiguration(new TransactionsViewModelGridConfiguration()); - }); + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + }) + .ConfigureServices(); - return builder.Build(); - } - } -} + return builder.Build(); + } +} \ No newline at end of file diff --git a/NethereumExplorer.Maui/NethereumExplorer.Maui.csproj b/NethereumExplorer.Maui/NethereumExplorer.Maui.csproj index 60f58d0..7b3453e 100644 --- a/NethereumExplorer.Maui/NethereumExplorer.Maui.csproj +++ b/NethereumExplorer.Maui/NethereumExplorer.Maui.csproj @@ -16,15 +16,17 @@ com.companyname.NethereumExplorer.Maui + 1.0 1 True - 14.2 - 14.0 - 21.0 - 10.0.18362.0 + 14.2 + 14.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 @@ -40,17 +42,6 @@ - - - - - - - - - WinExe - win-x64 - @@ -67,15 +58,6 @@ - - - - - - - - - diff --git a/NethereumExplorer.Maui/Platforms/MacCatalyst/AppDelegate.cs b/NethereumExplorer.Maui/Platforms/MacCatalyst/AppDelegate.cs index 0d4cf4b..a0cba02 100644 --- a/NethereumExplorer.Maui/Platforms/MacCatalyst/AppDelegate.cs +++ b/NethereumExplorer.Maui/Platforms/MacCatalyst/AppDelegate.cs @@ -2,11 +2,10 @@ using Microsoft.Maui; using Microsoft.Maui.Hosting; -namespace NethereumExplorer.Maui +namespace NethereumExplorer.Maui; + +[Register("AppDelegate")] +public class AppDelegate : MauiUIApplicationDelegate { - [Register("AppDelegate")] - public class AppDelegate : MauiUIApplicationDelegate - { - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); - } + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); } \ No newline at end of file diff --git a/NethereumExplorer.Maui/Platforms/MacCatalyst/Program.cs b/NethereumExplorer.Maui/Platforms/MacCatalyst/Program.cs index 6bb35af..da797c2 100644 --- a/NethereumExplorer.Maui/Platforms/MacCatalyst/Program.cs +++ b/NethereumExplorer.Maui/Platforms/MacCatalyst/Program.cs @@ -1,15 +1,14 @@ using UIKit; -namespace NethereumExplorer.Maui +namespace NethereumExplorer.Maui; + +public class Program { - public class Program + // This is the main entry point of the application. + static void Main(string[] args) { - // This is the main entry point of the application. - static void Main(string[] args) - { - // if you want to use a different Application Delegate class from "AppDelegate" - // you can specify it here. - UIApplication.Main(args, null, typeof(AppDelegate)); - } + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, typeof(AppDelegate)); } } \ No newline at end of file diff --git a/NethereumExplorer.Maui/Platforms/Windows/App.xaml b/NethereumExplorer.Maui/Platforms/Windows/App.xaml index 82577b3..8e84463 100644 --- a/NethereumExplorer.Maui/Platforms/Windows/App.xaml +++ b/NethereumExplorer.Maui/Platforms/Windows/App.xaml @@ -2,7 +2,6 @@ x:Class="NethereumExplorer.Maui.WinUI.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:maui="using:Microsoft.Maui" - xmlns:local="using:NethereumExplorer.Maui.WinUI"> + xmlns:maui="using:Microsoft.Maui"> diff --git a/NethereumExplorer.Maui/Platforms/Windows/App.xaml.cs b/NethereumExplorer.Maui/Platforms/Windows/App.xaml.cs index 7841e04..6ddc6e6 100644 --- a/NethereumExplorer.Maui/Platforms/Windows/App.xaml.cs +++ b/NethereumExplorer.Maui/Platforms/Windows/App.xaml.cs @@ -1,34 +1,21 @@ -using Microsoft.Maui; -using Microsoft.Maui.Hosting; -using Microsoft.UI.Xaml; -using Windows.ApplicationModel; - -// To learn more about WinUI, the WinUI project structure, +// To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. -namespace NethereumExplorer.Maui.WinUI +namespace NethereumExplorer.Maui.WinUI; + +/// +/// Provides application-specific behavior to supplement the default Application class. +/// +public partial class App : MauiWinUIApplication { /// - /// Provides application-specific behavior to supplement the default Application class. + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). /// - public partial class App : MauiWinUIApplication + public App() { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - } - - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); - - protected override void OnLaunched(LaunchActivatedEventArgs args) - { - base.OnLaunched(args); - - Microsoft.Maui.Essentials.Platform.OnLaunched(args); - } + this.InitializeComponent(); } + + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); } diff --git a/NethereumExplorer.Maui/Platforms/Windows/Package.appxmanifest b/NethereumExplorer.Maui/Platforms/Windows/Package.appxmanifest index 5eb27e3..07ea51c 100644 --- a/NethereumExplorer.Maui/Platforms/Windows/Package.appxmanifest +++ b/NethereumExplorer.Maui/Platforms/Windows/Package.appxmanifest @@ -14,7 +14,6 @@ NethereumExplorer.Maui Microsoft - Assets\appiconStoreLogo.png @@ -27,27 +26,8 @@ - - - - - - - - - - + + diff --git a/NethereumExplorer.Maui/Platforms/iOS/AppDelegate.cs b/NethereumExplorer.Maui/Platforms/iOS/AppDelegate.cs index 0d4cf4b..a0cba02 100644 --- a/NethereumExplorer.Maui/Platforms/iOS/AppDelegate.cs +++ b/NethereumExplorer.Maui/Platforms/iOS/AppDelegate.cs @@ -2,11 +2,10 @@ using Microsoft.Maui; using Microsoft.Maui.Hosting; -namespace NethereumExplorer.Maui +namespace NethereumExplorer.Maui; + +[Register("AppDelegate")] +public class AppDelegate : MauiUIApplicationDelegate { - [Register("AppDelegate")] - public class AppDelegate : MauiUIApplicationDelegate - { - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); - } + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); } \ No newline at end of file diff --git a/NethereumExplorer.Maui/Platforms/iOS/Program.cs b/NethereumExplorer.Maui/Platforms/iOS/Program.cs index 6bb35af..da797c2 100644 --- a/NethereumExplorer.Maui/Platforms/iOS/Program.cs +++ b/NethereumExplorer.Maui/Platforms/iOS/Program.cs @@ -1,15 +1,14 @@ using UIKit; -namespace NethereumExplorer.Maui +namespace NethereumExplorer.Maui; + +public class Program { - public class Program + // This is the main entry point of the application. + static void Main(string[] args) { - // This is the main entry point of the application. - static void Main(string[] args) - { - // if you want to use a different Application Delegate class from "AppDelegate" - // you can specify it here. - UIApplication.Main(args, null, typeof(AppDelegate)); - } + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, typeof(AppDelegate)); } } \ No newline at end of file diff --git a/NethereumExplorer.Maui/ServicesExtensions.cs b/NethereumExplorer.Maui/ServicesExtensions.cs new file mode 100644 index 0000000..7242dd4 --- /dev/null +++ b/NethereumExplorer.Maui/ServicesExtensions.cs @@ -0,0 +1,44 @@ +namespace NethereumExplorer.Maui; + +internal static class ServicesExtensions +{ + public static MauiAppBuilder ConfigureServices(this MauiAppBuilder builder) + { + var services = builder.Services; + + services.AddMauiBlazorWebView(); + + var web3ServiceProvider = new Web3ProviderService(); + var accountsService = new AccountsService(web3ServiceProvider); + var newBlockProcessingService = new NewBlockProcessingService(web3ServiceProvider); + var toastsViewModel = new ToastsViewModel(); + var blocksViewModel = new BlocksViewModel(newBlockProcessingService); + var latestBlockTransactionsViewModel = new LatestBlockTransactionsViewModel(web3ServiceProvider); + var newAccountPrivateKeyViewModel = new NewAccountPrivateKeyViewModel(); + var accountsViewModel = new AccountsViewModel(accountsService, newAccountPrivateKeyViewModel); + var accountsTransactionMonitoringService = new AccountsTransactionMonitoringService(accountsService, web3ServiceProvider); + + services.AddSingleton((x) => web3ServiceProvider); + services.AddSingleton((x) => accountsService); + services.AddSingleton(newBlockProcessingService); + services.AddSingleton(toastsViewModel); + services.AddSingleton(blocksViewModel); + services.AddSingleton(latestBlockTransactionsViewModel); + services.AddTransient(); + services.AddSingleton(accountsViewModel); + services.AddSingleton(newAccountPrivateKeyViewModel); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(accountsTransactionMonitoringService); + services.AddSingleton(); + services.AddSingleton(); + + + services.AddFlexGrid(cfg => + { + cfg.ApplyConfiguration(new TransactionsViewModelGridConfiguration()); + }); + + return builder; + } +}