An avatar, one or two

This commit is contained in:
2017-01-27 15:32:25 +01:00
parent 7fc85f72e3
commit 13bcb2c129
15 changed files with 85 additions and 44 deletions

View File

@ -324,7 +324,7 @@ namespace ZicMoove.Droid
public void AddAccount() public void AddAccount()
{ {
var auth = new YaOAuth2Authenticator( var auth = new YaOAuth2Authenticator(
clientId: "d9be5e97-c19d-42e4-b444-0e65863b19e1", clientId: Constants.APIKey,
clientSecret: "blouh", clientSecret: "blouh",
scope: "profile", scope: "profile",
authorizeUrl: new Uri(Constants.AuthorizeUrl), authorizeUrl: new Uri(Constants.AuthorizeUrl),

View File

@ -8,7 +8,7 @@
<ResourceDictionary> <ResourceDictionary>
<Color x:Key="PageBackgroundColor">#FFAAAAFF</Color> <Color x:Key="PageBackgroundColor">#20AAAAFF</Color>
<Color x:Key="DashboardPageBackgroundColor">#FFCCCCFF</Color> <Color x:Key="DashboardPageBackgroundColor">#FFCCCCFF</Color>
<Color x:Key="ContentBackgroundColor">#80FFFFFF</Color> <Color x:Key="ContentBackgroundColor">#80FFFFFF</Color>

View File

@ -382,7 +382,9 @@ namespace ZicMoove
}; };
DataManager.Instance.PrivateMessages.Add( DataManager.Instance.PrivateMessages.Add(
msg msg
); );
DataManager.Instance.PrivateMessages.SaveEntity();
DataManager.Instance.ChatUsers.OnPrivateMessage(msg); DataManager.Instance.ChatUsers.OnPrivateMessage(msg);
}); });
} }

View File

