using System;
namespace Uigenx.Actions
{
/// UI events the compiler can wire to an action. Mirrors `UI_EVENTS` in the studio schema.
public enum UgxUiEvent
{
Click,
PointerDown,
PointerUp,
PointerEnter,
PointerLeave,
Change,
Submit,
Focus,
Blur,
NavigationSubmit,
NavigationCancel,
LongPress,
}
public static class UgxUiEvents
{
/// Parses the kebab-case wire name used by the studio, for example `pointer-down`.
public static bool TryParse(string wireName, out UgxUiEvent value)
{
switch (wireName)
{
case "click": value = UgxUiEvent.Click; return true;
case "pointer-down": value = UgxUiEvent.PointerDown; return true;
case "pointer-up": value = UgxUiEvent.PointerUp; return true;
case "pointer-enter": value = UgxUiEvent.PointerEnter; return true;
case "pointer-leave": value = UgxUiEvent.PointerLeave; return true;
case "change": value = UgxUiEvent.Change; return true;
case "submit": value = UgxUiEvent.Submit; return true;
case "focus": value = UgxUiEvent.Focus; return true;
case "blur": value = UgxUiEvent.Blur; return true;
case "navigation-submit": value = UgxUiEvent.NavigationSubmit; return true;
case "navigation-cancel": value = UgxUiEvent.NavigationCancel; return true;
case "long-press": value = UgxUiEvent.LongPress; return true;
default: value = default; return false;
}
}
public static string ToWireName(this UgxUiEvent value)
{
switch (value)
{
case UgxUiEvent.Click: return "click";
case UgxUiEvent.PointerDown: return "pointer-down";
case UgxUiEvent.PointerUp: return "pointer-up";
case UgxUiEvent.PointerEnter: return "pointer-enter";
case UgxUiEvent.PointerLeave: return "pointer-leave";
case UgxUiEvent.Change: return "change";
case UgxUiEvent.Submit: return "submit";
case UgxUiEvent.Focus: return "focus";
case UgxUiEvent.Blur: return "blur";
case UgxUiEvent.NavigationSubmit: return "navigation-submit";
case UgxUiEvent.NavigationCancel: return "navigation-cancel";
case UgxUiEvent.LongPress: return "long-press";
default: throw new ArgumentOutOfRangeException(nameof(value));
}
}
}
}