Commit 4a8cffc6 authored by atraczyk's avatar atraczyk Committed by Andreas Traczyk

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
......@@ -24,6 +24,9 @@ using namespace Platform::Collections;
namespace RingClientUWP
{
delegate void NewAccountSelected();
delegate void NoAccountSelected();
namespace ViewModel {
public ref class AccountsViewModel sealed
{
......@@ -43,6 +46,23 @@ internal:
void clearAccountList();
/* 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
{
Vector<Account^>^ get()
......@@ -52,10 +72,15 @@ internal:
}
/* events */
event NewAccountSelected^ newAccountSelected;
event NoAccountSelected^ noAccountSelected;
private:
AccountsViewModel(); // singleton
Vector<Account^>^ accountsList_;
Account^ currentItem_;
Account^ oldItem_;
};
}
}
/***************************************************************************
* 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> *
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -27,6 +27,8 @@
#include "account_schema.h"
#include "SmartPanel.xaml.h"
using namespace Windows::ApplicationModel::Core;
using namespace Windows::Storage;
using namespace Windows::UI::Core;
......@@ -184,4 +186,4 @@ RingD::dequeueTasks()
}
tasksList_.pop();
}
}
\ No newline at end of file
}
......@@ -181,7 +181,8 @@
Height="80"/>
<StackPanel Grid.Column="1"
VerticalAlignment="Bottom">
<TextBlock Text="TOT fdsfds fdsO"
<TextBlock x:Name="_selectedAccountName_"
Text="default name"
Margin="10"
Style="{StaticResource TextStyle2}"/>
<StackPanel Orientation="Horizontal">
......@@ -224,6 +225,7 @@
</Grid.RowDefinitions>
<ListBox x:Name="_accountsList_"
Grid.Row="0"
SelectionChanged="_accountList__SelectionChanged"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollMode="Enabled"
Width="320"
......
......@@ -41,6 +41,16 @@ SmartPanel::SmartPanel()
_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)
{
_shareMenuButton_->IsChecked = false;
......@@ -151,6 +161,15 @@ SmartPanel::_smartList__SelectionChanged(Platform::Object^ sender, Windows::UI::
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)
{
/* add contact, test purpose but will be reused later in some way */
......@@ -158,4 +177,4 @@ void RingClientUWP::Views::SmartPanel::_ringTxtBx__KeyDown(Platform::Object^ sen
ContactsViewModel::instance->addNewContact(_ringTxtBx_->Text, _ringTxtBx_->Text);
_ringTxtBx_->Text = "";
}
}
}
......@@ -31,6 +31,7 @@ public ref class SmartPanel sealed
{
public:
SmartPanel();
void updatePageContent();
internal:
enum class Mode { Minimized, Normal };
......@@ -51,6 +52,7 @@ private:
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);
void _accountList__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _ringTxtBx__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
};
}
......
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