Merge branch 'vnext' of github.com:pazof/yavsc into vnext
This commit is contained in:
commit
f4d7c1b48e
14 changed files with 196 additions and 78 deletions
|
|
@ -29,8 +29,7 @@ namespace BookAStar
|
||||||
public static string AppName { get; set; }
|
public static string AppName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
// Exists in order to dispose of a static instance strongly typed,
|
[Obsolete("Instead using this, use new static properties.")]
|
||||||
// It Makes smaller code.
|
|
||||||
public static App CurrentApp { get { return Current as App; } }
|
public static App CurrentApp { get { return Current as App; } }
|
||||||
|
|
||||||
public static bool MasterPresented
|
public static bool MasterPresented
|
||||||
|
|
@ -253,8 +252,8 @@ namespace BookAStar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private HubConnection chatHubConnection = null;
|
private static HubConnection chatHubConnection = null;
|
||||||
public HubConnection ChatHubConnection
|
public static HubConnection ChatHubConnection
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
@ -273,9 +272,9 @@ namespace BookAStar
|
||||||
chatHubConnection.Error += ChatHubConnection_Error;
|
chatHubConnection.Error += ChatHubConnection_Error;
|
||||||
|
|
||||||
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
|
chatHubProxy = chatHubConnection.CreateHubProxy("ChatHub");
|
||||||
chatHubProxy.On<string, string>("PV", (n, m) => {
|
chatHubProxy.On<string, string>("addPV", (n, m) => {
|
||||||
DataManager.Current.PrivateMessages.Add(
|
DataManager.Current.PrivateMessages.Add(
|
||||||
new UserMessage
|
new ChatMessage
|
||||||
{
|
{
|
||||||
Message = m,
|
Message = m,
|
||||||
SenderId = n,
|
SenderId = n,
|
||||||
|
|
@ -283,17 +282,21 @@ namespace BookAStar
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
MainSettings_UserChanged(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainSettings_UserChanged(object sender, EventArgs e)
|
private void MainSettings_UserChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (MainSettings.CurrentUser != null)
|
if (MainSettings.CurrentUser == null)
|
||||||
{
|
{
|
||||||
if (chatHubConnection.Headers.ContainsKey("Bearer"))
|
chatHubConnection.Headers.Clear();
|
||||||
chatHubConnection.Headers.Remove("Bearer");
|
}
|
||||||
chatHubConnection.Headers.Add("Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken);
|
else
|
||||||
|
{
|
||||||
|
var token = MainSettings.CurrentUser.YavscTokens.AccessToken;
|
||||||
|
chatHubConnection.Headers.Add(
|
||||||
|
"Authorization", $"Bearer {token}");
|
||||||
}
|
}
|
||||||
else chatHubConnection.Headers.Remove("Bearer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChatHubConnection_Error(Exception obj)
|
private void ChatHubConnection_Error(Exception obj)
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
<Compile Include="Behaviors\PickerBehavior.cs" />
|
<Compile Include="Behaviors\PickerBehavior.cs" />
|
||||||
<Compile Include="Behaviors\StarBehavior.cs" />
|
<Compile Include="Behaviors\StarBehavior.cs" />
|
||||||
<Compile Include="Constants.cs" />
|
<Compile Include="Constants.cs" />
|
||||||
|
<Compile Include="Converters\SignalRConnectionStateToObject.cs" />
|
||||||
<Compile Include="Data\LocalState.cs" />
|
<Compile Include="Data\LocalState.cs" />
|
||||||
<Compile Include="Model\Social\Messaging\ChatStatus.cs" />
|
<Compile Include="Model\Social\Messaging\ChatStatus.cs" />
|
||||||
<Compile Include="Model\Social\Messaging\PrivateMessage.cs" />
|
<Compile Include="Model\Social\Messaging\PrivateMessage.cs" />
|
||||||
|
|
@ -376,6 +377,12 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Images\Chat\connected.png" />
|
||||||
|
<EmbeddedResource Include="Images\Chat\connecting.png" />
|
||||||
|
<EmbeddedResource Include="Images\Chat\disconnected.png" />
|
||||||
|
<EmbeddedResource Include="Images\Chat\reconnecting.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
<Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
<Import Project="..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.2.127\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using Xamarin.Forms;
|
||||||
|
|
||||||
namespace BookAStar.Converters
|
namespace BookAStar.Converters
|
||||||
{
|
{
|
||||||
class BooleanToObjectConverter<T> : IValueConverter
|
public class BooleanToObjectConverter<T> : IValueConverter
|
||||||
{
|
{
|
||||||
public T FalseObject { set; get; }
|
public T FalseObject { set; get; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Microsoft.AspNet.SignalR.Client;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace BookAStar.Converters
|
||||||
|
{
|
||||||
|
public class SignalRConnectionStateToObject<T> : IValueConverter
|
||||||
|
{
|
||||||
|
public T ConnectedObject { set; get; }
|
||||||
|
|
||||||
|
public T ConnectingObject { set; get; }
|
||||||
|
|
||||||
|
public T DisconnectedObject { set; get; }
|
||||||
|
|
||||||
|
public T ReconnectingObject { set; get; }
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType,
|
||||||
|
object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
switch ((ConnectionState)value) {
|
||||||
|
case ConnectionState.Connected: return ConnectedObject;
|
||||||
|
case ConnectionState.Connecting: return ConnectingObject;
|
||||||
|
case ConnectionState.Disconnected: return DisconnectedObject;
|
||||||
|
case ConnectionState.Reconnecting: return ReconnectingObject;
|
||||||
|
}
|
||||||
|
Debug.Assert(false);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType,
|
||||||
|
object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal LocalEntity<EditEstimateViewModel, long> EstimationCache { get; set; }
|
internal LocalEntity<EditEstimateViewModel, long> EstimationCache { get; set; }
|
||||||
internal LocalEntity<BillingLine, string> EstimateLinesTemplates { get; set; }
|
internal LocalEntity<BillingLine, string> EstimateLinesTemplates { get; set; }
|
||||||
internal LocalEntity<UserMessage, int> PrivateMessages { get; set; }
|
internal LocalEntity<ChatMessage, int> PrivateMessages { get; set; }
|
||||||
protected static DataManager current ;
|
protected static DataManager current ;
|
||||||
|
|
||||||
public static DataManager Current
|
public static DataManager Current
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
AppState = new LocalEntity<PageState, int>(s => s.Position);
|
AppState = new LocalEntity<PageState, int>(s => s.Position);
|
||||||
EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id);
|
EstimationCache = new LocalEntity<EditEstimateViewModel, long>(e => e.Query.Id);
|
||||||
EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description);
|
EstimateLinesTemplates = new LocalEntity<BillingLine, string>(l => l.Description);
|
||||||
PrivateMessages = new LocalEntity<UserMessage, int>(m=> m.GetHashCode());
|
PrivateMessages = new LocalEntity<ChatMessage, int>(m=> m.GetHashCode());
|
||||||
|
|
||||||
PrivateMessages.Load();
|
PrivateMessages.Load();
|
||||||
BookQueries.Load();
|
BookQueries.Load();
|
||||||
|
|
|
||||||
BIN
BookAStar/BookAStar/Images/Chat/connected.png
Normal file
BIN
BookAStar/BookAStar/Images/Chat/connected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
BIN
BookAStar/BookAStar/Images/Chat/connecting.png
Normal file
BIN
BookAStar/BookAStar/Images/Chat/connecting.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
BookAStar/BookAStar/Images/Chat/disconnected.png
Normal file
BIN
BookAStar/BookAStar/Images/Chat/disconnected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
BookAStar/BookAStar/Images/Chat/reconnecting.png
Normal file
BIN
BookAStar/BookAStar/Images/Chat/reconnecting.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4 KiB |
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BookAStar.Model.Social.Messaging
|
namespace BookAStar.Model.Social.Messaging
|
||||||
{
|
{
|
||||||
public class UserMessage
|
public class ChatMessage
|
||||||
{
|
{
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
public string SenderId { get; set; }
|
public string SenderId { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,20 @@ using XLabs.Platform.Services;
|
||||||
|
|
||||||
namespace BookAStar.Pages
|
namespace BookAStar.Pages
|
||||||
{
|
{
|
||||||
|
using Data;
|
||||||
public partial class BookQueriesPage : ContentPage
|
public partial class BookQueriesPage : ContentPage
|
||||||
{
|
{
|
||||||
public BookQueriesPage()
|
public BookQueriesPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BindingContext = new BookQueriesViewModel();
|
var model = new BookQueriesViewModel();
|
||||||
|
model.RefreshQueries =
|
||||||
|
new Command( () => {
|
||||||
|
DataManager.Current.BookQueries.Execute(null);
|
||||||
|
this.list.EndRefresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
BindingContext = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnViewDetail(object sender, ItemTappedEventArgs e)
|
private void OnViewDetail(object sender, ItemTappedEventArgs e)
|
||||||
|
|
@ -20,18 +27,5 @@ namespace BookAStar.Pages
|
||||||
BookQueryData data = e.Item as BookQueryData;
|
BookQueryData data = e.Item as BookQueryData;
|
||||||
App.NavigationService.NavigateTo<BookQueryPage>(true,data);
|
App.NavigationService.NavigateTo<BookQueryPage>(true,data);
|
||||||
}
|
}
|
||||||
protected override void OnSizeAllocated(double width, double height)
|
|
||||||
{
|
|
||||||
/* TODO find a responsive layout
|
|
||||||
if (width > height)
|
|
||||||
{
|
|
||||||
mainLayout.Orientation = StackOrientation.Horizontal;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mainLayout.Orientation = StackOrientation.Vertical;
|
|
||||||
} */
|
|
||||||
base.OnSizeAllocated(width, height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,78 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="BookAStar.Pages.ChatPage"
|
x:Class="BookAStar.Pages.ChatPage"
|
||||||
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
||||||
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
||||||
xmlns:toolkit="clr-namespace:XLabs.Forms.Mvvm;assembly=XLabs.Forms"
|
xmlns:toolkit="clr-namespace:XLabs.Forms.Mvvm;assembly=XLabs.Forms"
|
||||||
|
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
|
||||||
|
xmlns:local="clr-namespace:BookAStar;Assembly:BookAStar"
|
||||||
|
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<TabbedPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<converters:SignalRConnectionStateToObject x:Key="cxToStyleImage" x:TypeArguments="Style">
|
||||||
|
|
||||||
|
<converters:SignalRConnectionStateToObject.DisconnectedObject>
|
||||||
|
<Style TargetType="Image">
|
||||||
|
<Setter Property="Source"
|
||||||
|
Value="{extensions:ImageResource BookAStar.Images.Chat.disconnected.png}" />
|
||||||
|
</Style>
|
||||||
|
</converters:SignalRConnectionStateToObject.DisconnectedObject>
|
||||||
|
|
||||||
|
<converters:SignalRConnectionStateToObject.ConnectedObject>
|
||||||
|
<Style TargetType="Image">
|
||||||
|
<Setter Property="Source"
|
||||||
|
Value="{extensions:ImageResource BookAStar.Images.Chat.connected.png}" />
|
||||||
|
</Style>
|
||||||
|
</converters:SignalRConnectionStateToObject.ConnectedObject>
|
||||||
|
|
||||||
|
<converters:SignalRConnectionStateToObject.ConnectingObject>
|
||||||
|
<Style TargetType="Image">
|
||||||
|
<Setter Property="Source"
|
||||||
|
Value="{extensions:ImageResource BookAStar.Images.Chat.connecting.png}" />
|
||||||
|
</Style>
|
||||||
|
</converters:SignalRConnectionStateToObject.ConnectingObject>
|
||||||
|
|
||||||
|
<converters:SignalRConnectionStateToObject.ReconnectingObject>
|
||||||
|
<Style TargetType="Image">
|
||||||
|
<Setter Property="Source"
|
||||||
|
Value="{extensions:ImageResource BookAStar.Images.Chat.reconnecting.png}" />
|
||||||
|
</Style>
|
||||||
|
</converters:SignalRConnectionStateToObject.ReconnectingObject>
|
||||||
|
</converters:SignalRConnectionStateToObject>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</TabbedPage.Resources>
|
||||||
<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 Spacing = "12"
|
<StackLayout Spacing = "12"
|
||||||
Orientation = "Horizontal"
|
Orientation = "Horizontal"
|
||||||
Padding="5, 0, 5, 0">
|
Padding="5, 0, 5, 0">
|
||||||
|
<Image
|
||||||
|
x:Name="reconnectImage"
|
||||||
|
Style="{Binding Source={x:Static local:App.ChatHubConnection},
|
||||||
|
Path=State,
|
||||||
|
Converter={StaticResource cxToStyleImage}}" />
|
||||||
<Entry x:Name="messageEntry" Placeholder = "enter your Message"
|
<Entry x:Name="messageEntry" Placeholder = "enter your Message"
|
||||||
VerticalOptions = "Center"
|
VerticalOptions = "Center"
|
||||||
HorizontalOptions = "FillAndExpand"></Entry>
|
HorizontalOptions = "FillAndExpand"></Entry>
|
||||||
<Button x:Name="sendButton" Text = "Send" HorizontalOptions = "End"
|
<Button x:Name="sendButton" Text = "Send" HorizontalOptions = "End"
|
||||||
VerticalOptions = "Center"></Button>
|
VerticalOptions = "Center"></Button>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<ListView x:Name="messageList" HasUnevenRows="true">
|
<ListView x:Name="messageList" HasUnevenRows="true"
|
||||||
|
>
|
||||||
<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" />
|
||||||
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
|
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
|
||||||
<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" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ViewCell.View>
|
</ViewCell.View>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
|
|
@ -36,60 +81,61 @@
|
||||||
</ListView>
|
</ListView>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</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">
|
||||||
<ListView x:Name="notifList" HasUnevenRows="true">
|
<ListView x:Name="notifList" HasUnevenRows="true">
|
||||||
<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" />
|
||||||
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
|
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
|
||||||
<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" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ViewCell.View>
|
</ViewCell.View>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|
||||||
<ContentPage Title="Contacts" Icon="peer_to_peer.png" >
|
<ContentPage Title="Contacts" Icon="peer_to_peer.png" >
|
||||||
<StackLayout Padding="5, 5, 5, 5">
|
<StackLayout Padding="5, 5, 5, 5">
|
||||||
<StackLayout Spacing = "12"
|
<StackLayout Spacing = "12"
|
||||||
Orientation = "Horizontal"
|
Orientation = "Horizontal"
|
||||||
Padding="5, 0, 5, 0">
|
Padding="5, 0, 5, 0">
|
||||||
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
|
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
|
||||||
VerticalOptions = "Center"
|
VerticalOptions = "Center"
|
||||||
HorizontalOptions = "FillAndExpand"></Entry>
|
HorizontalOptions = "FillAndExpand"></Entry>
|
||||||
<!--
|
<!--
|
||||||
<controls:ExtendedPicker x:Name="contactPicker" Display="{Binding UserName}"></controls:ExtendedPicker>
|
<controls:ExtendedPicker x:Name="contactPicker" Display="{Binding UserName}"></controls:ExtendedPicker>
|
||||||
-->
|
-->
|
||||||
<controls:ExtendedPicker x:Name="contactPicker" />
|
<controls:ExtendedPicker x:Name="contactPicker" />
|
||||||
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
|
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
|
||||||
VerticalOptions = "Center"></Button>
|
VerticalOptions = "Center"></Button>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<ListView x:Name="PVList" HasUnevenRows="true">
|
<ListView x:Name="PVList" HasUnevenRows="true">
|
||||||
<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" />
|
||||||
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
|
<Label Text="{Binding SenderId}" FontFamily="monospace" FontAttributes="Italic" />
|
||||||
<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" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ViewCell.View>
|
</ViewCell.View>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
<!-- <views:UserListView ItemsSource="" /> -->
|
<!-- <views:UserListView ItemsSource="" /> -->
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
</TabbedPage.Children>
|
</TabbedPage.Children>
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@ namespace BookAStar.Pages
|
||||||
{
|
{
|
||||||
public partial class ChatPage : TabbedPage
|
public partial class ChatPage : TabbedPage
|
||||||
{
|
{
|
||||||
public ObservableCollection<UserMessage> Messages { get; set; }
|
public ObservableCollection<ChatMessage> Messages { get; set; }
|
||||||
|
public ObservableCollection<ChatMessage> Notifs { get; set; }
|
||||||
public string ChatUser { get; set; }
|
public string ChatUser { get; set; }
|
||||||
|
|
||||||
public ChatPage()
|
public ChatPage()
|
||||||
|
|
@ -28,6 +29,8 @@ namespace BookAStar.Pages
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ConnectionState cs = App.ChatHubConnection.State;
|
||||||
|
|
||||||
await App.CurrentApp.ChatHubProxy.Invoke<string>("Send", ChatUser, messageEntry.Text);
|
await App.CurrentApp.ChatHubProxy.Invoke<string>("Send", ChatUser, messageEntry.Text);
|
||||||
messageEntry.Text = null;
|
messageEntry.Text = null;
|
||||||
}
|
}
|
||||||
|
|
@ -38,19 +41,32 @@ namespace BookAStar.Pages
|
||||||
|
|
||||||
IsBusy = false;
|
IsBusy = false;
|
||||||
};
|
};
|
||||||
// contactPicker.DisplayProperty = "UserName";
|
|
||||||
|
|
||||||
messageList.ItemsSource = Messages = new ObservableCollection<UserMessage>();
|
sendPVButton.Clicked += async (sender, args) =>
|
||||||
PVList.ItemsSource = DataManager.Current.PrivateMessages;
|
{
|
||||||
App.CurrentApp.ChatHubConnection.StateChanged += ChatHubConnection_StateChanged;
|
IsBusy = true;
|
||||||
// DataManager.Current.Contacts
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await App.CurrentApp.ChatHubProxy.Invoke<string>("SendPV", ChatUser, pvEntry.Text);
|
||||||
|
pvEntry.Text = null;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
IsBusy = false;
|
||||||
|
};
|
||||||
|
messageList.ItemsSource = Messages = new ObservableCollection<ChatMessage>();
|
||||||
|
notifList.ItemsSource = Notifs = new ObservableCollection<ChatMessage>();
|
||||||
|
App.ChatHubConnection.StateChanged += ChatHubConnection_StateChanged;
|
||||||
MainSettings.UserChanged += MainSettings_UserChanged;
|
MainSettings.UserChanged += MainSettings_UserChanged;
|
||||||
MainSettings_UserChanged(this, null);
|
MainSettings_UserChanged(this, null);
|
||||||
|
|
||||||
App.CurrentApp.ChatHubProxy.On<string, string>("addMessage", (n, m) =>
|
App.CurrentApp.ChatHubProxy.On<string, string>("addMessage", (n, m) =>
|
||||||
{
|
{
|
||||||
Messages.Add(new UserMessage
|
Messages.Add(new ChatMessage
|
||||||
{
|
{
|
||||||
Message = m,
|
Message = m,
|
||||||
SenderId = n,
|
SenderId = n,
|
||||||
|
|
@ -58,9 +74,9 @@ namespace BookAStar.Pages
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
App.CurrentApp.ChatHubProxy.On<string, string>("addMessage", (n, m) =>
|
App.CurrentApp.ChatHubProxy.On<string, string>("notify", (n, m) =>
|
||||||
{
|
{
|
||||||
Messages.Add(new UserMessage
|
Notifs.Add(new ChatMessage
|
||||||
{
|
{
|
||||||
Message = m,
|
Message = m,
|
||||||
SenderId = n,
|
SenderId = n,
|
||||||
|
|
@ -69,15 +85,25 @@ namespace BookAStar.Pages
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ReconnectButton_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
App.ChatHubConnection.Stop();
|
||||||
|
App.ChatHubConnection.Start();
|
||||||
|
}
|
||||||
|
|
||||||
private void MainSettings_UserChanged(object sender, EventArgs e)
|
private void MainSettings_UserChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ChatUser = MainSettings.UserName;
|
ChatUser = MainSettings.UserName;
|
||||||
contactPicker.ItemsSource = DataManager.Current.Contacts;
|
contactPicker.ItemsSource = DataManager.Current.Contacts;
|
||||||
|
PVList.ItemsSource = DataManager.Current.PrivateMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChatHubConnection_StateChanged(StateChange obj)
|
private void ChatHubConnection_StateChanged(StateChange obj)
|
||||||
{
|
{
|
||||||
sendButton.IsEnabled = obj.NewState == ConnectionState.Connected;
|
Xamarin.Forms.Device.BeginInvokeOnMainThread(
|
||||||
|
() => {
|
||||||
|
sendButton.IsEnabled = obj.NewState == ConnectionState.Connected;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace BookAStar.ViewModels
|
||||||
|
|
||||||
public ICommand RefreshQueries
|
public ICommand RefreshQueries
|
||||||
{
|
{
|
||||||
get { return DataManager.Current.BookQueries; }
|
get; set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue