YMMyEarningsInfoView.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. //
  2. // YMMyEarningsInfoView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/29.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMyEarningsInfoView.h"
  9. #import "YMMyEarningsViewModel.h"
  10. @interface YMMyEarningsInfoView ()
  11. /// 我的收益VM
  12. @property (nonatomic, strong) YMMyEarningsViewModel *viewModel;
  13. /// 圆角视图
  14. @property (nonatomic, strong) UIView *roundedCornerView;
  15. /// 信息背景图
  16. @property (nonatomic, strong) UIImageView *infoBgView;
  17. /// 用户剩余金币标签
  18. @property (nonatomic, strong) UILabel *userRemainingPointsLb;
  19. /// 用户收益名称标签
  20. @property (nonatomic, strong) UILabel *userEarningsNameLb;
  21. @property (nonatomic, strong) UIImageView *userBalanceIcon;
  22. ///// 今日收益视图
  23. //@property (nonatomic, strong) UIView *userTodayEarningsView;
  24. ///// 今日收益图标
  25. //@property (nonatomic, strong) UIImageView *userTodayEarningsIcon;
  26. ///// 今日收益标题标签
  27. //@property (nonatomic, strong) UILabel *userTodayEarningsTitleLb;
  28. ///// 今日收益内容标签
  29. //@property (nonatomic, strong) UILabel *userTodayEarningsContentLb;
  30. //
  31. ///// 七日收益视图
  32. //@property (nonatomic, strong) UIView *userSevenDayEarningsView;
  33. ///// 七日收益图标
  34. //@property (nonatomic, strong) UIImageView *userSevenDayEarningsIcon;
  35. ///// 七日收益标题标签
  36. //@property (nonatomic, strong) UILabel *userSevenDayEarningsTitleLb;
  37. ///// 七日收益内容标签
  38. //@property (nonatomic, strong) UILabel *userSevenDayEarningsContentLb;
  39. @end
  40. @implementation YMMyEarningsInfoView
  41. - (void)ym_setupViews{
  42. [self addSubview:self.roundedCornerView];
  43. [self addSubview:self.infoBgView];
  44. [self.infoBgView addSubview:self.userEarningsNameLb];
  45. [self.infoBgView addSubview:self.userBalanceIcon];
  46. [self.infoBgView addSubview:self.userRemainingPointsLb];
  47. [self.infoBgView addSubview:self.incomeBreakdownBtn];
  48. // [self.infoBgView addSubview:self.userTodayEarningsView];
  49. // [self.userTodayEarningsView addSubview:self.userTodayEarningsIcon];
  50. // [self.userTodayEarningsView addSubview:self.userTodayEarningsTitleLb];
  51. // [self.userTodayEarningsView addSubview:self.userTodayEarningsContentLb];
  52. //
  53. // [self.infoBgView addSubview:self.userSevenDayEarningsView];
  54. // [self.userSevenDayEarningsView addSubview:self.userSevenDayEarningsIcon];
  55. // [self.userSevenDayEarningsView addSubview:self.userSevenDayEarningsTitleLb];
  56. // [self.userSevenDayEarningsView addSubview:self.userSevenDayEarningsContentLb];
  57. [self setNeedsUpdateConstraints];
  58. [self updateConstraintsIfNeeded];
  59. }
  60. - (void)updateConstraints{
  61. [self.roundedCornerView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.equalTo(self);
  63. make.right.equalTo(self);
  64. make.bottom.equalTo(self);
  65. make.height.mas_equalTo(adapt(70));
  66. }];
  67. [self.infoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.top.equalTo(self).offset(adapt(12));
  69. make.left.equalTo(self).offset(adapt(12));
  70. make.right.equalTo(self).offset(adapt(-12));
  71. make.bottom.equalTo(self);
  72. make.height.mas_equalTo(adapt(102));
  73. }];
  74. [self.userBalanceIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.centerY.equalTo(self.infoBgView).offset(adapt(0));
  76. make.left.equalTo(self.infoBgView.mas_left).offset(adapt(12));
  77. make.width.mas_equalTo(adapt(46));
  78. make.height.mas_equalTo(adapt(46));
  79. }];
  80. [self.userEarningsNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.bottom.equalTo(self.userBalanceIcon.mas_centerY).offset(adapt(-5));
  82. make.left.equalTo(self.userBalanceIcon.mas_right).offset(adapt(3));
  83. }];
  84. [self.userRemainingPointsLb mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.top.equalTo(self.userEarningsNameLb.mas_bottom).offset(adapt(0));
  86. make.left.equalTo(self.userBalanceIcon.mas_right).offset(adapt(3));
  87. }];
  88. [self.incomeBreakdownBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.right.equalTo(self.infoBgView).offset(-adapt(20));
  90. make.centerY.equalTo(self.infoBgView).offset(0);
  91. make.width.equalTo(adapt(88));
  92. make.height.equalTo(adapt(30));
  93. }];
  94. // [self.userTodayEarningsView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. // make.bottom.equalTo(self.infoBgView).offset(adapt(-10));
  96. // make.left.equalTo(self.infoBgView).offset(adapt(40));
  97. // }];
  98. //
  99. // [self.userTodayEarningsTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  100. // make.top.equalTo(self.userTodayEarningsView).offset(adapt(3));
  101. // make.left.equalTo(self.userTodayEarningsView).offset(adapt(3));
  102. // make.bottom.equalTo(self.userTodayEarningsView).offset(adapt(-3));
  103. // }];
  104. //
  105. // [self.userTodayEarningsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  106. // make.centerY.equalTo(self.userTodayEarningsView.mas_centerY);
  107. // make.left.equalTo(self.userTodayEarningsTitleLb.mas_right).offset(adapt(3));
  108. // make.width.height.mas_equalTo(adapt(15));
  109. // }];
  110. //
  111. // [self.userTodayEarningsContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  112. // make.centerY.equalTo(self.userTodayEarningsView.mas_centerY);
  113. // make.left.equalTo(self.userTodayEarningsIcon.mas_right).offset(adapt(3));
  114. // make.right.equalTo(self.userTodayEarningsView).offset(adapt(-3));
  115. // }];
  116. //
  117. // [self.userSevenDayEarningsView mas_makeConstraints:^(MASConstraintMaker *make) {
  118. // make.bottom.equalTo(self.infoBgView).offset(adapt(-10));
  119. // make.right.equalTo(self.infoBgView).offset(adapt(-40));
  120. // }];
  121. //
  122. // [self.userSevenDayEarningsTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  123. // make.top.equalTo(self.userSevenDayEarningsView).offset(adapt(3));
  124. // make.left.equalTo(self.userSevenDayEarningsView).offset(adapt(3));
  125. // make.bottom.equalTo(self.userSevenDayEarningsView).offset(adapt(-3));
  126. // }];
  127. //
  128. // [self.userSevenDayEarningsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  129. // make.centerY.equalTo(self.userSevenDayEarningsView.mas_centerY);
  130. // make.left.equalTo(self.userSevenDayEarningsTitleLb.mas_right).offset(adapt(3));
  131. // make.width.height.mas_equalTo(adapt(15));
  132. // }];
  133. //
  134. // [self.userSevenDayEarningsContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  135. // make.centerY.equalTo(self.userSevenDayEarningsView.mas_centerY);
  136. // make.left.equalTo(self.userSevenDayEarningsIcon.mas_right).offset(adapt(3));
  137. // make.right.equalTo(self.userSevenDayEarningsView).offset(adapt(-3));
  138. // }];
  139. [super updateConstraints];
  140. }
  141. - (void)ym_bindViewModel:(YMMyEarningsViewModel *)viewModel{
  142. if (!viewModel) {
  143. return;
  144. }
  145. _viewModel = viewModel;
  146. @weakify(self)
  147. [[[[RACObserve(self.viewModel, userRemainingPoints) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNumber * userRemainingPoints) {
  148. @strongify(self)
  149. self.userRemainingPointsLb.text = stringFormat(@"%.2f",[userRemainingPoints doubleValue]);
  150. }];
  151. }
  152. - (UIView *)roundedCornerView{
  153. if (!_roundedCornerView) {
  154. _roundedCornerView = [[UIView alloc]init];
  155. _roundedCornerView.hidden = YES;
  156. _roundedCornerView.backgroundColor = UIColor.whiteColor;
  157. [_roundedCornerView addRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight radius:adapt(20)];
  158. }
  159. return _roundedCornerView;
  160. }
  161. - (UIImageView *)infoBgView{
  162. if (!_infoBgView) {
  163. _infoBgView = [[UIImageView alloc]init];
  164. _infoBgView.image = ImageByName(@"ym_my_earnings_info_bg_icon");
  165. _infoBgView.layer.cornerRadius = adapt(16);
  166. _infoBgView.layer.masksToBounds = YES;
  167. _infoBgView.userInteractionEnabled = true;
  168. }
  169. return _infoBgView;
  170. }
  171. - (UILabel *)userRemainingPointsLb{
  172. if (!_userRemainingPointsLb) {
  173. _userRemainingPointsLb = [[UILabel alloc]init];
  174. _userRemainingPointsLb.font = LCBoldFont(24);
  175. _userRemainingPointsLb.textColor = HexColorFromRGB(0x333333);
  176. _userRemainingPointsLb.textAlignment = NSTextAlignmentLeft;
  177. _userRemainingPointsLb.text = @"******";
  178. }
  179. return _userRemainingPointsLb;
  180. }
  181. - (UILabel *)userEarningsNameLb{
  182. if (!_userEarningsNameLb) {
  183. _userEarningsNameLb = [[UILabel alloc]init];
  184. _userEarningsNameLb.font = LCFont(12);
  185. _userEarningsNameLb.textColor = HexColorFromRGB(0x333333);
  186. _userEarningsNameLb.textAlignment = NSTextAlignmentLeft;
  187. _userEarningsNameLb.text = @"我的金币";
  188. }
  189. return _userEarningsNameLb;
  190. }
  191. - (UIImageView *)userBalanceIcon{
  192. if (!_userBalanceIcon) {
  193. _userBalanceIcon = [[UIImageView alloc]init];
  194. _userBalanceIcon.image = ImageByName(@"ym_my_earnings_coin");
  195. }
  196. return _userBalanceIcon;
  197. }
  198. - (UIButton *)incomeBreakdownBtn {
  199. if (!_incomeBreakdownBtn) {
  200. _incomeBreakdownBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  201. _incomeBreakdownBtn.titleLabel.font = LCFont(13);
  202. [_incomeBreakdownBtn setTitle:@"收支明细 " forState:UIControlStateNormal];
  203. [_incomeBreakdownBtn setImage:ImageByName(@"ym_account_balance_go_detail") forState:(UIControlStateNormal)];
  204. _incomeBreakdownBtn.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
  205. [_incomeBreakdownBtn setTitleColor:HexColorFromRGB(0x000000) forState:UIControlStateNormal];
  206. _incomeBreakdownBtn.backgroundColor = HexColorFromRGB(0xF6F6F6);
  207. _incomeBreakdownBtn.layer.cornerRadius = adapt(15);
  208. _incomeBreakdownBtn.layer.masksToBounds = YES;
  209. WS(weakSelf)
  210. [[[_incomeBreakdownBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  211. [weakSelf.viewModel gotoIncomeBreakdown];
  212. }];
  213. }
  214. return _incomeBreakdownBtn;
  215. }
  216. //- (UIView *)userTodayEarningsView{
  217. // if (!_userTodayEarningsView) {
  218. // _userTodayEarningsView = [[UIView alloc]init];
  219. // }
  220. // return _userTodayEarningsView;
  221. //}
  222. //
  223. //- (UILabel *)userTodayEarningsTitleLb{
  224. // if (!_userTodayEarningsTitleLb) {
  225. // _userTodayEarningsTitleLb = [[UILabel alloc]init];
  226. // _userTodayEarningsTitleLb.font = LCFont(12);
  227. // _userTodayEarningsTitleLb.textColor = HexColorFromRGB(0xFFFFFF);
  228. // _userTodayEarningsTitleLb.textAlignment = NSTextAlignmentLeft;
  229. // _userTodayEarningsTitleLb.text = @"今日收益:";
  230. // }
  231. // return _userTodayEarningsTitleLb;
  232. //}
  233. //
  234. //- (UIImageView *)userTodayEarningsIcon{
  235. // if (!_userTodayEarningsIcon) {
  236. // _userTodayEarningsIcon = [[UIImageView alloc]init];
  237. // _userTodayEarningsIcon.image = ImageByName(@"");
  238. // }
  239. // return _userTodayEarningsIcon;
  240. //}
  241. //
  242. //- (UILabel *)userTodayEarningsContentLb{
  243. // if (!_userTodayEarningsContentLb) {
  244. // _userTodayEarningsContentLb = [[UILabel alloc]init];
  245. // _userTodayEarningsContentLb.font = LCBoldFont(13);
  246. // _userTodayEarningsContentLb.textColor = HexColorFromRGB(0xFFFFFF);
  247. // _userTodayEarningsContentLb.textAlignment = NSTextAlignmentLeft;
  248. // _userTodayEarningsContentLb.text = @"******";
  249. // }
  250. // return _userTodayEarningsContentLb;
  251. //}
  252. //
  253. //- (UIView *)userSevenDayEarningsView{
  254. // if (!_userSevenDayEarningsView) {
  255. // _userSevenDayEarningsView = [[UIView alloc]init];
  256. // }
  257. // return _userSevenDayEarningsView;
  258. //}
  259. //
  260. //- (UILabel *)userSevenDayEarningsTitleLb{
  261. // if (!_userSevenDayEarningsTitleLb) {
  262. // _userSevenDayEarningsTitleLb = [[UILabel alloc]init];
  263. // _userSevenDayEarningsTitleLb.font = LCFont(12);
  264. // _userSevenDayEarningsTitleLb.textColor = HexColorFromRGB(0xFFFFFF);
  265. // _userSevenDayEarningsTitleLb.textAlignment = NSTextAlignmentLeft;
  266. // _userSevenDayEarningsTitleLb.text = @"七日收益:";
  267. // }
  268. // return _userSevenDayEarningsTitleLb;
  269. //}
  270. //
  271. //- (UIImageView *)userSevenDayEarningsIcon{
  272. // if (!_userSevenDayEarningsIcon) {
  273. // _userSevenDayEarningsIcon = [[UIImageView alloc]init];
  274. // _userSevenDayEarningsIcon.image = ImageByName(@"");
  275. // }
  276. // return _userSevenDayEarningsIcon;
  277. //}
  278. //
  279. //- (UILabel *)userSevenDayEarningsContentLb{
  280. // if (!_userSevenDayEarningsContentLb) {
  281. // _userSevenDayEarningsContentLb = [[UILabel alloc]init];
  282. // _userSevenDayEarningsContentLb.font = LCBoldFont(13);
  283. // _userSevenDayEarningsContentLb.textColor = HexColorFromRGB(0xFFFFFF);
  284. // _userSevenDayEarningsContentLb.textAlignment = NSTextAlignmentLeft;
  285. // _userSevenDayEarningsContentLb.text = @"******";
  286. // }
  287. // return _userSevenDayEarningsContentLb;
  288. //}
  289. @end