12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using InABox.Core;
- 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();
- }
- }
-
- protected abstract void DoLoad();
- }
- }
|