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:
2026-05-27 04:27:33 +07:00
parent 51099afc79
commit fda094dd44
7 changed files with 133 additions and 8 deletions
+29 -4
View File
@@ -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)
+18 -3
View File
@@ -1,24 +1,39 @@
using System;
using System.Threading;
using Cysharp.Threading.Tasks;
using QuizPleaseTest.Boot.Settings;
using QuizPleaseTest.Boot.UI;
using QuizPleaseTest.Common.StateMachine;
using UnityEngine;
namespace QuizPleaseTest.Boot.States
{
public class SplashState : IState
{
private readonly SplashUIView _view;
private readonly BootSettings _settings;
public SplashState(SplashUIView view)
public SplashState(SplashUIView view, BootSettings settings)
{
_view = view;
_settings = settings;
}
public UniTask EnterAsync(CancellationToken ct)
public async UniTask EnterAsync(CancellationToken ct)
{
_view.Bind(new SplashUIViewModel());
_view.Initialize();
return UniTask.CompletedTask;
int delayMs = Mathf.Max(0, Mathf.RoundToInt(_settings.SplashDurationSeconds * 1000f));
try
{
await UniTask.Delay(delayMs, cancellationToken: ct);
}
catch (OperationCanceledException) when (ct.IsCancellationRequested)
{
_view.Release();
throw;
}
}
public UniTask ExitAsync(CancellationToken ct)