bitwarden-android/src/App/Pages/TabsPage.cs

95 lines
3.1 KiB
C#
Raw Normal View History

2019-06-12 15:31:33 +03:00
using Bit.App.Effects;
using Bit.App.Models;
2019-05-31 04:24:03 +03:00
using Bit.App.Resources;
2019-05-14 16:43:46 +03:00
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)
2019-05-14 16:43:46 +03:00
{
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
2019-05-14 16:43:46 +03:00
{
Title = AppResources.MyVault,
2020-03-11 16:46:48 +03:00
IconImageSource = "lock.png"
2019-05-14 16:43:46 +03:00
};
Children.Add(_groupingsPage);
2019-05-14 16:43:46 +03:00
_sendGroupingsPage = new NavigationPage(new SendGroupingsPage(true))
{
Title = AppResources.Send,
IconImageSource = "paper_plane.png",
};
Children.Add(_sendGroupingsPage);
_generatorPage = new NavigationPage(new GeneratorPage(true, null, this))
2019-05-14 16:43:46 +03:00
{
Title = AppResources.Generator,
2020-03-11 16:46:48 +03:00
IconImageSource = "refresh.png"
2019-05-14 16:43:46 +03:00
};
Children.Add(_generatorPage);
2019-05-14 16:43:46 +03:00
var settingsPage = new NavigationPage(new SettingsPage(this))
2019-05-14 16:43:46 +03:00
{
Title = AppResources.Settings,
2020-03-11 16:46:48 +03:00
IconImageSource = "cog.png"
2019-05-14 16:43:46 +03:00
};
Children.Add(settingsPage);
if (Device.RuntimePlatform == Device.Android)
2019-05-31 04:24:03 +03:00
{
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)
2019-06-07 03:34:59 +03:00
{
appOptions.MyVaultTile = false;
}
2019-05-14 16:43:46 +03:00
}
public void ResetToVaultPage()
{
CurrentPage = _groupingsPage;
}
public void ResetToGeneratorPage()
{
CurrentPage = _generatorPage;
}
2019-05-14 16:43:46 +03:00
protected async override void OnCurrentPageChanged()
{
if (CurrentPage is NavigationPage navPage)
2019-05-14 16:43:46 +03:00
{
if (navPage.RootPage is GroupingsPage groupingsPage)
2019-05-14 16:51:13 +03:00
{
// Load something?
}
else if (navPage.RootPage is GeneratorPage genPage)
2019-05-14 16:43:46 +03:00
{
await genPage.InitAsync();
}
else if (navPage.RootPage is SettingsPage settingsPage)
2019-05-14 16:51:13 +03:00
{
2019-05-31 21:18:32 +03:00
await settingsPage.InitAsync();
2019-05-14 16:51:13 +03:00
}
2019-05-14 16:43:46 +03:00
}
}
}
}