TOPasscodeViewContentLayout.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // TOPasscodeViewContentLayout.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 <Foundation/Foundation.h>
  23. #import <UIKit/UIKit.h>
  24. /**
  25. Depending on the width of the application window, all of the content views in
  26. the passcode view need to be resized in order to fit in the available space.
  27. This means that not only does the spacing and sizing of views need to be changed, but
  28. image assets need to be regenerated and font sizes need to change as well.
  29. This class assumes there will be three major screen sizes, and provides layout
  30. sizes, spacing, and styles in order to resize the passcode view for each one.
  31. The three screen styles it supports are:
  32. * Small Screens - iPhone 5/ or iPad 9.7" in 1/4 split screen mode
  33. * Medium Screens - iPhone 6/ or iPad 12.9" in 1/4 split screen mode
  34. * Large Screens - iPhone 6 Plus and all iPads when not in split screen mode.
  35. */
  36. @interface TOPasscodeViewContentLayout : NSObject
  37. /* The width of the PIN view in which this layout object is sizing the content to fit. */
  38. @property (nonatomic, assign) CGFloat viewWidth;
  39. /* Extra padding at the bottom in order to shift the content slightly up */
  40. @property (nonatomic, assign) CGFloat bottomPadding;
  41. /* The title view at the very top */
  42. @property (nonatomic, assign) CGFloat titleViewBottomSpacing; // Space from the bottom of the title view to the title label
  43. /* The Title Label Explaining the Passcode View */
  44. @property (nonatomic, assign) CGFloat titleLabelBottomSpacing; // Space from the title label to the input view
  45. @property (nonatomic, assign) CGFloat subtitleLabelBottomSpacing; // Space from the subtitle label to the input view
  46. @property (nonatomic, strong) UIFont *titleLabelFont; // The font of the title label
  47. @property (nonatomic, strong) UIFont *subtitleLabelFont; // The font of the subtitle label
  48. /* Title Label properties when the view is laid out horizontally */
  49. @property (nonatomic, assign) CGFloat titleHorizontalLayoutWidth; // When laid out horizontally, the width of the title view
  50. @property (nonatomic, assign) CGFloat titleHorizontalLayoutSpacing; // The amount of spacing between the title label and the passcode keypad
  51. @property (nonatomic, assign) CGFloat titleViewHorizontalBottomSpacing; // Space from the bottom of the title view when iPhone is horizontal
  52. @property (nonatomic, assign) CGFloat titleLabelHorizontalBottomSpacing; // Spacing from the title label to input view in horizontal mode
  53. @property (nonatomic, assign) CGFloat subtitleLabelHorizontalBottomSpacing; // Spacing from the subtitle label to input view in horizontal mode
  54. /* Circle Row Configuration */
  55. @property (nonatomic, assign) CGFloat circleRowDiameter; // The diameter of each circle representing a PIN number
  56. @property (nonatomic, assign) CGFloat circleRowSpacing; // The spacing between each circle
  57. @property (nonatomic, assign) CGFloat circleRowBottomSpacing; // Space between the view used to indicate input
  58. /* Text Field Configuration */
  59. @property (nonatomic, assign) CGFloat textFieldBorderThickness; // The thickness of the border stroke
  60. @property (nonatomic, assign) CGFloat textFieldBorderRadius; // The corner radius of the border
  61. @property (nonatomic, assign) CGFloat textFieldCircleDiameter; // The size of the circles in the passcode field
  62. @property (nonatomic, assign) CGFloat textFieldCircleSpacing; // The amount of spacing between each circle
  63. @property (nonatomic, assign) CGSize textFieldBorderPadding; // The amount of padding between the circles and the border
  64. @property (nonatomic, assign) NSInteger textFieldNumericCharacterLength; // The amount of circles to have in this field when set to numeric
  65. @property (nonatomic, assign) NSInteger textFieldAlphanumericCharacterLength; // The amount of circles to have in this field when set to alphanumeric
  66. @property (nonatomic, assign) CGFloat submitButtonFontSize; // The font size of the 'OK' button
  67. @property (nonatomic, assign) CGFloat submitButtonSpacing; // The spacing of the 'OK' button from the input
  68. /* Circle Button Shape and Layout */
  69. @property (nonatomic, assign) CGFloat circleButtonDiameter; // The size of each PIN button
  70. @property (nonatomic, assign) CGSize circleButtonSpacing; // The vertical/horizontal spacing between buttons
  71. @property (nonatomic, assign) CGFloat circleButtonStrokeWidth; // The thickness of the border line
  72. /* Circle Button Label */
  73. @property (nonatomic, strong) UIFont *circleButtonTitleLabelFont; // The font used for the '1' number labels
  74. @property (nonatomic, strong) UIFont *circleButtonLetteringLabelFont; // The font used for the 'ABC' labels
  75. @property (nonatomic, assign) CGFloat circleButtonLabelSpacing; // The vertical spacing between the number and lettering labels
  76. @property (nonatomic, assign) CGFloat circleButtonLetteringSpacing; // The spacing between the 'ABC' characters
  77. /* Default layout configurations for the various sizes */
  78. + (TOPasscodeViewContentLayout *)defaultScreenContentLayout; /* Default layout values. Designed for iPhone 6 Plus and above. */
  79. + (TOPasscodeViewContentLayout *)mediumScreenContentLayout; /* For medium screen sizes, like iPhone 6, or 1/4 view on iPad Pro. */
  80. + (TOPasscodeViewContentLayout *)smallScreenContentLayout; /* For the smallest screens, like iPhone SE, and 1/4 on standard size iPads/ */
  81. @end