mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor: merge ViewModels.PopupHost
into ViewModels.LauncherPage
This commit is contained in:
parent
0e34a77add
commit
f06b1d5d51
14 changed files with 342 additions and 344 deletions
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
|
||||
using Avalonia.Collections;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class LauncherPage : PopupHost
|
||||
public class LauncherPage : ObservableObject
|
||||
{
|
||||
public RepositoryNode Node
|
||||
{
|
||||
|
@ -18,6 +18,12 @@ namespace SourceGit.ViewModels
|
|||
set => SetProperty(ref _data, value);
|
||||
}
|
||||
|
||||
public Popup Popup
|
||||
{
|
||||
get => _popup;
|
||||
set => SetProperty(ref _popup, value);
|
||||
}
|
||||
|
||||
public AvaloniaList<Models.Notification> Notifications
|
||||
{
|
||||
get;
|
||||
|
@ -39,26 +45,59 @@ namespace SourceGit.ViewModels
|
|||
_data = repo;
|
||||
}
|
||||
|
||||
public override string GetId()
|
||||
{
|
||||
return _node.Id;
|
||||
}
|
||||
|
||||
public override bool IsInProgress()
|
||||
{
|
||||
if (_data is Repository { IsAutoFetching: true })
|
||||
return true;
|
||||
|
||||
return base.IsInProgress();
|
||||
}
|
||||
|
||||
public void CopyPath()
|
||||
{
|
||||
if (_node.IsRepository)
|
||||
App.CopyText(_node.Id);
|
||||
}
|
||||
|
||||
public bool CanCreatePopup()
|
||||
{
|
||||
return _popup == null || !_popup.InProgress;
|
||||
}
|
||||
|
||||
public void StartPopup(Popup popup)
|
||||
{
|
||||
var dumpPage = this;
|
||||
dumpPage.Popup = popup;
|
||||
dumpPage.ProcessPopup();
|
||||
}
|
||||
|
||||
public async void ProcessPopup()
|
||||
{
|
||||
if (_popup != null)
|
||||
{
|
||||
if (!_popup.Check())
|
||||
return;
|
||||
|
||||
_popup.InProgress = true;
|
||||
var task = _popup.Sure();
|
||||
if (task != null)
|
||||
{
|
||||
var finished = await task;
|
||||
_popup.InProgress = false;
|
||||
if (finished)
|
||||
Popup = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_popup.InProgress = false;
|
||||
Popup = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CancelPopup()
|
||||
{
|
||||
if (_popup == null)
|
||||
return;
|
||||
if (_popup.InProgress)
|
||||
return;
|
||||
Popup = null;
|
||||
}
|
||||
|
||||
private RepositoryNode _node = null;
|
||||
private object _data = null;
|
||||
private Popup _popup = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue