mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-24 16:38:22 +01:00
reorg groupings page
This commit is contained in:
parent
69ac98b2f6
commit
53974c4464
@ -26,8 +26,8 @@
|
|||||||
<Compile Update="Pages\SettingsPage.xaml.cs">
|
<Compile Update="Pages\SettingsPage.xaml.cs">
|
||||||
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Pages\VaultGroupingsPage.xaml.cs">
|
<Compile Update="Pages\GroupingsPage\GroupingsPage.xaml.cs">
|
||||||
<DependentUpon>VaultGroupingsPage.xaml</DependentUpon>
|
<DependentUpon>GroupingsPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Pages\TabsPage.xaml.cs">
|
<Compile Update="Pages\TabsPage.xaml.cs">
|
||||||
<DependentUpon>TabsPage.xaml</DependentUpon>
|
<DependentUpon>TabsPage.xaml</DependentUpon>
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
<ContentPage
|
<ContentPage
|
||||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
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"
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
x:DataType="pages:VaultGroupingsPageViewModel"
|
x:DataType="pages:GroupingsPageViewModel"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
|
|
||||||
<ContentPage.BindingContext>
|
<ContentPage.BindingContext>
|
||||||
<pages:VaultGroupingsPageViewModel />
|
<pages:GroupingsPageViewModel />
|
||||||
</ContentPage.BindingContext>
|
</ContentPage.BindingContext>
|
||||||
|
|
||||||
<ContentPage.Resources>
|
<ContentPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
x:Key="cipherTemplate"
|
x:Key="cipherTemplate"
|
||||||
x:DataType="pages:VaultGroupingsPageListItem">
|
x:DataType="pages:GroupingsPageListItem">
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
<StackLayout Padding="10">
|
<StackLayout Padding="10">
|
||||||
<Label
|
<Label
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
x:Key="folderTemplate"
|
x:Key="folderTemplate"
|
||||||
x:DataType="pages:VaultGroupingsPageListItem">
|
x:DataType="pages:GroupingsPageListItem">
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
<StackLayout Padding="10">
|
<StackLayout Padding="10">
|
||||||
<Label
|
<Label
|
||||||
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<DataTemplate
|
<DataTemplate
|
||||||
x:Key="collectionTemplate"
|
x:Key="collectionTemplate"
|
||||||
x:DataType="pages:VaultGroupingsPageListItem">
|
x:DataType="pages:GroupingsPageListItem">
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
<StackLayout Padding="10">
|
<StackLayout Padding="10">
|
||||||
<Label
|
<Label
|
||||||
@ -52,7 +52,7 @@
|
|||||||
</ViewCell>
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<pages:ListItemDataTemplateSelector
|
<pages:GroupingsPageListItemSelector
|
||||||
x:Key="listItemDataTemplateSelector"
|
x:Key="listItemDataTemplateSelector"
|
||||||
CipherTemplate="{StaticResource cipherTemplate}"
|
CipherTemplate="{StaticResource cipherTemplate}"
|
||||||
FolderTemplate="{StaticResource folderTemplate}"
|
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
|
namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
public class VaultGroupingsPageViewModel : BaseViewModel
|
public class GroupingsPageViewModel : BaseViewModel
|
||||||
{
|
{
|
||||||
private bool _loading = false;
|
private bool _loading = false;
|
||||||
|
|
||||||
public VaultGroupingsPageViewModel()
|
public GroupingsPageViewModel()
|
||||||
{
|
{
|
||||||
PageTitle = "My Vault";
|
PageTitle = "My Vault";
|
||||||
Items = new ExtendedObservableCollection<VaultGroupingsPageListItem>();
|
Items = new ExtendedObservableCollection<GroupingsPageListItem>();
|
||||||
LoadCommand = new Command(async () => await LoadAsync());
|
LoadCommand = new Command(async () => await LoadAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ namespace Bit.App.Pages
|
|||||||
get => _loading;
|
get => _loading;
|
||||||
set => SetProperty(ref _loading, value);
|
set => SetProperty(ref _loading, value);
|
||||||
}
|
}
|
||||||
public ExtendedObservableCollection<VaultGroupingsPageListItem> Items { get; set; }
|
public ExtendedObservableCollection<GroupingsPageListItem> Items { get; set; }
|
||||||
public Command LoadCommand { get; set; }
|
public Command LoadCommand { get; set; }
|
||||||
|
|
||||||
public Task LoadAsync()
|
public Task LoadAsync()
|
||||||
@ -35,41 +35,41 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Items.ResetWithRange(new List<VaultGroupingsPageListItem>
|
Items.ResetWithRange(new List<GroupingsPageListItem>
|
||||||
{
|
{
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Cipher = new CipherView { Name = "Cipher 1" }
|
Cipher = new CipherView { Name = "Cipher 1" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Cipher = new CipherView { Name = "Cipher 2" }
|
Cipher = new CipherView { Name = "Cipher 2" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Cipher = new CipherView { Name = "Cipher 3" }
|
Cipher = new CipherView { Name = "Cipher 3" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Cipher = new CipherView { Name = "Cipher 4" }
|
Cipher = new CipherView { Name = "Cipher 4" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Folder = new FolderView { Name = "Folder 1" }
|
Folder = new FolderView { Name = "Folder 1" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Folder = new FolderView { Name = "Folder 2" }
|
Folder = new FolderView { Name = "Folder 2" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Folder = new FolderView { Name = "Folder 3" }
|
Folder = new FolderView { Name = "Folder 3" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Collection = new Core.Models.View.CollectionView { Name = "Collection 1" }
|
Collection = new Core.Models.View.CollectionView { Name = "Collection 1" }
|
||||||
},
|
},
|
||||||
new VaultGroupingsPageListItem
|
new GroupingsPageListItem
|
||||||
{
|
{
|
||||||
Collection = new Core.Models.View.CollectionView { Name = "Collection 2" }
|
Collection = new Core.Models.View.CollectionView { Name = "Collection 2" }
|
||||||
},
|
},
|
||||||
@ -83,11 +83,4 @@ namespace Bit.App.Pages
|
|||||||
return Task.FromResult(0);
|
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>
|
<FileImageSource File="lock.png"></FileImageSource>
|
||||||
</NavigationPage.Icon>
|
</NavigationPage.Icon>
|
||||||
<x:Arguments>
|
<x:Arguments>
|
||||||
<pages:VaultGroupingsPage />
|
<pages:GroupingsPage />
|
||||||
</x:Arguments>
|
</x:Arguments>
|
||||||
</NavigationPage>
|
</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 New Issue
Block a user