Vario
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
@using System.Globalization
|
||||
@using System.Text.RegularExpressions
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using Java.Util.Jar
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@@ -126,13 +125,13 @@
|
||||
{
|
||||
@if (item.p.Type == AttachedDTO.TypeAttached.Position)
|
||||
{
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.LocationOn" Color="Color.Success" OnClose="() => OnRemoveAttached(item.index)">
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.LocationOn" Color="Color.Success" OnClick="() => OpenPosition(item.p)" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Description
|
||||
</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default" OnClose="() => OnRemoveAttached(item.index)">
|
||||
<MudChip T="string" Color="Color.Default" OnClick="() => OpenAttached(item.p)" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Name
|
||||
</MudChip>
|
||||
}
|
||||
@@ -518,7 +517,7 @@
|
||||
|
||||
if (resultNamePosition is true)
|
||||
attached.Description = NamePosition;
|
||||
attached.Name = NamePosition!;
|
||||
attached.Name = NamePosition!;
|
||||
}
|
||||
|
||||
AttachedList ??= [];
|
||||
@@ -542,4 +541,37 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OpenAttached(AttachedDTO attached)
|
||||
{
|
||||
if (attached is { FileContent: not null, MimeType: not null })
|
||||
{
|
||||
var fileViewerUrl = $"data:{attached.MimeType};base64,{Convert.ToBase64String(attached.FileContent)}";
|
||||
await ModalHelpers.OpenViewAttach(Dialog, fileViewerUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire il file", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenPosition(AttachedDTO attached)
|
||||
{
|
||||
if (attached is { Lat: not null, Lng: not null })
|
||||
{
|
||||
const string baseUrl = "https://www.google.it/maps/place/";
|
||||
NavigationManager.NavigateTo(
|
||||
$"{baseUrl}{AdjustCoordinate(attached.Lat.Value)},{AdjustCoordinate(attached.Lng.Value)}"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire la posizione", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string AdjustCoordinate(double coordinate) =>
|
||||
coordinate.ToString(CultureInfo.InvariantCulture).Replace(",", ".");
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user