From b4e7fd6fa8a40637d9be8deb39191dd966e52336 Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Tue, 12 Dec 2017 13:03:25 -0800 Subject: [PATCH] Improve the navigation on Windows platforms (#199) * App: Don't default to modal pushes on Windows On Windows we generally want to avoid modal pushes as that doesn't give us a back arrow on Windows 10. Default to non-modal pushes. Signed-off-by: Alistair Francis * App: LoginPage.cs: Don't add the cancel button on Windows With Windows Phone having a HW back buton and the UWP toolbar now supporting a back button we no longer need a cancel button. Signed-off-by: Alistair Francis * src: Set a icon for UWP cancel buttons We can't always use modal pages and in that case we need to set a icon for UWP otherwise the button can't be seen on the toolbar. Signed-off-by: Alistair Francis * App: Pages: Don't add Cancel/Close button on Windows Signed-off-by: Alistair Francis * Update DismissModalToolBarItem.cs --- src/App/Controls/DismissModalToolBarItem.cs | 4 +++- src/App/Pages/EnvironmentPage.cs | 2 +- src/App/Pages/LoginPage.cs | 2 +- src/App/Pages/RegisterPage.cs | 2 +- src/App/Pages/ScanPage.cs | 2 +- src/App/Pages/Tools/ToolsExtensionPage.cs | 2 +- .../Pages/Tools/ToolsPasswordGeneratorPage.cs | 2 +- src/App/Pages/Vault/VaultAddCipherPage.cs | 2 +- src/App/Pages/Vault/VaultAttachmentsPage.cs | 2 +- src/App/Pages/Vault/VaultCustomFieldsPage.cs | 4 ++-- src/App/Pages/Vault/VaultEditCipherPage.cs | 2 +- src/App/Pages/Vault/VaultViewCipherPage.cs | 2 +- src/App/Utilities/Extentions.cs | 13 ++++++++++++- src/UWP.Images/UWP.Images.projitems | 1 + src/UWP.Images/ion_chevron_left.png | Bin 0 -> 1029 bytes 15 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 src/UWP.Images/ion_chevron_left.png diff --git a/src/App/Controls/DismissModalToolBarItem.cs b/src/App/Controls/DismissModalToolBarItem.cs index 8e987b2b1..6423095b3 100644 --- a/src/App/Controls/DismissModalToolBarItem.cs +++ b/src/App/Controls/DismissModalToolBarItem.cs @@ -1,4 +1,5 @@ using Bit.App.Resources; +using Bit.App.Utilities; using System; using Xamarin.Forms; @@ -15,13 +16,14 @@ namespace Bit.App.Controls // TODO: init and dispose events from pages InitEvents(); Text = text ?? AppResources.Close; + Icon = Helpers.ToolbarImage("ion_chevron_left.png"); Priority = -1; } protected async override void ClickedItem(object sender, EventArgs e) { base.ClickedItem(sender, e); - await _page.Navigation.PopModalAsync(); + await _page.Navigation.PopForDeviceAsync(); } } } diff --git a/src/App/Pages/EnvironmentPage.cs b/src/App/Pages/EnvironmentPage.cs index dc34c5f4f..03af0ad5d 100644 --- a/src/App/Pages/EnvironmentPage.cs +++ b/src/App/Pages/EnvironmentPage.cs @@ -115,7 +115,7 @@ namespace Bit.App.Pages var toolbarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async () => await SaveAsync(), ToolbarItemOrder.Default, 0); - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { table.RowHeight = table2.RowHeight = -1; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; diff --git a/src/App/Pages/LoginPage.cs b/src/App/Pages/LoginPage.cs index 2e7d1045b..3226f8bc2 100644 --- a/src/App/Pages/LoginPage.cs +++ b/src/App/Pages/LoginPage.cs @@ -102,7 +102,7 @@ namespace Bit.App.Pages var scrollView = new ScrollView { Content = layout }; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 70; diff --git a/src/App/Pages/RegisterPage.cs b/src/App/Pages/RegisterPage.cs index 6236aeac4..fc116ac71 100644 --- a/src/App/Pages/RegisterPage.cs +++ b/src/App/Pages/RegisterPage.cs @@ -122,7 +122,7 @@ namespace Bit.App.Pages await Register(); }, ToolbarItemOrder.Default, 0); - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { table.RowHeight = table2.RowHeight = -1; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; diff --git a/src/App/Pages/ScanPage.cs b/src/App/Pages/ScanPage.cs index a3cd92fda..d54d022be 100644 --- a/src/App/Pages/ScanPage.cs +++ b/src/App/Pages/ScanPage.cs @@ -68,7 +68,7 @@ namespace Bit.App.Pages Children = { _zxing, _overlay } }; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); } diff --git a/src/App/Pages/Tools/ToolsExtensionPage.cs b/src/App/Pages/Tools/ToolsExtensionPage.cs index 245cf99c9..b6a5d0a97 100644 --- a/src/App/Pages/Tools/ToolsExtensionPage.cs +++ b/src/App/Pages/Tools/ToolsExtensionPage.cs @@ -205,7 +205,7 @@ namespace Bit.App.Pages VerticalOptions = LayoutOptions.FillAndExpand }; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); } diff --git a/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs b/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs index 523e68d27..24772f48f 100644 --- a/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs +++ b/src/App/Pages/Tools/ToolsPasswordGeneratorPage.cs @@ -87,7 +87,7 @@ namespace Bit.App.Pages } }; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { table.RowHeight = -1; table.EstimatedRowHeight = 44; diff --git a/src/App/Pages/Vault/VaultAddCipherPage.cs b/src/App/Pages/Vault/VaultAddCipherPage.cs index 3a864f98f..6650581ed 100644 --- a/src/App/Pages/Vault/VaultAddCipherPage.cs +++ b/src/App/Pages/Vault/VaultAddCipherPage.cs @@ -170,7 +170,7 @@ namespace Bit.App.Pages Title = AppResources.AddItem; Content = Table; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } diff --git a/src/App/Pages/Vault/VaultAttachmentsPage.cs b/src/App/Pages/Vault/VaultAttachmentsPage.cs index 144a53733..d7aeeda70 100644 --- a/src/App/Pages/Vault/VaultAttachmentsPage.cs +++ b/src/App/Pages/Vault/VaultAttachmentsPage.cs @@ -191,7 +191,7 @@ namespace Bit.App.Pages ToolbarItems.Add(saveToolBarItem); } - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ListView.RowHeight = -1; NewTable.RowHeight = -1; diff --git a/src/App/Pages/Vault/VaultCustomFieldsPage.cs b/src/App/Pages/Vault/VaultCustomFieldsPage.cs index 759f1db29..42a221691 100644 --- a/src/App/Pages/Vault/VaultCustomFieldsPage.cs +++ b/src/App/Pages/Vault/VaultCustomFieldsPage.cs @@ -159,7 +159,7 @@ namespace Bit.App.Pages { Content = Table; ToolbarItems.Add(SaveToolbarItem); - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } @@ -211,7 +211,7 @@ namespace Bit.App.Pages else { Content = NoDataLabel; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); } diff --git a/src/App/Pages/Vault/VaultEditCipherPage.cs b/src/App/Pages/Vault/VaultEditCipherPage.cs index ca88e0ea8..55d826ba2 100644 --- a/src/App/Pages/Vault/VaultEditCipherPage.cs +++ b/src/App/Pages/Vault/VaultEditCipherPage.cs @@ -139,7 +139,7 @@ namespace Bit.App.Pages Title = AppResources.EditItem; Content = Table; - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); } diff --git a/src/App/Pages/Vault/VaultViewCipherPage.cs b/src/App/Pages/Vault/VaultViewCipherPage.cs index 0dab43c50..046b05bf7 100644 --- a/src/App/Pages/Vault/VaultViewCipherPage.cs +++ b/src/App/Pages/Vault/VaultViewCipherPage.cs @@ -76,7 +76,7 @@ namespace Bit.App.Pages { EditItem = new EditCipherToolBarItem(this, _cipherId); ToolbarItems.Add(EditItem); - if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) + if(Device.RuntimePlatform == Device.iOS) { ToolbarItems.Add(new DismissModalToolBarItem(this)); } diff --git a/src/App/Utilities/Extentions.cs b/src/App/Utilities/Extentions.cs index ff5caf34e..7927bd018 100644 --- a/src/App/Utilities/Extentions.cs +++ b/src/App/Utilities/Extentions.cs @@ -55,13 +55,24 @@ namespace Bit.App public static async Task PushForDeviceAsync(this INavigation navigation, Page page) { - await navigation.PushModalAsync(new ExtendedNavigationPage(page), true); + if (Device.RuntimePlatform != Device.Windows) + { + await navigation.PushModalAsync(new ExtendedNavigationPage(page), true); + } + else + { + await navigation.PushAsync(page, true); + } } public static async Task PopForDeviceAsync(this INavigation navigation) { if(navigation.ModalStack.Count < 1) { + if (navigation.NavigationStack.Count > 0 && Device.RuntimePlatform == Device.Windows) + { + await navigation.PopAsync(); + } return; } diff --git a/src/UWP.Images/UWP.Images.projitems b/src/UWP.Images/UWP.Images.projitems index 6f7a773f5..453ca6721 100644 --- a/src/UWP.Images/UWP.Images.projitems +++ b/src/UWP.Images/UWP.Images.projitems @@ -29,6 +29,7 @@ + diff --git a/src/UWP.Images/ion_chevron_left.png b/src/UWP.Images/ion_chevron_left.png new file mode 100644 index 0000000000000000000000000000000000000000..ec1c903a051aba6796ead28f5d9ed87ea8e99d2d GIT binary patch literal 1029 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAifV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%Gr;0X`wFK=HeyfannL5l)x}46>AxAirP+MkZz!RyKAHPA+aM?Iw`|3# zO~XRiE|gPUcY(k-lHeaUc7$)@$=X3KY#yCY&XvU+Q(Vo5n0T@z;_sg8IR|$ zNCC#*drud~kO=p!Gj4_nJBlz^xA=y{+;9|_u+v504 zo4dDt_o}RHw@ROM^3J=mtgMRO)Kk;B_Vgy*s@^|sfl1uUiugy9=O(_a_&@V}7~6}A z{T&-Gx<8#JIj1#Fit%^shgWSa8=9_O4pdWIGy8qRHEp3o<)2$^cPl9VF({umXQIHi z?hMm@KM#)Gr5UEa`#m{+f6XxEbysP5?6zgrE?c2P^V>5_w_2;TTt1#*dQ?~F(9Pg2 zvu61U9eP^4W!52cp+lw8QND@2Edh0n*FLwpJTMJAZ`A6bA9h}*)j>Y&JWuNZg|PGP zT#boq<^^&!8m^hA$knL1W?mgvqkn|$dkvOn8>{XGaOfm|ElFj&p%vy|oz`%3x`FOY z#%+o5TyG}{ylFNNztzK`x_e7X{I+6!;lF>*m0sq!k$>V(d;_u~ik4AZXl{jgC z){jKxu9a)#7<%cdtbor$g#QA)9 d7gz93{^g%&8`)M%RbYBx@O1TaS?83{1OQ_!J%#`P literal 0 HcmV?d00001