Skip to content

Commit

Permalink
Merge branch 'master' of github.com:venmo/VENTouchLock
Browse files Browse the repository at this point in the history
Conflicts:
	VENTouchLock/Controllers/VENTouchLockSplashViewController.m
  • Loading branch information
Dasmer Singh committed Jan 7, 2015
2 parents 3713437 + 4dfce51 commit d73484c
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 19 deletions.
33 changes: 19 additions & 14 deletions VENTouchLock/Controllers/VENTouchLockCreatePasscodeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ - (void)showConfirmPasscodeView
VENTouchLockPasscodeView *firstPasscodeView = self.passcodeView;
CGFloat passcodeViewWidth = CGRectGetWidth(firstPasscodeView.frame);
CGRect confirmInitialFrame = CGRectMake(passcodeViewWidth,
CGRectGetMinY(firstPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(firstPasscodeView.frame));
CGRectGetMinY(firstPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(firstPasscodeView.frame));
CGRect confirmEndFrame = firstPasscodeView.frame;
CGRect firstEndFrame = CGRectMake(-passcodeViewWidth,
CGRectGetMinY(firstPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(firstPasscodeView.frame));
NSString *confirmPasscodeTitle = [self.touchLock appearance].createPasscodeConfirmLabelText;
CGRectGetMinY(firstPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(firstPasscodeView.frame));
VENTouchLockAppearance *appearance = [self.touchLock appearance];
NSString *confirmPasscodeTitle = appearance.createPasscodeConfirmLabelText;
VENTouchLockPasscodeView *confirmPasscodeView = [[VENTouchLockPasscodeView alloc]
initWithTitle:confirmPasscodeTitle
frame:confirmInitialFrame];
frame:confirmInitialFrame
titleColor:appearance.passcodeViewControllerTitleColor
characterColor:appearance.passcodeViewControllerCharacterColor];
[self.view addSubview:confirmPasscodeView];
[UIView animateWithDuration: VENTouchLockCreatePasscodeViewControllerAnimationDuration
delay: 0.0
Expand All @@ -75,25 +78,27 @@ - (void)showConfirmPasscodeView
[firstPasscodeView removeFromSuperview];
self.passcodeView = confirmPasscodeView;
}];

}

- (void)showFirstPasscodeView
{
VENTouchLockPasscodeView *confirmPasscodeView = self.passcodeView;
CGFloat passcodeViewWidth = CGRectGetWidth(confirmPasscodeView.frame);
CGRect firstInitialFrame = CGRectMake(-passcodeViewWidth,
CGRectGetMinY(confirmPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(confirmPasscodeView.frame));
CGRectGetMinY(confirmPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(confirmPasscodeView.frame));
CGRect firstEndFrame = confirmPasscodeView.frame;
CGRect confirmEndFrame = CGRectMake(passcodeViewWidth,
CGRectGetMinY(confirmPasscodeView.frame),
passcodeViewWidth,
CGRectGetHeight(confirmPasscodeView.frame));
NSString *firstPasscodeTitle = [self.touchLock appearance].createPasscodeMismatchedLabelText;
VENTouchLockAppearance *appearance = [self.touchLock appearance];
NSString *firstPasscodeTitle = appearance.createPasscodeMismatchedLabelText;
VENTouchLockPasscodeView *firstPasscodeView = [[VENTouchLockPasscodeView alloc] initWithTitle:firstPasscodeTitle
frame:firstInitialFrame];
frame:firstInitialFrame
titleColor:appearance.passcodeViewControllerTitleColor
characterColor:appearance.passcodeViewControllerCharacterColor];
[self.view addSubview:firstPasscodeView];
[UIView animateWithDuration: VENTouchLockCreatePasscodeViewControllerAnimationDuration
delay: 0.0
Expand Down
19 changes: 18 additions & 1 deletion VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ - (void)viewDidLoad
[self configurePasscodeView];
}

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (![self.invisiblePasscodeField isFirstResponder]) {
[self.invisiblePasscodeField becomeFirstResponder];
}
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if ([self.invisiblePasscodeField isFirstResponder]) {
[self.invisiblePasscodeField resignFirstResponder];
}
}

