Group rename WIP

This commit is contained in:
2023-07-05 02:17:58 +02:00
parent 453834646b
commit f9c98ff2dc
15 changed files with 389 additions and 68 deletions

View File

@@ -4,4 +4,7 @@ public interface IInputElement
{
InputType Type { get; }
string Label { get; }
IObservable<bool> IsValid { get; }
void SetValid();
void SetInvalid();
}

View File

@@ -0,0 +1,6 @@
namespace FileTime.Core.Interactions;
public interface IPreviewElement
{
object PreviewType { get; }
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}