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()
{
var auth = new YaOAuth2Authenticator(
clientId: "d9be5e97-c19d-42e4-b444-0e65863b19e1",
clientId: Constants.APIKey,
clientSecret: "blouh",
scope: "profile",
authorizeUrl: new Uri(Constants.AuthorizeUrl),

View File

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

View File

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

View File

@ -7,30 +7,9 @@ using Xamarin.Forms;
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 RedirectUrl = YavscHomeUrl + "/oauth/success";
public static readonly string AccessTokenUrl = YavscHomeUrl + "/token";

View File

@ -13,11 +13,11 @@ namespace ZicMoove.Helpers
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.FromUri(new Uri(Constants.YavscHomeUrl+"/Avatars/"+avatarPath)) ;
ImageSource.FromUri(new Uri(Constants.YavscHomeUrl+ $"/Avatars/{username}.png")) ;
return result;
}

View File

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

View File

@ -11,6 +11,13 @@
Style="{StaticResource PageStyle}" >
<TabbedPage.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>
<converters:SignalRConnectionStateToObject x:Key="cxToStyleImage" x:TypeArguments="Style">
<converters:SignalRConnectionStateToObject.DisconnectedObject>
@ -46,6 +53,17 @@
<TabbedPage.Children>
<ContentPage Title="Public" Icon="chat_icon_s.png" >
<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"
Orientation = "Horizontal"
Padding="5, 0, 5, 0">
@ -63,10 +81,13 @@
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:HH:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<Label Text="{Binding Date, StringFormat='{0:HH:mm}'}" FontAttributes="Italic"
HorizontalOptions="Start" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic"
HorizontalOptions="Start"/>
<BoxView WidthRequest="1" HeightRequest="15" Color="#000090"/>
<Label Text="{Binding Message}" FontFamily="monospace" />
<Label Text="{Binding Message}" FontFamily="monospace"
HorizontalOptions="Start" />
</StackLayout>
</ViewCell.View>
</ViewCell>
@ -77,16 +98,27 @@
</ContentPage>
<ContentPage Title="Notifications" Icon="exclam.png" >
<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.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Orientation="Horizontal" VerticalOptions="StartAndExpand">
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" />
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
<Label Text="{Binding Date, StringFormat='{0:hh:mm}'}" FontAttributes="Italic" HorizontalOptions="Start"/>
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" HorizontalOptions="Start" />
<BoxView Color="#000090" WidthRequest="1" HeightRequest="15" />
<Label Text="{Binding Message}" FontFamily="monospace" />
<Label Text="{Binding Message}" FontFamily="monospace" HorizontalOptions="Start" />
</StackLayout>
</ViewCell.View>
</ViewCell>
@ -106,6 +138,17 @@
<views:UserListView x:Name="chatUserList" />
<StackLayout BindingContext="{x:Reference Name=chatUserList}" IsVisible="{Binding HasASelection}">
<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"
VerticalOptions="StartAndExpand">

View File

@ -63,13 +63,28 @@ namespace ZicMoove.Pages.Chat
IsBusy = true;
try
{
bool sent = false;
foreach (var cx in dest.ObservableConnections)
{
if (cx.Connected)
{
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;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex);

View File

@ -7,18 +7,17 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace ZicMoove
namespace ZicMoove.Settings
{
using Model.Social;
using Model.Auth.Account;
using Data;
/// <summary>
/// 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
/// and setters.
/// </summary>
public static class MainSettings
public static partial class MainSettings
{
public static ISettings AppSettings

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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