- (void)configureInvisiblePasscodeField
{
self.invisiblePasscodeField = [[UITextField alloc] init];
Expand All @@ -49,7 +65,6 @@ - (void)configureInvisiblePasscodeField
self.invisiblePasscodeField.delegate = self;
[self.invisiblePasscodeField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
[self.view addSubview:self.invisiblePasscodeField];
[self.invisiblePasscodeField becomeFirstResponder];
}

- (void)configureNavigationItems
Expand All @@ -60,6 +75,8 @@ - (void)configureNavigationItems
- (void)configurePasscodeView
{
VENTouchLockPasscodeView *passcodeView = [[VENTouchLockPasscodeView alloc] init];
passcodeView.titleColor = self.touchLock.appearance.passcodeViewControllerTitleColor;
passcodeView.characterColor = self.touchLock.appearance.passcodeViewControllerCharacterColor;
[self.view addSubview:passcodeView];
self.passcodeView = passcodeView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
if (!self.isSnapshotViewController) {
dispatch_async(dispatch_get_main_queue(), ^{
[self showUnlockAnimated:NO];
Expand Down
2 changes: 2 additions & 0 deletions VENTouchLock/Models/VENTouchLockAppearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @description Passcode View Controller Preferences
* -----------------------------------------------------------------------------
*/
@property (strong, nonatomic) UIColor *passcodeViewControllerTitleColor;
@property (strong, nonatomic) UIColor *passcodeViewControllerCharacterColor;
@property (strong, nonatomic) UIColor *passcodeViewControllerBackgroundColor;
@property (strong, nonatomic) NSString *cancelBarButtonItemTitle;

Expand Down
6 changes: 4 additions & 2 deletions VENTouchLock/Models/VENTouchLockAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ - (instancetype)init
{
self = [super init];
if (self) { // Set default values
_passcodeViewControllerTitleColor = [UIColor blackColor];
_passcodeViewControllerCharacterColor = [UIColor blackColor];
_passcodeViewControllerBackgroundColor = [UIColor colorWithRed:239/255.0f green:239/255.0f blue:244/255.0f alpha:1.0f];
_cancelBarButtonItemTitle = NSLocalizedString(@"Cancel",nil);
_createPasscodeInitialLabelText = NSLocalizedString(@"Enter a new passcode",nil);
_cancelBarButtonItemTitle = NSLocalizedString(@"Cancel", nil);
_createPasscodeInitialLabelText = NSLocalizedString(@"Enter a new passcode", nil);
_createPasscodeConfirmLabelText = NSLocalizedString(@"Please re-enter your passcode", nil);
_createPasscodeMismatchedLabelText = NSLocalizedString(@"Passwords did not match. Try again", nil);
_createPasscodeViewControllerTitle = NSLocalizedString(@"Set Passcode", nil);
Expand Down
5 changes: 5 additions & 0 deletions VENTouchLock/Views/VENTouchLockPasscodeCharacterView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
*/
@property (assign, nonatomic) BOOL isEmpty;

/**
* The fill color of the passcode character.
*/
@property (strong, nonatomic) UIColor *fillColor;

@end
9 changes: 9 additions & 0 deletions VENTouchLock/Views/VENTouchLockPasscodeCharacterView.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,14 @@ - (void)setIsEmpty:(BOOL)isEmpty {
[self redraw];
}
}
- (void)setFillColor:(UIColor *)fillColor
{
_fillColor = fillColor;
CGColorRef cgColor = fillColor.CGColor;
self.hyphen.fillColor = cgColor;
self.hyphen.strokeColor = cgColor;
self.circle.fillColor = cgColor;
self.circle.strokeColor = cgColor;
}

@end
15 changes: 15 additions & 0 deletions VENTouchLock/Views/VENTouchLockPasscodeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@
*/
@property (strong, nonatomic) NSArray *characters;

/**
The color of the title text.
*/
@property (strong, nonatomic) UIColor *titleColor;

/**
The color of the passcode characters.
*/
@property (strong, nonatomic) UIColor *characterColor;

/**
Creates a passcode view controller with the given title and frame.
*/
- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame;

/**
Creates a passcode view controller with the given title and frame.
*/
- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame titleColor:(UIColor *)titleColor characterColor:(UIColor *)characterColor;

/**
Shakes the reciever and vibrates the device.
@param completionBlock called after shake and vibrate complete
Expand Down
27 changes: 26 additions & 1 deletion VENTouchLock/Views/VENTouchLockPasscodeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @interface VENTouchLockPasscodeView ()

@implementation VENTouchLockPasscodeView

- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame
- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame titleColor:(UIColor *)titleColor characterColor:(UIColor *)characterColor
{
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self options:nil];
Expand All @@ -24,11 +24,22 @@ - (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin;
_title = title;
_titleLabel.text = title;
_titleColor = titleColor;
_titleLabel.textColor = titleColor;
_characterColor = characterColor;
_characters = @[_firstCharacter, _secondCharacter, _thirdCharacter, _fourthCharacter];
for (VENTouchLockPasscodeCharacterView *characterView in _characters) {
characterView.fillColor = characterColor;
}
}
return self;
}

- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame;
{
return [self initWithTitle:title frame:frame titleColor:[UIColor blackColor] characterColor:[UIColor blackColor]];
}

- (instancetype)initWithFrame:(CGRect)frame
{
return [self initWithTitle:@"" frame:frame];
Expand Down Expand Up @@ -70,4 +81,18 @@ - (void)setTitle:(NSString *)title
self.titleLabel.text = _title;
}

- (void)setCharacterColor:(UIColor *)characterColor
{
_characterColor = characterColor;
for (VENTouchLockPasscodeCharacterView *characterView in self.characters) {
characterView.fillColor = characterColor;
}
}

- (void)setTitleColor:(UIColor *)titleColor
{
_titleColor = titleColor;
self.titleLabel.textColor = titleColor;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ - (void)dismissAndResetLock
}
[VENTouchLock sharedInstance].backgroundLockVisible = NO;
[[VENTouchLock sharedInstance] deletePasscode];
[VENTouchLock sharedInstance].appearance = [[VENTouchLockAppearance alloc] init];
}

- (void)simulateAppBackgroundThenForeground
Expand Down

0 comments on commit d73484c

Please sign in to comment.