Bitwarden-app-android-iphon.../src/App/Pages/TabsPage.cs

111 lines
3.6 KiB
C#
Raw Normal View History

2019-06-12 14:31:33 +02:00
using Bit.App.Effects;
using Bit.App.Models;
2019-05-31 03:24:03 +02:00
using Bit.App.Resources;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
2019-05-14 15:43:46 +02:00
using Xamarin.Forms;
namespace Bit.App.Pages
{
public class TabsPage : TabbedPage
{
private readonly IMessagingService _messagingService;
private NavigationPage _groupingsPage;
private NavigationPage _sendGroupingsPage;
private NavigationPage _generatorPage;
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null)
2019-05-14 15:43:46 +02:00
{
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
2019-05-14 15:43:46 +02:00
{
Title = AppResources.MyVault,
2020-03-11 14:46:48 +01:00
IconImageSource = "lock.png"
2019-05-14 15:43:46 +02:00
};
Children.Add(_groupingsPage);
2019-05-14 15:43:46 +02:00
_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))
2019-05-14 15:43:46 +02:00
{
Title = AppResources.Generator,
2020-03-11 14:46:48 +01:00
IconImageSource = "refresh.png"
2019-05-14 15:43:46 +02:00
};
Children.Add(_generatorPage);
2019-05-14 15:43:46 +02:00
var settingsPage = new NavigationPage(new SettingsPage(this))
2019-05-14 15:43:46 +02:00
{
Title = AppResources.Settings,
2020-03-11 14:46:48 +01:00
IconImageSource = "cog.png"
2019-05-14 15:43:46 +02:00
};
Children.Add(settingsPage);
if (Device.RuntimePlatform == Device.Android)
2019-05-31 03:24:03 +02: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 02:34:59 +02:00
{
appOptions.MyVaultTile = false;
}
else if (appOptions?.CreateSend != null)
{
ResetToSendPage();
}
2019-05-14 15:43:46 +02:00
}
public void ResetToVaultPage()
{
CurrentPage = _groupingsPage;
}
public void ResetToGeneratorPage()
{
CurrentPage = _generatorPage;
}
public void ResetToSendPage()
{
CurrentPage = _sendGroupingsPage;
}
2019-05-14 15:43:46 +02:00
protected async override void OnCurrentPageChanged()
{
if (CurrentPage is NavigationPage navPage)
2019-05-14 15:43:46 +02:00
{
_messagingService.Send("updatedTheme");
if (navPage.RootPage is GroupingsPage groupingsPage)
2019-05-14 15:51:13 +02:00
{
// Load something?
}
else if (navPage.RootPage is GeneratorPage genPage)
2019-05-14 15:43:46 +02:00
{
await genPage.InitAsync();
}
else if (navPage.RootPage is SettingsPage settingsPage)
2019-05-14 15:51:13 +02:00
{
2019-05-31 20:18:32 +02:00
await settingsPage.InitAsync();
2019-05-14 15:51:13 +02:00
}
2019-05-14 15:43:46 +02:00
}
}
}
}