From 586e3620800caa768e40e2decce33cc81307f008 Mon Sep 17 00:00:00 2001
From: Nicolas Jager <nicolas.jager@savoirfairelinux.com>
Date: Fri, 21 Oct 2016 08:21:11 -0400
Subject: [PATCH] smartpanel : add account type icons

Change-Id: I90d0b543568f268d6c9161de80bdd3df01f7ed68
Tuleap: #1237
---
 Account.cpp                     |   1 +
 Account.h                       |  10 ++++++
 AccountsViewModel.h             |   4 +++
 Assets/AccountTypeRING.png      | Bin 0 -> 1168 bytes
 Assets/AccountTypeSIP.png       | Bin 0 -> 679 bytes
 SmartPanel.xaml                 |  58 ++++++++++++++++++--------------
 SmartPanel.xaml.cpp             |  36 ++++++++++++++++++++
 SmartPanel.xaml.h               |  14 ++++++++
 Styles.xaml                     |  47 ++++++++++++++++++++++++++
 ring-client-uwp.vcxproj         |   2 ++
 ring-client-uwp.vcxproj.filters |   6 ++++
 11 files changed, 153 insertions(+), 25 deletions(-)
 create mode 100644 Assets/AccountTypeRING.png
 create mode 100644 Assets/AccountTypeSIP.png

diff --git a/Account.cpp b/Account.cpp
index 43cd68f..7f1c97d 100644
--- a/Account.cpp
+++ b/Account.cpp
@@ -38,6 +38,7 @@ Account::Account(String^ name,
     accountType_ = accountType;
     accountID_ = accountID;
     _deviceId = deviceId;
+    _isSelected = false;
 }
 
 void
diff --git a/Account.h b/Account.h
index 6f11812..224e1fa 100644
--- a/Account.h
+++ b/Account.h
@@ -45,12 +45,22 @@ public:
             devicesIdList_ = value;
         }
     }
+    property bool _isSelected {
+        void set(bool value) {
+            // isSelected_ = value; disabled on purpose for future use
+            PropertyChanged(this, ref new PropertyChangedEventArgs("_isSelected"));
+        }
+        bool get() {
+            return isSelected_;
+        }
+    }
 
 protected:
     void NotifyPropertyChanged(String^ propertyName);
 
 private:
     Windows::Foundation::Collections::IVector<String^>^ devicesIdList_;
+    bool isSelected_;
 
 };
 }
