Files
Ursa.Avalonia/demo/Ursa.Demo/ViewModels/VerificationCodeDemoViewModel.cs
2024-03-11 17:02:08 +08:00

29 lines
835 B
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Input;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ursa.Controls;
namespace Ursa.Demo.ViewModels;
public partial class VerificationCodeDemoViewModel: ObservableObject
{
public ICommand CompleteCommand { get; set; }
[ObservableProperty] private List<Exception>? _error;
public VerificationCodeDemoViewModel()
{
CompleteCommand = new AsyncRelayCommand<IList<string>>(OnComplete);
Error = [new Exception("Invalid verification code")];
}
private async Task OnComplete(IList<string>? obj)
{
if (obj is null) return;
var code = string.Join("", obj);
await MessageBox.ShowOverlayAsync(code);
}
}