mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
back button to groupings page on android
This commit is contained in:
parent
fc0d91d3e7
commit
582799464f
3 changed files with 37 additions and 7 deletions
|
@ -9,9 +9,11 @@ namespace Bit.App.Pages
|
||||||
private GeneratorPageViewModel _vm;
|
private GeneratorPageViewModel _vm;
|
||||||
private readonly bool _fromTabPage;
|
private readonly bool _fromTabPage;
|
||||||
private readonly Action<string> _selectAction;
|
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();
|
InitializeComponent();
|
||||||
_vm = BindingContext as GeneratorPageViewModel;
|
_vm = BindingContext as GeneratorPageViewModel;
|
||||||
_vm.Page = this;
|
_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)
|
private async void Regenerate_Clicked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
await _vm.RegenerateAsync();
|
await _vm.RegenerateAsync();
|
||||||
|
|
|
@ -8,11 +8,12 @@ namespace Bit.App.Pages
|
||||||
public partial class SettingsPage : BaseContentPage
|
public partial class SettingsPage : BaseContentPage
|
||||||
{
|
{
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
|
private readonly TabsPage _tabsPage;
|
||||||
private SettingsPageViewModel _vm;
|
private SettingsPageViewModel _vm;
|
||||||
|
|
||||||
public SettingsPage()
|
public SettingsPage(TabsPage tabsPage)
|
||||||
{
|
{
|
||||||
|
_tabsPage = tabsPage;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||||
_vm = BindingContext as SettingsPageViewModel;
|
_vm = BindingContext as SettingsPageViewModel;
|
||||||
|
@ -25,6 +26,16 @@ namespace Bit.App.Pages
|
||||||
await _vm.InitAsync();
|
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)
|
private async void RowSelected(object sender, SelectedItemChangedEventArgs e)
|
||||||
{
|
{
|
||||||
((ListView)sender).SelectedItem = null;
|
((ListView)sender).SelectedItem = null;
|
||||||
|
|
|
@ -6,23 +6,25 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
public class TabsPage : TabbedPage
|
public class TabsPage : TabbedPage
|
||||||
{
|
{
|
||||||
|
private NavigationPage _groupingsPage;
|
||||||
|
|
||||||
public TabsPage()
|
public TabsPage()
|
||||||
{
|
{
|
||||||
var groupingsPage = new NavigationPage(new GroupingsPage(true))
|
_groupingsPage = new NavigationPage(new GroupingsPage(true))
|
||||||
{
|
{
|
||||||
Title = AppResources.MyVault,
|
Title = AppResources.MyVault,
|
||||||
Icon = "lock.png"
|
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,
|
Title = AppResources.Generator,
|
||||||
Icon = "refresh.png"
|
Icon = "refresh.png"
|
||||||
};
|
};
|
||||||
Children.Add(generatorPage);
|
Children.Add(generatorPage);
|
||||||
|
|
||||||
var settingsPage = new NavigationPage(new SettingsPage())
|
var settingsPage = new NavigationPage(new SettingsPage(this))
|
||||||
{
|
{
|
||||||
Title = AppResources.Settings,
|
Title = AppResources.Settings,
|
||||||
Icon = "cog.png"
|
Icon = "cog.png"
|
||||||
|
@ -44,6 +46,11 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetToVaultPage()
|
||||||
|
{
|
||||||
|
CurrentPage = _groupingsPage;
|
||||||
|
}
|
||||||
|
|
||||||
protected async override void OnCurrentPageChanged()
|
protected async override void OnCurrentPageChanged()
|
||||||
{
|
{
|
||||||
if(CurrentPage is NavigationPage navPage)
|
if(CurrentPage is NavigationPage navPage)
|
||||||
|
|
Loading…
Reference in a new issue