refactoring
This commit is contained in:
parent
0e3e6f9751
commit
6ddf8892dc
15 changed files with 162 additions and 56 deletions
|
|
@ -9,6 +9,8 @@
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|
||||||
<Color x:Key="PageBackgroundColor">#FFAAAAFF</Color>
|
<Color x:Key="PageBackgroundColor">#FFAAAAFF</Color>
|
||||||
|
<Color x:Key="DashboardPageBackgroundColor">#FFCCCCFF</Color>
|
||||||
|
|
||||||
<Color x:Key="ContentBackgroundColor">#80FFFFFF</Color>
|
<Color x:Key="ContentBackgroundColor">#80FFFFFF</Color>
|
||||||
<Color x:Key="BackgroundColor">#FFFFFFFF</Color>
|
<Color x:Key="BackgroundColor">#FFFFFFFF</Color>
|
||||||
<Color x:Key="LabelBackgroundColor">#FFFFFFFF</Color>
|
<Color x:Key="LabelBackgroundColor">#FFFFFFFF</Color>
|
||||||
|
|
@ -24,7 +26,10 @@
|
||||||
<Color x:Key="OddColor">#207AFAFA</Color>
|
<Color x:Key="OddColor">#207AFAFA</Color>
|
||||||
<Color x:Key="EmphasisTextColor">#800080</Color>
|
<Color x:Key="EmphasisTextColor">#800080</Color>
|
||||||
<Color x:Key="QuietTextColor">#404040</Color>
|
<Color x:Key="QuietTextColor">#404040</Color>
|
||||||
|
<Color x:Key="DisconnectedUserBgColor">#909090</Color>
|
||||||
|
<Color x:Key="ConnectedUserBgColor">#ffffff</Color>
|
||||||
|
|
||||||
|
|
||||||
<OnPlatform x:TypeArguments="Font" Android="Large" iOS="Large" WinPhone="Large" x:Key="HeaderFont" />
|
<OnPlatform x:TypeArguments="Font" Android="Large" iOS="Large" WinPhone="Large" x:Key="HeaderFont" />
|
||||||
<OnPlatform x:TypeArguments="x:Double" Android="22" iOS="22" WinPhone="22" x:Key="LargeFontSize" />
|
<OnPlatform x:TypeArguments="x:Double" Android="22" iOS="22" WinPhone="22" x:Key="LargeFontSize" />
|
||||||
<OnPlatform x:TypeArguments="x:Double" Android="16" iOS="16" WinPhone="16" x:Key="MediumFontSize" />
|
<OnPlatform x:TypeArguments="x:Double" Android="16" iOS="16" WinPhone="16" x:Key="MediumFontSize" />
|
||||||
|
|
@ -90,11 +95,14 @@
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="PageStyle" TargetType="ContentPage">
|
<Style x:Key="PageStyle" TargetType="ContentPage">
|
||||||
<Setter Property="Padding" Value="5,5,5,5" />
|
<Setter Property="Padding" Value="15,15,15,15" />
|
||||||
<Setter Property="BackgroundColor" Value="{StaticResource PageBackgroundColor}" />
|
<Setter Property="BackgroundColor" Value="{StaticResource PageBackgroundColor}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style x:Key="DashboardPageStyle" TargetType="ContentPage">
|
||||||
|
<Setter Property="Padding" Value="10,10,10,10" />
|
||||||
|
<Setter Property="BackgroundColor" Value="{StaticResource DashboardPageBackgroundColor}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
|
@ -357,7 +357,6 @@ namespace BookAStar
|
||||||
msg
|
msg
|
||||||
);
|
);
|
||||||
DataManager.Instance.ChatUsers.OnPrivateMessage(msg);
|
DataManager.Instance.ChatUsers.OnPrivateMessage(msg);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -513,6 +513,9 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Images\Chat\talk.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">
|
||||||
|
|
|
||||||
BIN
BookAStar/BookAStar/Images/Chat/talk.png
Normal file
BIN
BookAStar/BookAStar/Images/Chat/talk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,4 +1,7 @@
|
||||||
using System;
|
using BookAStar.Data;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace BookAStar.Model.Social.Messaging
|
namespace BookAStar.Model.Social.Messaging
|
||||||
{
|
{
|
||||||
|
|
@ -7,5 +10,11 @@ namespace BookAStar.Model.Social.Messaging
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
public string SenderId { get; set; }
|
public string SenderId { get; set; }
|
||||||
public string Message { get; set; }
|
public string Message { get; set; }
|
||||||
|
public bool Read { get; set; }
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool FromMe { get
|
||||||
|
{
|
||||||
|
return App.ChatHubConnection?.ConnectionId == SenderId;
|
||||||
|
} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
|
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
|
||||||
xmlns:local="clr-namespace:BookAStar;Assembly:BookAStar"
|
xmlns:local="clr-namespace:BookAStar;Assembly:BookAStar"
|
||||||
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
|
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
|
||||||
>
|
Style="{StaticResource PageStyle}" >
|
||||||
|
|
||||||
<TabbedPage.Resources>
|
<TabbedPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|
@ -100,18 +100,15 @@
|
||||||
<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">
|
|
||||||
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
|
|
||||||
VerticalOptions = "Center"
|
|
||||||
HorizontalOptions = "FillAndExpand"></Entry>
|
|
||||||
|
|
||||||
|
|
||||||
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
|
|
||||||
VerticalOptions = "Center"></Button>
|
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<!-- <ListView x:Name="PVList" HasUnevenRows="true" ItemsSource="{Binding PVs}">
|
|
||||||
<ListView.ItemTemplate HeightRequest="80"
|
<views:UserListView x:Name="chatUserList" />
|
||||||
|
|
||||||
|
<StackLayout BindingContext="{x:Reference Name=chatUserList}" IsVisible="{Binding HasASelection}">
|
||||||
|
<ListView x:Name="pvList" HasUnevenRows="true" ItemsSource="{Binding SelectedUser.PrivateMessages}" BindingContext="{x:Reference Name=chatUserList}">
|
||||||
|
<ListView.ItemTemplate HeightRequest="80"
|
||||||
VerticalOptions="StartAndExpand">
|
VerticalOptions="StartAndExpand">
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
|
|
@ -126,8 +123,14 @@
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView> -->
|
</ListView>
|
||||||
<views:UserListView x:Name="chatUserList" />
|
|
||||||
|
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
|
||||||
|
VerticalOptions = "Center" HorizontalOptions = "FillAndExpand"></Entry>
|
||||||
|
|
||||||
|
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
|
||||||
|
VerticalOptions = "Center"></Button>
|
||||||
|
</StackLayout>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|
|
||||||
|
|
@ -44,25 +44,29 @@ namespace BookAStar.Pages.Chat
|
||||||
};
|
};
|
||||||
chatUserList.BindingContext = DataManager.Instance.ChatUsers;
|
chatUserList.BindingContext = DataManager.Instance.ChatUsers;
|
||||||
|
|
||||||
/*
|
|
||||||
sendPVButton.Clicked += async (sender, args) =>
|
sendPVButton.Clicked += async (sender, args) =>
|
||||||
{
|
{
|
||||||
string userName = contactPicker.SelectedItem as string;
|
var dest = chatUserList.SelectedUser;
|
||||||
if (string.IsNullOrEmpty(userName)) return;
|
if (dest!=null)
|
||||||
var user = DataManager.Current.Contacts.Single(
|
|
||||||
c => c.UserName == userName);
|
|
||||||
IsBusy = true;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await App.ChatHubProxy.Invoke<string>("SendPV", user.ChatHubConnectionId, pvEntry.Text);
|
IsBusy = true;
|
||||||
pvEntry.Text = null;
|
try
|
||||||
|
{
|
||||||
|
foreach (var cx in dest.ObservableConnections)
|
||||||
|
{
|
||||||
|
if (cx.Connected)
|
||||||
|
await App.ChatHubProxy.Invoke<string>("SendPV", cx.ConnectionId, pvEntry.Text);
|
||||||
|
}
|
||||||
|
pvEntry.Text = null;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(ex);
|
||||||
|
}
|
||||||
|
IsBusy = false;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
};
|
||||||
{
|
|
||||||
Debug.WriteLine(ex);
|
|
||||||
}
|
|
||||||
IsBusy = false;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<ContentPage 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.Chat.PrivateChatPage">
|
x:Class="BookAStar.Pages.Chat.PrivateChatPage"
|
||||||
|
Style="{StaticResource PageStyle}">
|
||||||
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
|
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms"
|
xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms"
|
||||||
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
||||||
x:Class="BookAStar.ViewModels.Signing.Signing">
|
x:Class="BookAStar.ViewModels.Signing.Signing"
|
||||||
|
Style="{StaticResource PageStyle}">
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<views:MarkdownView x:Name="mdView"
|
<views:MarkdownView x:Name="mdView"
|
||||||
Editable="False"
|
Editable="False"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
<ContentPage 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.EstimatesProviderPage">
|
x:Class="BookAStar.Pages.EstimatesProviderPage"
|
||||||
|
Style="{StaticResource PageStyle}">
|
||||||
|
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
|
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="BookAStar.Pages.UserProfile.AccountChooserPage"
|
x:Class="BookAStar.Pages.UserProfile.AccountChooserPage"
|
||||||
Title="{x:Static local:Strings.UserAccounts}" Style="{StaticResource PageStyle}"
|
Title="{x:Static local:Strings.UserAccounts}"
|
||||||
|
Style="{StaticResource PageStyle}"
|
||||||
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
||||||
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms">
|
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
x:Class="BookAStar.Pages.UserProfile.DashboardPage"
|
x:Class="BookAStar.Pages.UserProfile.DashboardPage"
|
||||||
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
||||||
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"
|
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"
|
||||||
Style="{StaticResource PageStyle}">
|
Style="{StaticResource DashboardPageStyle}">
|
||||||
<ContentPage.Resources>
|
<ContentPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<Style TargetType="Label">
|
<Style TargetType="Label">
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,15 @@ namespace BookAStar.Model.Social.Chat
|
||||||
{
|
{
|
||||||
public class ChatUserInfo : ViewModel, IChatUserInfo
|
public class ChatUserInfo : ViewModel, IChatUserInfo
|
||||||
{
|
{
|
||||||
|
public ChatUserInfo()
|
||||||
|
{
|
||||||
|
PrivateMessages.CollectionChanged += PrivateMessages_CollectionChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrivateMessages_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
NotifyPropertyChanged("Unread");
|
||||||
|
}
|
||||||
|
|
||||||
public string avatar;
|
public string avatar;
|
||||||
public string Avatar
|
public string Avatar
|
||||||
|
|
@ -132,7 +141,7 @@ namespace BookAStar.Model.Social.Chat
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObservableCollection<ChatMessage> privateMessages ;
|
ObservableCollection<ChatMessage> privateMessages = new ObservableCollection<ChatMessage>();
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public ObservableCollection<ChatMessage> PrivateMessages
|
public ObservableCollection<ChatMessage> PrivateMessages
|
||||||
{
|
{
|
||||||
|
|
@ -142,6 +151,21 @@ namespace BookAStar.Model.Social.Chat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Unread
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return PrivateMessages==null?false: PrivateMessages.Any(
|
||||||
|
m => !m.Read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ImageSource MessagesBadge
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Unread ? ImageSource.FromResource("BookAStar.Images.Chat.talk.png") :null;
|
||||||
|
}
|
||||||
|
}
|
||||||
public void OnConnected(string cxId)
|
public void OnConnected(string cxId)
|
||||||
{
|
{
|
||||||
// We do assume this cxId dosn't already exist in this list.
|
// We do assume this cxId dosn't already exist in this list.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="BookAStar.Views.UserListView"
|
x:Class="BookAStar.Views.UserListView"
|
||||||
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
||||||
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar">
|
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
|
||||||
|
xmlns:converters="clr-namespace:BookAStar.Converters;assembly=BookAStar"
|
||||||
|
>
|
||||||
<ContentView.Resources>
|
<ContentView.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<Style TargetType="Label">
|
<Style TargetType="Label">
|
||||||
|
|
@ -12,21 +14,45 @@
|
||||||
<Style TargetType="Button">
|
<Style TargetType="Button">
|
||||||
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
|
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<converters:BooleanToObjectConverter x:Key="cxtdToBck" x:TypeArguments="Style">
|
||||||
|
|
||||||
|
<converters:BooleanToObjectConverter.FalseObject>
|
||||||
|
<Style TargetType="StackLayout">
|
||||||
|
<Setter Property="BackgroundColor" Value="{StaticResource DisconnectedUserBgColor}" />
|
||||||
|
</Style>
|
||||||
|
</converters:BooleanToObjectConverter.FalseObject>
|
||||||
|
|
||||||
|
<converters:BooleanToObjectConverter.TrueObject>
|
||||||
|
<Style TargetType="StackLayout">
|
||||||
|
<Setter Property="BackgroundColor" Value="{StaticResource ConnectedUserBgColor}" />
|
||||||
|
</Style>
|
||||||
|
</converters:BooleanToObjectConverter.TrueObject>
|
||||||
|
|
||||||
|
</converters:BooleanToObjectConverter>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ContentView.Resources>
|
</ContentView.Resources>
|
||||||
<ContentView.Content>
|
<ContentView.Content>
|
||||||
<ListView x:Name="list" IsPullToRefreshEnabled="True"
|
<ListView x:Name="list" IsPullToRefreshEnabled="True"
|
||||||
HasUnevenRows="true" RowHeight="80" ItemsSource="{Binding .}"
|
HasUnevenRows="true" RowHeight="80" ItemsSource="{Binding .}"
|
||||||
SeparatorVisibility="Default" SeparatorColor="Black">
|
SeparatorVisibility="Default" SeparatorColor="Black">
|
||||||
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
|
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand" >
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
<ViewCell.View>
|
<ViewCell.View>
|
||||||
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" VerticalOptions="StartAndExpand">
|
<StackLayout
|
||||||
<Image Source="{Binding AvatarSource}" Aspect="AspectFit" />
|
Orientation="Horizontal" Padding="3,3,3,3" VerticalOptions="StartAndExpand">
|
||||||
<Label Text="{Binding UserName}" />
|
<StackLayout Orientation="Horizontal" Padding="5,5,5,5"
|
||||||
|
Style="{Binding IsConnected, Converter={StaticResource cxtdToBck}}" >
|
||||||
|
|
||||||
|
<Image Source="{Binding AvatarSource}" Aspect="AspectFit" />
|
||||||
|
<Image Source="{Binding MessagesBadge}" Aspect="AspectFit" />
|
||||||
|
<Label Text="{Binding UserName}" />
|
||||||
|
</StackLayout>
|
||||||
<Label Text="{Binding RolesAsAString}" TextColor="{StaticResource QuietTextColor}"
|
<Label Text="{Binding RolesAsAString}" TextColor="{StaticResource QuietTextColor}"
|
||||||
FontSize="{StaticResource SmallFontSize}"/>
|
FontSize="{StaticResource SmallFontSize}" />
|
||||||
|
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ViewCell.View>
|
</ViewCell.View>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using BookAStar.Model;
|
using BookAStar.Model;
|
||||||
|
using BookAStar.Model.Social.Chat;
|
||||||
using BookAStar.ViewModels.Messaging;
|
using BookAStar.ViewModels.Messaging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
@ -18,22 +19,36 @@ namespace BookAStar.Views
|
||||||
"ItemsSource", typeof(ChatUserCollection), typeof(UserListView), default(ChatUserCollection),
|
"ItemsSource", typeof(ChatUserCollection), typeof(UserListView), default(ChatUserCollection),
|
||||||
BindingMode.OneWay);
|
BindingMode.OneWay);
|
||||||
|
|
||||||
public BindableProperty ItemSelectedProperty = BindableProperty.Create(
|
public BindableProperty ItemSelectedCommandProperty = BindableProperty.Create(
|
||||||
"ItemSelected", typeof(ICommand), typeof(UserListView), default(ICommand));
|
"ItemSelectedCommand", typeof(ICommand), typeof(UserListView), default(ICommand));
|
||||||
|
|
||||||
public BindableProperty DisableSelectionProperty = BindableProperty.Create(
|
public BindableProperty DisableSelectionProperty = BindableProperty.Create(
|
||||||
"DisableSelection", typeof(bool), typeof(UserListView), false);
|
"DisableSelection", typeof(bool), typeof(UserListView), false);
|
||||||
|
|
||||||
|
public BindableProperty HasASelectionProperty = BindableProperty.Create(
|
||||||
|
"HasASelection", typeof(bool), typeof(UserListView), false);
|
||||||
|
|
||||||
|
public BindableProperty SelectedUserProperty = BindableProperty.Create(
|
||||||
|
"SelectedUser", typeof(ChatUserInfo), typeof(UserListView), default(ChatUserInfo));
|
||||||
|
|
||||||
public ChatUserCollection ItemsSource
|
public ChatUserCollection ItemsSource
|
||||||
{
|
{
|
||||||
get { return (ChatUserCollection) GetValue(ItemsSourceProperty); }
|
get { return (ChatUserCollection) GetValue(ItemsSourceProperty); }
|
||||||
set { SetValue(ItemsSourceProperty, value); }
|
set { SetValue(ItemsSourceProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand ItemSelected
|
public ChatUserInfo SelectedUser
|
||||||
{
|
{
|
||||||
get { return (ICommand) GetValue(ItemSelectedProperty); }
|
get
|
||||||
set { SetValue(ItemSelectedProperty, value); }
|
{
|
||||||
|
return (ChatUserInfo) GetValue(SelectedUserProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand ItemSelectedCommand
|
||||||
|
{
|
||||||
|
get { return (ICommand) GetValue(ItemSelectedCommandProperty); }
|
||||||
|
set { SetValue(ItemSelectedCommandProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisableSelection
|
public bool DisableSelection
|
||||||
|
|
@ -42,12 +57,18 @@ namespace BookAStar.Views
|
||||||
set { SetValue(DisableSelectionProperty, value); }
|
set { SetValue(DisableSelectionProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasASelection
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(HasASelectionProperty); }
|
||||||
|
set { SetValue(HasASelectionProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public UserListView()
|
public UserListView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
list.ItemSelected += OnUserSelected;
|
list.ItemSelected += OnUserSelected;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnBindingContextChanged()
|
protected override void OnBindingContextChanged()
|
||||||
{
|
{
|
||||||
base.OnBindingContextChanged();
|
base.OnBindingContextChanged();
|
||||||
|
|
@ -58,14 +79,19 @@ namespace BookAStar.Views
|
||||||
list.EndRefresh();
|
list.EndRefresh();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUserSelected(object sender, SelectedItemChangedEventArgs ev)
|
public void OnUserSelected(object sender, SelectedItemChangedEventArgs ev)
|
||||||
{
|
{
|
||||||
if (ItemSelected != null)
|
if (ItemSelectedCommand != null)
|
||||||
if (ItemSelected.CanExecute(ev.SelectedItem))
|
if (ItemSelectedCommand.CanExecute(ev.SelectedItem))
|
||||||
{
|
{
|
||||||
ItemSelected.Execute(ev.SelectedItem);
|
ItemSelectedCommand.Execute(ev.SelectedItem);
|
||||||
}
|
}
|
||||||
if (DisableSelection) list.SelectedItem = null;
|
if (DisableSelection)
|
||||||
|
list.SelectedItem = null;
|
||||||
|
SetValue(SelectedUserProperty, list.SelectedItem);
|
||||||
|
HasASelection = list.SelectedItem != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue