diff --git a/SteUp.Shared/Components/Pages/Login.razor b/SteUp.Shared/Components/Pages/Login.razor
index 9350fa2..dd309d1 100644
--- a/SteUp.Shared/Components/Pages/Login.razor
+++ b/SteUp.Shared/Components/Pages/Login.razor
@@ -36,7 +36,7 @@ else
diff --git a/SteUp.Shared/Components/SingleElements/AppVersion.razor b/SteUp.Shared/Components/SingleElements/AppVersion.razor
index b2f1d72..89e879f 100644
--- a/SteUp.Shared/Components/SingleElements/AppVersion.razor
+++ b/SteUp.Shared/Components/SingleElements/AppVersion.razor
@@ -2,21 +2,5 @@
@inject IGenericSystemService GenericSystemService
- @Version
+ @GenericSystemService.GetCurrentAppVersion()
-
-@code
-{
- private string Version { get; set; } = "";
-
- protected override void OnInitialized()
- {
-#if DEBUG
- Version = $"v{GenericSystemService.GetCurrentAppVersion()} [DEBUG]";
-#else
- Version = $"v{GenericSystemService.GetCurrentAppVersion()}";
-#endif
-
- StateHasChanged();
- }
-}
diff --git a/SteUp.Shared/Components/SingleElements/Modal/ModalAddAttached.razor b/SteUp.Shared/Components/SingleElements/Modal/ModalAddAttached.razor
index f828f49..2f25bd2 100644
--- a/SteUp.Shared/Components/SingleElements/Modal/ModalAddAttached.razor
+++ b/SteUp.Shared/Components/SingleElements/Modal/ModalAddAttached.razor
@@ -1,5 +1,7 @@
@using SteUp.Shared.Components.Layout
-@using SteUp.Shared.Components.Layout.Overlay
+@using SteUp.Shared.Core.Dto
+@using SteUp.Shared.Core.Interface.System
+@inject IAttachedService AttachedService
@@ -34,18 +36,11 @@
-
-
@code {
- [CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
-
+ [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter] public bool CanAddPosition { get; set; }
-
- //Overlay for save
- private bool VisibleOverlay { get; set; }
- private bool SuccessAnimation { get; set; }
-
- // private AttachedDTO? Attached { get; set; }
+
+ private AttachedDto? Attached { get; set; }
private bool _requireNewName;
@@ -60,8 +55,6 @@
}
}
- private bool SelectTypePicture { get; set; }
-
private string TitleModal { get; set; } = "Aggiungi allegati";
private string? _newName;
@@ -76,66 +69,53 @@
}
}
- protected override async Task OnInitializedAsync()
+ protected override void OnInitialized()
{
- SelectTypePicture = true;
RequireNewName = false;
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
}
private async Task OnCamera()
{
- // Attached = await AttachedService.SelectImageFromCamera();
- //
- // if (Attached != null)
- // {
- // RequireNewName = true;
- // StateHasChanged();
- // }
+ Attached = await AttachedService.SelectImageFromCamera();
+
+ if (Attached != null)
+ {
+ RequireNewName = true;
+ StateHasChanged();
+ }
}
private async Task OnGallery()
{
- // Attached = await AttachedService.SelectImageFromGallery();
- //
- // if (Attached != null)
- // {
- // RequireNewName = true;
- // StateHasChanged();
- // }
+ Attached = await AttachedService.SelectImageFromGallery();
+
+ if (Attached != null)
+ {
+ RequireNewName = true;
+ StateHasChanged();
+ }
}
private void OnNewName()
{
- // if (Attached != null)
- // {
- // switch (Attached.Type)
- // {
- // case AttachedDTO.TypeAttached.Position:
- // {
- // CanAddPosition = false;
- //
- // Attached.Description = NewName!;
- // Attached.Name = NewName!;
- //
- // break;
- // }
- // case AttachedDTO.TypeAttached.Image:
- // {
- // var extension = Path.GetExtension(Attached.Name);
- // Attached.Name = NewName! + extension;
- //
- // break;
- // }
- // case AttachedDTO.TypeAttached.Document:
- // break;
- // default:
- // throw new ArgumentOutOfRangeException();
- // }
- // }
+ if (Attached != null)
+ {
+ switch (Attached.Type)
+ {
+ case AttachedDto.TypeAttached.Image:
+ {
+ var extension = Path.GetExtension(Attached.Name);
+ Attached.Name = NewName! + extension;
+
+ break;
+ }
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
- // MudDialog.Close(Attached);
- MudDialog.Close();
+ MudDialog.Close(Attached);
}
}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Dto/AttachedDto.cs b/SteUp.Shared/Core/Dto/AttachedDto.cs
new file mode 100644
index 0000000..8c7e34a
--- /dev/null
+++ b/SteUp.Shared/Core/Dto/AttachedDto.cs
@@ -0,0 +1,23 @@
+namespace SteUp.Shared.Core.Dto;
+
+public class AttachedDto
+{
+ public string? Name { get; set; }
+ public string? Description { get; set; }
+
+ public string? MimeType { get; set; }
+ public long? DimensionBytes { get; set; }
+ public string? Path { get; set; }
+
+ public byte[]? FileBytes { get; set; }
+
+ public Stream? FileContent =>
+ FileBytes is null ? null : new MemoryStream(FileBytes);
+
+ public TypeAttached Type { get; set; }
+
+ public enum TypeAttached
+ {
+ Image
+ }
+}
\ No newline at end of file
diff --git a/SteUp.Shared/Core/Interface/System/IAttachedService.cs b/SteUp.Shared/Core/Interface/System/IAttachedService.cs
new file mode 100644
index 0000000..3a00cfb
--- /dev/null
+++ b/SteUp.Shared/Core/Interface/System/IAttachedService.cs
@@ -0,0 +1,12 @@
+using SteUp.Shared.Core.Dto;
+
+namespace SteUp.Shared.Core.Interface.System;
+
+public interface IAttachedService
+{
+ Task SelectImageFromCamera();
+ Task SelectImageFromGallery();
+
+ Task SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default);
+ Task OpenFile(string fileName, string filePath);
+}
\ No newline at end of file
diff --git a/SteUp.Shared/SteUp.Shared.csproj b/SteUp.Shared/SteUp.Shared.csproj
index 06b1778..c6b4b83 100644
--- a/SteUp.Shared/SteUp.Shared.csproj
+++ b/SteUp.Shared/SteUp.Shared.csproj
@@ -16,6 +16,7 @@
+