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 <alistair@alistair23.me>

* 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 <alistair@alistair23.me>

* 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 <alistair@alistair23.me>

* App: Pages: Don't add Cancel/Close button on Windows

Signed-off-by: Alistair Francis <alistair@alistair23.me>

* Update DismissModalToolBarItem.cs
This commit is contained in:
Alistair Francis 2017-12-12 13:03:25 -08:00 committed by Kyle Spearrin
parent baf785d9f1
commit b4e7fd6fa8
15 changed files with 28 additions and 14 deletions

View file

@ -1,4 +1,5 @@
using Bit.App.Resources; using Bit.App.Resources;
using Bit.App.Utilities;
using System; using System;
using Xamarin.Forms; using Xamarin.Forms;
@ -15,13 +16,14 @@ namespace Bit.App.Controls
// TODO: init and dispose events from pages // TODO: init and dispose events from pages
InitEvents(); InitEvents();
Text = text ?? AppResources.Close; Text = text ?? AppResources.Close;
Icon = Helpers.ToolbarImage("ion_chevron_left.png");
Priority = -1; Priority = -1;
} }
protected async override void ClickedItem(object sender, EventArgs e) protected async override void ClickedItem(object sender, EventArgs e)
{ {
base.ClickedItem(sender, e); base.ClickedItem(sender, e);
await _page.Navigation.PopModalAsync(); await _page.Navigation.PopForDeviceAsync();
} }
} }
} }

View file

@ -115,7 +115,7 @@ namespace Bit.App.Pages
var toolbarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async () => await SaveAsync(), var toolbarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("envelope.png"), async () => await SaveAsync(),
ToolbarItemOrder.Default, 0); ToolbarItemOrder.Default, 0);
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = table2.RowHeight = -1; table.RowHeight = table2.RowHeight = -1;
table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70;

View file

@ -102,7 +102,7 @@ namespace Bit.App.Pages
var scrollView = new ScrollView { Content = layout }; var scrollView = new ScrollView { Content = layout };
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = -1; table.RowHeight = -1;
table.EstimatedRowHeight = 70; table.EstimatedRowHeight = 70;

View file

@ -122,7 +122,7 @@ namespace Bit.App.Pages
await Register(); await Register();
}, ToolbarItemOrder.Default, 0); }, ToolbarItemOrder.Default, 0);
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
table.RowHeight = table2.RowHeight = -1; table.RowHeight = table2.RowHeight = -1;
table.EstimatedRowHeight = table2.EstimatedRowHeight = 70; table.EstimatedRowHeight = table2.EstimatedRowHeight = 70;

View file

@ -68,7 +68,7 @@ namespace Bit.App.Pages
Children = { _zxing, _overlay } Children = { _zxing, _overlay }
}; };
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
} }

View file

@ -205,7 +205,7 @@ namespace Bit.App.Pages
VerticalOptions = LayoutOptions.FillAndExpand VerticalOptions = LayoutOptions.FillAndExpand
}; };
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
} }

View file

@ -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.RowHeight = -1;
table.EstimatedRowHeight = 44; table.EstimatedRowHeight = 44;

View file

@ -170,7 +170,7 @@ namespace Bit.App.Pages
Title = AppResources.AddItem; Title = AppResources.AddItem;
Content = Table; Content = Table;
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -191,7 +191,7 @@ namespace Bit.App.Pages
ToolbarItems.Add(saveToolBarItem); ToolbarItems.Add(saveToolBarItem);
} }
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ListView.RowHeight = -1; ListView.RowHeight = -1;
NewTable.RowHeight = -1; NewTable.RowHeight = -1;

View file

@ -159,7 +159,7 @@ namespace Bit.App.Pages
{ {
Content = Table; Content = Table;
ToolbarItems.Add(SaveToolbarItem); ToolbarItems.Add(SaveToolbarItem);
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }
@ -211,7 +211,7 @@ namespace Bit.App.Pages
else else
{ {
Content = NoDataLabel; Content = NoDataLabel;
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
} }

View file

@ -139,7 +139,7 @@ namespace Bit.App.Pages
Title = AppResources.EditItem; Title = AppResources.EditItem;
Content = Table; Content = Table;
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel)); ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
} }

View file

@ -76,7 +76,7 @@ namespace Bit.App.Pages
{ {
EditItem = new EditCipherToolBarItem(this, _cipherId); EditItem = new EditCipherToolBarItem(this, _cipherId);
ToolbarItems.Add(EditItem); ToolbarItems.Add(EditItem);
if(Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows) if(Device.RuntimePlatform == Device.iOS)
{ {
ToolbarItems.Add(new DismissModalToolBarItem(this)); ToolbarItems.Add(new DismissModalToolBarItem(this));
} }

View file

@ -54,14 +54,25 @@ namespace Bit.App
} }
public static async Task PushForDeviceAsync(this INavigation navigation, Page page) public static async Task PushForDeviceAsync(this INavigation navigation, Page page)
{
if (Device.RuntimePlatform != Device.Windows)
{ {
await navigation.PushModalAsync(new ExtendedNavigationPage(page), true); await navigation.PushModalAsync(new ExtendedNavigationPage(page), true);
} }
else
{
await navigation.PushAsync(page, true);
}
}
public static async Task PopForDeviceAsync(this INavigation navigation) public static async Task PopForDeviceAsync(this INavigation navigation)
{ {
if(navigation.ModalStack.Count < 1) if(navigation.ModalStack.Count < 1)
{ {
if (navigation.NavigationStack.Count > 0 && Device.RuntimePlatform == Device.Windows)
{
await navigation.PopAsync();
}
return; return;
} }

View file

@ -29,6 +29,7 @@
<Content Include="$(MSBuildThisFileDirectory)globe.png" /> <Content Include="$(MSBuildThisFileDirectory)globe.png" />
<Content Include="$(MSBuildThisFileDirectory)icon.png" /> <Content Include="$(MSBuildThisFileDirectory)icon.png" />
<Content Include="$(MSBuildThisFileDirectory)id.png" /> <Content Include="$(MSBuildThisFileDirectory)id.png" />
<Content Include="$(MSBuildThisFileDirectory)ion_chevron_left.png" />
<Content Include="$(MSBuildThisFileDirectory)ion_chevron_right.png" /> <Content Include="$(MSBuildThisFileDirectory)ion_chevron_right.png" />
<Content Include="$(MSBuildThisFileDirectory)launch.png" /> <Content Include="$(MSBuildThisFileDirectory)launch.png" />
<Content Include="$(MSBuildThisFileDirectory)lightbulb.png" /> <Content Include="$(MSBuildThisFileDirectory)lightbulb.png" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB