mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-23 16:27:51 +01:00
manage URIS on add/edit
This commit is contained in:
parent
8d0dc2d230
commit
49c355e52f
@ -340,6 +340,51 @@
|
|||||||
</StackLayout>
|
</StackLayout>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
<StackLayout StyleClass="box" IsVisible="{Binding IsLogin}">
|
||||||
|
<StackLayout StyleClass="box-row-header">
|
||||||
|
<Label Text="{u:I18n URIs}"
|
||||||
|
StyleClass="box-header, box-header-platform" />
|
||||||
|
</StackLayout>
|
||||||
|
<controls:RepeaterView ItemsSource="{Binding Uris}">
|
||||||
|
<controls:RepeaterView.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="views:LoginUriView">
|
||||||
|
<StackLayout Spacing="0" Padding="0">
|
||||||
|
<Grid StyleClass="box-row">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n URI}"
|
||||||
|
StyleClass="box-label"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding Uri}"
|
||||||
|
Keyboard="Url"
|
||||||
|
StyleClass="box-value"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0" />
|
||||||
|
<controls:FaButton
|
||||||
|
StyleClass="box-row-button, box-row-button-platform"
|
||||||
|
Text=""
|
||||||
|
Command="{Binding BindingContext.UriOptionsCommand, Source={x:Reference _page}}"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.RowSpan="2" />
|
||||||
|
</Grid>
|
||||||
|
</StackLayout>
|
||||||
|
</DataTemplate>
|
||||||
|
</controls:RepeaterView.ItemTemplate>
|
||||||
|
</controls:RepeaterView>
|
||||||
|
<Button Text="{u:I18n NewUri}" StyleClass="box-button-row"
|
||||||
|
Clicked="NewUri_Clicked"></Button>
|
||||||
|
</StackLayout>
|
||||||
<StackLayout StyleClass="box">
|
<StackLayout StyleClass="box">
|
||||||
<StackLayout StyleClass="box-row-header">
|
<StackLayout StyleClass="box-row-header">
|
||||||
<Label Text="{u:I18n Notes}"
|
<Label Text="{u:I18n Notes}"
|
||||||
|
@ -56,5 +56,10 @@ namespace Bit.App.Pages
|
|||||||
await _vm.SubmitAsync();
|
await _vm.SubmitAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NewUri_Clicked(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
_vm.AddUri();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,17 @@ namespace Bit.App.Pages
|
|||||||
nameof(ShowAttachments),
|
nameof(ShowAttachments),
|
||||||
nameof(ShowIdentityAddress),
|
nameof(ShowIdentityAddress),
|
||||||
};
|
};
|
||||||
|
private List<KeyValuePair<UriMatchType?, string>> _matchDetectionOptions =
|
||||||
|
new List<KeyValuePair<UriMatchType?, string>>
|
||||||
|
{
|
||||||
|
new KeyValuePair<UriMatchType?, string>(null, AppResources.Default),
|
||||||
|
new KeyValuePair<UriMatchType?, string>(UriMatchType.Domain, AppResources.BaseDomain),
|
||||||
|
new KeyValuePair<UriMatchType?, string>(UriMatchType.Host, AppResources.Host),
|
||||||
|
new KeyValuePair<UriMatchType?, string>(UriMatchType.StartsWith, AppResources.StartsWith),
|
||||||
|
new KeyValuePair<UriMatchType?, string>(UriMatchType.RegularExpression, AppResources.RegEx),
|
||||||
|
new KeyValuePair<UriMatchType?, string>(UriMatchType.Exact, AppResources.Exact),
|
||||||
|
new KeyValuePair<UriMatchType?, string>(UriMatchType.Never, AppResources.Never),
|
||||||
|
};
|
||||||
|
|
||||||
public AddEditPageViewModel()
|
public AddEditPageViewModel()
|
||||||
{
|
{
|
||||||
@ -51,6 +62,8 @@ namespace Bit.App.Pages
|
|||||||
TogglePasswordCommand = new Command(TogglePassword);
|
TogglePasswordCommand = new Command(TogglePassword);
|
||||||
ToggleCardCodeCommand = new Command(ToggleCardCode);
|
ToggleCardCodeCommand = new Command(ToggleCardCode);
|
||||||
CheckPasswordCommand = new Command(CheckPasswordAsync);
|
CheckPasswordCommand = new Command(CheckPasswordAsync);
|
||||||
|
UriOptionsCommand = new Command<LoginUriView>(UriOptions);
|
||||||
|
Uris = new ExtendedObservableCollection<LoginUriView>();
|
||||||
|
|
||||||
TypeOptions = new List<KeyValuePair<string, CipherType>>
|
TypeOptions = new List<KeyValuePair<string, CipherType>>
|
||||||
{
|
{
|
||||||
@ -102,6 +115,7 @@ namespace Bit.App.Pages
|
|||||||
public Command TogglePasswordCommand { get; set; }
|
public Command TogglePasswordCommand { get; set; }
|
||||||
public Command ToggleCardCodeCommand { get; set; }
|
public Command ToggleCardCodeCommand { get; set; }
|
||||||
public Command CheckPasswordCommand { get; set; }
|
public Command CheckPasswordCommand { get; set; }
|
||||||
|
public Command UriOptionsCommand { get; set; }
|
||||||
public string CipherId { get; set; }
|
public string CipherId { get; set; }
|
||||||
public string OrganizationId { get; set; }
|
public string OrganizationId { get; set; }
|
||||||
public string FolderId { get; set; }
|
public string FolderId { get; set; }
|
||||||
@ -111,6 +125,7 @@ namespace Bit.App.Pages
|
|||||||
public List<KeyValuePair<string, string>> CardBrandOptions { get; set; }
|
public List<KeyValuePair<string, string>> CardBrandOptions { get; set; }
|
||||||
public List<KeyValuePair<string, string>> CardExpMonthOptions { get; set; }
|
public List<KeyValuePair<string, string>> CardExpMonthOptions { get; set; }
|
||||||
public List<KeyValuePair<string, string>> IdentityTitleOptions { get; set; }
|
public List<KeyValuePair<string, string>> IdentityTitleOptions { get; set; }
|
||||||
|
public ExtendedObservableCollection<LoginUriView> Uris { get; set; }
|
||||||
public int TypeSelectedIndex
|
public int TypeSelectedIndex
|
||||||
{
|
{
|
||||||
get => _typeSelectedIndex;
|
get => _typeSelectedIndex;
|
||||||
@ -238,6 +253,11 @@ namespace Bit.App.Pages
|
|||||||
IdentityTitleSelectedIndex = 0;
|
IdentityTitleSelectedIndex = 0;
|
||||||
// TODO: org/collection stuff
|
// TODO: org/collection stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Cipher.Login.Uris != null)
|
||||||
|
{
|
||||||
|
Uris.ResetWithRange(Cipher.Login.Uris);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SubmitAsync()
|
public async Task<bool> SubmitAsync()
|
||||||
@ -250,6 +270,7 @@ namespace Bit.App.Pages
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cipher.Login.Uris = Uris.ToList();
|
||||||
if(!EditMode && Cipher.Type == CipherType.Login && (Cipher.Login.Uris?.Count ?? 0) == 1 &&
|
if(!EditMode && Cipher.Type == CipherType.Login && (Cipher.Login.Uris?.Count ?? 0) == 1 &&
|
||||||
string.IsNullOrWhiteSpace(Cipher.Login.Uris.First().Uri))
|
string.IsNullOrWhiteSpace(Cipher.Login.Uris.First().Uri))
|
||||||
{
|
{
|
||||||
@ -312,6 +333,44 @@ namespace Bit.App.Pages
|
|||||||
// TODO: push modal for generate page
|
// TODO: push modal for generate page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void UriOptions(LoginUriView uri)
|
||||||
|
{
|
||||||
|
if(!(Page as AddEditPage).DoOnce())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var selection = await Page.DisplayActionSheet(AppResources.Options, AppResources.Cancel, null,
|
||||||
|
AppResources.MatchDetection, AppResources.Remove);
|
||||||
|
if(selection == AppResources.Remove)
|
||||||
|
{
|
||||||
|
Uris.Remove(uri);
|
||||||
|
}
|
||||||
|
else if(selection == AppResources.MatchDetection)
|
||||||
|
{
|
||||||
|
var options = _matchDetectionOptions.Select(o => o.Key == uri.Match ? $"✓ {o.Value}" : o.Value);
|
||||||
|
var matchSelection = await Page.DisplayActionSheet(AppResources.URIMatchDetection,
|
||||||
|
AppResources.Cancel, null, options.ToArray());
|
||||||
|
if(matchSelection != null && matchSelection != AppResources.Cancel)
|
||||||
|
{
|
||||||
|
var matchSelectionClean = matchSelection.Replace("✓ ", string.Empty);
|
||||||
|
uri.Match = _matchDetectionOptions.FirstOrDefault(o => o.Value == matchSelectionClean).Key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddUri()
|
||||||
|
{
|
||||||
|
if(Cipher.Type != CipherType.Login)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(Uris == null)
|
||||||
|
{
|
||||||
|
Uris = new ExtendedObservableCollection<LoginUriView>();
|
||||||
|
}
|
||||||
|
Uris.Add(new LoginUriView());
|
||||||
|
}
|
||||||
|
|
||||||
public void TogglePassword()
|
public void TogglePassword()
|
||||||
{
|
{
|
||||||
ShowPassword = !ShowPassword;
|
ShowPassword = !ShowPassword;
|
||||||
|
Loading…
Reference in New Issue
Block a user