1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-06-28 10:54:59 +02:00

more button on cipher listing

This commit is contained in:
Kyle Spearrin 2019-04-30 11:27:53 -04:00
parent 4a1bccd516
commit 5812dc7e7e
6 changed files with 54 additions and 9 deletions

View File

@ -74,13 +74,14 @@
Margin="5, 0, 0, 0" Margin="5, 0, 0, 0"
Text="" Text=""
IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" /> IsVisible="{Binding Cipher.HasAttachments, Mode=OneWay}" />
<ImageButton
<Button WidthRequest="60" Source="more.png"
Grid.Column="4" StyleClass="list-button, list-button-platform"
Grid.Row="0" Clicked="ImageButton_Clicked"
Grid.RowSpan="2" Grid.Column="4"
BackgroundColor="Transparent" /> Grid.Row="0"
Grid.RowSpan="2" />
</Grid> </Grid>
</ViewCell.View> </ViewCell.View>
</ViewCell> </ViewCell>

View File

@ -13,6 +13,9 @@ namespace Bit.App.Controls
public static readonly BindableProperty CipherProperty = BindableProperty.Create( public static readonly BindableProperty CipherProperty = BindableProperty.Create(
nameof(Cipher), typeof(CipherView), typeof(CipherViewCell), default(CipherView), BindingMode.OneWay); nameof(Cipher), typeof(CipherView), typeof(CipherViewCell), default(CipherView), BindingMode.OneWay);
public static readonly BindableProperty ButtonCommandProperty = BindableProperty.Create(
nameof(ButtonCommand), typeof(Command<CipherView>), typeof(CipherViewCell));
private CipherViewCellViewModel _viewModel; private CipherViewCellViewModel _viewModel;
public CipherViewCell() public CipherViewCell()
@ -27,6 +30,12 @@ namespace Bit.App.Controls
set => SetValue(CipherProperty, value); set => SetValue(CipherProperty, value);
} }
public Command<CipherView> ButtonCommand
{
get => GetValue(ButtonCommandProperty) as Command<CipherView>;
set => SetValue(ButtonCommandProperty, value);
}
protected override void OnPropertyChanged(string propertyName = null) protected override void OnPropertyChanged(string propertyName = null)
{ {
base.OnPropertyChanged(propertyName); base.OnPropertyChanged(propertyName);
@ -118,5 +127,10 @@ namespace Bit.App.Controls
} }
return new Tuple<string, string>(icon, image); return new Tuple<string, string>(icon, image);
} }
private void ImageButton_Clicked(object sender, EventArgs e)
{
ButtonCommand?.Execute(Cipher);
}
} }
} }

View File

@ -6,7 +6,8 @@
xmlns:u="clr-namespace:Bit.App.Utilities" 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}"
x:Name="_page">
<ContentPage.BindingContext> <ContentPage.BindingContext>
<pages:GroupingsPageViewModel /> <pages:GroupingsPageViewModel />
@ -16,7 +17,9 @@
<ResourceDictionary> <ResourceDictionary>
<DataTemplate x:Key="cipherTemplate" <DataTemplate x:Key="cipherTemplate"
x:DataType="pages:GroupingsPageListItem"> x:DataType="pages:GroupingsPageListItem">
<controls:CipherViewCell Cipher="{Binding Cipher}" /> <controls:CipherViewCell
Cipher="{Binding Cipher}"
ButtonCommand="{Binding BindingContext.CipherOptionsCommand, Source={x:Reference _page}}" />
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="folderTemplate" <DataTemplate x:Key="folderTemplate"

View File

@ -43,6 +43,7 @@ namespace Bit.App.Pages
await LoadAsync(); await LoadAsync();
}); });
AddCipherCommand = new Command(() => { /* TODO */ }); AddCipherCommand = new Command(() => { /* TODO */ });
CipherOptionsCommand = new Command<CipherView>(CipherOptionsAsync);
} }
public bool ShowFavorites { get; set; } = true; public bool ShowFavorites { get; set; } = true;
@ -99,6 +100,7 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; } public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; }
public Command RefreshCommand { get; set; } public Command RefreshCommand { get; set; }
public Command AddCipherCommand { get; set; } public Command AddCipherCommand { get; set; }
public Command<CipherView> CipherOptionsCommand { get; set; }
public async Task LoadAsync() public async Task LoadAsync()
{ {
@ -273,5 +275,15 @@ namespace Bit.App.Pages
} }
} }
} }
private async void CipherOptionsAsync(CipherView cipher)
{
var option = await Page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, "1", "2");
if(option == AppResources.Cancel)
{
return;
}
// TODO: process options
}
} }
} }

View File

@ -24,6 +24,9 @@
<Style TargetType="Grid" <Style TargetType="Grid"
Class="list-row-platform"> Class="list-row-platform">
</Style> </Style>
<Style TargetType="ImageButton"
Class="list-button-platform">
</Style>
<!-- Box --> <!-- Box -->

View File

@ -97,6 +97,18 @@
<Setter Property="TextColor" <Setter Property="TextColor"
Value="{StaticResource MutedColor}" /> Value="{StaticResource MutedColor}" />
</Style> </Style>
<Style TargetType="ImageButton"
ApplyToDerivedTypes="True"
Class="list-button">
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="Padding"
Value="0" />
<Setter Property="HorizontalOptions"
Value="End" />
<Setter Property="VerticalOptions"
Value="CenterAndExpand" />
</Style>
<!-- Box --> <!-- Box -->