Files
replicate.maui/Replicate.Maui/TransformerState.cs
2025-12-10 21:59:12 -05:00

82 lines
2.3 KiB
C#

namespace MarketAlly.Replicate.Maui
{
/// <summary>
/// Represents the current state of the ReplicateTransformerView control.
/// </summary>
public enum TransformerState
{
/// <summary>
/// No image selected - showing placeholder.
/// </summary>
Empty,
/// <summary>
/// Source image has been selected and is displayed.
/// </summary>
ImageSelected,
/// <summary>
/// A transformation is currently in progress.
/// </summary>
Processing,
/// <summary>
/// An image transformation has completed successfully.
/// </summary>
ImageResult,
/// <summary>
/// A video transformation has completed successfully.
/// </summary>
VideoResult,
/// <summary>
/// The video player is actively playing the generated video.
/// </summary>
PlayingVideo,
/// <summary>
/// An error occurred during transformation.
/// </summary>
Error
}
/// <summary>
/// Extension methods for TransformerState.
/// </summary>
public static class TransformerStateExtensions
{
/// <summary>
/// Whether the state indicates a result is available (image or video).
/// </summary>
public static bool HasResult(this TransformerState state)
{
return state is TransformerState.ImageResult or TransformerState.VideoResult or TransformerState.PlayingVideo;
}
/// <summary>
/// Whether the state indicates the control is busy.
/// </summary>
public static bool IsBusy(this TransformerState state)
{
return state == TransformerState.Processing;
}
/// <summary>
/// Whether the state allows starting a new transformation.
/// </summary>
public static bool CanTransform(this TransformerState state)
{
return state is TransformerState.ImageSelected or TransformerState.ImageResult or TransformerState.VideoResult;
}
/// <summary>
/// Whether the state allows selecting a new image.
/// </summary>
public static bool CanSelectImage(this TransformerState state)
{
return state != TransformerState.Processing;
}
}
}