| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | using System;using InABox.Core;using JetBrains.Annotations;using Xamarin.Forms;namespace InABox.Mobile{    public abstract class MobileViewModel : BindableObject, IMobileViewModel    {        public Color SelectedColor => XF.Material.Forms.Material.Color.Surface;        public Color SelectedTextColor => XF.Material.Forms.Material.Color.OnSurface;        public Color UnselectedColor => XF.Material.Forms.Material.Color.Primary;        public Color UnselectedTextColor => XF.Material.Forms.Material.Color.OnPrimary;                public event MobileViewModelLoadedEvent Loaded;        protected void OnLoaded()             => Loaded?.Invoke(this, new MobileViewModelLoadedEventArgs());    }        public abstract class MobileViewModel<TEntity,TShell> : MobileViewModel        where TEntity : Entity, IRemotable, IPersistent        where TShell : IShell<TEntity>    {                public static readonly BindableProperty ItemProperty = BindableProperty.Create(            nameof(Item),             typeof(TShell),             typeof(MobileViewModel<TEntity,TShell>)        );                public TShell Item        {            get => (TShell)GetValue(ItemProperty);            set            {                SetValue(ItemProperty,value);                DoLoad();                OnLoaded();                OnPropertyChanged(nameof(IsChanged));            }        }                protected abstract void DoLoad();        public abstract bool IsChanged { get; }        public void DoChanged([CanBeNull] MobileViewChangedEventArgs args = null)        {            if (args != null)                OnPropertyChanged(args.Property);            OnPropertyChanged(nameof(IsChanged));        }    }}
 |