mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
folders page
This commit is contained in:
parent
b68031bd11
commit
f9473ea61d
7 changed files with 183 additions and 0 deletions
|
@ -41,6 +41,9 @@
|
||||||
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
|
<Compile Update="Pages\Generator\GeneratorHistoryPage.xaml.cs">
|
||||||
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
|
<DependentUpon>GeneratorHistoryPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Pages\Settings\FoldersPage.xaml.cs">
|
||||||
|
<DependentUpon>FoldersPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Update="Pages\Settings\SyncPage.xaml.cs">
|
<Compile Update="Pages\Settings\SyncPage.xaml.cs">
|
||||||
<DependentUpon>SyncPage.xaml</DependentUpon>
|
<DependentUpon>SyncPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
71
src/App/Pages/Settings/FoldersPage.xaml
Normal file
71
src/App/Pages/Settings/FoldersPage.xaml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<pages:BaseContentPage
|
||||||
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Bit.App.Pages.FoldersPage"
|
||||||
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
|
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
||||||
|
xmlns:fab="clr-namespace:Refractored.FabControl;assembly=Refractored.FabControl"
|
||||||
|
x:DataType="pages:FoldersPageViewModel"
|
||||||
|
x:Name="_page"
|
||||||
|
Title="{Binding PageTitle}">
|
||||||
|
|
||||||
|
<ContentPage.BindingContext>
|
||||||
|
<pages:FoldersPageViewModel />
|
||||||
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||||
|
<StackLayout x:Name="_mainLayout" x:Key="mainLayout">
|
||||||
|
<Label IsVisible="{Binding ShowNoData}"
|
||||||
|
Text="{u:I18n NoFoldersToList}"
|
||||||
|
Margin="20, 0"
|
||||||
|
VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="CenterAndExpand"
|
||||||
|
HorizontalTextAlignment="Center"></Label>
|
||||||
|
<ListView x:Name="_listView"
|
||||||
|
IsVisible="{Binding ShowNoData, Converter={StaticResource inverseBool}}"
|
||||||
|
ItemsSource="{Binding Folders}"
|
||||||
|
VerticalOptions="FillAndExpand"
|
||||||
|
CachingStrategy="RecycleElement"
|
||||||
|
SelectedItem="Row_Selected"
|
||||||
|
StyleClass="list, list-platform">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="views:FolderView">
|
||||||
|
<ViewCell>
|
||||||
|
<StackLayout
|
||||||
|
StyleClass="list-row, list-row-platform"
|
||||||
|
Padding="10">
|
||||||
|
<Label LineBreakMode="TailTruncation"
|
||||||
|
StyleClass="list-title, list-title-platform"
|
||||||
|
Text="{Binding Name, Mode=OneWay}" />
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
|
||||||
|
<AbsoluteLayout
|
||||||
|
x:Name="_absLayout"
|
||||||
|
VerticalOptions="FillAndExpand"
|
||||||
|
HorizontalOptions="FillAndExpand">
|
||||||
|
<ContentView
|
||||||
|
x:Name="_mainContent"
|
||||||
|
AbsoluteLayout.LayoutFlags="All"
|
||||||
|
AbsoluteLayout.LayoutBounds="0, 0, 1, 1">
|
||||||
|
</ContentView>
|
||||||
|
<fab:FloatingActionButtonView
|
||||||
|
x:Name="_fab"
|
||||||
|
ImageName="plus.png"
|
||||||
|
AbsoluteLayout.LayoutFlags="PositionProportional"
|
||||||
|
AbsoluteLayout.LayoutBounds="1, 1, AutoSize, AutoSize">
|
||||||
|
</fab:FloatingActionButtonView>
|
||||||
|
</AbsoluteLayout>
|
||||||
|
|
||||||
|
</pages:BaseContentPage>
|
46
src/App/Pages/Settings/FoldersPage.xaml.cs
Normal file
46
src/App/Pages/Settings/FoldersPage.xaml.cs
Normal file
|
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
src/App/Pages/Settings/FoldersPageViewModel.cs
Normal file
47
src/App/Pages/Settings/FoldersPageViewModel.cs
Normal file
|
@ -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<IPlatformUtilsService>("platformUtilsService");
|
||||||
|
_folderService = ServiceContainer.Resolve<IFolderService>("folderService");
|
||||||
|
|
||||||
|
PageTitle = AppResources.Folders;
|
||||||
|
Folders = new ExtendedObservableCollection<FolderView>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtendedObservableCollection<FolderView> 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<FolderView>());
|
||||||
|
ShowNoData = Folders.Count == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,6 +36,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
await Navigation.PushModalAsync(new NavigationPage(new SyncPage()));
|
await Navigation.PushModalAsync(new NavigationPage(new SyncPage()));
|
||||||
}
|
}
|
||||||
|
else if(item.Name == AppResources.Folders)
|
||||||
|
{
|
||||||
|
await Navigation.PushModalAsync(new NavigationPage(new FoldersPage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
src/App/Resources/AppResources.Designer.cs
generated
9
src/App/Resources/AppResources.Designer.cs
generated
|
@ -2490,6 +2490,15 @@ namespace Bit.App.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to There are no folders to list..
|
||||||
|
/// </summary>
|
||||||
|
public static string NoFoldersToList {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("NoFoldersToList", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to There are no items in your vault..
|
/// Looks up a localized string similar to There are no items in your vault..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1464,4 +1464,7 @@
|
||||||
<value>Generator</value>
|
<value>Generator</value>
|
||||||
<comment>Short for "Password Generator"</comment>
|
<comment>Short for "Password Generator"</comment>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="NoFoldersToList" xml:space="preserve">
|
||||||
|
<value>There are no folders to list.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in a new issue