refactoring
This commit is contained in:
parent
0e3e6f9751
commit
6ddf8892dc
15 changed files with 162 additions and 56 deletions
|
|
@ -9,6 +9,8 @@
|
|||
<ResourceDictionary>
|
||||
|
||||
<Color x:Key="PageBackgroundColor">#FFAAAAFF</Color>
|
||||
<Color x:Key="DashboardPageBackgroundColor">#FFCCCCFF</Color>
|
||||
|
||||
<Color x:Key="ContentBackgroundColor">#80FFFFFF</Color>
|
||||
<Color x:Key="BackgroundColor">#FFFFFFFF</Color>
|
||||
<Color x:Key="LabelBackgroundColor">#FFFFFFFF</Color>
|
||||
|
|
@ -24,7 +26,10 @@
|
|||
<Color x:Key="OddColor">#207AFAFA</Color>
|
||||
<Color x:Key="EmphasisTextColor">#800080</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="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" />
|
||||
|
|
@ -90,11 +95,14 @@
|
|||
</Style>
|
||||
|
||||
<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}" />
|
||||
</Style>
|
||||
|
||||
|
||||
<Style x:Key="DashboardPageStyle" TargetType="ContentPage">
|
||||
<Setter Property="Padding" Value="10,10,10,10" />
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource DashboardPageBackgroundColor}" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
|
@ -357,7 +357,6 @@ namespace BookAStar
|
|||
msg
|
||||
);
|
||||
DataManager.Instance.ChatUsers.OnPrivateMessage(msg);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -513,6 +513,9 @@
|
|||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Images\Chat\talk.png" />
|
||||
</ItemGroup>
|
||||
<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')" />
|
||||
<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
|
||||
{
|
||||
|
|
@ -7,5 +10,11 @@ namespace BookAStar.Model.Social.Messaging
|
|||
public DateTime Date { get; set; }
|
||||
public string SenderId { 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:local="clr-namespace:BookAStar;Assembly:BookAStar"
|
||||
xmlns:extensions="clr-namespace:BookAStar.Extensions;assembly=BookAStar"
|
||||
>
|
||||
Style="{StaticResource PageStyle}" >
|
||||
|
||||
<TabbedPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
|
@ -100,18 +100,15 @@
|
|||
<ContentPage Title="Contacts" Icon="peer_to_peer.png" >
|
||||
<StackLayout Padding="5, 5, 5, 5">
|
||||
<StackLayout Spacing = "12"
|
||||
Orientation = "Horizontal"
|
||||
Padding="5, 0, 5, 0">
|
||||
<Entry x:Name="pvEntry" Placeholder = "enter your private message"
|
||||
VerticalOptions = "Center"
|
||||
HorizontalOptions = "FillAndExpand"></Entry>
|
||||
|
||||
Orientation = "Horizontal">
|
||||
|
||||
<Button x:Name="sendPVButton" Text = "Send" HorizontalOptions = "End"
|
||||
VerticalOptions = "Center"></Button>
|
||||
</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">
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
|
|
@ -126,8 +123,14 @@
|
|||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView> -->
|
||||
<views:UserListView x:Name="chatUserList" />
|
||||
</ListView>
|
||||
|
||||
<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>
|
||||
|
||||
</ContentPage>
|
||||
|
|
|
|||
|
|
@ -44,25 +44,29 @@ namespace BookAStar.Pages.Chat
|
|||
};
|
||||
chatUserList.BindingContext = DataManager.Instance.ChatUsers;
|
||||
|
||||
/*
|
||||
|
||||
sendPVButton.Clicked += async (sender, args) =>
|
||||
{
|
||||
string userName = contactPicker.SelectedItem as string;
|
||||
if (string.IsNullOrEmpty(userName)) return;
|
||||
var user = DataManager.Current.Contacts.Single(
|
||||
c => c.UserName == userName);
|
||||
IsBusy = true;
|
||||
try
|
||||
var dest = chatUserList.SelectedUser;
|
||||
if (dest!=null)
|
||||
{
|
||||
await App.ChatHubProxy.Invoke<string>("SendPV", user.ChatHubConnectionId, pvEntry.Text);
|
||||
pvEntry.Text = null;
|
||||
IsBusy = true;
|
||||
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" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
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" />
|
||||
</ContentPage>
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms"
|
||||
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
||||
x:Class="BookAStar.ViewModels.Signing.Signing">
|
||||
x:Class="BookAStar.ViewModels.Signing.Signing"
|
||||
Style="{StaticResource PageStyle}">
|
||||
<StackLayout>
|
||||
<views:MarkdownView x:Name="mdView"
|
||||
Editable="False"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="BookAStar.Pages.EstimatesProviderPage">
|
||||
x:Class="BookAStar.Pages.EstimatesProviderPage"
|
||||
Style="{StaticResource PageStyle}">
|
||||
|
||||
<ScrollView>
|
||||
<StackLayout Padding="10,10,10,10" x:Name="mainLayout">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
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:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms">
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
x:Class="BookAStar.Pages.UserProfile.DashboardPage"
|
||||
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
|
||||
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"
|
||||
Style="{StaticResource PageStyle}">
|
||||
Style="{StaticResource DashboardPageStyle}">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="Label">
|
||||
|
|
|
|||
|
|
@ -13,6 +13,15 @@ namespace BookAStar.Model.Social.Chat
|
|||
{
|
||||
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
|
||||
|
|
@ -132,7 +141,7 @@ namespace BookAStar.Model.Social.Chat
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
ObservableCollection<ChatMessage> privateMessages ;
|
||||
ObservableCollection<ChatMessage> privateMessages = new ObservableCollection<ChatMessage>();
|
||||
[JsonIgnore]
|
||||
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)
|
||||
{
|
||||
// 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"
|
||||
x:Class="BookAStar.Views.UserListView"
|
||||
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>
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="Label">
|
||||
|
|
@ -12,21 +14,45 @@
|
|||
<Style TargetType="Button">
|
||||
<Setter Property="Style" Value="{StaticResource ButtonStyle}" />
|
||||
</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>
|
||||
</ContentView.Resources>
|
||||
<ContentView.Content>
|
||||
<ListView x:Name="list" IsPullToRefreshEnabled="True"
|
||||
HasUnevenRows="true" RowHeight="80" ItemsSource="{Binding .}"
|
||||
SeparatorVisibility="Default" SeparatorColor="Black">
|
||||
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand">
|
||||
<ListView.ItemTemplate HeightRequest="80" VerticalOptions="StartAndExpand" >
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<ViewCell.View>
|
||||
<StackLayout Orientation="Horizontal" Padding="10,10,10,10" VerticalOptions="StartAndExpand">
|
||||
<Image Source="{Binding AvatarSource}" Aspect="AspectFit" />
|
||||
<Label Text="{Binding UserName}" />
|
||||
<StackLayout
|
||||
Orientation="Horizontal" Padding="3,3,3,3" VerticalOptions="StartAndExpand">
|
||||
<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}"
|
||||
FontSize="{StaticResource SmallFontSize}"/>
|
||||
FontSize="{StaticResource SmallFontSize}" />
|
||||
|
||||
</StackLayout>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using BookAStar.Model;
|
||||
using BookAStar.Model.Social.Chat;
|
||||
using BookAStar.ViewModels.Messaging;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
|
@ -18,22 +19,36 @@ namespace BookAStar.Views
|
|||
"ItemsSource", typeof(ChatUserCollection), typeof(UserListView), default(ChatUserCollection),
|
||||
BindingMode.OneWay);
|
||||
|
||||
public BindableProperty ItemSelectedProperty = BindableProperty.Create(
|
||||
"ItemSelected", typeof(ICommand), typeof(UserListView), default(ICommand));
|
||||
public BindableProperty ItemSelectedCommandProperty = BindableProperty.Create(
|
||||
"ItemSelectedCommand", typeof(ICommand), typeof(UserListView), default(ICommand));
|
||||
|
||||
public BindableProperty DisableSelectionProperty = BindableProperty.Create(
|
||||
"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
|
||||
{
|
||||
get { return (ChatUserCollection) GetValue(ItemsSourceProperty); }
|
||||
set { SetValue(ItemsSourceProperty, value); }
|
||||
}
|
||||
|
||||
public ICommand ItemSelected
|
||||
|
||||
public ChatUserInfo SelectedUser
|
||||
{
|
||||
get { return (ICommand) GetValue(ItemSelectedProperty); }
|
||||
set { SetValue(ItemSelectedProperty, value); }
|
||||
get
|
||||
{
|
||||
return (ChatUserInfo) GetValue(SelectedUserProperty);
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ItemSelectedCommand
|
||||
{
|
||||
get { return (ICommand) GetValue(ItemSelectedCommandProperty); }
|
||||
set { SetValue(ItemSelectedCommandProperty, value); }
|
||||
}
|
||||
|
||||
public bool DisableSelection
|
||||
|
|
@ -42,12 +57,18 @@ namespace BookAStar.Views
|
|||
set { SetValue(DisableSelectionProperty, value); }
|
||||
}
|
||||
|
||||
public bool HasASelection
|
||||
{
|
||||
get { return (bool)GetValue(HasASelectionProperty); }
|
||||
set { SetValue(HasASelectionProperty, value); }
|
||||
}
|
||||
|
||||
public UserListView()
|
||||
{
|
||||
InitializeComponent();
|
||||
list.ItemSelected += OnUserSelected;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
base.OnBindingContextChanged();
|
||||
|
|
@ -58,14 +79,19 @@ namespace BookAStar.Views
|
|||
list.EndRefresh();
|
||||
});
|
||||
}
|
||||
|
||||
public void OnUserSelected(object sender, SelectedItemChangedEventArgs ev)
|
||||
{
|
||||
if (ItemSelected != null)
|
||||
if (ItemSelected.CanExecute(ev.SelectedItem))
|
||||
if (ItemSelectedCommand != null)
|
||||
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