mirror of
https://github.com/bitwarden/mobile.git
synced 2025-01-02 18:07:56 +01:00
Created device specific navigation push/pops in order to support non-modal navigation on android (so we get the back button in nav).
This commit is contained in:
parent
0cba25fc0c
commit
22ac095dce
@ -56,7 +56,7 @@ namespace Bit.App
|
||||
}
|
||||
else
|
||||
{
|
||||
MainPage = new HomePage();
|
||||
MainPage = new ExtendedNavigationPage(new HomePage());
|
||||
}
|
||||
|
||||
MessagingCenter.Subscribe<Application, bool>(Current, "Resumed", async (sender, args) =>
|
||||
@ -203,7 +203,7 @@ namespace Bit.App
|
||||
_googleAnalyticsService.TrackAppEvent("LoggedOut");
|
||||
_googleAnalyticsService.RefreshUserId();
|
||||
|
||||
Current.MainPage = new HomePage();
|
||||
Current.MainPage = new ExtendedNavigationPage(new HomePage());
|
||||
if(!string.IsNullOrWhiteSpace(logoutMessage))
|
||||
{
|
||||
_userDialogs.Toast(logoutMessage);
|
||||
|
@ -77,6 +77,7 @@ namespace Bit.App.Pages
|
||||
};
|
||||
|
||||
Title = "bitwarden";
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
Content = new ScrollView { Content = buttonStackLayout };
|
||||
}
|
||||
|
||||
@ -88,18 +89,18 @@ namespace Bit.App.Pages
|
||||
|
||||
public async Task LoginAsync()
|
||||
{
|
||||
await Navigation.PushModalAsync(new ExtendedNavigationPage(new LoginPage()));
|
||||
await Navigation.PushForDeviceAsync(new LoginPage());
|
||||
}
|
||||
|
||||
public async Task RegisterAsync()
|
||||
{
|
||||
await Navigation.PushModalAsync(new ExtendedNavigationPage(new RegisterPage(this)));
|
||||
await Navigation.PushForDeviceAsync(new RegisterPage(this));
|
||||
}
|
||||
|
||||
public async Task DismissRegisterAndLoginAsync(string email)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PushModalAsync(new ExtendedNavigationPage(new LoginPage(email)));
|
||||
await Navigation.PopForDeviceAsync();
|
||||
await Navigation.PushForDeviceAsync(new LoginPage(email));
|
||||
_userDialogs.Toast("Your new account has been created! You may now log in.");
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace Bit.App.Pages
|
||||
|
||||
if(saveResult.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
_userDialogs.Toast("New folder created.");
|
||||
_googleAnalyticsService.TrackAppEvent("CreatedFolder");
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ namespace Bit.App.Pages
|
||||
|
||||
if(saveResult.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
_userDialogs.Toast("Folder updated.");
|
||||
_googleAnalyticsService.TrackAppEvent("EditedFolder");
|
||||
}
|
||||
@ -147,7 +147,7 @@ namespace Bit.App.Pages
|
||||
|
||||
if(deleteTask.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
_userDialogs.Toast("Folder deleted.");
|
||||
}
|
||||
else if(deleteTask.Errors.Count() > 0)
|
||||
|
@ -55,11 +55,11 @@ namespace Bit.App.Pages
|
||||
Folders.ResetWithRange(pageFolders);
|
||||
}
|
||||
|
||||
private void FolderSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
private async void FolderSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
var folder = e.SelectedItem as SettingsFolderPageModel;
|
||||
var page = new ExtendedNavigationPage(new SettingsEditFolderPage(folder.Id));
|
||||
Navigation.PushModalAsync(page);
|
||||
var page = new SettingsEditFolderPage(folder.Id);
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
|
||||
private class AddFolderToolBarItem : ToolbarItem
|
||||
@ -76,8 +76,8 @@ namespace Bit.App.Pages
|
||||
|
||||
private async void ClickedItem(object sender, EventArgs e)
|
||||
{
|
||||
var page = new ExtendedNavigationPage(new SettingsAddFolderPage());
|
||||
await _page.Navigation.PushModalAsync(page);
|
||||
var page = new SettingsAddFolderPage();
|
||||
await _page.Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace Bit.App.Pages
|
||||
"Use the bitwarden accessibility service to auto-fill your logins.", "upload");
|
||||
autofillServiceCell.Tapped += (object sender, EventArgs e) =>
|
||||
{
|
||||
Navigation.PushModalAsync(new ExtendedNavigationPage(new ToolsAutofillServicePage()));
|
||||
Navigation.PushAsync(new ToolsAutofillServicePage());
|
||||
};
|
||||
section.Add(autofillServiceCell);
|
||||
}
|
||||
@ -81,9 +81,9 @@ namespace Bit.App.Pages
|
||||
Content = table;
|
||||
}
|
||||
|
||||
private void GeneratorCell_Tapped(object sender, EventArgs e)
|
||||
private async void GeneratorCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
Navigation.PushModalAsync(new ExtendedNavigationPage(new ToolsPasswordGeneratorPage()));
|
||||
await Navigation.PushForDeviceAsync(new ToolsPasswordGeneratorPage());
|
||||
}
|
||||
|
||||
private void WebCell_Tapped(object sender, EventArgs e)
|
||||
|
@ -112,7 +112,7 @@ namespace Bit.App.Pages
|
||||
{
|
||||
_googleAnalyticsService.TrackAppEvent("SelectedGeneratedPassword");
|
||||
_passwordValueAction(Password.Text);
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
}, ToolbarItemOrder.Default, 0);
|
||||
|
||||
ToolbarItems.Add(selectToolBarItem);
|
||||
|
@ -146,7 +146,7 @@ namespace Bit.App.Pages
|
||||
_userDialogs.HideLoading();
|
||||
if(saveTask.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
_userDialogs.Toast("New site created.");
|
||||
_googleAnalyticsService.TrackAppEvent("CreatedSite");
|
||||
}
|
||||
@ -187,14 +187,14 @@ namespace Bit.App.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateCell_Tapped(object sender, EventArgs e)
|
||||
private async void GenerateCell_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
var page = new ToolsPasswordGeneratorPage((password) =>
|
||||
{
|
||||
PasswordCell.Entry.Text = password;
|
||||
_userDialogs.Toast("Password generated.");
|
||||
});
|
||||
Navigation.PushModalAsync(new ExtendedNavigationPage(page));
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
|
||||
private void AlertNoConnection()
|
||||
|
@ -176,7 +176,7 @@ namespace Bit.App.Pages
|
||||
|
||||
if(saveTask.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
_userDialogs.Toast("Site updated.");
|
||||
_googleAnalyticsService.TrackAppEvent("EditedSite");
|
||||
}
|
||||
@ -222,7 +222,7 @@ namespace Bit.App.Pages
|
||||
PasswordCell.Entry.Text = password;
|
||||
_userDialogs.Toast("Password generated.");
|
||||
});
|
||||
await Navigation.PushModalAsync(new ExtendedNavigationPage(page));
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
|
||||
private async void DeleteCell_Tapped(object sender, EventArgs e)
|
||||
@ -244,7 +244,7 @@ namespace Bit.App.Pages
|
||||
|
||||
if(deleteTask.Succeeded)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
_userDialogs.Toast("Site deleted.");
|
||||
_googleAnalyticsService.TrackAppEvent("DeletedSite");
|
||||
}
|
||||
|
@ -354,11 +354,11 @@ namespace Bit.App.Pages
|
||||
});
|
||||
}
|
||||
|
||||
private void SiteSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
private async void SiteSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
var site = e.SelectedItem as VaultListPageModel.Site;
|
||||
var page = new ExtendedNavigationPage(new VaultViewSitePage(site.Id));
|
||||
Navigation.PushModalAsync(page);
|
||||
var page = new VaultViewSitePage(site.Id);
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
|
||||
private async void MoreClickedAsync(VaultListPageModel.Site site)
|
||||
@ -382,13 +382,13 @@ namespace Bit.App.Pages
|
||||
|
||||
if(selection == AppResources.View)
|
||||
{
|
||||
var page = new ExtendedNavigationPage(new VaultViewSitePage(site.Id));
|
||||
await Navigation.PushModalAsync(page);
|
||||
var page = new VaultViewSitePage(site.Id);
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
else if(selection == AppResources.Edit)
|
||||
{
|
||||
var page = new ExtendedNavigationPage(new VaultEditSitePage(site.Id));
|
||||
await Navigation.PushModalAsync(page);
|
||||
var page = new VaultEditSitePage(site.Id);
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
else if(selection == AppResources.CopyPassword)
|
||||
{
|
||||
@ -412,8 +412,8 @@ namespace Bit.App.Pages
|
||||
|
||||
private async void AddSite()
|
||||
{
|
||||
var page = new ExtendedNavigationPage(new VaultAddSitePage());
|
||||
await Navigation.PushModalAsync(page);
|
||||
var page = new VaultAddSitePage();
|
||||
await Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
|
||||
private class AddSiteToolBarItem : ToolbarItem
|
||||
|
@ -116,7 +116,7 @@ namespace Bit.App.Pages
|
||||
var site = await _siteService.GetByIdAsync(_siteId);
|
||||
if(site == null)
|
||||
{
|
||||
await Navigation.PopModalAsync();
|
||||
await Navigation.PopForDeviceAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -182,8 +182,8 @@ namespace Bit.App.Pages
|
||||
|
||||
private async void ClickedItem(object sender, EventArgs e)
|
||||
{
|
||||
var page = new ExtendedNavigationPage(new VaultEditSitePage(_siteId));
|
||||
await _page.Navigation.PushModalAsync(page);
|
||||
var page = new VaultEditSitePage(_siteId);
|
||||
await _page.Navigation.PushForDeviceAsync(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ using Bit.App.Abstractions;
|
||||
using Bit.App.Models;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Ioc;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Controls;
|
||||
|
||||
namespace Bit.App
|
||||
{
|
||||
@ -33,9 +35,9 @@ namespace Bit.App
|
||||
{
|
||||
if(Device.OS == TargetPlatform.Android)
|
||||
{
|
||||
System.Threading.Tasks.Task.Run(async () =>
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(delay);
|
||||
await Task.Delay(delay);
|
||||
Device.BeginInvokeOnMainThread(() => entry.Focus());
|
||||
});
|
||||
}
|
||||
@ -45,6 +47,30 @@ namespace Bit.App
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task PushForDeviceAsync(this INavigation navigation, Page page)
|
||||
{
|
||||
if(Device.OS == TargetPlatform.iOS)
|
||||
{
|
||||
await navigation.PushModalAsync(new ExtendedNavigationPage(page), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
await navigation.PushAsync(page, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task PopForDeviceAsync(this INavigation navigation)
|
||||
{
|
||||
if(Device.OS == TargetPlatform.iOS)
|
||||
{
|
||||
await navigation.PopModalAsync(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
await navigation.PopAsync(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AdjustMarginsForDevice(this View view)
|
||||
{
|
||||
if(Device.OS == TargetPlatform.Android)
|
||||
|
Loading…
Reference in New Issue
Block a user