From 325c88018cfab0d32b4ee8aaa0cbe9e44c57759a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 14 Jun 2019 08:45:28 -0400 Subject: [PATCH] more menu for ios --- src/App/Pages/Vault/AddEditPage.xaml | 41 +++++++++++--------- src/App/Pages/Vault/AddEditPage.xaml.cs | 48 +++++++++++++++++++++--- src/App/Pages/Vault/ViewPage.xaml | 17 +++++---- src/App/Pages/Vault/ViewPage.xaml.cs | 46 ++++++++++++++++++++--- src/iOS/Resources/more.png | Bin 0 -> 145 bytes src/iOS/Resources/more@2x.png | Bin 0 -> 348 bytes src/iOS/Resources/more@3x.png | Bin 0 -> 555 bytes src/iOS/Resources/more_vert.png | Bin 0 -> 164 bytes src/iOS/Resources/more_vert@2x.png | Bin 0 -> 242 bytes src/iOS/Resources/more_vert@3x.png | Bin 0 -> 338 bytes src/iOS/iOS.csproj | 18 +++++++++ 11 files changed, 135 insertions(+), 35 deletions(-) create mode 100644 src/iOS/Resources/more.png create mode 100644 src/iOS/Resources/more@2x.png create mode 100644 src/iOS/Resources/more@3x.png create mode 100644 src/iOS/Resources/more_vert.png create mode 100644 src/iOS/Resources/more_vert@2x.png create mode 100644 src/iOS/Resources/more_vert@3x.png diff --git a/src/App/Pages/Vault/AddEditPage.xaml b/src/App/Pages/Vault/AddEditPage.xaml index f89ce6d2d..ac4193031 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml +++ b/src/App/Pages/Vault/AddEditPage.xaml @@ -15,17 +15,7 @@ - - - @@ -33,16 +23,31 @@ + + x:Key="collectionsItem" + x:Name="_collectionsItem" + Clicked="Collections_Clicked" + Order="Secondary" /> + x:Key="shareItem" + x:Name="_shareItem" + Clicked="Share_Clicked" + Order="Secondary" /> + + + diff --git a/src/App/Pages/Vault/AddEditPage.xaml.cs b/src/App/Pages/Vault/AddEditPage.xaml.cs index 0ebcb73b7..e7f27ec99 100644 --- a/src/App/Pages/Vault/AddEditPage.xaml.cs +++ b/src/App/Pages/Vault/AddEditPage.xaml.cs @@ -46,14 +46,15 @@ namespace Bit.App.Pages _vm.DefaultUri = uri ?? appOptions?.Uri; _vm.Init(); SetActivityIndicator(); - if(!_vm.EditMode || Device.RuntimePlatform == Device.iOS) + if(_vm.EditMode && Device.RuntimePlatform == Device.Android) { - ToolbarItems.Remove(_attachmentsItem); - ToolbarItems.Remove(_deleteItem); + ToolbarItems.Add(_attachmentsItem); + ToolbarItems.Add(_deleteItem); } - if(Device.RuntimePlatform == Device.Android) + if(Device.RuntimePlatform == Device.iOS) { - ToolbarItems.RemoveAt(0); + ToolbarItems.Add(_closeItem); + ToolbarItems.Add(_moreItem); } _typePicker.ItemDisplayBinding = new Binding("Key"); @@ -237,6 +238,43 @@ namespace Bit.App.Pages } } + private async void More_Clicked(object sender, System.EventArgs e) + { + if(!DoOnce()) + { + return; + } + var options = new List { AppResources.Attachments }; + if(_vm.EditMode) + { + options.Add(_vm.Cipher.OrganizationId != null ? AppResources.Share : AppResources.Collections); + } + var selection = await DisplayActionSheet(AppResources.Options, AppResources.Cancel, + _vm.EditMode ? AppResources.Delete : null, options.ToArray()); + if(selection == AppResources.Delete) + { + if(await _vm.DeleteAsync()) + { + await Navigation.PopModalAsync(); + } + } + else if(selection == AppResources.Attachments) + { + var page = new AttachmentsPage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + else if(selection == AppResources.Collections) + { + var page = new CollectionsPage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + else if(selection == AppResources.Share) + { + var page = new SharePage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + } + private async void Close_Clicked(object sender, System.EventArgs e) { if(DoOnce()) diff --git a/src/App/Pages/Vault/ViewPage.xaml b/src/App/Pages/Vault/ViewPage.xaml index d26b7dac0..92017518d 100644 --- a/src/App/Pages/Vault/ViewPage.xaml +++ b/src/App/Pages/Vault/ViewPage.xaml @@ -16,13 +16,6 @@ - - - - - - - @@ -38,6 +31,16 @@ x:Name="_shareItem" Clicked="Share_Clicked" Order="Secondary" /> + + + + + diff --git a/src/App/Pages/Vault/ViewPage.xaml.cs b/src/App/Pages/Vault/ViewPage.xaml.cs index 4640ed368..c285f1c89 100644 --- a/src/App/Pages/Vault/ViewPage.xaml.cs +++ b/src/App/Pages/Vault/ViewPage.xaml.cs @@ -1,4 +1,5 @@ -using Bit.Core.Abstractions; +using Bit.App.Resources; +using Bit.Core.Abstractions; using Bit.Core.Utilities; using System.Collections.Generic; using System.Threading.Tasks; @@ -25,15 +26,16 @@ namespace Bit.App.Pages if(Device.RuntimePlatform == Device.iOS) { _absLayout.Children.Remove(_fab); - ToolbarItems.RemoveAt(2); - ToolbarItems.RemoveAt(2); + ToolbarItems.Add(_closeItem); + ToolbarItems.Add(_editItem); + ToolbarItems.Add(_moreItem); } else { - ToolbarItems.RemoveAt(0); - ToolbarItems.RemoveAt(0); _fab.Clicked = EditButton_Clicked; _mainLayout.Padding = new Thickness(0, 0, 0, 75); + ToolbarItems.Add(_attachmentsItem); + ToolbarItems.Add(_deleteItem); } } @@ -145,6 +147,40 @@ namespace Bit.App.Pages } } + private async void More_Clicked(object sender, System.EventArgs e) + { + if(!DoOnce()) + { + return; + } + var options = new List { AppResources.Attachments }; + options.Add(_vm.Cipher.OrganizationId != null ? AppResources.Share : AppResources.Collections); + var selection = await DisplayActionSheet(AppResources.Options, AppResources.Cancel, + AppResources.Delete, options.ToArray()); + if(selection == AppResources.Delete) + { + if(await _vm.DeleteAsync()) + { + await Navigation.PopModalAsync(); + } + } + else if(selection == AppResources.Attachments) + { + var page = new AttachmentsPage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + else if(selection == AppResources.Collections) + { + var page = new CollectionsPage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + else if(selection == AppResources.Share) + { + var page = new SharePage(_vm.CipherId); + await Navigation.PushModalAsync(new NavigationPage(page)); + } + } + private async void Close_Clicked(object sender, System.EventArgs e) { if(DoOnce()) diff --git a/src/iOS/Resources/more.png b/src/iOS/Resources/more.png new file mode 100644 index 0000000000000000000000000000000000000000..c54bb2da03cd4615bd649675abe6cf948c333d2d GIT binary patch literal 145 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh-3?!F4n4AKnBm#UwT!Hj|Y(TkgZah$qy(Gvl zn1NAMd+PNErHxg*Kp{m>7sn8e=;VY2Tmi)?30{H>fe(-Jta-|&z;)2+L=Y V&eE-)rvVi+c)I$ztaD0e0swo_G^+pr literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/more@2x.png b/src/iOS/Resources/more@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0b5b032612298a522a4de0bda1dff2017c48e273 GIT binary patch literal 348 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`ZiUNE>T!Hj|`hvI!$0I;nRZD{W zf*BZ@SUII+WaV`AjLa;8Lc-E2DjS-byH~7Qy>`p-6X!49di3)3Gd*8PpoS7p7sn8b z({Crab2T{dxbE-U`~9Bm`+8T&#Y&G3F`tQkTI=MY(BQ%}` zd5!Ob`I?UpeOkRz)J!X*Z`o6y=EG*aKI+8>R|aUFJHcbruk*|NW%lw%dxh7`DnIvm lmtswf`B}}$@(Mps^DUal{~_>}R|e3222WQ%mvv4FO#lJH%TWLT literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/more@3x.png b/src/iOS/Resources/more@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..d587310ba893fa5207525da7df6d1a83578b8362 GIT binary patch literal 555 zcmeAS@N?(olHy`uVBq!ia0vp^W+2SL3?z5Yp7kC`oe%H{aRt)R$Es zGfs_v{+lzh&SBG1sc`hL^EY?*(@|$s;Ar}xy6;tz{kfa2FQ+X3wdaB0QeDdnVY(+z zd=%boRLbeTmUkuV*-Q7#RlMUjeXlsZCfzP<=jpYVQ(l*!bYht5p2ip_;5_r`rQS{4 z3mzyP*7nk{j&Tc+W8~X0q0&|OX~$_6uV)NbS4H1k6)p1gMol^(xYGr0|wQq clcuZ;s~7QKtG8Zl1XR!9>FVdQ&MBb@0Dd(_i2wiq literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/more_vert@2x.png b/src/iOS/Resources/more_vert@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..7ad71d8d4bb02bd3e70f7a6a18f78a8e7b07e341 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`Z>;rs4T!Hj|3V`$OUs*sSL`s7E zf*I7*4UKK>9C8YKCQjYH^T6TbpTDkJ``Q2~@8{{_7-DfcIl+N7=a18#Gdw>Sr*m)= zJP19k#l+b2L*%2g=*I`aDm-d^+aC?TN944$rjF6*2UngB(bb*KOU literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/more_vert@3x.png b/src/iOS/Resources/more_vert@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..ae39a7835b70a3ad87f28fdd7f46eb05245cfa1b GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^W+2SL3?z5Yp7kC`Wd`_!xB}__bOC>)*Omb-Qz{Aa z3ua(sV&jxnRMIvyGK-FhOV8-+o;rQQrUM7h-MaVj^Vjb`e=95#e+E=t=IP=X;&J@# z6jQzf20RSRscCNi|4*E{%BhXdbBW)_x62#WDnF5y+j@C|wF_^3>*Pr*BNXpk3AwlF zn|rfMoOe98+0X26O>En?Z0nfy{d?xjd$&#MgJwiKhdz^yi4HQ{`u0(wd4H?7fbs#B j#3lnrj%_T_NeSM3nwO2ce{}eO+{@tU>gTe~DWM4f*FnK4 literal 0 HcmV?d00001 diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 37689dbc9..c90a1b54c 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -331,4 +331,22 @@ false + + + + + + + + + + + + + + + + + + \ No newline at end of file