mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-19 15:48:21 +01:00
autofill page fixes
This commit is contained in:
parent
22366ec0a2
commit
65f3a146fa
@ -20,6 +20,8 @@
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
|
||||
<DataTemplate x:Key="cipherTemplate"
|
||||
x:DataType="pages:GroupingsPageListItem">
|
||||
<controls:CipherViewCell
|
||||
@ -35,9 +37,9 @@
|
||||
VerticalOptions="CenterAndExpand"
|
||||
Padding="20, 0"
|
||||
Spacing="20"
|
||||
IsVisible="{Binding ShowNoData}">
|
||||
IsVisible="{Binding ShowList, Converter={StaticResource inverseBool}}">
|
||||
<Label
|
||||
Text="TODO: no data"
|
||||
Text="{Binding NoDataText}"
|
||||
HorizontalTextAlignment="Center"></Label>
|
||||
<Button
|
||||
Text="{u:I18n AddAnItem}"
|
||||
|
@ -15,6 +15,7 @@ namespace Bit.App.Pages
|
||||
InitializeComponent();
|
||||
_vm = BindingContext as AutofillCiphersPageViewModel;
|
||||
_vm.Page = this;
|
||||
_fab.Clicked = AddButton_Clicked;
|
||||
_vm.Init(appOptions);
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace Bit.App.Pages
|
||||
private AppOptions _appOptions;
|
||||
private string _name;
|
||||
private string _uri;
|
||||
private bool _showNoData;
|
||||
private bool _showList;
|
||||
private string _noDataText;
|
||||
|
||||
public AutofillCiphersPageViewModel()
|
||||
{
|
||||
@ -41,18 +41,18 @@ namespace Bit.App.Pages
|
||||
public Command CipherOptionsCommand { get; set; }
|
||||
public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; }
|
||||
|
||||
public bool ShowNoData
|
||||
{
|
||||
get => _showNoData;
|
||||
set => SetProperty(ref _showNoData, value);
|
||||
}
|
||||
|
||||
public bool ShowList
|
||||
{
|
||||
get => _showList;
|
||||
set => SetProperty(ref _showList, value);
|
||||
}
|
||||
|
||||
public string NoDataText
|
||||
{
|
||||
get => _noDataText;
|
||||
set => SetProperty(ref _noDataText, value);
|
||||
}
|
||||
|
||||
public void Init(AppOptions appOptions)
|
||||
{
|
||||
_appOptions = appOptions;
|
||||
@ -67,23 +67,29 @@ namespace Bit.App.Pages
|
||||
_name = "--";
|
||||
}
|
||||
PageTitle = string.Format(AppResources.ItemsForUri, _name ?? "--");
|
||||
NoDataText = string.Format(AppResources.NoItemsForUri, _name ?? "--");
|
||||
}
|
||||
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
ShowNoData = false;
|
||||
ShowList = false;
|
||||
|
||||
var groupedItems = new List<GroupingsPageListGroup>();
|
||||
var ciphers = await _cipherService.GetAllDecryptedByUrlAsync(_uri, null);
|
||||
var matching = ciphers.Item1?.Select(c => new GroupingsPageListItem { Cipher = c }).ToList();
|
||||
var matchingGroup = new GroupingsPageListGroup(matching, AppResources.MatchingItems, matching.Count, false);
|
||||
var fuzzy = ciphers.Item2?.Select(c => new GroupingsPageListItem { Cipher = c, FuzzyAutofill = true })
|
||||
.ToList();
|
||||
var fuzzyGroup = new GroupingsPageListGroup(fuzzy, AppResources.PossibleMatchingItems, fuzzy.Count, false);
|
||||
GroupedItems.ResetWithRange(new List<GroupingsPageListGroup> { matchingGroup, fuzzyGroup });
|
||||
|
||||
ShowNoData = !matching.Any() && !fuzzy.Any();
|
||||
ShowList = !ShowNoData;
|
||||
if(matching?.Any() ?? false)
|
||||
{
|
||||
groupedItems.Add(
|
||||
new GroupingsPageListGroup(matching, AppResources.MatchingItems, matching.Count, false));
|
||||
}
|
||||
var fuzzy = ciphers.Item2?.Select(c =>
|
||||
new GroupingsPageListItem { Cipher = c, FuzzyAutofill = true }).ToList();
|
||||
if(fuzzy?.Any() ?? false)
|
||||
{
|
||||
groupedItems.Add(
|
||||
new GroupingsPageListGroup(fuzzy, AppResources.PossibleMatchingItems, fuzzy.Count, false));
|
||||
}
|
||||
GroupedItems.ResetWithRange(groupedItems);
|
||||
ShowList = groupedItems.Any();
|
||||
}
|
||||
|
||||
public async Task SelectCipherAsync(CipherView cipher, bool fuzzy)
|
||||
|
Loading…
Reference in New Issue
Block a user