From 8a85e1f2d073602a8a53f53c4758493613980dfc Mon Sep 17 00:00:00 2001 From: Nicolas Jager Date: Mon, 15 Aug 2016 15:11:06 -0400 Subject: [PATCH] Work on Message Text Page Change-Id: I5c05ff878df38aa83ed73efad65c5c84914a3331 --- ContactsViewModel.h | 4 +- MainPage.xaml | 27 ++++-- MainPage.xaml.cpp | 29 +++++++ MainPage.xaml.h | 2 + MessageTextPage.xaml | 147 ++++++++++++++++++++++++++++++++ MessageTextPage.xaml.cpp | 89 +++++++++++++++++++ MessageTextPage.xaml.h | 41 +++++++++ SmartPanel.xaml | 11 +-- SmartPanel.xaml.cpp | 11 ++- SmartPanel.xaml.h | 1 + ring-client-uwp.vcxproj | 14 +++ ring-client-uwp.vcxproj.filters | 3 + 12 files changed, 362 insertions(+), 17 deletions(-) create mode 100644 MessageTextPage.xaml create mode 100644 MessageTextPage.xaml.cpp create mode 100644 MessageTextPage.xaml.h diff --git a/ContactsViewModel.h b/ContactsViewModel.h index b4757fd..95feadf 100644 --- a/ContactsViewModel.h +++ b/ContactsViewModel.h @@ -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(); } diff --git a/MainPage.xaml b/MainPage.xaml index 2fed2bc..718f292 100644 --- a/MainPage.xaml +++ b/MainPage.xaml @@ -62,15 +62,24 @@ - - - - - - + + + + + + + + + + + + diff --git a/MainPage.xaml.cpp b/MainPage.xaml.cpp index 32f3bbd..d0e1d25 100644 --- a/MainPage.xaml.cpp +++ b/MainPage.xaml.cpp @@ -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(_messageTextFrame_->Content)->updatePageContent(); + } +} diff --git a/MainPage.xaml.h b/MainPage.xaml.h index 868add8..e2a9e0f 100644 --- a/MainPage.xaml.h +++ b/MainPage.xaml.h @@ -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 diff --git a/MessageTextPage.xaml b/MessageTextPage.xaml new file mode 100644 index 0000000..b505878 --- /dev/null +++ b/MessageTextPage.xaml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MessageTextPage.xaml.cpp b/MessageTextPage.xaml.cpp new file mode 100644 index 0000000..c326504 --- /dev/null +++ b/MessageTextPage.xaml.cpp @@ -0,0 +1,89 @@ +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: Jäger Nicolas * +* * +* 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 . * +**************************************************************************/ +#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; + +} diff --git a/MessageTextPage.xaml.h b/MessageTextPage.xaml.h new file mode 100644 index 0000000..ac87884 --- /dev/null +++ b/MessageTextPage.xaml.h @@ -0,0 +1,41 @@ +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: Jäger Nicolas * +* * +* 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 . * +**************************************************************************/ +#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(); +}; +} +} diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 780d6a5..810edb5 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -333,18 +333,19 @@ + Text=""/> diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index 42c8415..f2614f3 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -1,4 +1,4 @@ -/************************************************************************** +/*************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: Jäger Nicolas * * * @@ -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(sender); + auto contact = safe_cast(listbox->SelectedItem); + ContactsViewModel::instance->selectedContact = contact; +} diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index 2ef2cc6..168f340 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -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 diff --git a/ring-client-uwp.vcxproj b/ring-client-uwp.vcxproj index 1b76f4f..ec7a626 100644 --- a/ring-client-uwp.vcxproj +++ b/ring-client-uwp.vcxproj @@ -162,6 +162,9 @@ + + MessageTextPage.xaml + App.xaml @@ -175,6 +178,9 @@ SmartPanel.xaml + + VideoPage.xaml + WelcomePage.xaml @@ -186,9 +192,11 @@ Designer + + @@ -241,6 +249,9 @@ MainPage.xaml + + MessageTextPage.xaml + Create Create @@ -255,6 +266,9 @@ SmartPanel.xaml + + VideoPage.xaml + WelcomePage.xaml diff --git a/ring-client-uwp.vcxproj.filters b/ring-client-uwp.vcxproj.filters index 88b0355..4b8a433 100644 --- a/ring-client-uwp.vcxproj.filters +++ b/ring-client-uwp.vcxproj.filters @@ -152,6 +152,9 @@ Views + + Views + -- GitLab