Commit 8a85e1f2 authored by Nicolas Jager's avatar Nicolas Jager

Work on Message Text Page

Change-Id: I5c05ff878df38aa83ed73efad65c5c84914a3331
parent e069c41c
......@@ -21,7 +21,7 @@ using namespace Platform::Collections;
namespace RingClientUWP
{
delegate void NewContactSelected(Contact^ contact);
delegate void NewContactSelected();
delegate void NoContactSelected();
namespace ViewModel {
......@@ -55,7 +55,7 @@ internal:
oldItem_ = currentItem_;
currentItem_ = value;
if (value)
newContactSelected(currentItem_);
newContactSelected();
else
noContactSelected();
}
......
......@@ -62,15 +62,24 @@
<Frame x:Name="_smartPanel_"/>
</SplitView.Pane>
<SplitView.Content>
<StackPanel>
<Frame x:Name="_welcomeFrame_"
Visibility="Visible"/>
<Frame x:Name="_messageTextFrame_"
Visibility="Collapsed"/>
<Frame x:Name="_videoFrame_"
Visibility="Collapsed"/>
</StackPanel>
</SplitView.Content>
<Grid x:Name="_navGrid_">
<Grid.RowDefinitions>
<!-- stores the hidden frames. -->
<RowDefinition Height="0"/>
<!-- nesting the showed frame. -->
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Frame x:Name="_welcomeFrame_"
Grid.Row="1"
Visibility="Visible"/>
<Frame x:Name="_messageTextFrame_"
Grid.Row="0"
Visibility="Visible"/>
<Frame x:Name="_videoFrame_"
Grid.Row="0"
Visibility="Visible"/>
</Grid>
</SplitView.Content>
</SplitView>
</SplitView.Content>
</SplitView>
......
......@@ -17,6 +17,8 @@
**************************************************************************/
#include "pch.h"
#include "ContactsViewModel.h"
#include "MessageTextPage.xaml.h"
#include "SmartPanel.xaml.h"
#include "RingConsolePanel.xaml.h"
#include "VideoPage.xaml.h"
......@@ -26,6 +28,7 @@
using namespace RingClientUWP;
using namespace RingClientUWP::Views;
using namespace RingClientUWP::ViewModel;
using namespace Platform;
using namespace Windows::ApplicationModel::Core;
......@@ -54,6 +57,15 @@ MainPage::MainPage()
_smartPanel_->Navigate(TypeName(RingClientUWP::Views::SmartPanel::typeid));
_consolePanel_->Navigate(TypeName(RingClientUWP::Views::RingConsolePanel::typeid));
_videoFrame_->Navigate(TypeName(RingClientUWP::Views::VideoPage::typeid));
_messageTextFrame_->Navigate(TypeName(RingClientUWP::Views::MessageTextPage::typeid));
/* connect to delegates */
ContactsViewModel::instance->newContactSelected += ref new NewContactSelected([&]() {
showFrame(_messageTextFrame_);
});
ContactsViewModel::instance->noContactSelected += ref new NoContactSelected([&]() {
showFrame(_welcomeFrame_);
});
}
void
......@@ -69,3 +81,20 @@ void RingClientUWP::MainPage::_toggleSmartBoxButton__Click(Platform::Object^ sen
{
_innerSplitView_->IsPaneOpen = !_innerSplitView_->IsPaneOpen;
}
void
RingClientUWP::MainPage::showFrame(Windows::UI::Xaml::Controls::Frame^ frame)
{
_navGrid_->SetRow(_welcomeFrame_, 0);
_navGrid_->SetRow(_messageTextFrame_, 0);
_navGrid_->SetRow(_videoFrame_, 0);
if (frame == _welcomeFrame_) {
_navGrid_->SetRow(_welcomeFrame_, 1);
} else if (frame == _videoFrame_) {
_navGrid_->SetRow(_videoFrame_, 1);
} else if (frame == _messageTextFrame_) {
_navGrid_->SetRow(_messageTextFrame_, 1);
dynamic_cast<MessageTextPage^>(_messageTextFrame_->Content)->updatePageContent();
}
}
......@@ -18,6 +18,7 @@
**************************************************************************/
#include "MainPage.g.h"
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Input;
namespace RingClientUWP
......@@ -33,5 +34,6 @@ protected:
virtual void OnKeyDown(KeyRoutedEventArgs^ e) override;
private:
void _toggleSmartBoxButton__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void showFrame(Windows::UI::Xaml::Controls::Frame^ frame);
};
}
\ No newline at end of file
<Page
x:Class="RingClientUWP.Views.MessageTextPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RingClientUWP"
xmlns:ctl="using:RingClientUWP.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<!--<DataTemplate x:Key="MessageTemplate" x:DataType="local:RingInstantMessage">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image x:Name="_contactAvatar_"
Margin="2,2"
Source="ms-appx:///contact-avatar-test.png"
VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock x:Name="_msgContent_" Text="{x:Bind msg_}"/>
</Grid>
</DataTemplate>-->
<!-- barre d'envoi de message -->
<Style TargetType="TextBox">
<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="Background" Value="white" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="Padding" Value="4,4"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border x:Name="BackgroundElement"
Grid.Row="1"
Background="{TemplateBinding Background}"
Margin="{TemplateBinding BorderThickness}"
Opacity="1"
Grid.ColumnSpan="2"
BorderBrush="LightBlue"
BorderThickness="1"
Grid.RowSpan="1"/>
<ScrollViewer x:Name="ContentElement"
Grid.Row="1"
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
IsTabStop="False"
AutomationProperties.AccessibilityView="Raw"
ZoomMode="Disabled" />
<Button x:Name="_sendBtn_"
Background="Transparent"
Grid.Row="1"
FontFamily="Segoe MDL2 Assets"
Foreground="LightBlue"
Content="&#xE122;"
IsTabStop="False"
Grid.Column="1"
Click="_sendBtn__Click"
Visibility="Visible"
MinWidth="34"
FontSize="20"
VerticalAlignment="Stretch"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*"/>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Background="White"
Height="70"
Orientation="Horizontal"
Padding="10,10">
<Image Source="ms-appx:///contact-avatar-test.png" />
<StackPanel>
<TextBlock x:Name="_title_"
Text="[TEXT MISSING]"
TextWrapping="NoWrap"
VerticalAlignment="Center"
FontSize="20"
Margin="20,0" />
</StackPanel>
</StackPanel>
<ScrollViewer BorderThickness="0,1,0,1"
BorderBrush="LightBlue"
Grid.Row="1">
<StackPanel x:Name="_messagesWindowOutput_"
Background="#FFF2F2F2">
</StackPanel>
</ScrollViewer>
<Grid Height="50"
Grid.Row="2"
Margin="0"
Padding="0"
Background="#FFF2F2F2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<TextBox x:Name="_messageTextBox_"
Grid.Column="1"
HorizontalAlignment="Stretch"
TextWrapping="NoWrap"
VerticalAlignment="Center"
Margin="10"
Background="White"
KeyDown="_messageTextBox__KeyDown"/>
</Grid>
</Grid>
</Page>
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "pch.h"
#include "ContactsViewModel.h"
#include "MainPage.xaml.h"
#include "MessageTextPage.xaml.h"
using namespace RingClientUWP::Views;
using namespace RingClientUWP::ViewModel;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Documents;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
MessageTextPage::MessageTextPage()
{
InitializeComponent();
}
void
RingClientUWP::Views::MessageTextPage::OnNavigatedTo(NavigationEventArgs ^ e)
{
updatePageContent();
}
void
RingClientUWP::Views::MessageTextPage::updatePageContent()
{
auto contact = ContactsViewModel::instance->selectedContact;
if (!contact)
return;
_title_->Text = contact->name_;
_messagesWindowOutput_->Children->Clear();
}
void
RingClientUWP::Views::MessageTextPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
sendMessage();
}
void
RingClientUWP::Views::MessageTextPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if (e->Key == Windows::System::VirtualKey::Enter) {
sendMessage();
}
}
void
RingClientUWP::Views::MessageTextPage::sendMessage()
{
auto contact = ContactsViewModel::instance->selectedContact;
auto txt = _messageTextBox_->Text;
/* empty the textbox */
_messageTextBox_->Text = "";
if (!contact || txt->IsEmpty())
return;
}
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include "MessageTextPage.g.h"
namespace RingClientUWP
{
namespace Views
{
public ref class MessageTextPage sealed
{
public:
MessageTextPage();
void updatePageContent();
protected:
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
private:
void _sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
void sendMessage();
};
}
}
......@@ -333,18 +333,19 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox x:Name="_ringTxtBx_"
HorizontalAlignment="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="320"
TextWrapping="Wrap"
TextWrapping="Wrap"
Style="{StaticResource TextBoxStyle1}"
Text=""/>
Text=""/>
<ListBox x:Name="_smartList_"
Grid.Row="1"
Margin="0"
Padding="0"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
SelectionChanged="_smartList__SelectionChanged"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
ItemContainerStyle="{StaticResource contactsListBoxStyle}"
ItemTemplate="{StaticResource ContactTemplate}"/>
</Grid>
......
/**************************************************************************
/***************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
* *
......@@ -146,3 +146,12 @@ void RingClientUWP::Views::SmartPanel::_avatarWebcamCaptureBtn__Click(Platform::
});
}
void
SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
{
auto listbox = safe_cast<ListBox^>(sender);
auto contact = safe_cast<Contact^>(listbox->SelectedItem);
ContactsViewModel::instance->selectedContact = contact;
}
......@@ -50,6 +50,7 @@ private:
void _createAccountYes__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _createAccountNo__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
};
}
}
\ No newline at end of file
......@@ -162,6 +162,9 @@
<ClInclude Include="AccountsViewModel.h" />
<ClInclude Include="Contact.h" />
<ClInclude Include="ContactsViewModel.h" />
<ClInclude Include="MessageTextPage.xaml.h">
<DependentUpon>MessageTextPage.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="pch.h" />
<ClInclude Include="App.xaml.h">
<DependentUpon>App.xaml</DependentUpon>
......@@ -175,6 +178,9 @@
<ClInclude Include="SmartPanel.xaml.h">
<DependentUpon>SmartPanel.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="VideoPage.xaml.h">
<DependentUpon>VideoPage.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="WelcomePage.xaml.h">
<DependentUpon>WelcomePage.xaml</DependentUpon>
</ClInclude>
......@@ -186,9 +192,11 @@
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
</Page>
<Page Include="MessageTextPage.xaml" />
<Page Include="RingConsolePanel.xaml" />
<Page Include="SmartPanel.xaml" />
<Page Include="Styles.xaml" />
<Page Include="VideoPage.xaml" />
<Page Include="WelcomePage.xaml" />
</ItemGroup>
<ItemGroup>
......@@ -241,6 +249,9 @@
<ClCompile Include="MainPage.xaml.cpp">
<DependentUpon>MainPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="MessageTextPage.xaml.cpp">
<DependentUpon>MessageTextPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
......@@ -255,6 +266,9 @@
<ClCompile Include="SmartPanel.xaml.cpp">
<DependentUpon>SmartPanel.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="VideoPage.xaml.cpp">
<DependentUpon>VideoPage.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="WelcomePage.xaml.cpp">
<DependentUpon>WelcomePage.xaml</DependentUpon>
</ClCompile>
......
......@@ -152,6 +152,9 @@
<Page Include="VideoPage.xaml">
<Filter>Views</Filter>
</Page>
<Page Include="MessageTextPage.xaml">
<Filter>Views</Filter>
</Page>
</ItemGroup>
<ItemGroup>
<PRIResource Include="localization\US-en\Resources.resw">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment