diff --git a/Template.Maui/MauiProgram.cs b/Template.Maui/MauiProgram.cs index efec070..1d6ba7b 100644 --- a/Template.Maui/MauiProgram.cs +++ b/Template.Maui/MauiProgram.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging; using MudBlazor.Services; using Template.Maui.Services; using Template.Shared; +using Template.Shared.Core.Interface; using Template.Shared.Core.Services; using Template.Shared.Interfaces; @@ -34,6 +35,8 @@ namespace Template.Maui builder.Services.AddScoped(provider => provider.GetRequiredService()); + builder.Services.AddScoped(); + #if DEBUG builder.Services.AddBlazorWebViewDeveloperTools(); builder.Logging.AddDebug(); diff --git a/Template.Maui/Services/NetworkService.cs b/Template.Maui/Services/NetworkService.cs new file mode 100644 index 0000000..1f6284e --- /dev/null +++ b/Template.Maui/Services/NetworkService.cs @@ -0,0 +1,12 @@ +using Template.Shared.Core.Interface; + +namespace Template.Maui.Services; + +public class NetworkService : INetworkService +{ + public bool IsNetworkAvailable() + { + return Connectivity.Current.NetworkAccess == NetworkAccess.Internet; + } + +} \ No newline at end of file diff --git a/Template.Shared/Components/Layout/HeaderLayout.razor b/Template.Shared/Components/Layout/HeaderLayout.razor index ed4259c..4a7d4d8 100644 --- a/Template.Shared/Components/Layout/HeaderLayout.razor +++ b/Template.Shared/Components/Layout/HeaderLayout.razor @@ -1,10 +1,14 @@

@Title

