- tweak: Favorite button

This commit is contained in:
2025-01-29 12:32:42 +03:00
parent 730e2e5529
commit 37ff25ba70
18 changed files with 233 additions and 75 deletions

View File

@@ -0,0 +1,47 @@
using System;
using CommunityToolkit.Mvvm.ComponentModel;
using Nebula.Launcher.ViewModels.Pages;
using Nebula.Launcher.Views.Pages;
using Nebula.Shared.Services;
using Nebula.Shared.Utils;
using AddFavoriteView = Nebula.Launcher.Views.Popup.AddFavoriteView;
namespace Nebula.Launcher.ViewModels.Popup;
[ViewModelRegister(typeof(AddFavoriteView), false)]
[ConstructGenerator]
public partial class AddFavoriteViewModel : PopupViewModelBase
{
protected override void InitialiseInDesignMode()
{
}
protected override void Initialise()
{
}
[GenerateProperty]
public override PopupMessageService PopupMessageService { get; }
[GenerateProperty] private ServerListViewModel ServerListViewModel { get; }
[GenerateProperty] private DebugService DebugService { get; }
public override string Title => "Add to favorite";
public override bool IsClosable => true;
[ObservableProperty] private string _ipInput;
[ObservableProperty] private string _error = "";
public void OnEnter()
{
try
{
var uri = IpInput.ToRobustUrl();
ServerListViewModel.AddFavorite(uri);
Dispose();
}
catch (Exception e)
{
Error = e.Message;
DebugService.Error(e);
}
}
}