@ -7,30 +7,9 @@ using Xamarin.Forms;
namespace ZicMoove namespace ZicMoove
{ {
public static class Constants public static partial class Constants
{ {
#if DEV
public const string ApplicationName = "yadev";
public const string YavscHomeUrl = "http://dev.pschneider.fr";
#endif
#if WDEV
// against a Windows local API
public const string ApplicationName = "yawindev";
public const string YavscHomeUrl = "http://192.168.0.29:5000";
#endif
#if YAVSC
public const string ApplicationName = "yavsc";
public const string YavscHomeUrl = "https://yavsc.pschneider.fr";
#endif
#if LUA
public const string ApplicationName = "Luap";
public const string YavscHomeUrl = "https://lua.pschneider.fr";
#endif
#if ZICMOOVE
public const string ApplicationName = "ZicMoove";
public const string YavscHomeUrl = "https://zicmoove.pschneider.fr";
#endif
public static readonly string AuthorizeUrl = YavscHomeUrl + "/authorize"; public static readonly string AuthorizeUrl = YavscHomeUrl + "/authorize";
public static readonly string RedirectUrl = YavscHomeUrl + "/oauth/success"; public static readonly string RedirectUrl = YavscHomeUrl + "/oauth/success";
public static readonly string AccessTokenUrl = YavscHomeUrl + "/token"; public static readonly string AccessTokenUrl = YavscHomeUrl + "/token";

View File

@ -13,11 +13,11 @@ namespace ZicMoove.Helpers
public static class UserHelpers public static class UserHelpers
{ {
public static ImageSource Avatar(string avatarPath) public static ImageSource Avatar(string username)
{ {
var result = avatarPath == null ? var result = username == null ?
ImageSource.FromResource( "ZicMoove.Images.Users.icon_user.png") : ImageSource.FromResource( "ZicMoove.Images.Users.icon_user.png") :
ImageSource.FromUri(new Uri(Constants.YavscHomeUrl+"/Avatars/"+avatarPath)) ; ImageSource.FromUri(new Uri(Constants.YavscHomeUrl+ $"/Avatars/{username}.png")) ;
return result; return result;
} }

View File

@ -95,7 +95,7 @@ namespace ZicMoove.Model.Auth.Account
{ {
get get
{ {
return UserHelpers.Avatar(avatar); return UserHelpers.Avatar(UserName);
} }
} }
private Tokens yavscTokens; private Tokens yavscTokens;

View File

@ -11,6 +11,13 @@
Style="{StaticResource PageStyle}" > Style="{StaticResource PageStyle}" >
<TabbedPage.Resources> <TabbedPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
<Setter Property="HorizontalOptions" Value="Start" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
<converters:SignalRConnectionStateToObject x:Key="cxToStyleImage" x:TypeArguments="Style"> <converters:SignalRConnectionStateToObject x:Key="cxToStyleImage" x:TypeArguments="Style">
<converters:SignalRConnectionStateToObject.DisconnectedObject> <converters:SignalRConnectionStateToObject.DisconnectedObject>
@ -46,6 +53,17 @@
<TabbedPage.Children> <TabbedPage.Children>
<ContentPage Title="Public" Icon="chat_icon_s.png" > <ContentPage Title="Public" Icon="chat_icon_s.png" >
<StackLayout Padding="5, 5, 5, 5"> <StackLayout Padding="5, 5, 5, 5">
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
<Setter Property="HorizontalOptions" Value="Start" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</StackLayout.Resources>
<StackLayout Spacing = "12" <StackLayout Spacing = "12"
Orientation = "Horizontal" Orientation = "Horizontal"
Padding="5, 0, 5, 0"> Padding="5, 0, 5, 0">
@ -63,10 +81,13 @@
<ViewCell> <ViewCell>
<ViewCell.View> <ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand"> <StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:HH:mm}'}" FontAttributes="Italic" /> <Label Text="{Binding Date, StringFormat='{0:HH:mm}'}" FontAttributes="Italic"
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" /> HorizontalOptions="Start" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic"
HorizontalOptions="Start"/>
<BoxView WidthRequest="1" HeightRequest="15" Color="#000090"/> <BoxView WidthRequest="1" HeightRequest="15" Color="#000090"/>
<Label Text="{Binding Message}" FontFamily="monospace" /> <Label Text="{Binding Message}" FontFamily="monospace"
HorizontalOptions="Start" />
</StackLayout> </StackLayout>
</ViewCell.View> </ViewCell.View>
</ViewCell> </ViewCell>
@ -77,16 +98,27 @@
</ContentPage> </ContentPage>
<ContentPage Title="Notifications" Icon="exclam.png" > <ContentPage Title="Notifications" Icon="exclam.png" >
<StackLayout Padding="5, 5, 5, 5"> <StackLayout Padding="5, 5, 5, 5">
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
<Setter Property="HorizontalOptions" Value="Start" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</StackLayout.Resources>
<ListView x:Name="notifList" HasUnevenRows="true" ItemsSource="{Binding Notifs}"> <ListView x:Name="notifList" HasUnevenRows="true" ItemsSource="{Binding Notifs}">
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand"> <ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate> <DataTemplate>
<ViewCell> <ViewCell>
<ViewCell.View> <ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand"> <StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" /> <Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" HorizontalOptions="Start"/>
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" /> <Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" HorizontalOptions="Start" />
<BoxView Color="#000090" WidthRequest="1" HeightRequest="15" /> <BoxView Color="#000090" WidthRequest="1" HeightRequest="15" />
<Label Text="{Binding Message}" FontFamily="monospace" /> <Label Text="{Binding Message}" FontFamily="monospace" HorizontalOptions="Start" />
</StackLayout> </StackLayout>
</ViewCell.View> </ViewCell.View>
</ViewCell> </ViewCell>
@ -106,7 +138,18 @@
<views:UserListView x:Name="chatUserList" /> <views:UserListView x:Name="chatUserList" />
<StackLayout BindingContext="{x:Reference Name=chatUserList}" IsVisible="{Binding HasASelection}"> <StackLayout BindingContext="{x:Reference Name=chatUserList}" IsVisible="{Binding HasASelection}">
<ListView x:Name="pvList" HasUnevenRows="true" ItemsSource="{Binding SelectedUser.PrivateMessages}" BindingContext="{x:Reference Name=chatUserList}"> <StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="Style" Value="{StaticResource ContentLabelStyle}" />
<Setter Property="HorizontalOptions" Value="Start" />
</Style>
<Style TargetType="Button">
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
</Style>
</ResourceDictionary>
</StackLayout.Resources>
<ListView x:Name="pvList" HasUnevenRows="true" ItemsSource="{Binding SelectedUser.PrivateMessages}" BindingContext="{x:Reference Name=chatUserList}">
<ListView.ItemTemplate HeightRequest="80" <ListView.ItemTemplate HeightRequest="80"
VerticalOptions="StartAndExpand"> VerticalOptions="StartAndExpand">
<DataTemplate> <DataTemplate>

View File

@ -63,12 +63,27 @@ namespace ZicMoove.Pages.Chat
IsBusy = true; IsBusy = true;
try try
{ {
bool sent = false;
foreach (var cx in dest.ObservableConnections) foreach (var cx in dest.ObservableConnections)
{ {
if (cx.Connected) if (cx.Connected)
{
App.ChatHubProxy.Invoke<string>("SendPV", cx.ConnectionId, pvEntry.Text); App.ChatHubProxy.Invoke<string>("SendPV", cx.ConnectionId, pvEntry.Text);
sent = true;
}
}
if (sent)
{
chatUserList.SelectedUser.PrivateMessages.Add(
new Model.Social.Messaging.ChatMessage
{
Date = DateTime.Now,
Message = pvEntry.Text,
Read = true,
SenderId = MainSettings.CurrentUser.UserName
});
pvEntry.Text = null;
} }
pvEntry.Text = null;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -7,18 +7,17 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
namespace ZicMoove namespace ZicMoove.Settings
{ {
using Model.Social; using Model.Social;
using Model.Auth.Account; using Model.Auth.Account;
using Data;
/// <summary> /// <summary>
/// This is the Settings static class that can be used in your Core solution or in any /// This is the Settings static class that can be used in your Core solution or in any
/// of your client applications. All settings are laid out the same exact way with getters /// of your client applications. All settings are laid out the same exact way with getters
/// and setters. /// and setters.
/// </summary> /// </summary>
public static class MainSettings public static partial class MainSettings
{ {
public static ISettings AppSettings public static ISettings AppSettings

View File

@ -47,7 +47,7 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
{ {
get get
{ {
return UserHelpers.Avatar(Client.Avatar); return UserHelpers.Avatar(Client.UserName);
} }
} }
public ImageSource SmallAvatar public ImageSource SmallAvatar

View File

@ -36,7 +36,7 @@ namespace ZicMoove.ViewModels.Messaging
if (existent != null) { if (existent != null) {
existent.UserName = item.UserName; existent.UserName = item.UserName;
existent.Roles = item.Roles; existent.Roles = item.Roles;
existent.Avatar = item.Avatar; existent.Avatar = item.UserName;
existent.Connections = item.Connections; existent.Connections = item.Connections;
} }
else Add(item); else Add(item);

View File

@ -51,7 +51,7 @@ namespace ZicMoove.ViewModels.Messaging
// by assigning a server side username to anonymous. // by assigning a server side username to anonymous.
if (string.IsNullOrEmpty(userName)) if (string.IsNullOrEmpty(userName))
{ {
msg.SenderId = $"({cxId})"; msg.SenderId = $"[{cxId}]";
} }
Notifs.Add(msg); Notifs.Add(msg);
if (eventId == "connected") if (eventId == "connected")

View File

@ -13,6 +13,7 @@ namespace ZicMoove.ViewModels.UserProfile
using Helpers; using Helpers;
using Model.Auth.Account; using Model.Auth.Account;
using Pages.UserProfile; using Pages.UserProfile;
using Settings;
using System.Threading.Tasks; using System.Threading.Tasks;
internal class DashboardViewModel : ViewModel internal class DashboardViewModel : ViewModel
@ -200,7 +201,7 @@ namespace ZicMoove.ViewModels.UserProfile
newQueriesButtonText = newUserIsPro ? newQueriesButtonText = newUserIsPro ?
$"{newQueryCount} demandes valides en cours" : $"{newQueryCount} demandes valides en cours" :
"Profile professionel non renseigné"; "Profile professionel non renseigné";
newAvatar = UserHelpers.Avatar(user.Avatar); newAvatar = UserHelpers.Avatar(user.UserName);
} }
SetProperty<bool>(ref haveAnUser, userIsNull, "HaveAnUser"); SetProperty<bool>(ref haveAnUser, userIsNull, "HaveAnUser");
SetProperty<bool>(ref userIsPro, newUserIsPro, "UserIsPro"); SetProperty<bool>(ref userIsPro, newUserIsPro, "UserIsPro");

View File

@ -197,7 +197,7 @@ namespace ZicMoove.ViewModels.UserProfile
newQueriesButtonText = newUserIsPro ? newQueriesButtonText = newUserIsPro ?
$"{newQueryCount} demandes valides en cours" : $"{newQueryCount} demandes valides en cours" :
"Profile professionel non renseigné"; "Profile professionel non renseigné";
newAvatar = UserHelpers.Avatar(user.Avatar); newAvatar = UserHelpers.Avatar(user.UserName);
} }
SetProperty<bool>(ref haveAnUser, newHaveAnUser, "HaveAnUser"); SetProperty<bool>(ref haveAnUser, newHaveAnUser, "HaveAnUser");
SetProperty<string>(ref performerStatus, newStatusString, "PerformerStatus"); SetProperty<string>(ref performerStatus, newStatusString, "PerformerStatus");

View File

@ -53,6 +53,7 @@
</Compile> </Compile>
<Compile Include="Attributes\CurrencyAttribute.cs" /> <Compile Include="Attributes\CurrencyAttribute.cs" />
<Compile Include="Attributes\DisplayAttribute.cs" /> <Compile Include="Attributes\DisplayAttribute.cs" />
<Compile Include="Constants.Private.cs" />
<Compile Include="Converters\Behaviors\EmailValidatorBehavior.cs" /> <Compile Include="Converters\Behaviors\EmailValidatorBehavior.cs" />
<Compile Include="Converters\Behaviors\IntegerEntryBehavior.cs" /> <Compile Include="Converters\Behaviors\IntegerEntryBehavior.cs" />
<Compile Include="Converters\Behaviors\EditorMaxLengthValidator.cs" /> <Compile Include="Converters\Behaviors\EditorMaxLengthValidator.cs" />
@ -78,6 +79,7 @@
<Compile Include="Pages\ClientPages\SearchPage.xaml.cs"> <Compile Include="Pages\ClientPages\SearchPage.xaml.cs">
<DependentUpon>SearchPage.xaml</DependentUpon> <DependentUpon>SearchPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Settings\MainSettings.Private.cs" />
<Compile Include="ViewModels\HomeViewModel.cs" /> <Compile Include="ViewModels\HomeViewModel.cs" />
<Compile Include="ViewModels\Messaging\ChatUserCollection.cs" /> <Compile Include="ViewModels\Messaging\ChatUserCollection.cs" />
<Compile Include="ViewModels\Messaging\ChatUserInfo.cs" /> <Compile Include="ViewModels\Messaging\ChatUserInfo.cs" />