Skip to content

Commit

Permalink
Added User List in Chat window
Browse files Browse the repository at this point in the history
  • Loading branch information
svab0ni committed Jun 12, 2017
1 parent deb348c commit 8b2a9cc
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ChatApp/ChatApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
<Compile Include="Dialog\EditTeamDialog.xaml.cs">
<DependentUpon>EditTeamDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Dialog\UserListDialog.xaml.cs">
<DependentUpon>UserListDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Model\Channel.cs" />
<Compile Include="Model\Entity.cs" />
<Compile Include="Model\Message.cs" />
Expand Down Expand Up @@ -187,6 +190,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Dialog\UserListDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\ChatPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
59 changes: 59 additions & 0 deletions ChatApp/Dialog/UserListDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<ContentDialog
x:Class="ChatApp.Dialog.UserListDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ChatApp.Dialog"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="using:Windows.System"
mc:Ignorable="d"
Title="User list"
PrimaryButtonText="Create"
SecondaryButtonText="Cancel"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
SecondaryButtonClick="ContentDialog_SecondaryButtonClick">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<ListView Name ="UserList" Grid.Column="0"
Grid.Row="0" SelectionMode="Single">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<ListViewItemPresenter
ContentTransitions="{TemplateBinding ContentTransitions}"
SelectionCheckMarkVisualEnabled="True"
CheckBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
CheckBoxBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
FocusBorderBrush="{ThemeResource SystemControlForegroundAltHighBrush}"
FocusSecondaryBorderBrush="{ThemeResource SystemControlForegroundBaseHighBrush}"
PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"
PointerOverBackground="{ThemeResource SystemControlHighlightListLowBrush}"
PointerOverForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
SelectedBackground="{ThemeResource SystemControlHighlightListAccentLowBrush}"
SelectedForeground="{ThemeResource SystemControlHighlightAltBaseHighBrush}"
SelectedPointerOverBackground="{ThemeResource SystemControlHighlightListAccentMediumBrush}"
PressedBackground="{ThemeResource SystemControlHighlightListMediumBrush}"
SelectedPressedBackground="{ThemeResource SystemControlHighlightListAccentHighBrush}"
DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}"
DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}"
ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
ContentMargin="{TemplateBinding Padding}"
CheckMode="Inline"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
</ListView>
</Grid>
</ContentDialog>

44 changes: 44 additions & 0 deletions ChatApp/Dialog/UserListDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using ChatApp.Model;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace ChatApp.Dialog
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class UserListDialog : ContentDialog
{
private List<User> Users;

public UserListDialog(List<User> target)
{
InitializeComponent();
UserList.ItemsSource = target;
}

private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
throw new NotImplementedException();
}

private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
Hide();
}
}
}
5 changes: 5 additions & 0 deletions ChatApp/Model/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@ public string Gender
}

public ObservableCollection<Team> Teams { get; set; }

public override string ToString()
{
return this.FirstName + " " + this.LastName;
}
}
}
4 changes: 3 additions & 1 deletion ChatApp/Pages/ChatPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
<AppBarButton Icon="Add" Label="Add new channel" Click="NewChannelButton_Click"/>
<AppBarButton Icon="AddFriend" Label="Add a user"/>
<AppBarButton Icon="BlockContact" Label="Remove a user"/>
<AppBarButton Icon="ContactInfo" Label="User list"/>
<AppBarButton Icon="ContactInfo" Label="User list" Click="UserListButton_Click"/>
</CommandBar.PrimaryCommands>
</CommandBar>
</Page.BottomAppBar>


<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="303*"/>
Expand Down
9 changes: 9 additions & 0 deletions ChatApp/Pages/ChatPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -15,6 +16,7 @@
using ChatApp.Request;
using ChatApp.ViewModel;
using Refit;
using User = ChatApp.Model.User;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

Expand Down Expand Up @@ -195,5 +197,12 @@ private void MessageView_SelectionChanged(object sender, SelectionChangedEventAr
{

}

private async void UserListButton_Click(object sender, RoutedEventArgs e)
{
var item = HttpApi.SelectedTeam.Users.ToList();

await new UserListDialog(item).ShowAsync();
}
}
}

0 comments on commit 8b2a9cc

Please sign in to comment.