1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-30 04:17:55 +02:00

back button to groupings page on android

This commit is contained in:
Kyle Spearrin 2019-05-31 14:15:37 -04:00
parent fc0d91d3e7
commit 582799464f
3 changed files with 37 additions and 7 deletions

View File

@ -9,9 +9,11 @@ namespace Bit.App.Pages
private GeneratorPageViewModel _vm;
private readonly bool _fromTabPage;
private readonly Action<string> _selectAction;
private readonly TabsPage _tabsPage;
public GeneratorPage(bool fromTabPage, Action<string> selectAction = null)
public GeneratorPage(bool fromTabPage, Action<string> selectAction = null, TabsPage tabsPage = null)
{
_tabsPage = tabsPage;
InitializeComponent();
_vm = BindingContext as GeneratorPageViewModel;
_vm.Page = this;
@ -37,6 +39,16 @@ namespace Bit.App.Pages
}
}
protected override bool OnBackButtonPressed()
{
if(Device.RuntimePlatform == Device.Android && _tabsPage != null)
{
_tabsPage.ResetToVaultPage();
return true;
}
return base.OnBackButtonPressed();
}
private async void Regenerate_Clicked(object sender, EventArgs e)
{
await _vm.RegenerateAsync();

View File

@ -8,11 +8,12 @@ namespace Bit.App.Pages
public partial class SettingsPage : BaseContentPage
{
private readonly IDeviceActionService _deviceActionService;
private readonly TabsPage _tabsPage;
private SettingsPageViewModel _vm;
public SettingsPage()
public SettingsPage(TabsPage tabsPage)
{
_tabsPage = tabsPage;
InitializeComponent();
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
_vm = BindingContext as SettingsPageViewModel;
@ -25,6 +26,16 @@ namespace Bit.App.Pages
await _vm.InitAsync();
}
protected override bool OnBackButtonPressed()
{
if(Device.RuntimePlatform == Device.Android && _tabsPage != null)
{
_tabsPage.ResetToVaultPage();
return true;
}
return base.OnBackButtonPressed();
}
private async void RowSelected(object sender, SelectedItemChangedEventArgs e)
{
((ListView)sender).SelectedItem = null;

View File

@ -6,23 +6,25 @@ namespace Bit.App.Pages
{
public class TabsPage : TabbedPage
{
private NavigationPage _groupingsPage;
public TabsPage()
{
var groupingsPage = new NavigationPage(new GroupingsPage(true))
_groupingsPage = new NavigationPage(new GroupingsPage(true))
{
Title = AppResources.MyVault,
Icon = "lock.png"
};
Children.Add(groupingsPage);
Children.Add(_groupingsPage);
var generatorPage = new NavigationPage(new GeneratorPage(true, null))
var generatorPage = new NavigationPage(new GeneratorPage(true, null, this))
{
Title = AppResources.Generator,
Icon = "refresh.png"
};
Children.Add(generatorPage);
var settingsPage = new NavigationPage(new SettingsPage())
var settingsPage = new NavigationPage(new SettingsPage(this))
{
Title = AppResources.Settings,
Icon = "cog.png"
@ -44,6 +46,11 @@ namespace Bit.App.Pages
}
}
public void ResetToVaultPage()
{
CurrentPage = _groupingsPage;
}
protected async override void OnCurrentPageChanged()
{
if(CurrentPage is NavigationPage navPage)