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:
38
FoodsharingSiegen.Shared/Helper/TermHelper.cs
Normal file
38
FoodsharingSiegen.Shared/Helper/TermHelper.cs
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user