mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
reorg groupings page
This commit is contained in:
parent
69ac98b2f6
commit
53974c4464
8 changed files with 90 additions and 82 deletions
|
@ -26,8 +26,8 @@
|
|||
<Compile Update="Pages\SettingsPage.xaml.cs">
|
||||
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Pages\VaultGroupingsPage.xaml.cs">
|
||||
<DependentUpon>VaultGroupingsPage.xaml</DependentUpon>
|
||||
<Compile Update="Pages\GroupingsPage\GroupingsPage.xaml.cs">
|
||||
<DependentUpon>GroupingsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Pages\TabsPage.xaml.cs">
|
||||
<DependentUpon>TabsPage.xaml</DependentUpon>
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
<ContentPage
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Bit.App.Pages.VaultGroupingsPage"
|
||||
x:Class="Bit.App.Pages.GroupingsPage"
|
||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||
x:DataType="pages:VaultGroupingsPageViewModel"
|
||||
x:DataType="pages:GroupingsPageViewModel"
|
||||
Title="{Binding PageTitle}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<pages:VaultGroupingsPageViewModel />
|
||||
<pages:GroupingsPageViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<DataTemplate
|
||||
x:Key="cipherTemplate"
|
||||
x:DataType="pages:VaultGroupingsPageListItem">
|
||||
x:DataType="pages:GroupingsPageListItem">
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10">
|
||||
<Label
|
||||
|
@ -28,7 +28,7 @@
|
|||
|
||||
<DataTemplate
|
||||
x:Key="folderTemplate"
|
||||
x:DataType="pages:VaultGroupingsPageListItem">
|
||||
x:DataType="pages:GroupingsPageListItem">
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10">
|
||||
<Label
|
||||
|
@ -41,7 +41,7 @@
|
|||
|
||||
<DataTemplate
|
||||
x:Key="collectionTemplate"
|
||||
x:DataType="pages:VaultGroupingsPageListItem">
|
||||
x:DataType="pages:GroupingsPageListItem">
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10">
|
||||
<Label
|
||||
|
@ -52,7 +52,7 @@
|
|||
</ViewCell>
|
||||
</DataTemplate>
|
||||
|
||||
<pages:ListItemDataTemplateSelector
|
||||
<pages:GroupingsPageListItemSelector
|
||||
x:Key="listItemDataTemplateSelector"
|
||||
CipherTemplate="{StaticResource cipherTemplate}"
|
||||
FolderTemplate="{StaticResource folderTemplate}"
|
27
src/App/Pages/GroupingsPage/GroupingsPage.xaml.cs
Normal file
27
src/App/Pages/GroupingsPage/GroupingsPage.xaml.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
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 GroupingsPage : ContentPage
|
||||
{
|
||||
private GroupingsPageViewModel _viewModel;
|
||||
|
||||
public GroupingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_viewModel = BindingContext as GroupingsPageViewModel;
|
||||
}
|
||||
|
||||
protected async override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
await _viewModel.LoadAsync();
|
||||
}
|
||||
}
|
||||
}
|
11
src/App/Pages/GroupingsPage/GroupingsPageListItem.cs
Normal file
11
src/App/Pages/GroupingsPage/GroupingsPageListItem.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Bit.Core.Models.View;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class GroupingsPageListItem
|
||||
{
|
||||
public FolderView Folder { get; set; }
|
||||
public Core.Models.View.CollectionView Collection { get; set; }
|
||||
public CipherView Cipher { get; set; }
|
||||
}
|
||||
}
|
28
src/App/Pages/GroupingsPage/GroupingsPageListItemSelector.cs
Normal file
28
src/App/Pages/GroupingsPage/GroupingsPageListItemSelector.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class GroupingsPageListItemSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate CipherTemplate { get; set; }
|
||||
public DataTemplate FolderTemplate { get; set; }
|
||||
public DataTemplate CollectionTemplate { get; set; }
|
||||
|
||||
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
|
||||
{
|
||||
if(item is GroupingsPageListItem listItem)
|
||||
{
|
||||
if(listItem.Collection != null)
|
||||
{
|
||||
return CollectionTemplate;
|
||||
}
|
||||
else if(listItem.Folder != null)
|
||||
{
|
||||
return FolderTemplate;
|
||||
}
|
||||
return CipherTemplate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,14 +6,14 @@ using Xamarin.Forms;
|
|||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class VaultGroupingsPageViewModel : BaseViewModel
|
||||
public class GroupingsPageViewModel : BaseViewModel
|
||||
{
|
||||
private bool _loading = false;
|
||||
|
||||
public VaultGroupingsPageViewModel()
|
||||
public GroupingsPageViewModel()
|
||||
{
|
||||
PageTitle = "My Vault";
|
||||
Items = new ExtendedObservableCollection<VaultGroupingsPageListItem>();
|
||||
Items = new ExtendedObservableCollection<GroupingsPageListItem>();
|
||||
LoadCommand = new Command(async () => await LoadAsync());
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace Bit.App.Pages
|
|||
get => _loading;
|
||||
set => SetProperty(ref _loading, value);
|
||||
}
|
||||
public ExtendedObservableCollection<VaultGroupingsPageListItem> Items { get; set; }
|
||||
public ExtendedObservableCollection<GroupingsPageListItem> Items { get; set; }
|
||||
public Command LoadCommand { get; set; }
|
||||
|
||||
public Task LoadAsync()
|
||||
|
@ -35,41 +35,41 @@ namespace Bit.App.Pages
|
|||
|
||||
try
|
||||
{
|
||||
Items.ResetWithRange(new List<VaultGroupingsPageListItem>
|
||||
Items.ResetWithRange(new List<GroupingsPageListItem>
|
||||
{
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Cipher = new CipherView { Name = "Cipher 1" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Cipher = new CipherView { Name = "Cipher 2" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Cipher = new CipherView { Name = "Cipher 3" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Cipher = new CipherView { Name = "Cipher 4" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Folder = new FolderView { Name = "Folder 1" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Folder = new FolderView { Name = "Folder 2" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Folder = new FolderView { Name = "Folder 3" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Collection = new Core.Models.View.CollectionView { Name = "Collection 1" }
|
||||
},
|
||||
new VaultGroupingsPageListItem
|
||||
new GroupingsPageListItem
|
||||
{
|
||||
Collection = new Core.Models.View.CollectionView { Name = "Collection 2" }
|
||||
},
|
||||
|
@ -83,11 +83,4 @@ namespace Bit.App.Pages
|
|||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
|
||||
public class VaultGroupingsPageListItem
|
||||
{
|
||||
public FolderView Folder { get; set; }
|
||||
public Core.Models.View.CollectionView Collection { get; set; }
|
||||
public CipherView Cipher { get; set; }
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
<FileImageSource File="lock.png"></FileImageSource>
|
||||
</NavigationPage.Icon>
|
||||
<x:Arguments>
|
||||
<pages:VaultGroupingsPage />
|
||||
<pages:GroupingsPage />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
|
||||
|
|
|
@ -1,51 +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 VaultGroupingsPage : ContentPage
|
||||
{
|
||||
private VaultGroupingsPageViewModel _viewModel;
|
||||
|
||||
public VaultGroupingsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
_viewModel = BindingContext as VaultGroupingsPageViewModel;
|
||||
}
|
||||
|
||||
protected async override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
await _viewModel.LoadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public class ListItemDataTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate CipherTemplate { get; set; }
|
||||
public DataTemplate FolderTemplate { get; set; }
|
||||
public DataTemplate CollectionTemplate { get; set; }
|
||||
|
||||
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
|
||||
{
|
||||
if(item is VaultGroupingsPageListItem listItem)
|
||||
{
|
||||
if(listItem.Collection != null)
|
||||
{
|
||||
return CollectionTemplate;
|
||||
}
|
||||
else if(listItem.Folder != null)
|
||||
{
|
||||
return FolderTemplate;
|
||||
}
|
||||
return CipherTemplate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue