APInputAlertView.m 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //
  2. // APInputAlertView.m
  3. // westkissMob
  4. //
  5. // Created by iOS on 2023/7/28.
  6. //
  7. #import "APInputAlertView.h"
  8. #import "ASWindowManager.h"
  9. @interface APInputAlertView() <UITextViewDelegate>
  10. @property (nonatomic, strong) UILabel *titleLb;
  11. @property (nonatomic, strong) UIButton *closeBt;
  12. @property (nonatomic, strong) UILabel *contentLb;
  13. @property (nonatomic, strong) UIView *inputBgV;
  14. @property (nonatomic, strong) UITextView *inputTv;
  15. @property (nonatomic, strong) UIButton *sureBt;
  16. @property (nonatomic, strong) UIButton *cancelBt;
  17. @property (nonatomic, strong) UILabel *tvPlaceHoldLb;
  18. @property (nonatomic, strong) UILabel *tipLb;
  19. @end
  20. @implementation APInputAlertView
  21. - (void)setTitle:(NSString *)title des:(NSString *)des {
  22. self.titleLb.text = title;
  23. self.contentLb.text = des;
  24. }
  25. - (instancetype)initWithFrame:(CGRect)frame {
  26. self = [super initWithFrame:frame];
  27. if (self) {
  28. [self setUI];
  29. }
  30. return self;
  31. }
  32. - (void)setUI {
  33. self.backgroundColor = UIColor.whiteColor;
  34. self.layer.cornerRadius = 16;
  35. self.layer.masksToBounds = true;
  36. [self addSubview:self.titleLb];
  37. [self addSubview:self.closeBt];
  38. [self addSubview:self.contentLb];
  39. [self addSubview:self.inputBgV];
  40. [self addSubview:self.cancelBt];
  41. [self addSubview:self.sureBt];
  42. [self addSubview:self.tipLb];
  43. [self.inputBgV addSubview:self.inputTv];
  44. [self.inputBgV addSubview:self.tvPlaceHoldLb];
  45. [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.centerX.equalTo(self);
  47. make.top.equalTo(self).offset(16);
  48. }];
  49. [self.closeBt mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(self).offset(12);
  51. make.trailing.equalTo(self).offset(-12);
  52. make.width.height.equalTo(@30);
  53. make.leading.equalTo(self.titleLb.mas_trailing).offset(8);
  54. }];
  55. [self.contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.equalTo(self.titleLb.mas_bottom).offset(16);
  57. make.leading.equalTo(self).offset(25);
  58. make.trailing.equalTo(self).offset(-25);
  59. }];
  60. [self.inputBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.equalTo(self.contentLb.mas_bottom).offset(16);
  62. make.leading.trailing.equalTo(self.contentLb);
  63. make.height.equalTo(self.inputBgV.mas_width).multipliedBy(3.0/5);
  64. }];
  65. [self.inputTv mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.leading.equalTo(self.inputBgV).offset(14);
  67. make.bottom.trailing.equalTo(self.inputBgV).offset(-14);
  68. }];
  69. [self.tvPlaceHoldLb mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.leading.equalTo(self.inputTv).offset(6);
  71. make.trailing.equalTo(self.inputTv).offset(-6);
  72. make.bottom.lessThanOrEqualTo(self.inputTv);
  73. }];
  74. [self.cancelBt mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.trailing.equalTo(self.inputBgV);
  76. make.height.equalTo(@45);
  77. make.top.equalTo(self.inputBgV.mas_bottom).offset(16);
  78. }];
  79. [self.sureBt mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.leading.equalTo(self.inputBgV);
  81. make.height.width.centerY.equalTo(self.cancelBt);
  82. make.trailing.equalTo(self.cancelBt.mas_leading).offset(-20);
  83. }];
  84. [self.tipLb mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.top.equalTo(self.sureBt.mas_bottom).offset(10);
  86. make.leading.trailing.equalTo(self.inputBgV);
  87. IPhoneXHeigh;
  88. make.bottom.equalTo(self).offset(-securityBottom_H-30);
  89. }];
  90. }
  91. - (UILabel *)tvPlaceHoldLb {
  92. if (!_tvPlaceHoldLb) {
  93. UILabel *lb = [UILabel new];
  94. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  95. lb.textColor = Col_999;
  96. lb.numberOfLines = 0;
  97. lb.text = @"Please Input The Reason For Your Leave";
  98. _tvPlaceHoldLb = lb;
  99. }
  100. return _tvPlaceHoldLb;
  101. }
  102. - (UIView *)inputBgV {
  103. if (!_inputBgV) {
  104. UIView *v = [UIView new];
  105. v.backgroundColor = _F8F8F8;
  106. v.layer.cornerRadius = 5;
  107. v.layer.borderWidth = 1;
  108. v.layer.borderColor = _D0D0D0.CGColor;
  109. v.layer.masksToBounds = true;
  110. _inputBgV = v;
  111. }
  112. return _inputBgV;
  113. }
  114. - (UITextView *)inputTv {
  115. if (!_inputTv) {
  116. UITextView *v = [UITextView new];
  117. v.backgroundColor = UIColor.clearColor;
  118. v.font = [UIFont fontWithName:Rob_Regular size:14];
  119. v.textColor = Col_333;
  120. v.delegate = self;
  121. _inputTv = v;
  122. }
  123. return _inputTv;
  124. }
  125. - (UIButton *)closeBt {
  126. if (!_closeBt) {
  127. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  128. [btn setImage:[UIImage imageNamed:@"productLsit_filter_close"] forState:UIControlStateNormal];
  129. [btn addTarget:self action:@selector(closeBtAction) forControlEvents:UIControlEventTouchUpInside];
  130. _closeBt = btn;
  131. }
  132. return _closeBt;
  133. }
  134. - (UILabel *)contentLb {
  135. if (!_contentLb) {
  136. UILabel *lb = [[UILabel alloc] init];
  137. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  138. lb.textColor = [UIColor blackColor];
  139. lb.numberOfLines = 0;
  140. lb.text = @"A New Version Of West Kiss Upgrade Version 1.1.0 Is Available For Your Phone And Is Ready To Install Now!";
  141. lb.textAlignment = NSTextAlignmentCenter;
  142. lb.backgroundColor = [UIColor clearColor];
  143. lb.qmui_lineHeight = 24;
  144. _contentLb = lb;
  145. }
  146. return _contentLb;
  147. }
  148. - (UILabel *)tipLb {
  149. if (!_tipLb) {
  150. UILabel *lb = [[UILabel alloc] init];
  151. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  152. lb.textColor = [UIColor redColor];
  153. lb.numberOfLines = 0;
  154. lb.text = @"* Your account will be deleted after submit.";
  155. lb.textAlignment = NSTextAlignmentCenter;
  156. lb.backgroundColor = [UIColor clearColor];
  157. lb.qmui_lineHeight = 24;
  158. _tipLb = lb;
  159. }
  160. return _tipLb;
  161. }
  162. - (UILabel *)titleLb {
  163. if (!_titleLb) {
  164. UILabel *lb = [[UILabel alloc] init];
  165. lb.font = [UIFont fontWithName:Rob_Bold size:22];
  166. lb.qmui_lineHeight = 24;
  167. lb.textColor = [UIColor blackColor];
  168. lb.text = @"Deleted Account";
  169. lb.textAlignment = NSTextAlignmentCenter;
  170. lb.backgroundColor = [UIColor clearColor];
  171. _titleLb = lb;
  172. }
  173. return _titleLb;
  174. }
  175. - (UIButton *)sureBt {
  176. if (!_sureBt) {
  177. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  178. btn.backgroundColor = [UIColor blackColor];
  179. [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  180. [btn setTitle:@"Submit" forState:UIControlStateNormal];
  181. btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  182. btn.layer.cornerRadius = 4;
  183. btn.layer.masksToBounds = true;
  184. [btn addTarget:self action:@selector(sureBtAction) forControlEvents:UIControlEventTouchUpInside];
  185. _sureBt = btn;
  186. }
  187. return _sureBt;
  188. }
  189. - (UIButton *)cancelBt {
  190. if (!_cancelBt) {
  191. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  192. btn.backgroundColor = [UIColor whiteColor];
  193. [btn setTitleColor:Col_666 forState:UIControlStateNormal];
  194. [btn setTitle:@"Cancel" forState:UIControlStateNormal];
  195. btn.layer.borderWidth = 1;
  196. btn.layer.borderColor = _D0D0D0.CGColor;
  197. btn.layer.cornerRadius = 4;
  198. btn.layer.masksToBounds = true;
  199. btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  200. [btn addTarget:self action:@selector(cancelBtAction) forControlEvents:UIControlEventTouchUpInside];
  201. _cancelBt = btn;
  202. }
  203. return _cancelBt;
  204. }
  205. - (void)sureBtAction {
  206. if (self.sureAction) {
  207. self.sureAction(self.inputTv.text);
  208. }
  209. ASWindowManager.share.activeW = nil;
  210. }
  211. - (void)cancelBtAction {
  212. if (self.cancelAction) {
  213. self.cancelAction();
  214. }
  215. ASWindowManager.share.activeW = nil;
  216. }
  217. - (void)closeBtAction {
  218. if (self.closeAction) {
  219. self.closeAction();
  220. }
  221. ASWindowManager.share.activeW = nil;
  222. }
  223. - (void)textViewDidChange:(UITextView *)textView {
  224. self.tvPlaceHoldLb.hidden = textView.text.length > 0;
  225. }
  226. @end