Added eye button icon for show/hide password

This commit is contained in:
Kyle Spearrin 2016-06-17 00:37:51 -04:00
parent 0c3bd0b92c
commit 79892cbf9f
9 changed files with 24 additions and 2 deletions

View file

@ -1,6 +1,7 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using Bit.App.Resources; using Bit.App.Resources;
using Xamarin.Forms;
namespace Bit.App.Models.Page namespace Bit.App.Models.Page
{ {
@ -103,10 +104,12 @@ namespace Bit.App.Models.Page
PropertyChanged(this, new PropertyChangedEventArgs(nameof(RevealPassword))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(RevealPassword)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(MaskedPassword)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowHideText))); PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowHideText)));
PropertyChanged(this, new PropertyChangedEventArgs(nameof(ShowHideImage)));
} }
} }
public string MaskedPassword => RevealPassword ? Password : Password == null ? null : new string('●', Password.Length); public string MaskedPassword => RevealPassword ? Password : Password == null ? null : new string('●', Password.Length);
public string ShowHideText => RevealPassword ? AppResources.Hide : AppResources.Show; public string ShowHideText => RevealPassword ? AppResources.Hide : AppResources.Show;
public ImageSource ShowHideImage => RevealPassword ? ImageSource.FromFile("eye_slash") : ImageSource.FromFile("eye");
public void Update(Site site) public void Update(Site site)
{ {

View file

@ -52,9 +52,10 @@ namespace Bit.App.Pages
UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username)); UsernameCell.Button1.Command = new Command(() => Copy(Model.Username, AppResources.Username));
// Password // Password
PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: AppResources.Show, button2Text: AppResources.Copy); PasswordCell = new LabeledValueCell(AppResources.Password, button1Text: string.Empty, button2Text: AppResources.Copy);
PasswordCell.Value.SetBinding<VaultViewSitePageModel>(Label.TextProperty, s => s.MaskedPassword); PasswordCell.Value.SetBinding<VaultViewSitePageModel>(Label.TextProperty, s => s.MaskedPassword);
PasswordCell.Button1.SetBinding<VaultViewSitePageModel>(Button.TextProperty, s => s.ShowHideText); PasswordCell.Button1.SetBinding<VaultViewSitePageModel>(Button.ImageProperty, s => s.ShowHideImage);
PasswordCell.Button1.Margin = new Thickness(10, 0);
PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword); PasswordCell.Button1.Command = new Command(() => Model.RevealPassword = !Model.RevealPassword);
PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password)); PasswordCell.Button2.Command = new Command(() => Copy(Model.Password, AppResources.Password));

BIN
src/iOS/Resources/eye.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -394,6 +394,24 @@
<ItemGroup> <ItemGroup>
<BundleResource Include="Resources\more_selected%402x.png" /> <BundleResource Include="Resources\more_selected%402x.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\eye_slash.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\eye.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\eye%402x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\eye%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\eye_slash%403x.png" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\eye_slash%402x.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>