From 0cbda0b574923ae479c2164aec1f067a4dbe8ce1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 27 Jun 2016 22:17:49 -0400 Subject: [PATCH] added image option to form entry cell. Added clear option to extended entry --- src/App/Controls/ExtendedEntry.cs | 1 + src/App/Controls/FormEntryCell.cs | 58 ++++++++++++++++++---- src/App/Pages/LoginPage.cs | 6 ++- src/App/Pages/RegisterPage.cs | 15 +++--- src/iOS/Controls/ExtendedEntryRenderer.cs | 5 ++ src/iOS/Resources/envelope.png | Bin 0 -> 374 bytes src/iOS/Resources/envelope@2x.png | Bin 0 -> 629 bytes src/iOS/Resources/envelope@3x.png | Bin 0 -> 884 bytes src/iOS/Resources/lightbulb-o.png | Bin 0 -> 468 bytes src/iOS/Resources/lightbulb-o@2x.png | Bin 0 -> 789 bytes src/iOS/Resources/lightbulb-o@3x.png | Bin 0 -> 1164 bytes src/iOS/Resources/lock.png | Bin 0 -> 359 bytes src/iOS/Resources/lock@2x.png | Bin 0 -> 569 bytes src/iOS/Resources/lock@3x.png | Bin 0 -> 733 bytes src/iOS/Resources/user.png | Bin 0 -> 425 bytes src/iOS/Resources/user@2x.png | Bin 0 -> 685 bytes src/iOS/Resources/user@3x.png | Bin 0 -> 895 bytes src/iOS/iOS.csproj | 36 ++++++++++++++ 18 files changed, 104 insertions(+), 17 deletions(-) create mode 100644 src/iOS/Resources/envelope.png create mode 100644 src/iOS/Resources/envelope@2x.png create mode 100644 src/iOS/Resources/envelope@3x.png create mode 100644 src/iOS/Resources/lightbulb-o.png create mode 100644 src/iOS/Resources/lightbulb-o@2x.png create mode 100644 src/iOS/Resources/lightbulb-o@3x.png create mode 100644 src/iOS/Resources/lock.png create mode 100644 src/iOS/Resources/lock@2x.png create mode 100644 src/iOS/Resources/lock@3x.png create mode 100644 src/iOS/Resources/user.png create mode 100644 src/iOS/Resources/user@2x.png create mode 100644 src/iOS/Resources/user@3x.png diff --git a/src/App/Controls/ExtendedEntry.cs b/src/App/Controls/ExtendedEntry.cs index d804b5d56..55ccdd7be 100644 --- a/src/App/Controls/ExtendedEntry.cs +++ b/src/App/Controls/ExtendedEntry.cs @@ -45,6 +45,7 @@ namespace Bit.App.Controls public ReturnType? ReturnType { get; set; } public bool? Autocorrect { get; set; } public bool DisableAutocapitalize { get; set; } + public bool AllowClear { get; set; } // Need to overwrite default handler because we cant Invoke otherwise public new event EventHandler Completed; diff --git a/src/App/Controls/FormEntryCell.cs b/src/App/Controls/FormEntryCell.cs index 9a41a93b0..fd6bb8df9 100644 --- a/src/App/Controls/FormEntryCell.cs +++ b/src/App/Controls/FormEntryCell.cs @@ -5,7 +5,13 @@ namespace Bit.App.Controls { public class FormEntryCell : ExtendedViewCell { - public FormEntryCell(string labelText, Keyboard entryKeyboard = null, bool IsPassword = false, VisualElement nextElement = null, bool useLabelAsPlaceholder = false) + public FormEntryCell( + string labelText, + Keyboard entryKeyboard = null, + bool IsPassword = false, + VisualElement nextElement = null, + bool useLabelAsPlaceholder = false, + string imageSource = null) { if(!useLabelAsPlaceholder) { @@ -14,7 +20,8 @@ namespace Bit.App.Controls Text = labelText, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), VerticalOptions = LayoutOptions.Start, - Style = (Style)Application.Current.Resources["text-muted"] + Style = (Style)Application.Current.Resources["text-muted"], + HorizontalOptions = LayoutOptions.FillAndExpand }; } @@ -23,7 +30,9 @@ namespace Bit.App.Controls Keyboard = entryKeyboard, HasBorder = false, VerticalOptions = LayoutOptions.CenterAndExpand, - IsPassword = IsPassword + IsPassword = IsPassword, + AllowClear = true, + HorizontalOptions = LayoutOptions.FillAndExpand }; if(useLabelAsPlaceholder) @@ -37,22 +46,53 @@ namespace Bit.App.Controls Entry.Completed += (object sender, EventArgs e) => { nextElement.Focus(); }; } - var stackLayout = new StackLayout + var imageStackLayout = new StackLayout { - Padding = new Thickness(15, 10) + Padding = new Thickness(15, 10), + Orientation = StackOrientation.Horizontal, + Spacing = 10, + HorizontalOptions = LayoutOptions.FillAndExpand, + VerticalOptions = LayoutOptions.FillAndExpand }; - if(!useLabelAsPlaceholder) + if(imageSource != null) { - stackLayout.Children.Add(Label); + var tgr = new TapGestureRecognizer(); + tgr.Tapped += Tgr_Tapped; + + var theImage = new Image + { + Source = imageSource, + HorizontalOptions = LayoutOptions.Start, + VerticalOptions = LayoutOptions.Center + }; + theImage.GestureRecognizers.Add(tgr); + + imageStackLayout.Children.Add(theImage); } - stackLayout.Children.Add(Entry); + var formStackLayout = new StackLayout + { + HorizontalOptions = LayoutOptions.FillAndExpand, + VerticalOptions = LayoutOptions.FillAndExpand + }; + if(!useLabelAsPlaceholder) + { + formStackLayout.Children.Add(Label); + } - View = stackLayout; + formStackLayout.Children.Add(Entry); + imageStackLayout.Children.Add(formStackLayout); + + View = imageStackLayout; } public Label Label { get; private set; } public ExtendedEntry Entry { get; private set; } + + private void Tgr_Tapped(object sender, EventArgs e) + { + Entry.Focus(); + } } } diff --git a/src/App/Pages/LoginPage.cs b/src/App/Pages/LoginPage.cs index dc859310e..6fe017863 100644 --- a/src/App/Pages/LoginPage.cs +++ b/src/App/Pages/LoginPage.cs @@ -36,8 +36,10 @@ namespace Bit.App.Pages private void Init() { - PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, useLabelAsPlaceholder: true); - EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true); + PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, + useLabelAsPlaceholder: true, imageSource: "lock"); + EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry, + entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope"); PasswordCell.Entry.ReturnType = Enums.ReturnType.Go; PasswordCell.Entry.Completed += Entry_Completed; diff --git a/src/App/Pages/RegisterPage.cs b/src/App/Pages/RegisterPage.cs index 1de6524dd..4be1bdab1 100644 --- a/src/App/Pages/RegisterPage.cs +++ b/src/App/Pages/RegisterPage.cs @@ -34,11 +34,11 @@ namespace Bit.App.Pages private void Init() { - PasswordHintCell = new FormEntryCell("Master Password Hint (optional)", useLabelAsPlaceholder: true); - ConfirmPasswordCell = new FormEntryCell("Re-type Master Password", IsPassword: true, nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true); - PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true); - NameCell = new FormEntryCell("Your Name", nextElement: PasswordCell.Entry, useLabelAsPlaceholder: true); - EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: NameCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true); + PasswordHintCell = new FormEntryCell("Master Password Hint (optional)", useLabelAsPlaceholder: true, imageSource: "lightbulb-o"); + ConfirmPasswordCell = new FormEntryCell("Re-type Master Password", IsPassword: true, nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock"); + PasswordCell = new FormEntryCell(AppResources.MasterPassword, IsPassword: true, nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock"); + NameCell = new FormEntryCell("Your Name", nextElement: PasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "user"); + EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: NameCell.Entry, entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope"); PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done; PasswordHintCell.Entry.Completed += Entry_Completed; @@ -54,7 +54,10 @@ namespace Bit.App.Pages new TableSection() { EmailCell, - NameCell, + NameCell + }, + new TableSection() + { PasswordCell, ConfirmPasswordCell, PasswordHintCell diff --git a/src/iOS/Controls/ExtendedEntryRenderer.cs b/src/iOS/Controls/ExtendedEntryRenderer.cs index fbc2403e0..86922b2ea 100644 --- a/src/iOS/Controls/ExtendedEntryRenderer.cs +++ b/src/iOS/Controls/ExtendedEntryRenderer.cs @@ -25,6 +25,11 @@ namespace Bit.iOS.Controls SetMaxLength(view); UpdateKeyboard(); + if(view.AllowClear) + { + Control.ClearButtonMode = UITextFieldViewMode.WhileEditing; + } + if(view.DisableAutocapitalize) { Control.AutocapitalizationType = UITextAutocapitalizationType.None; diff --git a/src/iOS/Resources/envelope.png b/src/iOS/Resources/envelope.png new file mode 100644 index 0000000000000000000000000000000000000000..95c64ed09c652fe69a6e7f7c2b05cd7b21d12b38 GIT binary patch literal 374 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+3?vf;>QaGJOMp*^E08{Z{OrIYr6c_9KzC@D z1o;IsFfuW7aq|cWiinCStC(8Y`1*xMM#okxShaT3o`Z*vpE!5^;^k*A-oF3+*Xf_k zTcEZwPZ!4!3CZ4r*M*u47+eo>YiO9Qi3nJuQuOct{}hR1h96sFziu|LI1{69GnKF6 zTNf{%u(p)QAC0z&?-nNvy7x_7 wURzANB&>UJrIyvBejT~hXC7^sS@n}apH(IGV%F59Ko>B0y85}Sb4q9e01kY?IsgCw literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/envelope@2x.png b/src/iOS/Resources/envelope@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a174a6927057ec56c05a899741e022cc783cbb31 GIT binary patch literal 629 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`Z9tQY?xB}_p$IlL9^j0*{5$H*; zk|4ie21X_pHg*m!UOs*SL17UINhuXob!}ZeBNJ0I3u|XLZ{M((*tn#Ww5I0Pj?SK` zGiJ@5w|edNUHc9kK6?4;^_$OLzkUDl^Vjdc|E_O;BLOt^r>Bc!h=k+T<;ms>!RQ>fI*hd;b4_$0(DjsrP<9DdMYt`ytZtSFh}iX&3cOB~3F{=XOVtjz@9;3ki%l%n}3a=HX<~}%a+5Dbi zLcE7ZQSgCFi}zJTv0aPt%y_}F;hf3yJ4{?sPRd_dCKNp_zTW5(tDN!1mib1Xou%1^ z`&T7q733(~y>#HVT!Qs1hkehq1T0JAxdaoIYRb=g_58!rU$dMxuUp*XqCKni*_STQ z(_UiLvznb86c-2taFnE6dFJLODrRkzq3@s*uf?wMH2IIayi5s0+3Jew4ZuKP@O1Ta JS?83{1OPz!QMv#C literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/envelope@3x.png b/src/iOS/Resources/envelope@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..9e819acebbeedfb92442c6f65b732301c3f9a25b GIT binary patch literal 884 zcmeAS@N?(olHy`uVBq!ia0vp^W+2SL3?z5Yp7oxAfzcwsC&U%VJ%0S`C?Yika=YA| zfMJ(j666=mz{teR!pgzP#Vsf#EFvK(C8MCEtfHZ*rLALNWNc<`X>DugdjmC9z1&X z;^phN?>~P2`u+D`1Fns&z-Vjnba4!kkbHYEGg>H7qU~Y!j3Yf_N?Nxz>l_xl-F-?` zCwKd%5U(!Ro&W#aXUzM4KqkTCx$UnPm7DYr?lk9JdLcqbXy@uHd4~)uH9on>iA7Fs zXUnbpaWcKK;^-2a9^q?KZ}s!c3CmjEF=gr{k#o#TKTTMd?e)+~O`)hHw0g@dbs>Z9 zlQx&;*_=yAyYN~dcvW`zS0S}ETrYnMo;lG}7ASjACTik@E1HjEGGEJ^t$*ZGrlR;c zPo((6-nL%`Z726lb@Y3!bgs8gsPvS@^VvlK*Eb7H{=JALo@5Y zeuJN;xz5(_SY|l++GerNiN4jCWY?R>cSb8s?MP2u2v1jb{2|Hw)vHS-pF4RMt_W9c zKDlp-@%*DH^Hzz!`mEbNd3{b!$R~@PqF){VZc}?;LidL=^ hndR;J?XP(~gYi=howHh1=YdIp!PC{xWt~$(69BO&@bv%y literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/lightbulb-o.png b/src/iOS/Resources/lightbulb-o.png new file mode 100644 index 0000000000000000000000000000000000000000..6d30f8b19afaea65add127266fad53c5b3abfdd3 GIT binary patch literal 468 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+3?vf;>QaH!_5hy{S0H`-_}L+cEE6kPfljw6 z3GxeOU}R!uW#{1J;TI4QmywlI*3i;7w{`Fi3JDF*$j-?vuBhwlpEzae?0GBJZ`pd_ z=&3Uouim=%;L(fs-+vyst_?D0f~SjPh=gS5K~}Lt1_BNT=R0Wztl6=9_v?HAV@xzZ z9O8+3sj@Kq`oq=glY0(j+wv7EHBK?S^LfgNBEJj^@4zW6#}>Ce(goLzejh)wop~eZd12maPoUcvJYD@<);T3K0RT^={lx$P literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/lightbulb-o@2x.png b/src/iOS/Resources/lightbulb-o@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a71f9bd7689e106474db7232eff6dc7422e6af07 GIT binary patch literal 789 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UH$0z$g;n6XFWw9zT9|6d{MeRO<&z zf#DKe666=mz{teR!pg?Z&BHG!Bqc2)E2p5Sq@t#wqibMjZee9@>)`0@>f;|6otT`G zo}FJ)-_X|4-P1R5%GBvIX3d_vblHlvo3`%RcktA?%U5sSy7%bW%hzw;fByRY=kLFZ zLagQiqaoDO#W6%evi2ai^Q8cWwukw}EE=hk(iS~o-BmH2>GQe_O-a`lzPrEw|8I9V zaqij7^NTx5KAsNUUHf(GjIc>DQzvHmnVqu|%gURR#<9l|Se|xrM3y*LxYM$*(M1QfKxlu2(EC>c2ke zQ-Mk_w@qu=e(z5Y`h8+2BtC1eTA&>)9CNhi;8q{?4_=0q786$T?C!E`b)6Yh{vk~8 z^oR4IN78r9osh^E5p;%ii%styo&}3`T*M{w8QaT W%ZqF=W<3gwM+Q$Q8d^>;B>F< zOJLlzmjw9*GcYnSv#_$Ub8vF=@bU`@i-?L#$;inoC@LwdscUFz>FVhln3|beSX$fI z+BrG9y19FL`}q0=1O|nKg-66EC8wmNXJlsQ+Vxwu?m2My=a!-$&vcPZ$`O zWISCQLnI`p9_)<>@cfl+r`DBpO$sb>-;8ayCm-Z_Ba3cx^G*z z{+@kv<~(=CM^}BVw_R1YS?hTDZss&yKKYpC9$x)*>07@vd$r!4eCT5QvPY-dKYXrU z-nDYx!~HL%bwyP_Ju+2ykG!@xVXCIlvDsUdDouTlrLuPZJ#c25cKjnT?X0<)ye#R{#nzY8*9-bgEpkg!UuT|mQ$kHs-qUA#(VqMn=dYfM=-;U#-`-d< zGpypIZ+Kc{R^Tz`2eWHzSmRbUTtEBBYNne{%)0dlBrVx26@`yqIW?8()>8|I^+pE1 zMSoduJ?Xf6V*!uP*w2oe>mKd#pAq%6B;l9HGQQ7V zmhla(JDh9}hiI(ky1cSL+OT~}DWk`9&8ET!t()8$>|6`wW`td{+29{IXX$}D*9%>X z9UrO{?g`u>Df3?RonhZ=uJC5%g$3UWOSJFk%LsFQmps1V(A#4d*Kp(oEeHqif+rrsE>6C$m3&sq9*|$=3DS`D?sgdHRvMQInNZblzT)nmYe=eUa8WhW`xA XsksMs{$eZvCS3+kS3j3^P6QaGJU4T!BE08{Z{OmxX-*+r#09~M2 z666=mz{teR%Fe;b%f~OQps1^7W#Z~OY>ATP z>Q}12FI}^GU;domU;bnXr@_@iZ((1C9lJ6zpRJwQT|k3?#4J%UA`Z&IkB}xB}_p$IlKM^!9|*0-%>% zN`m}?85o(ES=rb*xVU+E1w_RqWn`7~O)PAjUEDmq{X@dSBjYnNvvUecYnoa+CQg|( zd+DmJ$IqR=c=OJKN6%iqe*g9R&)2tb1^t^g)R_Y34Lr2%v+17DiyjqlFWObx} zO%ATJaxqbR^MQX$=BflS4s=HO~YE#iWyHb-TJIu+;UHS zuF?iuHkb0Upe*L>M@JZ(;tE(gj-TZ6Xqzytp~zw;lcvBV7LD%7g)iQ`_quwN^Fr96 zB8EjipXM2tEGqU_ekr8M5&ovT#y^N?4zb_xk1!Oc}n%Ym>ho R(*}Bw!PC{xWt~$(699~pGN=Fm literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/lock@3x.png b/src/iOS/Resources/lock@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..789c5449eddc7f77a874f48a0831440f0db575ad GIT binary patch literal 733 zcmeAS@N?(olHy`uVBq!ia0vp^W+2SL3?z5Yp7oxAfsr-9C&U%VJ%0S`2uI6qZ_5J) zL|93XUoZnB6Eh1d8#@;_4==xfppb~DxQx7#ikiBnwvMizfuWIwm92xTXJAlBOl)FO zMs`kaX?aaueM56=+muC1m#tX6Y5UGS`wkyJb?)NLJI`Lce*5w3_n*H5y*Ew*2Dzc9 zi(`mK=i964;fD-F*dCZI+2JU&4-dxh@+HsHLzng4Lw*#zHYUOVmVp7l}t3eVeoKC}6MLaCkgwTP+b!%V^w;-{?F-QVam gb?f8Ki{jHl9o}k7Z^PZp00i_>zopr0A5C#Bme*a literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/user.png b/src/iOS/Resources/user.png new file mode 100644 index 0000000000000000000000000000000000000000..de6d504fdf079db49f3b1441c94d11db9ade7255 GIT binary patch literal 425 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+3?vf;>QaH!(g2?jS0H`-_}M{@HgEeB0CcEX zNswPK10xeN3nv#h4=tp@GG3?EV=7>#lpck>u0ELv0E=ulnk@n*W~52mnq)!j_%_jdsu O!rEJ2= literal 0 HcmV?d00001 diff --git a/src/iOS/Resources/user@2x.png b/src/iOS/Resources/user@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..58874ba40c45ae28d7fa41a64fbb53cece3f2854 GIT binary patch literal 685 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`Z{sj1hxB}_p$Ip&TBrm&K4(R{j zk|4ie21X`k7B+S+ZazUFVNod=c?A_M14CmIQ!{f58#{XkCudhrZ~uUx@R;^;1Z>&rQdl`M00oY^=tY>dw|YMtzu*Rbfo3K5Z1x2FpEn!^FBcbCGCp3ro+nl3$a>C;PZ<=xE$BNiOY=h??SOD4hNOXi~_ z4d=}kOO$8boRDR*+9B)GnZ_&2Zz`*t`@rN-&}Qy2XCddwr8iBN2+w+|cy?>%rH1^E qlP}vI73_Fx|0m%2?l=*Ke~fWY82!&25*LnC7gTYCpb7f;{7 z(C~=p_{8M&jLhu9(u&IJ`iADVo=H+}rLnI`p9_(}y3Y1`dQ0#8RG3ky+V2qK^*)=OQqAnDj z+-k&CbXwxcp8wiMdVF{czMuPZzdb-Jz5eIZKXz62<}E+u;xAm+QWZGw(d&3l>5+!T zn`GsvdChT(Ub_wocy|<>GBEd)IBOik>Qkz?8q<$ zb-{KJ11#b+*H$8B#b%z#R;ED)Gt+l)o$-@=rpCG1r&)2DKx$iaoO0B{lXhl4$FAAe zuf4mXK5*tkW)?N9mwwq6cY1z%yY3J2+S6ENZZhsT%G~FsWXYr5xsUP1S zUaqHU(ACGJdT&wkWTE;Cg}xKnKipaFBRG%sR87ls*3?xWa)Ot!`cHK_Twtm(rL{Zg zaYpczSx&QESK8dt@j83p>Y@u0F`-<%hf{-}soO}NvN^c6e98*#J3;C_@AIYXww~Nk vcgOj_5%qRM8T|$ERY_L)Q%*;H_{&_gTe~DWM4f8o27B literal 0 HcmV?d00001 diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 7032f8fa5..60628c5dc 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -400,6 +400,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +