Fixes User's dashboard

main
Paul Schneider 9 years ago
parent 435c084fe2
commit 7b96137d74
3 changed files with 35 additions and 11 deletions

@ -157,11 +157,18 @@ namespace BookAStar
if (olduserid != value.Id)
{
App.CurrentApp.PostDeviceInfo();
UserChanged.Invoke(App.CurrentApp, new EventArgs());
}
}
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)
{

@ -16,18 +16,11 @@ namespace BookAStar.Pages
{
public partial class DashboardPage : ContentPage
{
public RelayGesture UserNameGesture { get; set; }
public DashboardPage()
{
InitializeComponent();
UserNameGesture = new RelayGesture((g, x) =>
{
if (g.GestureType == GestureType.LongPress)
{
Resolver.Resolve<INavigationService>().NavigateTo<AccountChooserPage>(true);
}
});
}
public void OnViewPerformerStatus(object sender, EventArgs e)

@ -1,9 +1,14 @@
using BookAStar.Helpers;
using BookAStar.Model.Auth.Account;
using BookAStar.Pages;
using System.Collections.ObjectModel;
using System.Linq;
using Xamarin.Forms;
using XLabs.Forms.Behaviors;
using XLabs.Forms.Controls;
using XLabs.Forms.Mvvm;
using XLabs.Ioc;
using XLabs.Platform.Services;
namespace BookAStar.ViewModels
{
@ -98,6 +103,22 @@ namespace BookAStar.ViewModels
Accounts = MainSettings.AccountList;
User = MainSettings.CurrentUser;
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 ()
@ -117,9 +138,9 @@ namespace BookAStar.ViewModels
{
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 non renseigné";
newAvatar = UserHelpers.Avatar(user.Avatar);
@ -133,5 +154,8 @@ namespace BookAStar.ViewModels
{
UpdateUserMeta();
}
public RelayGesture UserNameGesture { get; set; }
}
}
Loading…