diff --git a/AccountsViewModel.h b/AccountsViewModel.h
index b4a3e92..5612b10 100644
--- a/AccountsViewModel.h
+++ b/AccountsViewModel.h
@@ -56,7 +56,11 @@ internal:
         void set(Account^ value)
         {
             oldItem_ = currentItem_;
+            if (oldItem_)
+                oldItem_->_isSelected = false;
             currentItem_ = value;
+            if (currentItem_)
+                currentItem_->_isSelected = true;
             if (value)
                 newAccountSelected();
             else
diff --git a/Assets/AccountTypeRING.png b/Assets/AccountTypeRING.png
new file mode 100644
index 0000000000000000000000000000000000000000..7d61ed6e6c47a40dd760dea611313c66983e06b7
GIT binary patch
literal 1168
zcmeAS@N?(olHy`uVBq!ia0y~yV31{CV6fz1V_;x7wN62wfq{W7$=lt9;Xep2*t>i(
z0|NtRfk$L90|U1(2s1Lwnj^u$z`$PO>Fdh=fJ;PBP2D7Wnls3#%#er@=ltB<)VvY~
z5O6L^O)N=GQ7F$W$xv|j^bJVSOJ!$ZVE*Fi;usQf`0WhejF?b~w)w@+)6$IEuDN8i
zCw=I@(6Ci2<d1X5Ro9I>G@2GDh?Is0h;!{)(ZRK7?W1k1D_M1;%DJ3^yN-%DZdiIX
zEs^u@LZ8gVK66v%_`Ew)v!46>kwT;TnJPO9;&ycJyub7L-sg4qEBAlr`EtRT-@75(
z++h+k)BnqJinBzD&xKm4@>)w2vwz@7I8gXtk~&Xgb>rCsbC!HuxpL*36DK-K|8lCR
zs^(592?+ALBtPk!=PuVEg_nw+?kZ1JW2b)ExFmPduic8TzYD*gSQ2t+{x9}Q&-q?e
zPM3BpS)o_vbxC{DHJw%iy_c$<_CKyp-72wp(m78pvyM=e*ePG;EZOH*{Hh_kQP*K}
zJ6pp<wT%oOzgK5YWGmG+eIQf78?gQ9g}ej%J(?9X7~30-_eD()Y~SP;F2(Rs^v3VM
z=XP$Ll$W8!S9ks{iw&0z^Bw**uU%}U7BKzciuscHOJE1jnQL6!b@qMUyL48noZMm)
z@+Wk{m(5G|Ze6`DEPsFaw6EGK>mASTnceW&VNIalR<B>{e*J9zzvwiJDXZujCHD&*
zCQR$rGc9BcZ@e$I^nCf0bk(_2ro=YB()B*&VWpS3ddcj)Y*+S9iab<4{qCf7y3IFK
z=1%=GWeIQZi6$w|IpybKnd-jGUlQ$dVETdW=XPqJv&>d+=6q0?kUTvr<gQe4TG%^}
zYFjS{J`H{6>gK-a+3I)r_dEz)B6!MSo2$4MgR!H4&RTCzsYxX#tXrbIgC>>uT<V@w
zw^DoCs&jP;ns<GTOXmGZ^o;kMHKoMulK7-|AER^H)io>YzwBHR=*fKg)82d6?{U~L
zoMBwvIH%Ze--~U`{fx#3>Ym?e6*as)&xUQqzCX3{?>=u#djICq;r|@mwI|o4q}fmP
zTB^Hsqu0_;znZ$uPCxzpv-Iov@Z$_;&Y$m}ann3)n)&AYXWs-kzct-#zHIsO>r6W%
zbjlVSwLZ5zXl3~<R_@kAZTt4^6K+_faVthg?ESh@weDR$R&(_j)EjO`O^{<Ka|tX7
zUz}hxvqpG>kJ{%FqnS4Iy_Om|3cShknsqkqI>YUTWZj^`*h|rg5_MNnPLw@({qW(#
zBz5)`-`UvNiyaEf%F5DLOU;-u;|BX0{pqLu%{Z1fYJdG2boS?>IkRs1J=j-ab8l00
zPj7GNnKw@rIKKJ#`CXfzT72L_(*f(}QC95{I%NVDGd)zww*Q^3!n2?GTwh<`yGbG0
zhWo#7Tb{hTY35#T8+q4@%eLw1bj6jP+xv|7=KX7nV(O%K+&yz|{>+(@U5j3v+qNW8
zLXOd|HF3vw*-WFEdpK$y&G8O-fAsOk%Tv8lwLd&KaKJ&0=kVf5cG^?D+N-;6IP=?@
a9F6Z@J%@SDgwi9Rg2B_(&t;ucLK6T-O&HAp

literal 0
HcmV?d00001

diff --git a/Assets/AccountTypeSIP.png b/Assets/AccountTypeSIP.png
new file mode 100644
index 0000000000000000000000000000000000000000..21464eaf7193e5d8a8172de53afb32b382e8dea6
GIT binary patch
literal 679
zcmeAS@N?(olHy`uVBq!ia0y~yV31{CV6fz1V_;x7wN62wfq{W7$=lt9;Xep2*t>i(
z0|NtRfk$L90|U1(2s1Lwnj^u$z`$PO>Fdh=fJ;PB$IvR^^bC+unIRD+&iT2ysd*&~
zAmCh-npl#WqEMb$lA+-4=^K!um&(q-z{Kt8;usQf`0e!b*;gDyj^AJBy(>0CaAH!V
zrW|)u)y2h^>=(vWeN}RD{jwrLF<{RR`HFW-AN40MbV_`=wLNZ+YhvnMTM@SDYi8$6
zs=WWvsBwc@?#&dN6E%qmpVCgWPyc!DaqEdwr%s*H@^|VmYw%~NVX!{@u;8M`h0iwZ
z4YOq34l-;Do)DzPeXl%rdm7g-W!7bvE(mKr-Mi`idhsLExgY5=?Dt94+B7rGZhiJA
zAO4~R)oyoBpYi`}#C!O|EW;NWCc8o&#BEMUyZ7t)gPg__hF9VrSoGz4YF_uc|5(NI
z-8^=l18cVw8Gb&NnZQu(=A~wAZ_hkO{Qk;A5z>_tY+l-44Oyq+`ECyDxi$4`u3SCy
z$LhVzW@nCz>;8EC+*dzy=KPnFG#QRCR55I`Jztz7osydRRbGRmiLc@Nt}}BPDx6)G
zObI&kM``YBCwb-{T1#sT@;CdsxSUP<Y%I9eC9uSrqe<FjOTdLq`($|7#5-R&?~S|P
zyC`F;&wp#S4`pU{voo#4owj`a{CKCa>Y`YsszYb^&tERMnzgmW-=cik-MsHi#`~E*
zNFNB4Id0x<^!95N_pY@c)hD04s>QRFCqceJzU`q`<3u5b<3Xo>PqnPHk&C~$;p`$~
z-QTNcNWHvUVzu|)`|q>YhGoY(@0;qopzzkBpjXQuTeQ#hOYiL1$6RqG!(^Yv(j39f
en>MYAt7ni22`*PTF1!hpUOZj>T-G@yGywoat0%bt

literal 0
HcmV?d00001

diff --git a/SmartPanel.xaml b/SmartPanel.xaml
index 0ac9e7b..213c138 100644
--- a/SmartPanel.xaml
+++ b/SmartPanel.xaml
@@ -32,6 +32,8 @@
         <views:IncomingVisibility x:Key="_IncomingVisibility_" />
         <views:OutGoingVisibility x:Key="_OutGoingVisibility_" />
         <views:HasAnActiveCall x:Key="_HasAnActiveCall_" />
+        <views:AccountTypeToSourceImage x:Key="_AccountTypeToSourceImage_" />
+        <views:AccountSelectedToVisibility x:Key="_AccountSelectedToVisibility_" />
 
         <Style x:Key="addContactTextBoxStyle"
            TargetType="TextBox">
@@ -171,36 +173,42 @@
         <!-- template for accounts. -->
         <DataTemplate x:Key="AccountTemplate"
                       x:DataType="local:Account">
-            <Grid>
+            <Grid Margin="0,10">
                 <Grid.ColumnDefinitions>
-                    <ColumnDefinition Width="260"/>
-                    <ColumnDefinition Width="60"/>
+                    <ColumnDefinition Width="40"/>
+                    <ColumnDefinition Width="290"/>
                 </Grid.ColumnDefinitions>
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="30"/>
-                    <RowDefinition Height="30"/>
-                </Grid.RowDefinitions>
-                <TextBlock x:Name="_accountName_"
-                           Grid.Column="0"
-                           Grid.Row="0"
-                           Margin="10,5,10,0"
+                <Border Grid.Column="0"
+                        Margin="5,0"
+                        Style="{StaticResource BorderStyle3}">
+                    <Image x:Name="_AccountTypeIcon_"
+                           VerticalAlignment="Center"
+                           HorizontalAlignment="Center"
+                           Source="{x:Bind accountType_, Converter={StaticResource _AccountTypeToSourceImage_}, Mode=OneWay}"/>
+                </Border>
+                <Button x:Name="_editAccountMenuButton_"
+                        HorizontalAlignment="Right"
+                        VerticalAlignment="Top"
+                        Content="&#xE104;"
+                        FontFamily="Segoe MDL2 Assets"
+                        FontSize="20"
+                        Foreground="White"
+                        Background="Transparent"
+                        Visibility="{x:Bind _isSelected, Converter={StaticResource _AccountSelectedToVisibility_}, Mode=OneWay}"
+                        Grid.Column="1">
+                    <Button.RenderTransform>
+                        <TranslateTransform X="-5" Y="-5"/>
+                    </Button.RenderTransform>
+                </Button>
+                <StackPanel Grid.Column="1">
+                    <TextBlock x:Name="_accountName_"
+                           Style="{StaticResource TextStyle5}"
                            Text="{x:Bind name_}"/>
-                <TextBlock x:Name="_accountType_"
-                           Grid.Column="1"
-                           Grid.Row="0"
-                           TextAlignment="Right"
-                           Margin="0,5,18,0"
-                           Foreground="ForestGreen"
-                           Text="{x:Bind accountType_}"/>
-                <TextBlock x:Name="_ringID_"
-                           Grid.Column="0"
+                    <TextBlock x:Name="_ringID_"
                            Grid.ColumnSpan="2"
-                           Grid.Row="1"
-                           Foreground="Crimson"
-                           Margin="10,5,10,0"
-                           FontSize="14"
-                           TextTrimming="CharacterEllipsis"
+                           Style="{StaticResource TextStyle6}"
                            Text="{x:Bind ringID_}"/>
+                </StackPanel>
             </Grid>
         </DataTemplate>
         <!-- template for smartpanelitems. -->
diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp
index bee9236..2af5527 100644
--- a/SmartPanel.xaml.cpp
+++ b/SmartPanel.xaml.cpp
@@ -667,3 +667,39 @@ void RingClientUWP::Views::SmartPanel::_shareMenuDone__Click(Platform::Object^ s
 
     _shareMenuGrid_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
 }
+
+Object ^ RingClientUWP::Views::AccountTypeToSourceImage::Convert(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language)
+{
+    auto accountType = dynamic_cast<String^>(value);
+    Uri^ uri = (accountType == "RING")
+               ? ref new Uri("ms-appx:///Assets/AccountTypeRING.png")
+               : ref new Uri("ms-appx:///Assets/AccountTypeSIP.png");
+
+    return ref new BitmapImage(uri);
+}
+
+Object ^ RingClientUWP::Views::AccountTypeToSourceImage::ConvertBack(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language)
+{
+    throw ref new Platform::NotImplementedException();
+}
+
+RingClientUWP::Views::AccountTypeToSourceImage::AccountTypeToSourceImage()
+{}
+
+Object ^ RingClientUWP::Views::AccountSelectedToVisibility::Convert(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language)
+{
+    //auto accountId = static_cast<bool(value);
+
+    if (/*AccountsViewModel::instance->selectedAccount->_isSelected ==*/ (bool)value == true)
+        return Windows::UI::Xaml::Visibility::Visible;
+
+    return Windows::UI::Xaml::Visibility::Collapsed;
+}
+
+Object ^ RingClientUWP::Views::AccountSelectedToVisibility::ConvertBack(Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object ^ parameter, String ^ language)
+{
+    throw ref new Platform::NotImplementedException();
+}
+
+RingClientUWP::Views::AccountSelectedToVisibility::AccountSelectedToVisibility()
+{}
diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h
index 74d8bcb..84b38f7 100644
--- a/SmartPanel.xaml.h
+++ b/SmartPanel.xaml.h
@@ -50,6 +50,20 @@ public:
     HasAnActiveCall();
 };
 
+public ref class AccountTypeToSourceImage sealed : IValueConverter {
+public:
+    virtual Object^ Convert(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
+    virtual Object^ ConvertBack(Object^ value, Windows::UI::Xaml::Interop::TypeName  targetType, Object^ parameter, String^ language);
+    AccountTypeToSourceImage();
+};
+
+public ref class AccountSelectedToVisibility sealed : IValueConverter {
+public:
+    virtual Object^ Convert(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
+    virtual Object^ ConvertBack(Object^ value, Windows::UI::Xaml::Interop::TypeName  targetType, Object^ parameter, String^ language);
+    AccountSelectedToVisibility();
+};
+
 public ref class NewMessageBubleNotification sealed : IValueConverter {
 public:
     virtual Object^ Convert(Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Object^ parameter, String^ language);
diff --git a/Styles.xaml b/Styles.xaml
index aa8e173..8f43934 100644
--- a/Styles.xaml
+++ b/Styles.xaml
@@ -67,6 +67,30 @@
         <Setter Property="Foreground"
                 Value="Black"/>
     </Style>
+    <Style x:Key="TextStyle5"
+           TargetType="TextBlock">
+        <Setter Property="FontSize"
+                Value="15"/>
+        <Setter Property="HorizontalAlignment"
+                Value="Left"/>
+        <Setter Property="VerticalAlignment"
+                Value="Center"/>
+        <Setter Property="FontStyle"
+                Value="Italic"/>
+        <Setter Property="Foreground"
+                Value="Black"/>
+    </Style>
+    <Style x:Key="TextStyle6"
+           TargetType="TextBlock">
+        <Setter Property="FontSize"
+                Value="12"/>
+        <Setter Property="HorizontalAlignment"
+                Value="Left"/>
+        <Setter Property="VerticalAlignment"
+                Value="Center"/>
+        <Setter Property="Foreground"
+                Value="Black"/>
+    </Style>
     <Style x:Key="TextSegoeStyle1"
            TargetType="TextBlock">
         <Setter Property="FontFamily"
@@ -165,6 +189,19 @@
         <Setter Property="Background"
             Value="Transparent"/>
     </Style>
+    <Style x:Key="ButtonStyle7"
+        TargetType="Button">
+        <Setter Property="Width"
+            Value="20"/>
+        <Setter Property="Height"
+            Value="20"/>
+        <Setter Property="FontFamily"
+            Value="Segoe MDL2 Assets"/>
+        <Setter Property="Foreground"
+            Value="White"/>
+        <Setter Property="Background"
+            Value="Transparent"/>
+    </Style>
     <Style x:Key="ToggleButtonStyle1"
            TargetType="ToggleButton">
         <Setter Property="Width"
@@ -279,6 +316,16 @@
         <Setter Property="Height" Value="23"/>
         <Setter Property="Padding" Value="4"/>
     </Style>
+    <Style x:Key="BorderStyle3"
+           TargetType="Border">
+        <Setter Property="Background" Value="LightBlue"/>
+        <Setter Property="CornerRadius" Value="6"/>
+        <Setter Property="Width" Value="28"/>
+        <Setter Property="Height" Value="50"/>
+        <Setter Property="BorderThickness" Value="2"/>
+        <Setter Property="BorderBrush" Value="white"/>
+        <Setter Property="Padding" Value="4"/>
+    </Style>
     <Style x:Key="messageBubleStyle"
        TargetType="ListBoxItem">
         <Setter Property="HorizontalAlignment" Value="Stretch" />
diff --git a/ring-client-uwp.vcxproj b/ring-client-uwp.vcxproj
index f40930b..2c4350a 100644
--- a/ring-client-uwp.vcxproj
+++ b/ring-client-uwp.vcxproj
@@ -262,6 +262,8 @@
     <None Include="ring-client-uwp_TemporaryKey.pfx" />
   </ItemGroup>
   <ItemGroup>
+    <Image Include="Assets\AccountTypeRING.png" />
+    <Image Include="Assets\AccountTypeSIP.png" />
     <Image Include="Assets\LockScreenLogo.scale-200.png" />
     <Image Include="Assets\qrCodeIcon.png" />
     <Image Include="Assets\SplashScreen.scale-200.png" />
diff --git a/ring-client-uwp.vcxproj.filters b/ring-client-uwp.vcxproj.filters
index ff41035..e06ba95 100644
--- a/ring-client-uwp.vcxproj.filters
+++ b/ring-client-uwp.vcxproj.filters
@@ -217,6 +217,12 @@
     <Image Include="Assets\qrCodeIcon.png">
       <Filter>Assets</Filter>
     </Image>
+    <Image Include="Assets\AccountTypeSIP.png">
+      <Filter>Assets\TESTS</Filter>
+    </Image>
+    <Image Include="Assets\AccountTypeRING.png">
+      <Filter>Assets\TESTS</Filter>
+    </Image>
   </ItemGroup>
   <ItemGroup>
     <AppxManifest Include="Package.appxmanifest" />
-- 
GitLab