- + @if (ShowFilter) + { + + }
@code{ [Parameter] public string? Title { get; set; } + [Parameter] public bool ShowFilter { get; set; } } \ No newline at end of file diff --git a/Template.Shared/Components/Layout/MainLayout.razor b/Template.Shared/Components/Layout/MainLayout.razor index 143c838..7d9bdf2 100644 --- a/Template.Shared/Components/Layout/MainLayout.razor +++ b/Template.Shared/Components/Layout/MainLayout.razor @@ -1,6 +1,6 @@ @inherits LayoutComponentBase - + @@ -14,4 +14,18 @@ - \ No newline at end of file + + +@code { + private readonly MudTheme _currentTheme = new() + { + PaletteLight = new PaletteLight() + { + Primary = "#ABA9BF", + Secondary = "#BEB7DF", + Tertiary = "#D4F2D2", + Background = "#f6f6f8" + } + }; + +} \ No newline at end of file diff --git a/Template.Shared/Components/Layout/NavMenu.razor.css b/Template.Shared/Components/Layout/NavMenu.razor.css index 5e4d7aa..e2811c9 100644 --- a/Template.Shared/Components/Layout/NavMenu.razor.css +++ b/Template.Shared/Components/Layout/NavMenu.razor.css @@ -1,5 +1,5 @@ .navbar { - background: var(--mud-palette-background-gray); + background: var(--mud-palette-surface); position: fixed; bottom: 0; width: 100%; @@ -12,7 +12,7 @@ .nav-item ::deep a { display: flex; align-items: center; - line-height: 1.4; + line-height: 1.2; justify-content: center; } @@ -22,7 +22,7 @@ min-width: 60px; } -.nav-item ::deep a.active > div { color: var(--mud-palette-primary); } +.nav-item ::deep a.active > div { color: var(--mud-palette-secondary-darken); } .nav-item ::deep a.active > div > i { /*background-color: color-mix(in srgb, var(--mud-palette-primary) 20%, transparent);*/ diff --git a/Template.Shared/Components/Pages/Calendar.razor b/Template.Shared/Components/Pages/Calendar.razor index 4e5c6c4..ac90024 100644 --- a/Template.Shared/Components/Pages/Calendar.razor +++ b/Template.Shared/Components/Pages/Calendar.razor @@ -2,7 +2,7 @@ @attribute [Authorize] @using Template.Shared.Components.Layout - +
diff --git a/Template.Shared/Components/Pages/Home.razor b/Template.Shared/Components/Pages/Home.razor index 50f37db..ea71e0a 100644 --- a/Template.Shared/Components/Pages/Home.razor +++ b/Template.Shared/Components/Pages/Home.razor @@ -1,10 +1,23 @@ @page "/" +@using Template.Shared.Core.Interface +@using Template.Shared.Interfaces @attribute [Authorize] +@inject IFormFactor FormFactor +@inject INetworkService NetworkService @code { protected override Task OnInitializedAsync() { + var lastSyncDate = DateOnly.FromDateTime(LocalStorage.Get("last-sync")); + + if (!FormFactor.IsWeb() && NetworkService.IsNetworkAvailable() && lastSyncDate < DateOnly.FromDateTime(DateTime.Now)) + { + //NavigationManager.NavigateTo("/sync"); + NavigationManager.NavigateTo("/Calendar"); + return base.OnInitializedAsync(); + } + NavigationManager.NavigateTo("/Calendar"); return base.OnInitializedAsync(); } diff --git a/Template.Shared/Components/Pages/Login.razor b/Template.Shared/Components/Pages/Login.razor index c432699..f25980a 100644 --- a/Template.Shared/Components/Pages/Login.razor +++ b/Template.Shared/Components/Pages/Login.razor @@ -11,7 +11,7 @@ else {
-
+
Nome App @@ -23,7 +23,7 @@ else
- +
@@ -55,6 +55,26 @@ else private string ErrorMessage { get; set; } = ""; private bool _attemptFailed; + private bool _isShow; + private InputType _passwordInput = InputType.Password; + private string _passwordInputIcon = Icons.Material.Rounded.VisibilityOff; + + private void ShowPassword() + { + @if (_isShow) + { + _isShow = false; + _passwordInputIcon = Icons.Material.Rounded.VisibilityOff; + _passwordInput = InputType.Password; + } + else + { + _isShow = true; + _passwordInputIcon = Icons.Material.Rounded.Visibility; + _passwordInput = InputType.Text; + } + } + protected override void OnInitialized() { UserData.CodHash = LocalStorage.GetString("codHash"); diff --git a/Template.Shared/Components/Pages/Login.razor.css b/Template.Shared/Components/Pages/Login.razor.css index eeff625..1c8804f 100644 --- a/Template.Shared/Components/Pages/Login.razor.css +++ b/Template.Shared/Components/Pages/Login.razor.css @@ -35,9 +35,8 @@ .button-login { text-align: center; - border: 2px solid var(--mud-palette-primary); background-color: var(--mud-palette-primary); - border-radius: 25px; + border-radius: 6px; padding: .3rem 2rem; width: 100%; font-weight: 700; diff --git a/Template.Shared/Components/Pages/PersonalInfo.razor b/Template.Shared/Components/Pages/PersonalInfo.razor index 17cc92d..a5776e1 100644 --- a/Template.Shared/Components/Pages/PersonalInfo.razor +++ b/Template.Shared/Components/Pages/PersonalInfo.razor @@ -1,9 +1,113 @@ @page "/PersonalInfo" @attribute [Authorize] @using Template.Shared.Components.Layout +@using Template.Shared.Core.Authorization.Enum +@using Template.Shared.Core.Interface +@using Template.Shared.Core.Services +@using Template.Shared.Core.Utility +@using Template.Shared.Interfaces +@inject AppAuthenticationStateProvider AuthenticationStateProvider +@inject INetworkService NetworkService +@inject IFormFactor FormFactor +
+
+ + + + +
+ @UserSession.User.Fullname + @if (UserSession.User.KeyGroup is not null) + { + @(((KeyGroupEnum)UserSession.User.KeyGroup).ConvertToHumanReadable()) + } +
+
+ + + +
+ Impostazioni account +
+ +
+ Esci + +
+
+ @code { + private bool Unavailable { get; set; } + private DateTime LastSync { get; set; } + + protected override async Task OnInitializedAsync() + { + await LoadData(); + } + + private void Logout() + { + AuthenticationStateProvider.SignOut(); + } + + private async Task LoadData() + { + await Task.Run(() => + { + Unavailable = FormFactor.IsWeb() || !NetworkService.IsNetworkAvailable(); + LastSync = LocalStorage.Get("last-sync"); + }); + + StateHasChanged(); + } } \ No newline at end of file diff --git a/Template.Shared/Components/Pages/PersonalInfo.razor.css b/Template.Shared/Components/Pages/PersonalInfo.razor.css index e69de29..dd3738d 100644 --- a/Template.Shared/Components/Pages/PersonalInfo.razor.css +++ b/Template.Shared/Components/Pages/PersonalInfo.razor.css @@ -0,0 +1,95 @@ +.section-primary-info { + display: flex; + flex-direction: column; + align-items: center; +} + +.personal-info { + display: flex; + flex-direction: column; + align-items: center; + line-height: normal; + margin: 2rem 0; +} + +.info-nome { + color: var(--mud-palette-text-primary); + font-weight: 800; + font-size: x-large; +} + +.info-section { + color: var(--mud-palette-gray-default); + font-size: medium; + font-weight: 600; +} + +.section-info { + width: 100%; + margin-bottom: 1rem; + border-radius: 12px; + display: flex; + justify-content: space-between; + flex-direction: row; + padding: .8rem 1.2rem; + background: var(--mud-palette-surface); +} + +.section-personal-info { + display: flex; + flex-direction: column; +} + + .section-personal-info > div { + display: flex; + flex-direction: column; + line-height: normal; + margin: .25rem 0; + } + +.info-title { + color: var(--mud-palette-gray-darker); + font-weight: 800; +} + +.info-text { + color: var(--mud-palette-text-secondary); + font-weight: 700; + font-size: small; +} + +.user-button { + border: 2px solid var(--mud-palette-overlay-dark); + margin-top: 1rem; + background: transparent; + text-align: center; + border-radius: 6px; + padding: .45rem 2rem; + width: 100%; + font-weight: 700; + line-height: normal; +} + +.user-button.logout { + border: 2px solid var(--mud-palette-error); + color: var(--mud-palette-error); +} + +.user-button > i { font-size: large; } + +.user-button > span { + font-size: medium; + font-weight: 600; +} + +.status { + font-weight: 700; +} + +.status.online { + color: var(--mud-palette-success); +} + +.status.offline { + color: var(--mud-palette-error); +} \ No newline at end of file diff --git a/Template.Shared/Components/SingleElements/Card/ActivityCard.razor b/Template.Shared/Components/SingleElements/Card/ActivityCard.razor index 32f82f4..046ca18 100644 --- a/Template.Shared/Components/SingleElements/Card/ActivityCard.razor +++ b/Template.Shared/Components/SingleElements/Card/ActivityCard.razor @@ -1,4 +1,4 @@ -
+
14:00 diff --git a/Template.Shared/Components/SingleElements/Card/ActivityCard.razor.css b/Template.Shared/Components/SingleElements/Card/ActivityCard.razor.css index cee9f50..6267f00 100644 --- a/Template.Shared/Components/SingleElements/Card/ActivityCard.razor.css +++ b/Template.Shared/Components/SingleElements/Card/ActivityCard.razor.css @@ -7,6 +7,7 @@ padding: .5rem .7rem; border-radius: 12px; line-height: normal; + background: var(--mud-palette-surface); } .activity-card.memo { border-left: 5px solid var(--mud-palette-info-darken); } diff --git a/Template.Shared/Core/Authorization/Enum/KeyGroupEnum.cs b/Template.Shared/Core/Authorization/Enum/KeyGroupEnum.cs new file mode 100644 index 0000000..974ff67 --- /dev/null +++ b/Template.Shared/Core/Authorization/Enum/KeyGroupEnum.cs @@ -0,0 +1,8 @@ +namespace Template.Shared.Core.Authorization.Enum; + +public enum KeyGroupEnum +{ + UtenteAziendale = 2, + Agenti = 5, + Tecnico = 22 +} \ No newline at end of file diff --git a/Template.Shared/Core/Helpers/KeyGroupHelper.cs b/Template.Shared/Core/Helpers/KeyGroupHelper.cs new file mode 100644 index 0000000..6f40829 --- /dev/null +++ b/Template.Shared/Core/Helpers/KeyGroupHelper.cs @@ -0,0 +1,17 @@ +using Template.Shared.Core.Authorization.Enum; + +namespace Template.Shared.Core.Helpers; + +public static class KeyGroupHelper +{ + public static string ConvertToHumanReadable(this KeyGroupEnum keyGroup) + { + return keyGroup switch + { + KeyGroupEnum.Agenti => "Agenti", + KeyGroupEnum.Tecnico => "Tecnico", + KeyGroupEnum.UtenteAziendale => "Utente Aziendale", + _ => throw new ArgumentOutOfRangeException(nameof(keyGroup), keyGroup, null) + }; + } +} \ No newline at end of file diff --git a/Template.Shared/Core/Interface/INetworkService.cs b/Template.Shared/Core/Interface/INetworkService.cs new file mode 100644 index 0000000..48f50e0 --- /dev/null +++ b/Template.Shared/Core/Interface/INetworkService.cs @@ -0,0 +1,6 @@ +namespace Template.Shared.Core.Interface; + +public interface INetworkService +{ + public bool IsNetworkAvailable(); +} \ No newline at end of file diff --git a/Template.Shared/Core/Utility/UtilityColor.cs b/Template.Shared/Core/Utility/UtilityColor.cs new file mode 100644 index 0000000..dad6304 --- /dev/null +++ b/Template.Shared/Core/Utility/UtilityColor.cs @@ -0,0 +1,118 @@ +namespace Template.Shared.Core.Utility; + +public static class UtilityColor +{ + public static string CalcHexColor(string input) + { + try + { + var hue = (int)(Math.Abs(input.GetHashCode()) * 137.508 % 360); + + var data = new HSL(hue, 0.90f, 0.85f); + var myColor = HSLToRGB(data); + + return myColor.R.ToString("X2") + myColor.G.ToString("X2") + myColor.B.ToString("X2"); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return "dddddd"; + } + } + + private struct RGB(byte r, byte g, byte b) + { + public byte R + { + get => r; + set => r = value; + } + + public byte G + { + get => g; + set => g = value; + } + + public byte B + { + get => b; + set => b = value; + } + + public bool Equals(RGB rgb) + { + return (this.R == rgb.R) && (this.G == rgb.G) && (this.B == rgb.B); + } + } + + private struct HSL(int h, float s, float l) + { + public int H + { + get => h; + set => h = value; + } + + public float S + { + get => s; + set => s = value; + } + + public float L + { + get => l; + set => l = value; + } + + public bool Equals(HSL hsl) + { + return H == hsl.H && (this.S == hsl.S) && (this.L == hsl.L); + } + } + + private static RGB HSLToRGB(HSL hsl) + { + byte r; + byte g; + byte b; + + var hue = (float)hsl.H / 360; + if (hsl.S == 0) + { + r = g = b = (byte)(hsl.L * 255); + } + else + { + var v2 = hsl.L < 0.5 ? hsl.L * (1 + hsl.S) : hsl.L + hsl.S - hsl.L * hsl.S; + var v1 = 2 * hsl.L - v2; + + r = (byte)(255 * HueToRGB(v1, v2, hue + 1.0f / 3)); + g = (byte)(255 * HueToRGB(v1, v2, hue)); + b = (byte)(255 * HueToRGB(v1, v2, hue - 1.0f / 3)); + } + + return new RGB(r, g, b); + } + + private static float HueToRGB(float v1, float v2, float vH) + { + if (vH < 0) + vH += 1; + + if (vH > 1) + vH -= 1; + + if (6 * vH < 1) + return v1 + (v2 - v1) * 6 * vH; + + if (2 * vH < 1) + return v2; + + if (3 * vH < 2) + return v1 + (v2 - v1) * (2.0f / 3 - vH) * 6; + + return v1; + } +} \ No newline at end of file diff --git a/Template.Shared/Core/Utility/UtilityString.cs b/Template.Shared/Core/Utility/UtilityString.cs new file mode 100644 index 0000000..98b842b --- /dev/null +++ b/Template.Shared/Core/Utility/UtilityString.cs @@ -0,0 +1,11 @@ +namespace Template.Shared.Core.Utility; + +public static class UtilityString +{ + public static string ExtractInitials(string fullname) + { + return string.Concat(fullname + .Split(' ', StringSplitOptions.RemoveEmptyEntries) + .Select(word => char.ToUpper(word[0]))); + } +} \ No newline at end of file diff --git a/Template.Shared/Interfaces/IFormFactor.cs b/Template.Shared/Interfaces/IFormFactor.cs index aa7a4fa..2c665bc 100644 --- a/Template.Shared/Interfaces/IFormFactor.cs +++ b/Template.Shared/Interfaces/IFormFactor.cs @@ -4,4 +4,10 @@ public interface IFormFactor { public string GetFormFactor(); public string GetPlatform(); + + public bool IsWeb() + { + var formFactor = GetFormFactor(); + return formFactor == "Web"; + } } diff --git a/Template.Web/Program.cs b/Template.Web/Program.cs index 8bba9af..c81da2b 100644 --- a/Template.Web/Program.cs +++ b/Template.Web/Program.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using MudBlazor.Services; using Template.Shared.Components; +using Template.Shared.Core.Interface; using Template.Shared.Core.Services; using Template.Shared.Interfaces; using Template.Web.Services; @@ -14,6 +15,7 @@ builder.Services.AddMudServices(); builder.Services.AddAuthorizationCore(); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(provider => provider.GetRequiredService()); diff --git a/Template.Web/Services/NetworkService.cs b/Template.Web/Services/NetworkService.cs new file mode 100644 index 0000000..debe2a6 --- /dev/null +++ b/Template.Web/Services/NetworkService.cs @@ -0,0 +1,12 @@ +using Template.Shared.Core.Interface; + +namespace Template.Web.Services; + +public class NetworkService : INetworkService +{ + public bool IsNetworkAvailable() + { + return true; + } + +} \ No newline at end of file