mirror of
https://github.com/bitwarden/android.git
synced 2024-12-29 04:18:33 +03:00
d926565358
* Android implementation * remove iOS attempt for now
103 lines
3.3 KiB
C#
103 lines
3.3 KiB
C#
using Bit.App.Effects;
|
|
using Bit.App.Models;
|
|
using Bit.App.Resources;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Bit.App.Pages
|
|
{
|
|
public class TabsPage : TabbedPage
|
|
{
|
|
private NavigationPage _groupingsPage;
|
|
private NavigationPage _sendGroupingsPage;
|
|
private NavigationPage _generatorPage;
|
|
|
|
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null)
|
|
{
|
|
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
|
|
{
|
|
Title = AppResources.MyVault,
|
|
IconImageSource = "lock.png"
|
|
};
|
|
Children.Add(_groupingsPage);
|
|
|
|
_sendGroupingsPage = new NavigationPage(new SendGroupingsPage(true, null, null, appOptions))
|
|
{
|
|
Title = AppResources.Send,
|
|
IconImageSource = "paper_plane.png",
|
|
};
|
|
Children.Add(_sendGroupingsPage);
|
|
|
|
_generatorPage = new NavigationPage(new GeneratorPage(true, null, this))
|
|
{
|
|
Title = AppResources.Generator,
|
|
IconImageSource = "refresh.png"
|
|
};
|
|
Children.Add(_generatorPage);
|
|
|
|
var settingsPage = new NavigationPage(new SettingsPage(this))
|
|
{
|
|
Title = AppResources.Settings,
|
|
IconImageSource = "cog.png"
|
|
};
|
|
Children.Add(settingsPage);
|
|
|
|
if (Device.RuntimePlatform == Device.Android)
|
|
{
|
|
Effects.Add(new TabBarEffect());
|
|
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetToolbarPlacement(this,
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement.Bottom);
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSwipePagingEnabled(this, false);
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetIsSmoothScrollEnabled(this, false);
|
|
}
|
|
|
|
if (appOptions?.GeneratorTile ?? false)
|
|
{
|
|
appOptions.GeneratorTile = false;
|
|
ResetToGeneratorPage();
|
|
}
|
|
else if (appOptions?.MyVaultTile ?? false)
|
|
{
|
|
appOptions.MyVaultTile = false;
|
|
}
|
|
else if (appOptions?.CreateSend != null)
|
|
{
|
|
ResetToSendPage();
|
|
}
|
|
}
|
|
|
|
public void ResetToVaultPage()
|
|
{
|
|
CurrentPage = _groupingsPage;
|
|
}
|
|
|
|
public void ResetToGeneratorPage()
|
|
{
|
|
CurrentPage = _generatorPage;
|
|
}
|
|
|
|
public void ResetToSendPage()
|
|
{
|
|
CurrentPage = _sendGroupingsPage;
|
|
}
|
|
|
|
protected async override void OnCurrentPageChanged()
|
|
{
|
|
if (CurrentPage is NavigationPage navPage)
|
|
{
|
|
if (navPage.RootPage is GroupingsPage groupingsPage)
|
|
{
|
|
// Load something?
|
|
}
|
|
else if (navPage.RootPage is GeneratorPage genPage)
|
|
{
|
|
await genPage.InitAsync();
|
|
}
|
|
else if (navPage.RootPage is SettingsPage settingsPage)
|
|
{
|
|
await settingsPage.InitAsync();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|