mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
no data messages
This commit is contained in:
parent
003092a55b
commit
be5fd8381f
2 changed files with 56 additions and 7 deletions
|
@ -3,6 +3,7 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="Bit.App.Pages.GroupingsPage"
|
x:Class="Bit.App.Pages.GroupingsPage"
|
||||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
xmlns:controls="clr-namespace:Bit.App.Controls"
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
x:DataType="pages:GroupingsPageViewModel"
|
x:DataType="pages:GroupingsPageViewModel"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
|
@ -60,9 +61,23 @@
|
||||||
CollectionTemplate="{StaticResource collectionTemplate}" />
|
CollectionTemplate="{StaticResource collectionTemplate}" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</ContentPage.Resources>
|
</ContentPage.Resources>
|
||||||
|
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
|
<ActivityIndicator VerticalOptions="CenterAndExpand"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
IsRunning="True"
|
||||||
|
IsVisible="{Binding Loading}"></ActivityIndicator>
|
||||||
|
<StackLayout VerticalOptions="CenterAndExpand"
|
||||||
|
Padding="20, 0"
|
||||||
|
Spacing="20"
|
||||||
|
IsVisible="{Binding ShowNoData}">
|
||||||
|
<Label Text="{Binding NoDataText}"
|
||||||
|
HorizontalTextAlignment="Center"></Label>
|
||||||
|
<Button Text="{u:I18n AddAnItem}"
|
||||||
|
Command="{Binding AddCipherCommand}"
|
||||||
|
IsVisible="{Binding ShowAddCipherButton}"></Button>
|
||||||
|
</StackLayout>
|
||||||
<ListView x:Name="ItemsListView"
|
<ListView x:Name="ItemsListView"
|
||||||
|
IsVisible="{Binding ShowList}"
|
||||||
ItemsSource="{Binding GroupedItems}"
|
ItemsSource="{Binding GroupedItems}"
|
||||||
VerticalOptions="FillAndExpand"
|
VerticalOptions="FillAndExpand"
|
||||||
HasUnevenRows="true"
|
HasUnevenRows="true"
|
||||||
|
|
|
@ -15,6 +15,10 @@ namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
private bool _loading = false;
|
private bool _loading = false;
|
||||||
private bool _loaded = false;
|
private bool _loaded = false;
|
||||||
|
private bool _showAddCipherButton = false;
|
||||||
|
private bool _showNoData = false;
|
||||||
|
private bool _showList = false;
|
||||||
|
private string _noDataText;
|
||||||
private List<CipherView> _allCiphers;
|
private List<CipherView> _allCiphers;
|
||||||
|
|
||||||
private readonly ICipherService _cipherService;
|
private readonly ICipherService _cipherService;
|
||||||
|
@ -32,6 +36,7 @@ namespace Bit.App.Pages
|
||||||
PageTitle = AppResources.MyVault;
|
PageTitle = AppResources.MyVault;
|
||||||
GroupedItems = new ExtendedObservableCollection<GroupingsPageListGroup>();
|
GroupedItems = new ExtendedObservableCollection<GroupingsPageListGroup>();
|
||||||
LoadCommand = new Command(async () => await LoadAsync());
|
LoadCommand = new Command(async () => await LoadAsync());
|
||||||
|
AddCipherCommand = new Command(() => { /* TODO */ });
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShowFavorites { get; set; } = true;
|
public bool ShowFavorites { get; set; } = true;
|
||||||
|
@ -58,17 +63,40 @@ namespace Bit.App.Pages
|
||||||
public bool Loaded
|
public bool Loaded
|
||||||
{
|
{
|
||||||
get => _loaded;
|
get => _loaded;
|
||||||
set
|
set => SetProperty(ref _loaded, value);
|
||||||
{
|
|
||||||
SetProperty(ref _loaded, value);
|
|
||||||
SetProperty(ref _loading, !value);
|
|
||||||
}
|
}
|
||||||
|
public bool ShowAddCipherButton
|
||||||
|
{
|
||||||
|
get => _showAddCipherButton;
|
||||||
|
set => SetProperty(ref _showAddCipherButton, value);
|
||||||
|
}
|
||||||
|
public bool ShowNoData
|
||||||
|
{
|
||||||
|
get => _showNoData;
|
||||||
|
set => SetProperty(ref _showNoData, value);
|
||||||
|
}
|
||||||
|
public string NoDataText
|
||||||
|
{
|
||||||
|
get => _noDataText;
|
||||||
|
set => SetProperty(ref _noDataText, value);
|
||||||
|
}
|
||||||
|
public bool ShowList
|
||||||
|
{
|
||||||
|
get => _showList;
|
||||||
|
set => SetProperty(ref _showList, value);
|
||||||
}
|
}
|
||||||
public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; }
|
public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; }
|
||||||
public Command LoadCommand { get; set; }
|
public Command LoadCommand { get; set; }
|
||||||
|
public Command AddCipherCommand { get; set; }
|
||||||
|
|
||||||
public async Task LoadAsync()
|
public async Task LoadAsync()
|
||||||
{
|
{
|
||||||
|
ShowNoData = false;
|
||||||
|
Loading = true;
|
||||||
|
ShowList = false;
|
||||||
|
ShowAddCipherButton = true;
|
||||||
|
var groupedItems = new List<GroupingsPageListGroup>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await LoadDataAsync();
|
await LoadDataAsync();
|
||||||
|
@ -79,7 +107,6 @@ namespace Bit.App.Pages
|
||||||
var collectionListItems = NestedCollections?.Select(c =>
|
var collectionListItems = NestedCollections?.Select(c =>
|
||||||
new GroupingsPageListItem { Collection = c.Node }).ToList();
|
new GroupingsPageListItem { Collection = c.Node }).ToList();
|
||||||
|
|
||||||
var groupedItems = new List<GroupingsPageListGroup>();
|
|
||||||
if(favListItems?.Any() ?? false)
|
if(favListItems?.Any() ?? false)
|
||||||
{
|
{
|
||||||
groupedItems.Add(new GroupingsPageListGroup(favListItems, AppResources.Favorites,
|
groupedItems.Add(new GroupingsPageListGroup(favListItems, AppResources.Favorites,
|
||||||
|
@ -104,7 +131,10 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
ShowNoData = !groupedItems.Any();
|
||||||
|
ShowList = !ShowNoData;
|
||||||
Loaded = true;
|
Loaded = true;
|
||||||
|
Loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +182,7 @@ namespace Bit.App.Pages
|
||||||
|
|
||||||
private async Task LoadDataAsync()
|
private async Task LoadDataAsync()
|
||||||
{
|
{
|
||||||
|
NoDataText = AppResources.NoItems;
|
||||||
_allCiphers = await _cipherService.GetAllDecryptedAsync();
|
_allCiphers = await _cipherService.GetAllDecryptedAsync();
|
||||||
if(MainPage)
|
if(MainPage)
|
||||||
{
|
{
|
||||||
|
@ -195,6 +226,7 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
else if(FolderId != null)
|
else if(FolderId != null)
|
||||||
{
|
{
|
||||||
|
NoDataText = AppResources.NoItemsFolder;
|
||||||
FolderId = FolderId == "none" ? null : FolderId;
|
FolderId = FolderId == "none" ? null : FolderId;
|
||||||
if(FolderId != null)
|
if(FolderId != null)
|
||||||
{
|
{
|
||||||
|
@ -213,6 +245,8 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
else if(CollectionId != null)
|
else if(CollectionId != null)
|
||||||
{
|
{
|
||||||
|
ShowAddCipherButton = false;
|
||||||
|
NoDataText = AppResources.NoItemsCollection;
|
||||||
var collectionNode = await _collectionService.GetNestedAsync(CollectionId);
|
var collectionNode = await _collectionService.GetNestedAsync(CollectionId);
|
||||||
if(collectionNode?.Node != null)
|
if(collectionNode?.Node != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue