Skip to content

Commit 49e2202

Browse files
committed
Adding code header and documentation
1 parent 309f039 commit 49e2202

11 files changed

+257
-34
lines changed

TOPasscodeViewController/Models/TOPasscodeCircleImage.h

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
11
//
2-
// TOPasscodeImage.h
3-
// TOPasscodeViewControllerExample
2+
// TOPasscodeCircleImage.h
43
//
5-
// Created by Tim Oliver on 5/17/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import <UIKit/UIKit.h>
1024

1125
NS_ASSUME_NONNULL_BEGIN
1226

27+
/**
28+
A subclass of `UIImage` that can procedurally generate both hollow and full circle graphics at any size.
29+
These are used for the 'normal' and 'tapped' states of the passcode circle buttons.
30+
*/
1331
@interface TOPasscodeCircleImage : UIImage
1432

33+
/**
34+
Generates and returns a `UIImage` of a filled circle at the specified size.
35+
36+
@param size The diameter of the final circle image
37+
@param inset An inset value that will shrink the size of the circle. This is so it can be overlaid on a hollow circle
38+
without interfering with the anti-aliasing on the outer border.
39+
@param padding External padding around the circle to ensure it won't be clipped by the edge of the layer.
40+
Setting this value will increase the dimensions of the final `UIImage`.
41+
@param antialias Whether the circle boundary will be antialiased (Since antialiasing is unnecessary if this circle will overlay another.)
42+
*/
1543
+ (UIImage *)circleImageOfSize:(CGFloat)size inset:(CGFloat)inset padding:(CGFloat)padding antialias:(BOOL)antialias;
44+
45+
/**
46+
Generates and returns a `UIImage` of a hollow circle at the specified size.
47+
48+
@param size The diameter of the final circle image
49+
@param strokeWidth The thickness, in points, of the stroke making up the circle image.
50+
@param padding External padding around the circle to ensure it won't be clipped by the edge of the layer.
51+
Setting this value will increase the dimensions of the final `UIImage`.
52+
*/
1653
+ (UIImage *)hollowCircleImageOfSize:(CGFloat)size strokeWidth:(CGFloat)strokeWidth padding:(CGFloat)padding;
1754

1855
@end

TOPasscodeViewController/Models/TOPasscodeCircleImage.m

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
//
2-
// TOPasscodeImage.m
3-
// TOPasscodeViewControllerExample
2+
// TOPasscodeCircleImage.m
43
//
5-
// Created by Tim Oliver on 5/17/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import "TOPasscodeCircleImage.h"
1024

TOPasscodeViewController/Models/TOPasscodeViewContentLayout.h

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,45 @@
11
//
2-
// TOPasscodeViewContentConfiguration.h
3-
// TOPasscodeViewControllerExample
2+
// TOPasscodeViewContentLayout.h
43
//
5-
// Created by Tim Oliver on 5/19/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import <Foundation/Foundation.h>
1024
#import <UIKit/UIKit.h>
1125

26+
/**
27+
Depending on the width of the application window, all of the content views in
28+
the passcode view need to be resized in order to fit in the available space.
29+
30+
This means that not only does the spacing and sizing of views need to be changed, but
31+
image assets need to be regenerated and font sizes need to change as well.
32+
33+
This class assumes there will be three major screen sizes, and provides layout
34+
sizes, spacing, and styles in order to resize the passcode view for each one.
35+
36+
The three screen styles it supports are:
37+
38+
* Small Screens - iPhone 5/ or iPad 9.7" in 1/4 split screen mode
39+
* Medium Screens - iPhone 6/ or iPad 12.9" in 1/4 split screen mode
40+
* Large Screens - iPhone 6 Plus and all iPads when not in split screen mode.
41+
42+
*/
1243
@interface TOPasscodeViewContentLayout : NSObject
1344

1445
/* The width of the PIN view in which this layout object is sizing the content to fit. */

TOPasscodeViewController/Models/TOPasscodeViewContentLayout.m

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
//
2-
// TOPasscodeViewContentConfiguration.m
3-
// TOPasscodeViewControllerExample
2+
// TOPasscodeViewContentLayout.m
43
//
5-
// Created by Tim Oliver on 5/19/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import "TOPasscodeViewContentLayout.h"
1024

TOPasscodeViewController/Models/TOPasscodeViewControllerAnimatedTransitioning.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,33 @@
1313

1414
NS_ASSUME_NONNULL_BEGIN
1515

16+
/**
17+
An class conforming to `UIViewControllerAnimatedTransitioning` that handles the custom animation
18+
that plays when the passcode view controller is presented on the user's screen.
19+
*/
1620
@interface TOPasscodeViewControllerAnimatedTransitioning : NSObject <UIViewControllerAnimatedTransitioning>
1721

22+
/** The parent passcode view controller that this object will be controlling */
1823
@property (nonatomic, weak, readonly) TOPasscodeViewController *passcodeViewController;
24+
25+
/** Whether the controller is being presented or dismissed. The animation is played in reverse when dismissing. */
1926
@property (nonatomic, assign) BOOL dismissing;
20-
@property (nonatomic, assign) BOOL passcodeSuccess; //Play a different animation if the password succeeeded
2127

