JXWebAuthView.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // JXWebAuthView.m
  3. // shiku_im
  4. //
  5. // Created by p on 2019/3/4.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXWebAuthView.h"
  9. @interface JXWebAuthView ()
  10. @end
  11. @implementation JXWebAuthView
  12. /*
  13. // Only override drawRect: if you perform custom drawing.
  14. // An empty implementation adversely affects performance during animation.
  15. - (void)drawRect:(CGRect)rect {
  16. // Drawing code
  17. }
  18. */
  19. - (instancetype)init {
  20. if (self = [super init]) {
  21. self.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
  22. self.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];
  23. [self customView];
  24. }
  25. return self;
  26. }
  27. - (void)customView {
  28. UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 100, JX_SCREEN_WIDTH - 100)];
  29. contentView.center = g_window.center;
  30. contentView.backgroundColor = [UIColor whiteColor];
  31. contentView.layer.cornerRadius = 3.0;
  32. contentView.layer.masksToBounds = YES;
  33. [self addSubview:contentView];
  34. UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, contentView.frame.size.width, 50)];
  35. titleLabel.textAlignment = NSTextAlignmentCenter;
  36. titleLabel.textColor = [UIColor blackColor];
  37. titleLabel.font = [UIFont systemFontOfSize:17.0];
  38. titleLabel.text = [NSString stringWithFormat:@"%@%@",APP_NAME,Localized(@"JX_Login")];
  39. [contentView addSubview:titleLabel];
  40. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(titleLabel.frame), contentView.frame.size.width, .5)];
  41. line.backgroundColor = HEXCOLOR(0xdcdcdc);
  42. [contentView addSubview:line];
  43. self.headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(line.frame) + 10, 50, 50)];
  44. self.headImage.center = CGPointMake(contentView.frame.size.width / 2, self.headImage.center.y);
  45. self.headImage.layer.cornerRadius = self.headImage.frame.size.width / 2;
  46. self.headImage.layer.masksToBounds = YES;
  47. [contentView addSubview:self.headImage];
  48. self.tipTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(self.headImage.frame) + 10, contentView.frame.size.width - 40, 20)];
  49. self.tipTitle.textColor = [UIColor blackColor];
  50. self.tipTitle.font = [UIFont systemFontOfSize:15.0];
  51. self.tipTitle.text = [NSString stringWithFormat:@"%@%@:",APP_NAME,Localized(@"JX_ApplyFollowingPermissions")];
  52. [contentView addSubview:self.tipTitle];
  53. UIView *point = [[UIView alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(self.tipTitle.frame) + 20, 10, 10)];
  54. point.backgroundColor = HEXCOLOR(0xf0f0f0);
  55. point.layer.cornerRadius = point.frame.size.width / 2;
  56. [contentView addSubview:point];
  57. UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(point.frame) + 10, CGRectGetMaxY(self.tipTitle.frame) + 10, contentView.frame.size.width - CGRectGetMaxX(point.frame) - 30, 35)];
  58. tipLabel.textColor = [UIColor grayColor];
  59. tipLabel.numberOfLines = 0;
  60. tipLabel.font = [UIFont systemFontOfSize:14.0];
  61. tipLabel.text = Localized(@"JX_GetPublicInformation");
  62. [contentView addSubview:tipLabel];
  63. line = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(tipLabel.frame) + 10, contentView.frame.size.width, .5)];
  64. line.backgroundColor = HEXCOLOR(0xdcdcdc);
  65. [contentView addSubview:line];
  66. UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(line.frame), contentView.frame.size.width / 2, 40)];
  67. [cancelBtn setTitle:Localized(@"JX_WebRefused") forState:UIControlStateNormal];
  68. [cancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  69. [cancelBtn addTarget:self action:@selector(cancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
  70. [contentView addSubview:cancelBtn];
  71. line = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(cancelBtn.frame), CGRectGetMaxY(line.frame), .5, cancelBtn.frame.size.height)];
  72. line.backgroundColor = HEXCOLOR(0xdcdcdc);
  73. [contentView addSubview:line];
  74. UIButton *confirmBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(line.frame), cancelBtn.frame.origin.y, contentView.frame.size.width / 2, 40)];
  75. [confirmBtn setTitle:Localized(@"JX_WebAllow") forState:UIControlStateNormal];
  76. [confirmBtn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
  77. [confirmBtn addTarget:self action:@selector(confirmBtnAction) forControlEvents:UIControlEventTouchUpInside];
  78. [contentView addSubview:confirmBtn];
  79. contentView.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH - 100, CGRectGetMaxY(confirmBtn.frame));
  80. contentView.center = g_window.center;
  81. }
  82. - (void)confirmBtnAction {
  83. if ([self.delegate respondsToSelector:@selector(webAuthViewConfirmBtnAction)]) {
  84. [self.delegate webAuthViewConfirmBtnAction];
  85. }
  86. [self removeFromSuperview];
  87. }
  88. - (void)cancelBtnAction {
  89. [self removeFromSuperview];
  90. }
  91. @end