feat(task-0005): implement splash delay and loading progress with reactive properties
- Add SplashState delay timer using BootSettings.SplashDurationSeconds with cancellation support - Implement LoadState progress tracking via ReactiveProperty<float> with step-by-step updates - Update LoadingUIViewModel to accept and expose Progress reactive property - Connect LoadingUIView to ViewModel progress changes using UniRx subscriptions - Add CompositeDisposable for proper cleanup of UI subscriptions in Release() - Scale ProgressFill transform based on progress value for visual feedback Выполнена задача TASK-0005 и реализованы splash и loading состояния: - Добавлен таймер задержки в SplashState с использованием BootSettings.SplashDurationSeconds и поддержкой отмены - Реализован трекинг прогресса в LoadState через ReactiveProperty<float> со пошаговыми обновлениями - Обновлён LoadingUIViewModel для принятия и экспорта реактивного свойства Progress - Подключён LoadingUIView к изменениям прогресса ViewModel с использованием подписок UniRx - Добавлен CompositeDisposable для правильной очистки UI подписок в Release() - Масштабирование ProgressFill на основе значения прогресса для визуальной обратной связи
This commit is contained in:
@@ -1,24 +1,49 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using QuizPleaseTest.Boot.Settings;
|
||||
using QuizPleaseTest.Boot.UI;
|
||||
using QuizPleaseTest.Common.StateMachine;
|
||||
using UniRx;
|
||||
|
||||
namespace QuizPleaseTest.Boot.States
|
||||
{
|
||||
public class LoadState : IState
|
||||
{
|
||||
private readonly LoadingUIView _view;
|
||||
private readonly BootSettings _settings;
|
||||
private readonly ReactiveProperty<float> _progress = new ReactiveProperty<float>(0f);
|
||||
|
||||
public LoadState(LoadingUIView view)
|
||||
public IReadOnlyReactiveProperty<float> Progress => _progress;
|
||||
|
||||
public LoadState(LoadingUIView view, BootSettings settings)
|
||||
{
|
||||
_view = view;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public UniTask EnterAsync(CancellationToken ct)
|
||||
public async UniTask EnterAsync(CancellationToken ct)
|
||||
{
|
||||
_view.Bind(new LoadingUIViewModel());
|
||||
_progress.Value = 0f;
|
||||
_view.Bind(new LoadingUIViewModel(Progress));
|
||||
_view.Initialize();
|
||||
return UniTask.CompletedTask;
|
||||
|
||||
int loadSteps = _settings.LoadSteps > 0 ? _settings.LoadSteps : 1;
|
||||
int stepDurationMs = _settings.LoadStepDurationMs > 0 ? _settings.LoadStepDurationMs : 0;
|
||||
|
||||
try
|
||||
{
|
||||
for (int step = 1; step <= loadSteps; step++)
|
||||
{
|
||||
await UniTask.Delay(stepDurationMs, cancellationToken: ct);
|
||||
_progress.Value = (float)step / loadSteps;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
_view.Release();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public UniTask ExitAsync(CancellationToken ct)
|
||||
|
||||
Reference in New Issue
Block a user