Refactor interaction handling with utility for translations

Introduced `TermHelper.Translate` to centralize string mappings for `InteractionType`, reducing duplication across components. Updated related code to leverage this utility and streamline interaction row implementation by removing the `Caption` parameter. Minor UI adjustments were also made to align button positioning and styling.
This commit is contained in:
Andre Beging
2025-03-28 20:31:25 +01:00
parent 350e2003ca
commit 0324e0f529
7 changed files with 70 additions and 45 deletions

View File

@@ -0,0 +1,38 @@
#nullable enable
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
namespace FoodsharingSiegen.Shared.Helper
{
public static class TermHelper
{
#region Public Method Translate
/// <summary>
/// Translates an <see cref="InteractionType" /> instance into a corresponding string representation,
/// using the provided application settings if necessary.
/// </summary>
/// <param name="type">The interaction type to translate.</param>
/// <param name="appSettings">The application settings used for custom translations.</param>
/// <returns>A string representation of the specified interaction type.</returns>
public static string Translate(this InteractionType type, AppSettings appSettings)
{
return type switch
{
InteractionType.EinAb => "Einführung",
InteractionType.Welcome => "Begrüßung",
InteractionType.IdCheck => "Perso prüfen",
InteractionType.PrintPass => "FS-Ausweis (Print)",
InteractionType.PdfPass => "FS-Ausweis (PDF)",
InteractionType.Verify => "Verifizieren",
InteractionType.Complete => "Fertig",
InteractionType.StepInBriefing => appSettings.Terms.StepInName ?? "StepIn",
InteractionType.ReleasedForVerification => "Freigabe zur Verifizierung",
_ => type.ToString()
};
}
#endregion
}
}