GT3CaptchaButton.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // GTCaptchanActivityIndicator.h
  3. // GT3Captcha
  4. //
  5. // Created by NikoXu on 9/27/16.
  6. // Copyright © 2016 Geetest. All rights reserved.
  7. //
  8. #import "GT3Utils.h"
  9. @class GT3CaptchaManager;
  10. @protocol GT3CaptchaButtonDelegate;
  11. @interface GT3CaptchaButton : UIControl
  12. /** Captcha Manager */
  13. @property (nonatomic, readonly, strong) GT3CaptchaManager *captchaManager;
  14. /** Captcha Button Delegate */
  15. @property (nonatomic, weak) id<GT3CaptchaButtonDelegate> delegate;
  16. /** Captcha State */
  17. @property (nonatomic, readonly, assign) GT3CaptchaState captchaState;
  18. /** Defines Inset for Captcha Button. */
  19. @property (nonatomic, assign) UIEdgeInsets captchaEdgeInsets;
  20. /**
  21. * @abstract
  22. * Use thoes keys to config title label in different
  23. * state on the captcha button.
  24. *
  25. * @discussion
  26. * - contain keys: 'inactive', 'active', 'initial',
  27. * 'waiting', 'collecting', 'computing', 'success',
  28. * 'fail', 'error', 'cancel'.
  29. */
  30. @property (nonatomic, strong) NSMutableDictionary<NSString *, NSAttributedString *> *tipsDict;
  31. /**
  32. * Captcha Button `backgroundColor`. Defaults to
  33. * 0xf3f3f3. Animatable.
  34. */
  35. @property (nonatomic, strong) UIColor *mainColor;
  36. /**
  37. * Defines color for Captcha Indicator View background.
  38. */
  39. @property (nonatomic, strong) UIColor *indicatorColor;
  40. /**
  41. * Captcha Button `layer.borderColor`. Defaults
  42. * to 0xcccccc. Animatable.
  43. */
  44. @property (nonatomic, assign) CGColorRef borderColor;
  45. /**
  46. * Captcha Button `layer.borderWidth` Defaults to
  47. * 1.0. Animatable.
  48. */
  49. @property (nonatomic, assign) CGFloat borderWidth;
  50. /**
  51. * Captcha Button `layer.cornerRadius`. Defaults
  52. * to 3.0. Animatable.
  53. */
  54. @property (nonatomic, assign) CGFloat cornerRadius;
  55. /**
  56. * Logo Image View, just work in same configuration
  57. * as back-end.
  58. */
  59. @property (nonatomic, strong) UIImage *logoImage;
  60. /**
  61. * @abstract
  62. * Initializes and returns a newly allocated captcha
  63. * button object with the specified frame rectangle
  64. *
  65. * @param frame The frame rectangle for the button, measured in points.
  66. * @param captchaManager GT3CaptchaManager instance.
  67. * @return A initialized GTCaptchaButton object.
  68. */
  69. - (instancetype)initWithFrame:(CGRect)frame captchaManager:(GT3CaptchaManager *)captchaManager;
  70. /**
  71. * @abstract Start Captcha.
  72. *
  73. * @discussion
  74. * Depending on captcha state, call GT3CaptchaManager
  75. * instance method `startGTCaptchaWithAnimated:`,
  76. * `requestGTCaptcha`, `showGTViewIfRegiested` inner.
  77. */
  78. - (void)startCaptcha;
  79. /**
  80. * @abstract Stop Captcha.
  81. *
  82. * @discussion Call GT3CaptchaManager instance method
  83. * `stopGTCaptcha` inner.
  84. */
  85. - (void)stopCaptcha;
  86. /**
  87. * @abstract Reset Captcha.
  88. *
  89. * @discussion Call GT3CaptchaManager instance method
  90. * `resetCaptcha` inner.
  91. */
  92. - (void)resetCaptcha;
  93. /**
  94. * @abstract Update captcha button tips label instantly.
  95. *
  96. * @param title An attributed string for title
  97. */
  98. - (void)updateTitleLabel:(NSAttributedString *)title;
  99. @end
  100. @protocol GT3CaptchaButtonDelegate <NSObject>
  101. @optional
  102. /** Return NO to disallow captcha event. Default YES. */
  103. - (BOOL)captchaButtonShouldBeginTapAction:(GT3CaptchaButton *)button;
  104. /** Called this method after GT3CaptchaButton's property 'cpatchaState' did change. */
  105. - (void)captchaButton:(GT3CaptchaButton *)button didChangeState:(GT3CaptchaState)state;
  106. @end