diff --git a/salesbook.Maui/App.xaml.cs b/salesbook.Maui/App.xaml.cs index 641e04a..02ecbaf 100644 --- a/salesbook.Maui/App.xaml.cs +++ b/salesbook.Maui/App.xaml.cs @@ -4,17 +4,12 @@ namespace salesbook.Maui { public partial class App : Application { - private readonly IMessenger _messenger; - public App(IMessenger messenger) { InitializeComponent(); - _messenger = messenger; - } - protected override Window CreateWindow(IActivationState? activationState) - { - return new Window(new MainPage(_messenger)); + MainPage = new NavigationPage(new MainPage(messenger)); + } } } diff --git a/salesbook.Maui/Core/Services/NavigationService.cs b/salesbook.Maui/Core/Services/NavigationService.cs new file mode 100644 index 0000000..b824217 --- /dev/null +++ b/salesbook.Maui/Core/Services/NavigationService.cs @@ -0,0 +1,15 @@ +using salesbook.Shared.Core.Interface; + +namespace salesbook.Maui.Core.Services; + +public class NavigationService(IServiceProvider serviceProvider) : INavigationService +{ + public async Task NavigateToDetailsAsync() + { + var detailsPage = serviceProvider.GetService(); + if (Application.Current.MainPage is NavigationPage nav && detailsPage != null) + { + await nav.Navigation.PushAsync(detailsPage); + } + } +} diff --git a/salesbook.Maui/Core/Services/PageTitleService.cs b/salesbook.Maui/Core/Services/PageTitleService.cs new file mode 100644 index 0000000..a71b29c --- /dev/null +++ b/salesbook.Maui/Core/Services/PageTitleService.cs @@ -0,0 +1,18 @@ +using salesbook.Shared.Core.Interface; + +namespace salesbook.Maui.Core.Services; + +public class PageTitleService(IDispatcher dispatcher) : IPageTitleService +{ + public void SetTitle(string title) + { + dispatcher.Dispatch(() => + { + if (Application.Current?.MainPage is NavigationPage nav && + nav.CurrentPage is ContentPage cp) + { + cp.Title = title; + } + }); + } +} \ No newline at end of file diff --git a/salesbook.Maui/MainPage.xaml b/salesbook.Maui/MainPage.xaml index 170689a..a531c74 100644 --- a/salesbook.Maui/MainPage.xaml +++ b/salesbook.Maui/MainPage.xaml @@ -1,12 +1,11 @@ - + diff --git a/salesbook.Maui/MainPage.xaml.cs b/salesbook.Maui/MainPage.xaml.cs index 0b723b4..ce98182 100644 --- a/salesbook.Maui/MainPage.xaml.cs +++ b/salesbook.Maui/MainPage.xaml.cs @@ -11,6 +11,8 @@ namespace salesbook.Maui { InitializeComponent(); _messenger = messenger; + + Title = "Home"; } protected override bool OnBackButtonPressed() diff --git a/salesbook.Maui/MauiProgram.cs b/salesbook.Maui/MauiProgram.cs index 32b4cc2..ff36496 100644 --- a/salesbook.Maui/MauiProgram.cs +++ b/salesbook.Maui/MauiProgram.cs @@ -13,6 +13,7 @@ using salesbook.Shared.Core.Messages.Activity.Copy; using salesbook.Shared.Core.Messages.Activity.New; using salesbook.Shared.Core.Messages.Back; using salesbook.Shared.Core.Services; +using System.Globalization; namespace salesbook.Maui { @@ -24,6 +25,9 @@ namespace salesbook.Maui { InteractiveRenderSettings.ConfigureBlazorHybridRenderModes(); + CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("it-IT"); + CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("it-IT"); + var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() @@ -61,6 +65,10 @@ namespace salesbook.Maui builder.Services.AddSingleton(); builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + builder.Services.AddTransient(); + return builder.Build(); } } diff --git a/salesbook.Maui/PersonalInfo.xaml b/salesbook.Maui/PersonalInfo.xaml new file mode 100644 index 0000000..5cbfbef --- /dev/null +++ b/salesbook.Maui/PersonalInfo.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/salesbook.Maui/PersonalInfo.xaml.cs b/salesbook.Maui/PersonalInfo.xaml.cs new file mode 100644 index 0000000..620f70d --- /dev/null +++ b/salesbook.Maui/PersonalInfo.xaml.cs @@ -0,0 +1,11 @@ +namespace salesbook.Maui; + +public partial class PersonalInfo : ContentPage +{ + public PersonalInfo() + { + InitializeComponent(); + + Title = "Profilo"; + } +} \ No newline at end of file diff --git a/salesbook.Maui/Platforms/Android/MainActivity.cs b/salesbook.Maui/Platforms/Android/MainActivity.cs index 1c93fe9..cde7d2e 100644 --- a/salesbook.Maui/Platforms/Android/MainActivity.cs +++ b/salesbook.Maui/Platforms/Android/MainActivity.cs @@ -1,5 +1,6 @@ using Android.App; using Android.Content.PM; +using AndroidX.AppCompat.App; namespace salesbook.Maui { @@ -9,5 +10,9 @@ namespace salesbook.Maui ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] public class MainActivity : MauiAppCompatActivity { + public MainActivity() + { + AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo; + } } } \ No newline at end of file diff --git a/salesbook.Maui/Platforms/iOS/Info.plist b/salesbook.Maui/Platforms/iOS/Info.plist index ee8e215..a0e8510 100644 --- a/salesbook.Maui/Platforms/iOS/Info.plist +++ b/salesbook.Maui/Platforms/iOS/Info.plist @@ -35,5 +35,8 @@ NSAllowsArbitraryLoads + + UIUserInterfaceStyle + Light diff --git a/salesbook.Maui/salesbook.Maui.csproj b/salesbook.Maui/salesbook.Maui.csproj index 53f4292..e6c0364 100644 --- a/salesbook.Maui/salesbook.Maui.csproj +++ b/salesbook.Maui/salesbook.Maui.csproj @@ -55,8 +55,7 @@ - + - + true true true - + 14.2 $(DefineConstants);APPLE;PLATFORM @@ -85,8 +82,7 @@ VS: WildCard Development - + - + @@ -137,4 +133,16 @@ + + + PersonalInfo.xaml + + + + + + MSBuild:Compile + + + \ No newline at end of file diff --git a/salesbook.Shared/Components/Layout/HeaderLayout.razor b/salesbook.Shared/Components/Layout/HeaderLayout.razor index 19f494c..ed3fded 100644 --- a/salesbook.Shared/Components/Layout/HeaderLayout.razor +++ b/salesbook.Shared/Components/Layout/HeaderLayout.razor @@ -1,4 +1,7 @@ +@using Microsoft.Maui.Controls +@using salesbook.Shared.Core.Interface @inject IJSRuntime JS +@inject INavigationService NavigationService
@@ -83,7 +86,9 @@ await JS.InvokeVoidAsync("goBack"); } - private void OpenPersonalInfo() => - NavigationManager.NavigateTo("/PersonalInfo"); + private async Task OpenPersonalInfo() + { + await NavigationService.NavigateToDetailsAsync(); + } } \ No newline at end of file diff --git a/salesbook.Shared/Components/Layout/MainLayout.razor b/salesbook.Shared/Components/Layout/MainLayout.razor index 0130251..b1158a1 100644 --- a/salesbook.Shared/Components/Layout/MainLayout.razor +++ b/salesbook.Shared/Components/Layout/MainLayout.razor @@ -1,10 +1,10 @@ @using System.Globalization -@using CommunityToolkit.Mvvm.Messaging +@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Messages.Back @inherits LayoutComponentBase @inject IJSRuntime JS -@inject IMessenger Messenger @inject BackNavigationService BackService +@inject INavigationService NavigationService diff --git a/salesbook.Shared/Components/Pages/Calendar.razor b/salesbook.Shared/Components/Pages/Calendar.razor index 1f8eca0..88cfe56 100644 --- a/salesbook.Shared/Components/Pages/Calendar.razor +++ b/salesbook.Shared/Components/Pages/Calendar.razor @@ -1,21 +1,20 @@ @page "/Calendar" @using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Interface -@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.SingleElements @using salesbook.Shared.Components.Layout.Spinner @using salesbook.Shared.Components.SingleElements.BottomSheet -@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Messages.Activity.New @inject IManageDataService ManageData @inject IJSRuntime JS @inject NewActivityService NewActivity +@inject IPageTitleService PageTitleService - + OnCalendarToggle="ToggleExpanded"/> *@
@if (Expanded) @@ -260,6 +259,8 @@ private void PrepareHeaderTitle() { _headerTitle = CurrentMonth.ToString("MMMM yyyy", new System.Globalization.CultureInfo("it-IT")).FirstCharToUpper(); + PageTitleService?.SetTitle(_headerTitle); + } private void PrepareEventsCache() diff --git a/salesbook.Shared/Components/Pages/Notifications.razor b/salesbook.Shared/Components/Pages/Notifications.razor index 9579556..9213a88 100644 --- a/salesbook.Shared/Components/Pages/Notifications.razor +++ b/salesbook.Shared/Components/Pages/Notifications.razor @@ -1,14 +1,19 @@ @page "/Notifications" @attribute [Authorize] -@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.SingleElements +@using salesbook.Shared.Core.Interface +@inject IPageTitleService PageTitleService - +@* *@
@code { + protected override void OnInitialized() + { + PageTitleService?.SetTitle("Notifiche"); + } } \ No newline at end of file diff --git a/salesbook.Shared/Components/Pages/PersonalInfo.razor b/salesbook.Shared/Components/Pages/PersonalInfo.razor index b3f2bd3..04bd3bb 100644 --- a/salesbook.Shared/Components/Pages/PersonalInfo.razor +++ b/salesbook.Shared/Components/Pages/PersonalInfo.razor @@ -1,6 +1,5 @@ @page "/PersonalInfo" @attribute [Authorize] -@using salesbook.Shared.Components.Layout @using salesbook.Shared.Core.Authorization.Enum @using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Services @@ -8,7 +7,7 @@ @inject INetworkService NetworkService @inject IFormFactor FormFactor - +@* *@ @if (IsLoggedIn) { diff --git a/salesbook.Shared/Components/Pages/Users.razor b/salesbook.Shared/Components/Pages/Users.razor index b5a3d8f..5c0efdf 100644 --- a/salesbook.Shared/Components/Pages/Users.razor +++ b/salesbook.Shared/Components/Pages/Users.razor @@ -1,11 +1,11 @@ @page "/Users" @attribute [Authorize] -@using salesbook.Shared.Components.Layout @using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Interface @inject IManageDataService ManageData +@inject IPageTitleService PageTitleService - +@* *@