Skip to content
Snippets Groups Projects
Commit 4a8cffc6 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Andreas Traczyk
Browse files

account: change account name title upon account selection

- changes smart panel account title when an account has
  been selected from the account list

Change-Id: I94172f8e991d783ef3460b11c9cfea9e83038e6d
Tuleap: #964
parent 8ce1dee5
Branches
No related tags found
No related merge requests found
...@@ -24,6 +24,9 @@ using namespace Platform::Collections; ...@@ -24,6 +24,9 @@ using namespace Platform::Collections;
namespace RingClientUWP namespace RingClientUWP
{ {
delegate void NewAccountSelected();
delegate void NoAccountSelected();
namespace ViewModel { namespace ViewModel {
public ref class AccountsViewModel sealed public ref class AccountsViewModel sealed
{ {
...@@ -43,6 +46,23 @@ internal: ...@@ -43,6 +46,23 @@ internal:
void clearAccountList(); void clearAccountList();
/* properties */ /* properties */
property Account^ selectedAccount
{
Account^ get()
{
return currentItem_;
}
void set(Account^ value)
{
oldItem_ = currentItem_;
currentItem_ = value;
if (value)
newAccountSelected();
else
noAccountSelected();
}
}
property Vector<Account^>^ accountsList property Vector<Account^>^ accountsList
{ {
Vector<Account^>^ get() Vector<Account^>^ get()
...@@ -52,10 +72,15 @@ internal: ...@@ -52,10 +72,15 @@ internal:
} }
/* events */ /* events */
event NewAccountSelected^ newAccountSelected;
event NoAccountSelected^ noAccountSelected;
private: private:
AccountsViewModel(); // singleton AccountsViewModel(); // singleton
Vector<Account^>^ accountsList_; Vector<Account^>^ accountsList_;
Account^ currentItem_;
Account^ oldItem_;
}; };
} }
} }
/*************************************************************************** /***************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux * * Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> * * Author: Jger Nicolas <nicolas.jager@savoirfairelinux.com> *
* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * * Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "account_schema.h" #include "account_schema.h"
#include "SmartPanel.xaml.h"
using namespace Windows::ApplicationModel::Core; using namespace Windows::ApplicationModel::Core;
using namespace Windows::Storage; using namespace Windows::Storage;
using namespace Windows::UI::Core; using namespace Windows::UI::Core;
......
...@@ -181,7 +181,8 @@ ...@@ -181,7 +181,8 @@
Height="80"/> Height="80"/>
<StackPanel Grid.Column="1" <StackPanel Grid.Column="1"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<TextBlock Text="TOT fdsfds fdsO" <TextBlock x:Name="_selectedAccountName_"
Text="default name"
Margin="10" Margin="10"
Style="{StaticResource TextStyle2}"/> Style="{StaticResource TextStyle2}"/>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
...@@ -224,6 +225,7 @@ ...@@ -224,6 +225,7 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListBox x:Name="_accountsList_" <ListBox x:Name="_accountsList_"
Grid.Row="0" Grid.Row="0"
SelectionChanged="_accountList__SelectionChanged"
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled" ScrollViewer.HorizontalScrollMode="Enabled"
Width="320" Width="320"
......
...@@ -41,6 +41,16 @@ SmartPanel::SmartPanel() ...@@ -41,6 +41,16 @@ SmartPanel::SmartPanel()
_smartList_->ItemsSource = ContactsViewModel::instance->contactsList; _smartList_->ItemsSource = ContactsViewModel::instance->contactsList;
} }
void
RingClientUWP::Views::SmartPanel::updatePageContent()
{
auto account = AccountsViewModel::instance->selectedAccount;
if (!account)
return;
_selectedAccountName_->Text = account->name_;
}
void RingClientUWP::Views::SmartPanel::_accountsMenuButton__Checked(Object^ sender, RoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_accountsMenuButton__Checked(Object^ sender, RoutedEventArgs^ e)
{ {
_shareMenuButton_->IsChecked = false; _shareMenuButton_->IsChecked = false;
...@@ -151,6 +161,15 @@ SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI:: ...@@ -151,6 +161,15 @@ SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::
ContactsViewModel::instance->selectedContact = contact; ContactsViewModel::instance->selectedContact = contact;
} }
void
SmartPanel::_accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
{
auto listbox = safe_cast<ListBox^>(sender);
auto account = safe_cast<Account^>(listbox->SelectedItem);
AccountsViewModel::instance->selectedAccount = account;
updatePageContent();
}
void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{ {
/* add contact, test purpose but will be reused later in some way */ /* add contact, test purpose but will be reused later in some way */
......
...@@ -31,6 +31,7 @@ public ref class SmartPanel sealed ...@@ -31,6 +31,7 @@ public ref class SmartPanel sealed
{ {
public: public:
SmartPanel(); SmartPanel();
void updatePageContent();
internal: internal:
enum class Mode { Minimized, Normal }; enum class Mode { Minimized, Normal };
...@@ -51,6 +52,7 @@ private: ...@@ -51,6 +52,7 @@ private:
void _createAccountNo__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 _avatarWebcamCaptureBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); void _smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e); void _ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment