mirror of
https://github.com/bitwarden/mobile
synced 2026-01-18 08:23:15 +00:00
PM-3349 PM-3350 MAUI Migration Initial
This commit is contained in:
66
src/Core/Pages/Settings/ExtensionPageViewModel.cs
Normal file
66
src/Core/Pages/Settings/ExtensionPageViewModel.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Resources.Localization;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class ExtensionPageViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IMessagingService _messagingService;
|
||||
|
||||
private bool _started;
|
||||
private bool _activated;
|
||||
|
||||
public ExtensionPageViewModel()
|
||||
{
|
||||
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||
PageTitle = AppResources.AppExtension;
|
||||
}
|
||||
|
||||
public bool Started
|
||||
{
|
||||
get => _started;
|
||||
set => SetProperty(ref _started, value, additionalPropertyNames: new string[]
|
||||
{
|
||||
nameof(NotStarted),
|
||||
nameof(StartedAndNotActivated),
|
||||
nameof(StartedAndActivated)
|
||||
});
|
||||
}
|
||||
|
||||
public bool Activated
|
||||
{
|
||||
get => _activated;
|
||||
set => SetProperty(ref _activated, value, additionalPropertyNames: new string[]
|
||||
{
|
||||
nameof(StartedAndNotActivated),
|
||||
nameof(StartedAndActivated)
|
||||
});
|
||||
}
|
||||
|
||||
public bool NotStarted => !Started;
|
||||
public bool StartedAndNotActivated => Started && !Activated;
|
||||
public bool StartedAndActivated => Started && Activated;
|
||||
|
||||
public async Task InitAsync()
|
||||
{
|
||||
Started = false;
|
||||
Activated = false;
|
||||
}
|
||||
|
||||
public void ShowExtension()
|
||||
{
|
||||
_messagingService.Send("showAppExtension", this);
|
||||
}
|
||||
|
||||
public void EnabledExtension(bool enabled)
|
||||
{
|
||||
Started = true;
|
||||
if (!Activated && enabled)
|
||||
{
|
||||
Activated = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user