diff --git a/src/App/App.csproj b/src/App/App.csproj index a979c09be..ff19d424d 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -68,9 +68,6 @@ GroupingsPage.xaml - - TabsPage.xaml - diff --git a/src/App/Pages/Generator/GeneratorPage.xaml.cs b/src/App/Pages/Generator/GeneratorPage.xaml.cs index a30a619b3..d5b9495c1 100644 --- a/src/App/Pages/Generator/GeneratorPage.xaml.cs +++ b/src/App/Pages/Generator/GeneratorPage.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Xamarin.Forms; namespace Bit.App.Pages @@ -6,17 +7,15 @@ namespace Bit.App.Pages public partial class GeneratorPage : BaseContentPage { private GeneratorPageViewModel _vm; + private readonly bool _fromTabPage; private readonly Action _selectAction; - public GeneratorPage() - : this(null) - { } - - public GeneratorPage(Action selectAction) + public GeneratorPage(bool fromTabPage, Action selectAction = null) { InitializeComponent(); _vm = BindingContext as GeneratorPageViewModel; _vm.Page = this; + _fromTabPage = fromTabPage; _selectAction = selectAction; if(selectAction == null) { @@ -24,10 +23,18 @@ namespace Bit.App.Pages } } + public async Task InitAsync() + { + await _vm.InitAsync(); + } + protected async override void OnAppearing() { base.OnAppearing(); - await _vm.InitAsync(); + if(!_fromTabPage) + { + await InitAsync(); + } } private async void Regenerate_Clicked(object sender, EventArgs e) diff --git a/src/App/Pages/TabsPage.cs b/src/App/Pages/TabsPage.cs new file mode 100644 index 000000000..9227aafaa --- /dev/null +++ b/src/App/Pages/TabsPage.cs @@ -0,0 +1,48 @@ +using Bit.App.Resources; +using Xamarin.Forms; + +namespace Bit.App.Pages +{ + public class TabsPage : TabbedPage + { + public TabsPage() + { + var groupingsPage = new NavigationPage(new GroupingsPage()) + { + Title = AppResources.MyVault, + Icon = "lock.png" + }; + Children.Add(groupingsPage); + + var generatorPage = new NavigationPage(new GeneratorPage(true, null)) + { + Title = AppResources.Generator, + Icon = "refresh.png" + }; + Children.Add(generatorPage); + + var settingsPage = new NavigationPage(new SettingsPage()) + { + Title = AppResources.Settings, + Icon = "cogs.png" + }; + Children.Add(settingsPage); + + 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); + } + + protected async override void OnCurrentPageChanged() + { + if(CurrentPage is NavigationPage navPage) + { + if(navPage.RootPage is GeneratorPage genPage) + { + await genPage.InitAsync(); + } + } + } + } +} diff --git a/src/App/Pages/TabsPage.xaml b/src/App/Pages/TabsPage.xaml deleted file mode 100644 index 3b0db1f77..000000000 --- a/src/App/Pages/TabsPage.xaml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/App/Pages/TabsPage.xaml.cs b/src/App/Pages/TabsPage.xaml.cs deleted file mode 100644 index 5844a392c..000000000 --- a/src/App/Pages/TabsPage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xamarin.Forms; -using Xamarin.Forms.Xaml; - -namespace Bit.App.Pages -{ - public partial class TabsPage : TabbedPage - { - public TabsPage() - { - InitializeComponent(); - } - } -} diff --git a/src/App/Pages/Vault/AddEditPageViewModel.cs b/src/App/Pages/Vault/AddEditPageViewModel.cs index 5d6378dbd..ea02bdd40 100644 --- a/src/App/Pages/Vault/AddEditPageViewModel.cs +++ b/src/App/Pages/Vault/AddEditPageViewModel.cs @@ -429,7 +429,7 @@ namespace Bit.App.Pages return; } } - var page = new GeneratorPage(async (password) => + var page = new GeneratorPage(false, async (password) => { Cipher.Login.Password = password; TriggerCipherChanged(); diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index d273e376f..98e417c28 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -1698,6 +1698,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to Generator. + /// + public static string Generator { + get { + return ResourceManager.GetString("Generator", resourceCulture); + } + } + /// /// Looks up a localized string similar to Get your master password hint. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 0e2e858f0..8b83ed8bb 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1460,4 +1460,8 @@ Clear To clear something out. example: To clear browser history. + + Generator + Short for "Password Generator" + \ No newline at end of file