22-
- (instancetype)initWithPasscodeViewController:(TOPasscodeViewController *)passcodeViewController dismissing:(BOOL)dismissing success:(BOOL)success;
28+
/** If the correct passcode was successfully entered, this property can be set to YES. When the view controller
29+
is dismissing, the keypad view will also play a zooming out animation to give added context to the dismissal. */
30+
@property (nonatomic, assign) BOOL success;
31+
32+
/**
33+
Creates a new instanc of `TOPasscodeViewControllerAnimatedTransitioning` that will control the provided passcode
34+
view controller.
35+
36+
@param passcodeViewController The passcode view controller in which this object will coordinate the animation upon.
37+
@param dismissing Whether the animation is played to present the view controller, or dismiss it.
38+
@param success Whether the object needs to play an additional zooming animation denoting the passcode was successfully entered.
39+
*/
40+
- (instancetype)initWithPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
41+
dismissing:(BOOL)dismissing
42+
success:(BOOL)success;
2343

2444
@end
2545

TOPasscodeViewController/Models/TOPasscodeViewControllerAnimatedTransitioning.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ - (instancetype)initWithPasscodeViewController:(TOPasscodeViewController *)passc
2121
if (self = [super init]) {
2222
_passcodeViewController = passcodeViewController;
2323
_dismissing = dismissing;
24-
_passcodeSuccess = success;
24+
_success = success;
2525
}
2626

2727
return self;

TOPasscodeViewController/Models/TOSettingsKeypadImage.h

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,52 @@
11
//
22
// TOSettingsKeypadImage.h
3-
// TOPasscodeViewControllerExample
43
//
5-
// Created by Tim Oliver on 6/20/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import <UIKit/UIKit.h>
1024

1125
NS_ASSUME_NONNULL_BEGIN
1226

27+
/**
28+
A subclass of `UIImage` that procedurally generates images for `TOPasscodeSettingsKeypadView`.
29+
This includes background images for each keypad button, and a delete icon for the bottom right corner
30+
of the keypad.
31+
*/
1332
@interface TOSettingsKeypadImage : UIImage
1433

34+
/**
35+
Generates and returns an image of button background with a raised border in a pseudo-skeuomorphic style.
36+
37+
@param radius The rounded radius of the button image's corners
38+
@param foregroundColor The fill color of the primary section of the button
39+
@param edgeColor The color of the raised border edge along the bottom.
40+
@param thickness The size of the border running along the bottom
41+
*/
1542
+ (UIImage *)buttonImageWithCornerRadius:(CGFloat)radius
1643
foregroundColor:(UIColor *)foregroundColor
1744
edgeColor:(UIColor *)edgeColor
1845
edgeThickness:(CGFloat)thickness;
1946

47+
/**
48+
Generates and returns a tintable delete icon.
49+
*/
2050
+ (UIImage *)deleteIcon;
2151

2252
@end

TOPasscodeViewController/TOPasscodeSettingsViewController.h

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
//
22
// TOPasscodeSettingsViewController.h
3-
// TOPasscodeViewControllerExample
43
//
5-
// Created by Tim Oliver on 6/8/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import <UIKit/UIKit.h>
1024
#import "TOPasscodeViewControllerConstants.h"
@@ -19,6 +33,9 @@ typedef NS_ENUM(NSInteger, TOPasscodeSettingsViewState) {
1933

2034
NS_ASSUME_NONNULL_BEGIN
2135

36+
/**
37+
A delegate object in charge of validating and recording the passcodes entered by the user.
38+
*/
2239
@protocol TOPasscodeSettingsViewControllerDelegate <NSObject>
2340

2441
@optional
@@ -40,6 +57,14 @@ NS_ASSUME_NONNULL_BEGIN
4057

4158
// ----------------------------------------------------------------------
4259

60+
/**
61+
A standard system-styled view controller that users can use to change the passcode
62+
that they will need to enter for the main passcode view controller.
63+
64+
This controller allows requiring the user to enter their previous passcode in first,
65+
and has passcode validation by requiring them to enter the new passcode twice.
66+
*/
67+
4368
@interface TOPasscodeSettingsViewController : UIViewController
4469

4570
/** Delegate event for controlling and responding to the behavior of this controller */

TOPasscodeViewController/TOPasscodeSettingsViewController.m

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
//
22
// TOPasscodeSettingsViewController.m
3-
// TOPasscodeViewControllerExample
43
//
5-
// Created by Tim Oliver on 6/8/17.
6-
// Copyright © 2017 Timothy Oliver. All rights reserved.
4+
// Copyright 2017 Timothy Oliver. All rights reserved.
75
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files (the "Software"), to
8+
// deal in the Software without restriction, including without limitation the
9+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10+
// sell copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions:
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20+
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
21+
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
822

923
#import "TOPasscodeSettingsViewController.h"
1024
#import "TOPasscodeInputField.h"

0 commit comments

Comments
 (0)