1using System.Reflection;
2using CommunityToolkit.Mvvm.ComponentModel;
3using CommunityToolkit.Mvvm.Input;
4using CommunityToolkit.Mvvm.Messaging;
20 private readonly List<BaseViewModel> childViewModels = [];
21 private bool isOverlayVisible;
22 private DateTime overlayLastActivationTime;
44 public IEnumerable<BaseViewModel>
Children => this.childViewModels;
46 public virtual double ViewWidthRequest => (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density) * (7.0 / 8.0);
47 public virtual double MaximumViewHeightRequest => (DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density) * (3.0 / 4.0);
66 this.childViewModels.Add(ChildViewModel);
67 return ChildViewModel;
78 this.childViewModels.Remove(ChildViewModel);
79 return ChildViewModel;
87 foreach (
BaseViewModel ChildViewModel
in this.childViewModels)
98 foreach (
BaseViewModel ChildViewModel
in this.childViewModels)
118 return Task.CompletedTask;
126 return Task.CompletedTask;
136 return this.GetType().FullName +
"." + PropertyName;
151 this.IsBusy = IsBusy;
159 get => this.isOverlayVisible;
162 if (this.isOverlayVisible == value)
167 this.isOverlayVisible =
true;
168 this.overlayLastActivationTime = DateTime.Now;
169 this.OnPropertyChanged();
173 TimeSpan MinimumOverlayTime = TimeSpan.FromMilliseconds(500);
174 TimeSpan ElapsedTime = DateTime.Now.Subtract(this.overlayLastActivationTime);
176 if (ElapsedTime >= MinimumOverlayTime)
178 this.isOverlayVisible =
false;
179 this.OnPropertyChanged();
185 Task.Delay(MinimumOverlayTime - ElapsedTime).GetAwaiter().OnCompleted(() => this.isOverlayVisible =
false);
205 public async Task<bool> OnBackButtonPressedAsync()
207 if (this.GoBackCommand.CanExecute(
null))
208 _ = this.GoBackCommand.ExecuteAsync(
null);
216 [RelayCommand(AllowConcurrentExecutions =
false)]
227 public virtual object?
GetValue(
string PropertyName)
229 PropertyInfo? PI = this.GetType().GetProperty(PropertyName)
230 ??
throw new ArgumentException(
"Property not found: " + PropertyName, nameof(PropertyName));
232 return PI.GetValue(
this);
240 public virtual void SetValue(
string PropertyName,
object? Value)
242 PropertyInfo? PI = this.GetType().GetProperty(PropertyName)
243 ??
throw new ArgumentException(
"Property not found: " + PropertyName, nameof(PropertyName));
245 PI.SetValue(
this, Value);
252 foreach (
BaseViewModel ChildViewModel
in this.childViewModels)
258 foreach (
BaseViewModel ChildViewModel
in this.childViewModels)
266 foreach (
BaseViewModel ChildViewModel
in this.childViewModels)
272 foreach (
BaseViewModel ChildViewModel
in this.childViewModels)
Represents an instance of the Neuro-Access app.
static Task ServicesReady
Task that completes once all core services have finished loading.
A strongly-typed resource class, for looking up localized strings, etc.
static string Yes
Looks up a localized string similar to Yes.
static string Confirm
Looks up a localized string similar to Confirm.
static string No
Looks up a localized string similar to No.
Base class that references services in the app.
static IUiService UiService
Service serializing and managing UI-related tasks.
static INavigationService NavigationService
The navigation service for navigating between pages.
static ITagProfile TagProfile
TAG Profile service.
static IReportingStringLocalizer Localizer
Localization service
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
static async Task< bool > AreYouSure(string Message)
Asks the user to confirm an action.
virtual async Task OnDisappearingAsync()
Method called when view is disappearing from the screen.
virtual async Task OnAppearingAsync()
Method called when view is appearing on the screen.
static void GoToRegistrationStep(RegistrationStep NewStep)
Set a new registration step
string GetSettingsKey(string PropertyName)
Helper method for getting a unique settings key for a given property.
bool IsOverlayVisible
Gets or sets a value which indicates if the protective overlay with a spinner is visible.
virtual void SetValue(string PropertyName, object? Value)
Sets the value of a property in the view model.
T AddChildViewModel< T >(T ChildViewModel)
Use this method when nesting view models. This is the view model equivalent of master/detail pages.
T RemoveChildViewModel< T >(T ChildViewModel)
Use this method when nesting view models. This is the view model equivalent of master/detail pages.
virtual ? object GetValue(string PropertyName)
Gets the value of a property in the view model.
virtual Task DoRestoreState()
Override this method to do view model specific restoring of state when it's parent page/view appears ...
async Task Shutdown()
Convenience method that calls SaveState and then DoDisappearing.
bool IsAppearing
Returns true if the view model is shown.
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
bool IsInitialized
Returns true if the view model is initialized.
IEnumerable< BaseViewModel > Children
Gets the child view models.
BaseViewModel()
Create an instance of a BaseViewModel.
async Task SaveState()
Called by the parent page when it disappears on screen, before the DoDisappearing" method is called.
virtual async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
async Task RestoreState()
Called by the parent page when it appears on screen, after the DoAppearing method is called.
virtual Task DoSaveState()
Override this method to do view model specific saving of state when it's parent page/view disappears ...
virtual void SetIsBusy(bool IsBusy)
Sets the IsBusy property.
virtual async Task OnDisposeAsync()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
RegistrationStep Step
This profile's current registration step.
void GoToStep(RegistrationStep NewStep, bool SupressEvent=false)
Changes the current onboarding step.
Task GoBackAsync()
Pops the current page from the navigation stack and displays the previous page.
Task< bool > DisplayAlert(string Title, string Message, string? Accept=null, string? Cancel=null)
Displays an alert/message box to the user.
Interface for views who need to react to life-cycle events.
RegistrationStep
The different steps of a TAG Profile registration journey.
class RegistrationPageMessage(RegistrationStep Step)
RegistrationPage view change message