| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Runtime.CompilerServices;
- using System.Windows.Input;
- using Xamarin.Forms;
- namespace comal.timesheets
- {
- public class ExistingFormsViewModel : INotifyPropertyChanged
- {
-
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- protected bool SetField<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer<T>.Default.Equals(field, value)) return false;
- field = value;
- OnPropertyChanged(propertyName);
- return true;
- }
-
- public ExistingFormsViewModel()
- {
- TapCommand = new Command<object>(Tapped);
- }
- private IModel _dataModel;
- public IModel DataModel
- {
- get => _dataModel;
- set
- {
- _dataModel = value;
- }
- }
- public Func<IModel, IDigitalFormInstanceShell[]> Property;
-
- public String AppliesTo
- {
- get;
- set;
- }
-
- public IDigitalFormInstanceShell[] Forms { get; private set; }
-
- private bool _isRefreshing = false;
- public ICommand RefreshCommand { get; private set; }
- public void Refresh(bool force)
- {
- IsRefreshing = true;
- _dataModel.Refresh(force, () => Device.BeginInvokeOnMainThread(() =>
- {
- Forms = Property?.Invoke(_dataModel);
- IsRefreshing = false;
- }));
- }
-
- public bool IsRefreshing {
- get { return _isRefreshing; }
- set {
- _isRefreshing = value;
- OnPropertyChanged(nameof(IsRefreshing));
- }
- }
- public ICommand TapCommand { get; private set; }
-
- private void Tapped(object sender)
- {
-
- }
-
- }
- }
|