2019-06-12 15:31:33 +03:00
|
|
|
|
using Bit.App.Effects;
|
2019-06-05 23:37:54 +03:00
|
|
|
|
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
|
|
|
|
|
{
|
2019-05-31 21:15:37 +03:00
|
|
|
|
private NavigationPage _groupingsPage;
|
2019-06-05 23:37:54 +03:00
|
|
|
|
private NavigationPage _generatorPage;
|
2019-05-31 21:15:37 +03:00
|
|
|
|
|
2019-07-31 23:50:16 +03:00
|
|
|
|
public TabsPage(AppOptions appOptions = null, PreviousPageInfo previousPage = null)
|
2019-05-14 16:43:46 +03:00
|
|
|
|
{
|
2019-07-31 23:50:16 +03:00
|
|
|
|
_groupingsPage = new NavigationPage(new GroupingsPage(true, previousPage: previousPage))
|
2019-05-14 16:43:46 +03:00
|
|
|
|
{
|
|
|
|
|
Title = AppResources.MyVault,
|
|
|
|
|
Icon = "lock.png"
|
|
|
|
|
};
|
2019-05-31 21:15:37 +03:00
|
|
|
|
Children.Add(_groupingsPage);
|
2019-05-14 16:43:46 +03:00
|
|
|
|
|
2019-06-05 23:37:54 +03:00
|
|
|
|
_generatorPage = new NavigationPage(new GeneratorPage(true, null, this))
|
2019-05-14 16:43:46 +03:00
|
|
|
|
{
|
|
|
|
|
Title = AppResources.Generator,
|
|
|
|
|
Icon = "refresh.png"
|
|
|
|
|
};
|
2019-06-05 23:37:54 +03:00
|
|
|
|
Children.Add(_generatorPage);
|
2019-05-14 16:43:46 +03:00
|
|
|
|
|
2019-05-31 21:15:37 +03:00
|
|
|
|
var settingsPage = new NavigationPage(new SettingsPage(this))
|
2019-05-14 16:43:46 +03:00
|
|
|
|
{
|
|
|
|
|
Title = AppResources.Settings,
|
2019-05-31 04:24:03 +03:00
|
|
|
|
Icon = "cog.png"
|
2019-05-14 16:43:46 +03:00
|
|
|
|
};
|
|
|
|
|
Children.Add(settingsPage);
|
|
|
|
|
|
2019-05-31 04:24:03 +03:00
|
|
|
|
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);
|
|
|
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetBarSelectedItemColor(this,
|
|
|
|
|
(Color)Application.Current.Resources["TabBarSelectedItemColor"]);
|
|
|
|
|
Xamarin.Forms.PlatformConfiguration.AndroidSpecific.TabbedPage.SetBarItemColor(this,
|
|
|
|
|
(Color)Application.Current.Resources["TabBarItemColor"]);
|
|
|
|
|
}
|
2019-06-05 23:37:54 +03:00
|
|
|
|
|
|
|
|
|
if(appOptions?.GeneratorTile ?? false)
|
|
|
|
|
{
|
|
|
|
|
appOptions.GeneratorTile = false;
|
|
|
|
|
ResetToGeneratorPage();
|
|
|
|
|
}
|
2019-06-07 03:34:59 +03:00
|
|
|
|
else if(appOptions?.MyVaultTile ?? false)
|
|
|
|
|
{
|
|
|
|
|
appOptions.MyVaultTile = false;
|
|
|
|
|
}
|
2019-05-14 16:43:46 +03:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-31 21:15:37 +03:00
|
|
|
|
public void ResetToVaultPage()
|
|
|
|
|
{
|
|
|
|
|
CurrentPage = _groupingsPage;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-05 23:37:54 +03:00
|
|
|
|
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:51:13 +03:00
|
|
|
|
if(navPage.RootPage is GroupingsPage groupingsPage)
|
|
|
|
|
{
|
|
|
|
|
// Load something?
|
|
|
|
|
}
|
|
|
|
|
else if(navPage.RootPage is GeneratorPage genPage)
|
2019-05-14 16:43:46 +03:00
|
|
|
|
{
|
|
|
|
|
await genPage.InitAsync();
|
|
|
|
|
}
|
2019-05-14 16:51:13 +03:00
|
|
|
|
else if(navPage.RootPage is SettingsPage settingsPage)
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|