Fixes User's dashboard
This commit is contained in:
parent
6a211566d3
commit
c81cf1adab
3 changed files with 35 additions and 11 deletions
|
|
@ -157,12 +157,19 @@ namespace BookAStar
|
||||||
if (olduserid != value.Id)
|
if (olduserid != value.Id)
|
||||||
{
|
{
|
||||||
App.CurrentApp.PostDeviceInfo();
|
App.CurrentApp.PostDeviceInfo();
|
||||||
|
UserChanged.Invoke(App.CurrentApp, new EventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO else Unregister this device
|
else if (olduserid != null)
|
||||||
|
{
|
||||||
|
UserChanged.Invoke(App.CurrentApp, new EventArgs());
|
||||||
|
// TODO else Unregister this device
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static event EventHandler<EventArgs> UserChanged;
|
||||||
|
|
||||||
public static void SaveUser(User user)
|
public static void SaveUser(User user)
|
||||||
{
|
{
|
||||||
var existent = AccountList.FirstOrDefault(u => u.UserName == user.UserName);
|
var existent = AccountList.FirstOrDefault(u => u.UserName == user.UserName);
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,11 @@ namespace BookAStar.Pages
|
||||||
{
|
{
|
||||||
public partial class DashboardPage : ContentPage
|
public partial class DashboardPage : ContentPage
|
||||||
{
|
{
|
||||||
public RelayGesture UserNameGesture { get; set; }
|
|
||||||
|
|
||||||
public DashboardPage()
|
public DashboardPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
UserNameGesture = new RelayGesture((g, x) =>
|
|
||||||
{
|
|
||||||
if (g.GestureType == GestureType.LongPress)
|
|
||||||
{
|
|
||||||
Resolver.Resolve<INavigationService>().NavigateTo<AccountChooserPage>(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnViewPerformerStatus(object sender, EventArgs e)
|
public void OnViewPerformerStatus(object sender, EventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
using BookAStar.Helpers;
|
using BookAStar.Helpers;
|
||||||
using BookAStar.Model.Auth.Account;
|
using BookAStar.Model.Auth.Account;
|
||||||
|
using BookAStar.Pages;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
using XLabs.Forms.Behaviors;
|
||||||
|
using XLabs.Forms.Controls;
|
||||||
using XLabs.Forms.Mvvm;
|
using XLabs.Forms.Mvvm;
|
||||||
|
using XLabs.Ioc;
|
||||||
|
using XLabs.Platform.Services;
|
||||||
|
|
||||||
namespace BookAStar.ViewModels
|
namespace BookAStar.ViewModels
|
||||||
{
|
{
|
||||||
|
|
@ -98,6 +103,22 @@ namespace BookAStar.ViewModels
|
||||||
Accounts = MainSettings.AccountList;
|
Accounts = MainSettings.AccountList;
|
||||||
User = MainSettings.CurrentUser;
|
User = MainSettings.CurrentUser;
|
||||||
UpdateUserMeta();
|
UpdateUserMeta();
|
||||||
|
|
||||||
|
UserNameGesture = new RelayGesture((g, x) =>
|
||||||
|
{
|
||||||
|
if (g.GestureType == GestureType.LongPress)
|
||||||
|
{
|
||||||
|
Resolver.Resolve<INavigationService>().NavigateTo<AccountChooserPage>(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MainSettings.UserChanged += MainSettings_UserChanged;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainSettings_UserChanged(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
User = MainSettings.CurrentUser;
|
||||||
|
UpdateUserMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateUserMeta ()
|
private void UpdateUserMeta ()
|
||||||
|
|
@ -117,9 +138,9 @@ namespace BookAStar.ViewModels
|
||||||
{
|
{
|
||||||
newUserIsPro = User.Roles?.Contains("Performer") ?? false;
|
newUserIsPro = User.Roles?.Contains("Performer") ?? false;
|
||||||
|
|
||||||
newQueryCount = userIsPro ? DataManager.Current.BookQueries.Count : 0;
|
newQueryCount = newUserIsPro ? DataManager.Current.BookQueries.Count : 0;
|
||||||
|
|
||||||
newStatusString = userIsPro ?
|
newStatusString = newUserIsPro ?
|
||||||
$"Profile professionel renseigné,\n{newQueryCount} demandes valides en cours" :
|
$"Profile professionel renseigné,\n{newQueryCount} demandes valides en cours" :
|
||||||
"Profile professionel non renseigné";
|
"Profile professionel non renseigné";
|
||||||
newAvatar = UserHelpers.Avatar(user.Avatar);
|
newAvatar = UserHelpers.Avatar(user.Avatar);
|
||||||
|
|
@ -133,5 +154,8 @@ namespace BookAStar.ViewModels
|
||||||
{
|
{
|
||||||
UpdateUserMeta();
|
UpdateUserMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RelayGesture UserNameGesture { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue