mirror of
https://github.com/bitwarden/android.git
synced 2024-12-30 21:08:33 +03:00
4aad34cd75
* Dynamic theme switching and visual tweaks * update action runner to use macos-11 for iOS 15 support * additional tweaks * refinements * refinements * formatting and tweaks
110 lines
3.6 KiB
C#
110 lines
3.6 KiB
C#
using Bit.App.Effects;
|
|
using Bit.App.Models;
|
|
using Bit.App.Resources;
|
|
using Bit.Core.Abstractions;
|
|
using Bit.Core.Utilities;
|
|
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)
|
|
{
|
|
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
|
|
|
_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)
|
|
{
|
|
_messagingService.Send("updatedTheme");
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|