diff --git a/src/App/App.csproj b/src/App/App.csproj index 6b3979c98..33f7945b5 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -41,6 +41,9 @@ GeneratorHistoryPage.xaml + + FoldersPage.xaml + SyncPage.xaml diff --git a/src/App/Pages/Settings/FoldersPage.xaml b/src/App/Pages/Settings/FoldersPage.xaml new file mode 100644 index 000000000..5af7b1e4c --- /dev/null +++ b/src/App/Pages/Settings/FoldersPage.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/App/Pages/Settings/FoldersPage.xaml.cs b/src/App/Pages/Settings/FoldersPage.xaml.cs new file mode 100644 index 000000000..63e868702 --- /dev/null +++ b/src/App/Pages/Settings/FoldersPage.xaml.cs @@ -0,0 +1,46 @@ +using System; +using Xamarin.Forms; + +namespace Bit.App.Pages +{ + public partial class FoldersPage : BaseContentPage + { + private FoldersPageViewModel _vm; + + public FoldersPage() + { + InitializeComponent(); + SetActivityIndicator(_mainContent); + _vm = BindingContext as FoldersPageViewModel; + _vm.Page = this; + + if(Device.RuntimePlatform == Device.iOS) + { + _absLayout.Children.Remove(_fab); + } + else + { + _fab.Clicked = AddButton_Clicked; + } + } + + protected override async void OnAppearing() + { + base.OnAppearing(); + await LoadOnAppearedAsync(_mainLayout, true, async () => + { + await _vm.InitAsync(); + }, _mainContent); + } + + private async void RowSelected(object sender, SelectedItemChangedEventArgs e) + { + + } + + private async void AddButton_Clicked(object sender, EventArgs e) + { + + } + } +} diff --git a/src/App/Pages/Settings/FoldersPageViewModel.cs b/src/App/Pages/Settings/FoldersPageViewModel.cs new file mode 100644 index 000000000..8c2019ae6 --- /dev/null +++ b/src/App/Pages/Settings/FoldersPageViewModel.cs @@ -0,0 +1,47 @@ +using Bit.App.Resources; +using Bit.Core.Abstractions; +using Bit.Core.Models.View; +using Bit.Core.Utilities; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Bit.App.Pages +{ + public class FoldersPageViewModel : BaseViewModel + { + private readonly IPlatformUtilsService _platformUtilsService; + private readonly IFolderService _folderService; + + private bool _showNoData; + + public FoldersPageViewModel() + { + _platformUtilsService = ServiceContainer.Resolve("platformUtilsService"); + _folderService = ServiceContainer.Resolve("folderService"); + + PageTitle = AppResources.Folders; + Folders = new ExtendedObservableCollection(); + } + + public ExtendedObservableCollection Folders { get; set; } + + public bool ShowNoData + { + get => _showNoData; + set => SetProperty(ref _showNoData, value); + } + + public async Task InitAsync() + { + var folders = await _folderService.GetAllDecryptedAsync(); + // Remove "No Folder" + if(folders?.Any() ?? false) + { + folders.Remove(folders.Last()); + } + Folders.ResetWithRange(folders ?? new List()); + ShowNoData = Folders.Count == 0; + } + } +} diff --git a/src/App/Pages/Settings/SettingsPage.xaml.cs b/src/App/Pages/Settings/SettingsPage.xaml.cs index 331d177c7..0b3661e9f 100644 --- a/src/App/Pages/Settings/SettingsPage.xaml.cs +++ b/src/App/Pages/Settings/SettingsPage.xaml.cs @@ -36,6 +36,10 @@ namespace Bit.App.Pages { await Navigation.PushModalAsync(new NavigationPage(new SyncPage())); } + else if(item.Name == AppResources.Folders) + { + await Navigation.PushModalAsync(new NavigationPage(new FoldersPage())); + } } } } diff --git a/src/App/Resources/AppResources.Designer.cs b/src/App/Resources/AppResources.Designer.cs index 98e417c28..7060e8372 100644 --- a/src/App/Resources/AppResources.Designer.cs +++ b/src/App/Resources/AppResources.Designer.cs @@ -2490,6 +2490,15 @@ namespace Bit.App.Resources { } } + /// + /// Looks up a localized string similar to There are no folders to list.. + /// + public static string NoFoldersToList { + get { + return ResourceManager.GetString("NoFoldersToList", resourceCulture); + } + } + /// /// Looks up a localized string similar to There are no items in your vault.. /// diff --git a/src/App/Resources/AppResources.resx b/src/App/Resources/AppResources.resx index 8b83ed8bb..3bbbb2ee6 100644 --- a/src/App/Resources/AppResources.resx +++ b/src/App/Resources/AppResources.resx @@ -1464,4 +1464,7 @@ Generator Short for "Password Generator" + + There are no folders to list. + \ No newline at end of file