2019-06-12 14:31:33 +02:00
|
|
|
|
using Bit.App.Effects;
|
2019-06-05 22:37:54 +02:00
|
|
|
|
using Bit.App.Models;
|
2019-05-31 03:24:03 +02:00
|
|
|
|
using Bit.App.Resources;
|
2021-10-08 14:47:40 +02:00
|
|
|
|
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
|
|
|
|
|
{
|
2021-10-08 14:47:40 +02:00
|
|
|
|
private readonly IMessagingService _messagingService;
|
|
|
|
|
|
2019-05-31 20:15:37 +02:00
|
|
|
|
private NavigationPage _groupingsPage;
|
2021-02-11 01:50:10 +01:00
|
|
|
|
private NavigationPage _sendGroupingsPage;
|
2019-06-05 22:37:54 +02:00
|
|
|
|
private NavigationPage _generatorPage;
|
2019-05-31 20:15:37 +02:00
|
|
|
|
|
2019-07-31 22:50:16 +02:00
|
|
|
|
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null)
|
2019-05-14 15:43:46 +02:00
|
|
|
|
{
|
2021-10-08 14:47:40 +02:00
|
|
|
|
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
|
|
|
|
|
2019-07-31 22:50:16 +02:00
|
|
|
|
_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
|
|
|
|
};
|
2019-05-31 20:15:37 +02:00
|
|
|
|
Children.Add(_groupingsPage);
|
2019-05-14 15:43:46 +02:00
|
|
|
|
|
2021-03-31 16:19:05 +02:00
|
|
|
|
_sendGroupingsPage = new NavigationPage(new SendGroupingsPage(true, null, null, appOptions))
|
2021-02-11 01:50:10 +01:00
|
|
|
|
{
|
|
|
|
|
Title = AppResources.Send,
|
|
|
|
|
IconImageSource = "paper_plane.png",
|
|
|
|
|
};
|
|
|
|
|
Children.Add(_sendGroupingsPage);
|
|
|
|
|
|
2019-06-05 22:37:54 +02:00
|
|
|
|
_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
|
|
|
|
};
|
2019-06-05 22:37:54 +02:00
|
|
|
|
Children.Add(_generatorPage);
|
2019-05-14 15:43:46 +02:00
|
|
|
|
|
2019-05-31 20:15:37 +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);
|
|
|
|
|
|
2020-03-28 14:16:28 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
2019-06-05 22:37:54 +02:00
|
|
|
|
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (appOptions?.GeneratorTile ?? false)
|
2019-06-05 22:37:54 +02:00
|
|
|
|
{
|
|
|
|
|
appOptions.GeneratorTile = false;
|
|
|
|
|
ResetToGeneratorPage();
|
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (appOptions?.MyVaultTile ?? false)
|
2019-06-07 02:34:59 +02:00
|
|
|
|
{
|
|
|
|
|
appOptions.MyVaultTile = false;
|
|
|
|
|
}
|
2021-03-31 16:19:05 +02:00
|
|
|
|
else if (appOptions?.CreateSend != null)
|
|
|
|
|
{
|
|
|
|
|
ResetToSendPage();
|
|
|
|
|
}
|
2019-05-14 15:43:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-31 20:15:37 +02:00
|
|
|
|
public void ResetToVaultPage()
|
|
|
|
|
{
|
|
|
|
|
CurrentPage = _groupingsPage;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 22:37:54 +02:00
|
|
|
|
public void ResetToGeneratorPage()
|
|
|
|
|
{
|
|
|
|
|
CurrentPage = _generatorPage;
|
|
|
|
|
}
|
2021-03-31 16:19:05 +02:00
|
|
|
|
|
|
|
|
|
public void ResetToSendPage()
|
|
|
|
|
{
|
|
|
|
|
CurrentPage = _sendGroupingsPage;
|
|
|
|
|
}
|
2019-06-05 22:37:54 +02:00
|
|
|
|
|
2019-05-14 15:43:46 +02:00
|
|
|
|
protected async override void OnCurrentPageChanged()
|
|
|
|
|
{
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (CurrentPage is NavigationPage navPage)
|
2019-05-14 15:43:46 +02:00
|
|
|
|
{
|
2021-10-08 14:47:40 +02:00
|
|
|
|
_messagingService.Send("updatedTheme");
|
2020-03-28 14:16:28 +01:00
|
|
|
|
if (navPage.RootPage is GroupingsPage groupingsPage)
|
2019-05-14 15:51:13 +02:00
|
|
|
|
{
|
|
|
|
|
// Load something?
|
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
else if (navPage.RootPage is GeneratorPage genPage)
|
2019-05-14 15:43:46 +02:00
|
|
|
|
{
|
|
|
|
|
await genPage.InitAsync();
|
|
|
|
|
}
|
2020-03-28 14:16:28 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|