Group rename WIP
This commit is contained in:
@@ -4,4 +4,7 @@ public interface IInputElement
|
||||
{
|
||||
InputType Type { get; }
|
||||
string Label { get; }
|
||||
IObservable<bool> IsValid { get; }
|
||||
void SetValid();
|
||||
void SetInvalid();
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public interface IPreviewElement
|
||||
{
|
||||
object PreviewType { get; }
|
||||
}
|
||||
@@ -3,6 +3,8 @@ namespace FileTime.Core.Interactions;
|
||||
public interface IUserCommunicationService
|
||||
{
|
||||
Task<bool> ReadInputs(params IInputElement[] fields);
|
||||
Task<bool> ReadInputs(IInputElement field, IEnumerable<IPreviewElement>? previews = null);
|
||||
Task<bool> ReadInputs(IEnumerable<IInputElement> fields, IEnumerable<IPreviewElement>? previews = null);
|
||||
void ShowToastMessage(string text);
|
||||
Task<MessageBoxResult> ShowMessageBox(string text);
|
||||
}
|
||||
@@ -1,13 +1,23 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public abstract class InputElementBase : IInputElement
|
||||
{
|
||||
private readonly BehaviorSubject<bool> _isValid = new(true);
|
||||
public InputType Type { get; }
|
||||
public string Label { get; }
|
||||
public IObservable<bool> IsValid { get; }
|
||||
|
||||
protected InputElementBase(string label, InputType type)
|
||||
{
|
||||
Label = label;
|
||||
Type = type;
|
||||
IsValid = _isValid.AsObservable();
|
||||
}
|
||||
|
||||
public void SetValid() => _isValid.OnNext(true);
|
||||
|
||||
public void SetInvalid() => _isValid.OnNext(false);
|
||||
}
|
||||
@@ -3,12 +3,19 @@ using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public partial class TextInputElement : InputElementBase, INotifyPropertyChanged
|
||||
public partial class TextInputElement : InputElementBase
|
||||
{
|
||||
[Notify] private string? _value;
|
||||
private readonly Action<string?>? _update;
|
||||
|
||||
public TextInputElement(string label, string? value = null) : base(label, InputType.Text)
|
||||
public TextInputElement(
|
||||
string label,
|
||||
string? value = null,
|
||||
Action<string?>? update = null) : base(label, InputType.Text)
|
||||
{
|
||||
_value = value;
|
||||
_update = update;
|
||||
}
|
||||
|
||||
private void OnValueChanged(string? oldValue, string? newValue) => _update?.Invoke(newValue);
|
||||
}
|
||||
Reference in New Issue
Block a user