From 7b083d5d0dbf55f1d5ad444ca8280e73dbb9123e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 23 Jul 2016 15:58:50 -0400 Subject: [PATCH] added instruction label to pin code screens --- src/App/Controls/PinControl.cs | 2 +- src/App/Pages/Lock/LockPinPage.cs | 14 +++- src/App/Pages/Settings/SettingsPinPage.cs | 14 +++- src/iOS.Extension/LockPinViewController.cs | 7 +- .../LockPinViewController.designer.cs | 76 +++++++++++-------- src/iOS.Extension/MainInterface.storyboard | 17 ++++- src/iOS/Controls/CustomLabelRenderer.cs | 5 ++ 7 files changed, 94 insertions(+), 41 deletions(-) diff --git a/src/App/Controls/PinControl.cs b/src/App/Controls/PinControl.cs index a8f7d50ac..0e4a4429b 100644 --- a/src/App/Controls/PinControl.cs +++ b/src/App/Controls/PinControl.cs @@ -12,7 +12,7 @@ namespace Bit.App.Controls Label = new Label { HorizontalTextAlignment = TextAlignment.Center, - FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), + FontSize = 35, FontFamily = "Courier" }; diff --git a/src/App/Pages/Lock/LockPinPage.cs b/src/App/Pages/Lock/LockPinPage.cs index 05fd9de1f..18cc41a7f 100644 --- a/src/App/Pages/Lock/LockPinPage.cs +++ b/src/App/Pages/Lock/LockPinPage.cs @@ -32,6 +32,15 @@ namespace Bit.App.Pages public void Init() { + var instructionLabel = new Label + { + Text = "Enter your PIN code.", + LineBreakMode = LineBreakMode.WordWrap, + FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), + HorizontalTextAlignment = TextAlignment.Center, + Style = (Style)Application.Current.Resources["text-muted"] + }; + PinControl = new PinControl(); PinControl.OnPinEntered += PinEntered; PinControl.Label.SetBinding(Label.TextProperty, s => s.LabelText); @@ -48,13 +57,14 @@ namespace Bit.App.Pages var stackLayout = new StackLayout { Padding = new Thickness(30, 40), - Spacing = 10, - Children = { PinControl.Label, logoutButton, PinControl.Entry } + Spacing = 20, + Children = { PinControl.Label, instructionLabel, logoutButton, PinControl.Entry } }; var tgr = new TapGestureRecognizer(); tgr.Tapped += Tgr_Tapped; PinControl.Label.GestureRecognizers.Add(tgr); + instructionLabel.GestureRecognizers.Add(tgr); Title = "Verify PIN"; Content = stackLayout; diff --git a/src/App/Pages/Settings/SettingsPinPage.cs b/src/App/Pages/Settings/SettingsPinPage.cs index 718260965..87a240806 100644 --- a/src/App/Pages/Settings/SettingsPinPage.cs +++ b/src/App/Pages/Settings/SettingsPinPage.cs @@ -30,6 +30,15 @@ namespace Bit.App.Pages public void Init() { + var instructionLabel = new Label + { + Text = "Enter a 4 digit PIN code to unlock the app with.", + LineBreakMode = LineBreakMode.WordWrap, + FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), + HorizontalTextAlignment = TextAlignment.Center, + Style = (Style)Application.Current.Resources["text-muted"] + }; + PinControl = new PinControl(); PinControl.OnPinEntered += PinEntered; PinControl.Label.SetBinding(Label.TextProperty, s => s.LabelText); @@ -38,13 +47,14 @@ namespace Bit.App.Pages var stackLayout = new StackLayout { Padding = new Thickness(30, 40), - Spacing = 10, - Children = { PinControl.Label, PinControl.Entry } + Spacing = 20, + Children = { PinControl.Label, instructionLabel, PinControl.Entry } }; var tgr = new TapGestureRecognizer(); tgr.Tapped += Tgr_Tapped; PinControl.Label.GestureRecognizers.Add(tgr); + instructionLabel.GestureRecognizers.Add(tgr); Title = "Set PIN"; Content = stackLayout; diff --git a/src/iOS.Extension/LockPinViewController.cs b/src/iOS.Extension/LockPinViewController.cs index bdc4515a6..e666d36da 100644 --- a/src/iOS.Extension/LockPinViewController.cs +++ b/src/iOS.Extension/LockPinViewController.cs @@ -39,7 +39,12 @@ namespace Bit.iOS.Extension View.BackgroundColor = new UIColor(red: 0.94f, green: 0.94f, blue: 0.96f, alpha: 1.0f); var descriptor = UIFontDescriptor.PreferredBody; - PinLabel.Font = UIFont.FromName("Courier", descriptor.PointSize * 1.3f); + PinLabel.Font = UIFont.FromName("Courier", 35); + + InstructionLabel.LineBreakMode = UILineBreakMode.WordWrap; + InstructionLabel.Lines = 0; + InstructionLabel.Font = UIFont.FromDescriptor(descriptor, descriptor.PointSize * 0.8f); + InstructionLabel.TextColor = new UIColor(red: 0.47f, green: 0.47f, blue: 0.47f, alpha: 1.0f); PinTextField.EditingChanged += PinTextField_EditingChanged; diff --git a/src/iOS.Extension/LockPinViewController.designer.cs b/src/iOS.Extension/LockPinViewController.designer.cs index b3d5f3628..765008753 100644 --- a/src/iOS.Extension/LockPinViewController.designer.cs +++ b/src/iOS.Extension/LockPinViewController.designer.cs @@ -11,39 +11,51 @@ using UIKit; namespace Bit.iOS.Extension { - [Register ("LockPinViewController")] - partial class LockPinViewController - { - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UIBarButtonItem CancelButton { get; set; } + [Register ("LockPinViewController")] + partial class LockPinViewController + { + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UIBarButtonItem CancelButton { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UILabel PinLabel { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UILabel InstructionLabel { get; set; } - [Outlet] - [GeneratedCode ("iOS Designer", "1.0")] - UITextField PinTextField { get; set; } + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UILabel PinLabel { get; set; } - [Action ("CancelButton_Activated:")] - [GeneratedCode ("iOS Designer", "1.0")] - partial void CancelButton_Activated (UIBarButtonItem sender); + [Outlet] + [GeneratedCode ("iOS Designer", "1.0")] + UIKit.UITextField PinTextField { get; set; } - void ReleaseDesignerOutlets () - { - if (CancelButton != null) { - CancelButton.Dispose (); - CancelButton = null; - } - if (PinLabel != null) { - PinLabel.Dispose (); - PinLabel = null; - } - if (PinTextField != null) { - PinTextField.Dispose (); - PinTextField = null; - } - } - } -} + + [Action ("CancelButton_Activated:")] + [GeneratedCode ("iOS Designer", "1.0")] + partial void CancelButton_Activated (UIBarButtonItem sender); + + void ReleaseDesignerOutlets () + { + if (CancelButton != null) { + CancelButton.Dispose (); + CancelButton = null; + } + + if (InstructionLabel != null) { + InstructionLabel.Dispose (); + InstructionLabel = null; + } + + if (PinLabel != null) { + PinLabel.Dispose (); + PinLabel = null; + } + + if (PinTextField != null) { + PinTextField.Dispose (); + PinTextField = null; + } + } + } +} \ No newline at end of file diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard index 087793a2b..537c89ba2 100644 --- a/src/iOS.Extension/MainInterface.storyboard +++ b/src/iOS.Extension/MainInterface.storyboard @@ -373,14 +373,14 @@ - @@ -397,6 +404,9 @@ + + + @@ -410,6 +420,7 @@ + diff --git a/src/iOS/Controls/CustomLabelRenderer.cs b/src/iOS/Controls/CustomLabelRenderer.cs index b29b4fa84..5471c0c80 100644 --- a/src/iOS/Controls/CustomLabelRenderer.cs +++ b/src/iOS/Controls/CustomLabelRenderer.cs @@ -60,6 +60,11 @@ namespace Bit.iOS.Controls { pointSize *= .6f; } + else + { + // not using dyanmic font sizes, return + return; + } Control.Font = UIFont.FromDescriptor(Element.Font.ToUIFont().FontDescriptor, pointSize); }