TOPasscodeSettingsViewController.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // TOPasscodeSettingsViewController.h
  3. //
  4. // Copyright 2017 Timothy Oliver. All rights reserved.
  5. //
  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.
  22. #import <UIKit/UIKit.h>
  23. #import "TOPasscodeViewControllerConstants.h"
  24. @class TOPasscodeSettingsViewController;
  25. typedef NS_ENUM(NSInteger, TOPasscodeSettingsViewState) {
  26. TOPasscodeSettingsViewStateEnterCurrentPasscode,
  27. TOPasscodeSettingsViewStateEnterNewPasscode,
  28. TOPasscodeSettingsViewStateConfirmNewPasscode
  29. };
  30. NS_ASSUME_NONNULL_BEGIN
  31. /**
  32. A delegate object in charge of validating and recording the passcodes entered by the user.
  33. */
  34. @protocol TOPasscodeSettingsViewControllerDelegate <NSObject>
  35. @optional
  36. /** Called when the user was prompted to input their current passcode.
  37. Return YES if passcode was right and NO otherwise.
  38. Returning NO will cause a warning label to appear
  39. */
  40. - (BOOL)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController
  41. didAttemptCurrentPasscode:(NSString *)passcode;
  42. /** Called when the user has successfully set a new passcode. At this point, you should save over
  43. the old passcode with the new one. */
  44. - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController
  45. didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type;
  46. @end
  47. // ----------------------------------------------------------------------
  48. /**
  49. A standard system-styled view controller that users can use to change the passcode
  50. that they will need to enter for the main passcode view controller.
  51. This controller allows requiring the user to enter their previous passcode in first,
  52. and has passcode validation by requiring them to enter the new passcode twice.
  53. */
  54. @interface TOPasscodeSettingsViewController : UIViewController
  55. /** Delegate event for controlling and responding to the behavior of this controller */
  56. @property (nonatomic, weak, nullable) id<TOPasscodeSettingsViewControllerDelegate> delegate;
  57. /** The current state of the controller (confirming old passcode or creating a new one) */
  58. @property (nonatomic, assign) TOPasscodeSettingsViewState state;
  59. /** The input type of the passcode */
  60. @property (nonatomic, assign) TOPasscodeType passcodeType;
  61. /** The number of incorrect passcode attempts the user has made. Use this property to decide when to disable input. */
  62. @property (nonatomic, assign) NSInteger failedPasscodeAttemptCount;
  63. /** Before setting a new passcode, show a UI to validate the existing passcode. (Default is NO) */
  64. @property (nonatomic, assign) BOOL requireCurrentPasscode;
  65. /** If set, the view controller will disable input until this date time has been reached */
  66. @property (nonatomic, strong, nullable) NSDate *disabledInputDate;
  67. /** Hide the button Options (Default is NO) */
  68. @property (nonatomic, assign) BOOL hideOptionsButton;
  69. /*
  70. Create a new instance with the desird light or dark style
  71. @param style The visual style of the view controller
  72. */
  73. - (instancetype)init;
  74. /*
  75. Changes the passcode type and animates if required
  76. @param passcodeType Change the type of passcode to enter.
  77. @param animated Play a crossfade animation.
  78. */
  79. - (void)setPasscodeType:(TOPasscodeType)passcodeType animated:(BOOL)animated;
  80. @end
  81. NS_ASSUME_NONNULL_END