- add: content migration loading bar

This commit is contained in:
2025-03-14 18:32:03 +03:00
parent 6ae50486d5
commit 39cd190f10
4 changed files with 120 additions and 8 deletions

View File

@@ -40,6 +40,7 @@ public partial class MainViewModel : ViewModelBase
[GenerateProperty] private DebugService DebugService { get; } = default!;
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
[GenerateProperty] private FileService FileService { get; } = default!;
public ObservableCollection<ListItemTemplate> Items { get; private set; }
@@ -56,6 +57,20 @@ public partial class MainViewModel : ViewModelBase
PopupMessageService.OnPopupRequired += OnPopupRequired;
PopupMessageService.OnCloseRequired += OnPopupCloseRequired;
CheckMigration();
}
private void CheckMigration()
{
var loadingHandler = ViewHelperService.GetViewModel<LoadingContextViewModel>();
loadingHandler.LoadingName = "Migration task, please wait...";
loadingHandler.IsCancellable = false;
if (!FileService.CheckMigration(loadingHandler))
return;
OnPopupRequired(loadingHandler);
}
partial void OnSelectedListItemChanged(ListItemTemplate? value)

View File

@@ -17,6 +17,7 @@ public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadi
[ObservableProperty] private int _resolvedJobs;
public string LoadingName { get; set; } = "Loading...";
public bool IsCancellable { get; set; } = true;
public override bool IsClosable => false;
public override string Title => LoadingName;
@@ -42,6 +43,7 @@ public sealed partial class LoadingContextViewModel : PopupViewModelBase, ILoadi
}
public void Cancel(){
if(!IsCancellable) return;
CancellationService.Cancel();
Dispose();
}

View File

@@ -24,7 +24,11 @@
</Label>
</StackPanel>
<Button HorizontalAlignment="Right" VerticalAlignment="Center" Command="{Binding Cancel}">
<Button
HorizontalAlignment="Right"
VerticalAlignment="Center"
Command="{Binding Cancel}"
IsVisible="{Binding IsCancellable}">
<Label>Cancel</Label>
</Button>
</Panel>