This commit is contained in:
Paul Schneider 2016-09-29 04:54:14 +02:00
commit a72d457eef
52 changed files with 919 additions and 280 deletions

View file

@ -0,0 +1,78 @@
using BookAStar.Interfaces;
using BookAStar.Model.Workflow;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XLabs.Forms.Mvvm;
namespace BookAStar.ViewModels
{
class BillingLineViewModel : ViewModel, IBillingLine
{
public BillingLineViewModel(BillingLine data)
{
if (data == null) data = new BillingLine();
count = data.Count;
description = data.Description;
unitaryCost = data.UnitaryCost;
duration = data.Duration;
}
protected int count;
public int Count
{
get
{
return count;
}
set
{
SetProperty<int>(ref count, value, "Count");
}
}
protected string description;
public string Description
{
get
{
return description;
}
set
{
SetProperty<string>(ref description, value, "Description");
}
}
protected TimeSpan duration;
public TimeSpan Duration
{
get
{
return duration;
}
set
{
SetProperty<TimeSpan>(ref duration, value, "Duration");
}
}
protected decimal unitaryCost;
public decimal UnitaryCost
{
get
{
return unitaryCost;
}
set
{
SetProperty<decimal>(ref unitaryCost, value, "UnitaryCost");
}
}
}
}

View file

@ -1,4 +1,5 @@
using BookAStar.Model;
using BookAStar.Interfaces;
using BookAStar.Model;
using BookAStar.Model.Social;
using System;
using System.Collections.Generic;
@ -9,7 +10,7 @@ using System.Threading.Tasks;
namespace BookAStar.ViewModels
{
class BookQueryViewModel : XLabs.Forms.Mvvm.ViewModel
class BookQueryViewModel : XLabs.Forms.Mvvm.ViewModel, IBookQueryData
{
public BookQueryViewModel()
{

View file

@ -0,0 +1,137 @@
using BookAStar.Helpers;
using BookAStar.Model.Auth.Account;
using System.Collections.ObjectModel;
using System.Linq;
using Xamarin.Forms;
using XLabs.Forms.Mvvm;
namespace BookAStar.ViewModels
{
internal class DashboardViewModel : ViewModel
{
public string UserId
{
get
{
return User?.Id;
}
}
public bool AllowUseMyPosition
{
get
{
return MainSettings.AllowGPSUsage;
}
set
{
MainSettings.AllowGPSUsage = value;
}
}
public bool AllowProBookingOnly
{
get
{
return MainSettings.AllowProBookingOnly;
}
set
{
MainSettings.AllowProBookingOnly = value;
}
}
private long queryCount;
private User user;
public long QueryCount
{
get
{
return queryCount;
}
}
public User User
{
get { return user; }
protected set
{
SetProperty<User>(ref user, value, "User");
if (user!=null)
{
user.PropertyChanged += User_PropertyChanged;
}
UpdateUserMeta();
}
}
private ImageSource avatar;
public ImageSource Avatar { get {
return avatar;
} }
public ObservableCollection<User> Accounts { get; protected set; }
private string performerStatus;
public string PerformerStatus
{
get
{
return performerStatus;
}
}
public string UserName
{
get
{
return User?.UserName;
}
}
private bool userIsPro = false;
public DashboardViewModel()
{
Accounts = MainSettings.AccountList;
User = MainSettings.CurrentUser;
UpdateUserMeta();
}
private void UpdateUserMeta ()
{
string newStatusString;
long newQueryCount;
bool newUserIsPro;
ImageSource newAvatar;
if (user==null)
{
newQueryCount = 0;
newUserIsPro = false;
newStatusString = null;
newAvatar = null;
}
else
{
newUserIsPro = User.Roles?.Contains("Performer") ?? false;
newQueryCount = userIsPro ? DataManager.Current.BookQueries.Count : 0;
newStatusString = userIsPro ?
$"Profile professionel renseigné,\n{newQueryCount} demandes valides en cours" :
"Profile professionel non renseigné";
newAvatar = UserHelpers.Avatar(user.Avatar);
}
SetProperty<string>(ref performerStatus, newStatusString, "PerformerStatus");
SetProperty<long>(ref queryCount, newQueryCount, "QueryCount");
SetProperty<ImageSource>(ref avatar, newAvatar, "Avatar");
}
private void User_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
UpdateUserMeta();
}
}
}

View file

@ -0,0 +1,91 @@
using BookAStar.Model.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XLabs.Forms.Mvvm;
using BookAStar.Model.Workflow;
using System.Collections.ObjectModel;
using BookAStar.Model;
namespace BookAStar.ViewModels
{
class EstimateViewModel : ViewModel
{
public EstimateViewModel(Estimate data)
{
estimate = data;
AttachedFiles = new ObservableCollection<string>(data.AttachedFiles);
AttachedGraphicList = new ObservableCollection<string>(data.AttachedGraphicList);
Bill = new ObservableCollection<BillingLine>(data.Bill);
description = data.Description;
title = data.Title;
status = data.Status;
}
Estimate estimate;
public ObservableCollection<string> AttachedFiles
{
get; protected set;
}
public ObservableCollection<string> AttachedGraphicList
{
get; protected set;
}
public ObservableCollection<BillingLine> Bill
{
get; protected set;
}
private string description;
public string Description
{
get
{
return description;
}
set
{
SetProperty<string>(ref description, value, "Description");
}
}
private int? status;
public int? Status
{
get
{
return status;
}
set
{
SetProperty<int?>(ref status, value, "Status");
}
}
private string title;
public string Title
{
get
{
return title;
}
set
{
SetProperty<string>(ref title, value, "Title");
}
}
public ClientProviderInfo Client { get { return estimate.Client; } }
public BookQueryData Query { get { return estimate.Query; } }
}
}

View file

@ -1,11 +0,0 @@
using System;
using XLabs.Forms.Mvvm;
using XLabs.Platform.Services;
namespace BookAStar.ViewModels
{
internal class SettingsViewModel : XLabs.Forms.Mvvm.ViewModel
{
}
}

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XLabs.Forms.Mvvm;
namespace BookAStar.ViewModels
{
class UserLoginViewModel : ViewModel
{
}
}

View file

@ -11,6 +11,7 @@ using System.Threading.Tasks;
namespace BookAStar.ViewModels
{
[Obsolete("Use legacy XLabs ViewModel")]
public class ViewModelBase : IModelViewModel
{
public string Title { get; set; }