YMGuildManagementMyEarningsInfoView.m 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. //
  2. // YMGuildManagementMyEarningsInfoView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/26.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMGuildManagementMyEarningsInfoView.h"
  9. @interface YMGuildManagementMyEarningsInfoView ()
  10. @property (nonatomic, strong) UIView *bgView;
  11. @property (nonatomic, strong) UIImageView *bgImgv;
  12. @property (nonatomic, strong) UILabel *imgvMask;
  13. @property (nonatomic, strong) UILabel *timeMidLab;
  14. @property (nonatomic, strong) UILabel *coinLab;
  15. @property (nonatomic, strong) UILabel *contentLab;
  16. @property (nonatomic, strong) UIView *bottomView;
  17. @property (nonatomic, strong) UILabel *earnCountLab;
  18. @property (nonatomic, strong) UIButton *memberBtn;
  19. @property (nonatomic, strong) YMGuildManagementViewModel *viewModel;
  20. @end
  21. @implementation YMGuildManagementMyEarningsInfoView
  22. -(void)ym_setupViews{
  23. [self addSubview:self.bgView];
  24. [self.bgView addSubview:self.bgImgv];
  25. [self.bgImgv addSubview:self.imgvMask];
  26. [self.bgView addSubview:self.btnView];
  27. [self.btnView addSubview:self.timeMidLab];
  28. [self.btnView addSubview:self.timeBtn1];
  29. [self.btnView addSubview:self.timeBtn2];
  30. [self.bgView addSubview:self.coinLab];
  31. [self.bgView addSubview:self.contentLab];
  32. [self addSubview:self.bottomView];
  33. [self.bottomView addSubview:self.earnCountLab];
  34. [self.bottomView addSubview:self.memberBtn];
  35. [self.bottomView addSubview:self.sortBtn];
  36. [self setNeedsUpdateConstraints];
  37. [self updateConstraintsIfNeeded];
  38. }
  39. - (void)updateConstraints{
  40. [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.left.right.equalTo(self);
  42. make.height.mas_equalTo(adapt(256));
  43. }];
  44. [self.bgImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.edges.equalTo(self.bgView);
  46. }];
  47. [self.imgvMask mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.edges.equalTo(self.bgImgv);
  49. }];
  50. [self.btnView mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.centerX.equalTo(self.bgView);
  52. make.top.equalTo(self.bgView).offset(adapt(102));
  53. make.width.equalTo(adapt(204));
  54. make.height.mas_equalTo(adapt(26));
  55. }];
  56. [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.equalTo(self.bgView.mas_bottom);
  58. make.left.right.equalTo(self);
  59. make.height.mas_equalTo(adapt(60));
  60. }];
  61. [self.timeMidLab mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.center.equalTo(self.btnView);
  63. make.width.mas_equalTo(adapt(20));
  64. }];
  65. [self.timeBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.leading.bottom.equalTo(self.btnView);
  67. make.trailing.equalTo(self.timeMidLab.leading);
  68. }];
  69. [self.timeBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.trailing.bottom.equalTo(self.btnView);
  71. make.leading.equalTo(self.timeMidLab.trailing);
  72. }];
  73. [self.coinLab mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.equalTo(self.btnView.mas_bottom).offset(adapt(10));
  75. make.centerX.equalTo(self.bgView);
  76. }];
  77. [self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.centerX.equalTo(self.bgView);
  79. make.top.equalTo(self.coinLab.mas_bottom).offset(adapt(10));
  80. }];
  81. [self.earnCountLab mas_makeConstraints:^(MASConstraintMaker *make) {
  82. make.centerY.equalTo(self.bottomView);
  83. make.left.equalTo(self.bottomView).offset(15);
  84. }];
  85. [self.memberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.centerY.equalTo(self.bottomView);
  87. make.left.equalTo(self.earnCountLab.mas_right).offset(15);
  88. }];
  89. [self.sortBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.centerY.equalTo(self.bottomView);
  91. make.right.equalTo(self.bottomView).offset(-15);
  92. make.width.mas_equalTo(adapt(60));
  93. make.height.mas_equalTo(adapt(30));
  94. }];
  95. [super updateConstraints];
  96. }
  97. - (void)ym_bindViewModel:(YMGuildManagementViewModel *)viewModel{
  98. if (!viewModel) {
  99. return;
  100. }
  101. _viewModel = viewModel;
  102. @weakify(self)
  103. [[[[RACObserve(self.viewModel, startTime) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * startTime) {
  104. @strongify(self)
  105. [self.timeBtn1 setTitle:startTime forState:UIControlStateNormal];
  106. }];
  107. [[[[RACObserve(self.viewModel, endTime) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * endTime) {
  108. @strongify(self)
  109. [self.timeBtn2 setTitle:endTime forState:UIControlStateNormal];
  110. }];
  111. [[[[RACObserve(self.viewModel, myEarnStr) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * myEarnStr) {
  112. @strongify(self)
  113. self.coinLab.text = myEarnStr;
  114. }];
  115. [[[[RACObserve(self.viewModel, peopleStr) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * peopleStr) {
  116. @strongify(self)
  117. self.earnCountLab.text = [NSString stringWithFormat:@"产生收益(%@)人",peopleStr];
  118. }];
  119. }
  120. - (UIView *)bgView{
  121. if (!_bgView) {
  122. _bgView = [[UIView alloc]init];
  123. _bgView.backgroundColor = UIColor.whiteColor;
  124. }
  125. return _bgView;
  126. }
  127. - (UIImageView *)bgImgv {
  128. if (!_bgImgv) {
  129. _bgImgv = [[UIImageView alloc] init];
  130. _bgImgv.image = [UIImage imageNamed:@"gonghui_nav_bg"];
  131. }
  132. return _bgImgv;
  133. }
  134. - (UILabel *)imgvMask {
  135. if (!_imgvMask) {
  136. _imgvMask = [[UILabel alloc] init];
  137. }
  138. return _imgvMask;
  139. }
  140. - (UIView *)bottomView{
  141. if (!_bottomView) {
  142. _bottomView = [[UIView alloc]init];
  143. _bottomView.backgroundColor = UIColor.whiteColor;
  144. }
  145. return _bottomView;
  146. }
  147. - (UIButton *)btnView{
  148. if (!_btnView) {
  149. _btnView = [[UIButton alloc]init];
  150. _btnView.layer.cornerRadius = adapt(13);
  151. _btnView.layer.borderWidth = 0.5;
  152. _btnView.layer.borderColor = UIColor.whiteColor.CGColor;
  153. }
  154. return _btnView;
  155. }
  156. - (UILabel *)timeMidLab{
  157. if (!_timeMidLab) {
  158. _timeMidLab = [[UILabel alloc]init];
  159. _timeMidLab.textAlignment = NSTextAlignmentCenter;
  160. _timeMidLab.font = LCFont(15);
  161. _timeMidLab.textColor = UIColor.whiteColor;
  162. _timeMidLab.text = @"至";
  163. }
  164. return _timeMidLab;
  165. }
  166. - (UIButton *)timeBtn1{
  167. if (!_timeBtn1) {
  168. _timeBtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
  169. _timeBtn1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentTrailing;
  170. _timeBtn1.titleLabel.font = LCFont(15);
  171. _timeBtn1.userInteractionEnabled = NO;
  172. [_timeBtn1 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  173. }
  174. return _timeBtn1;
  175. }
  176. - (UIButton *)timeBtn2{
  177. if (!_timeBtn2) {
  178. _timeBtn2 = [UIButton buttonWithType:UIButtonTypeCustom];
  179. _timeBtn2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading;
  180. _timeBtn2.titleLabel.font = LCFont(15);
  181. _timeBtn2.userInteractionEnabled = NO;
  182. [_timeBtn2 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  183. }
  184. return _timeBtn2;
  185. }
  186. - (UILabel *)coinLab{
  187. if (!_coinLab) {
  188. _coinLab = [[UILabel alloc]init];
  189. _coinLab.textAlignment = NSTextAlignmentCenter;
  190. _coinLab.font = LCBoldFont(20);
  191. _coinLab.textColor = UIColor.whiteColor;
  192. }
  193. return _coinLab;
  194. }
  195. - (UILabel *)contentLab{
  196. if (!_contentLab) {
  197. _contentLab = [[UILabel alloc]init];
  198. _contentLab.textAlignment = NSTextAlignmentCenter;
  199. _contentLab.font = LCFont(15);
  200. _contentLab.textColor = UIColor.whiteColor;
  201. _contentLab.text = @"我的收益(金币)";
  202. }
  203. return _contentLab;
  204. }
  205. - (UILabel *)earnCountLab{
  206. if (!_earnCountLab) {
  207. _earnCountLab = [[UILabel alloc]init];
  208. _earnCountLab.font = LCFont(15);
  209. _earnCountLab.textColor = [UIColor secondaryLabelColor];
  210. _earnCountLab.text = @"产生收益(*)人";
  211. }
  212. return _earnCountLab;
  213. }
  214. - (UIButton *)memberBtn{
  215. if (!_memberBtn) {
  216. _memberBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  217. _memberBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading;
  218. _memberBtn.titleLabel.font = LCFont(15);
  219. [_memberBtn setTitleColor:HexColorFromRGBA(0xFF76C0, 1) forState:UIControlStateNormal];
  220. [_memberBtn setTitle:@"公会成员列表" forState:UIControlStateNormal];
  221. WS(weakSelf)
  222. [[[_memberBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  223. [weakSelf.viewModel gotoMember];
  224. }];
  225. }
  226. return _memberBtn;
  227. }
  228. - (UIButton *)sortBtn{
  229. if (!_sortBtn) {
  230. _sortBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  231. _sortBtn.titleLabel.font = LCFont(13);
  232. [_sortBtn setTitle:@"排序" forState:UIControlStateNormal];
  233. [_sortBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
  234. _sortBtn.backgroundColor = HexColorFromRGBA(0xFF76C0, 1);
  235. _sortBtn.layer.cornerRadius = 5;
  236. _sortBtn.layer.masksToBounds = true;
  237. }
  238. return _sortBtn;
  239. }
  240. @end