YMMyEarningsInfoView.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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(10));
  69. make.left.equalTo(self).offset(adapt(16));
  70. make.right.equalTo(self).offset(adapt(-15));
  71. make.bottom.equalTo(self);
  72. make.height.mas_equalTo(adapt(160));
  73. }];
  74. [self.userBalanceIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.top.equalTo(self.infoBgView.mas_top).offset(adapt(42));
  76. make.left.equalTo(self.infoBgView.mas_left).offset(adapt(43));
  77. make.width.mas_equalTo(adapt(15));
  78. make.height.mas_equalTo(adapt(14));
  79. }];
  80. [self.userEarningsNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.centerY.equalTo(self.userBalanceIcon).offset(adapt(0));
  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(10));
  86. make.left.equalTo(self.userBalanceIcon.mas_left).offset(adapt(3));
  87. }];
  88. // [self.incomeBreakdownBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  89. // make.right.equalTo(self.infoBgView).offset(-adapt(22));
  90. // make.bottom.equalTo(self.infoBgView).offset(-adapt(22));
  91. // make.width.equalTo(adapt(74));
  92. // make.height.equalTo(adapt(28));
  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.backgroundColor = UIColor.whiteColor;
  156. [_roundedCornerView addRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight radius:adapt(20)];
  157. }
  158. return _roundedCornerView;
  159. }
  160. - (UIImageView *)infoBgView{
  161. if (!_infoBgView) {
  162. _infoBgView = [[UIImageView alloc]init];
  163. _infoBgView.image = ImageByName(@"ym_my_earnings_info_bg_icon");
  164. // _infoBgView.layer.cornerRadius = adapt(10);
  165. // _infoBgView.layer.masksToBounds = YES;
  166. // _infoBgView.clipsToBounds = 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(30);
  175. _userRemainingPointsLb.textColor = HexColorFromRGB(0xFFFFFF);
  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(14);
  185. _userEarningsNameLb.textColor = HexColorFromRGB(0xFFFFFF);
  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 setTitleColor:HexColorFromRGB(0x000000) forState:UIControlStateNormal];
  204. // _incomeBreakdownBtn.backgroundColor = HexColorFromRGB(0xFFFFFF);
  205. // _incomeBreakdownBtn.layer.cornerRadius = adapt(8);
  206. // _incomeBreakdownBtn.layer.masksToBounds = YES;
  207. // }
  208. // return _incomeBreakdownBtn;
  209. //}
  210. //- (UIView *)userTodayEarningsView{
  211. // if (!_userTodayEarningsView) {
  212. // _userTodayEarningsView = [[UIView alloc]init];
  213. // }
  214. // return _userTodayEarningsView;
  215. //}
  216. //
  217. //- (UILabel *)userTodayEarningsTitleLb{
  218. // if (!_userTodayEarningsTitleLb) {
  219. // _userTodayEarningsTitleLb = [[UILabel alloc]init];
  220. // _userTodayEarningsTitleLb.font = LCFont(12);
  221. // _userTodayEarningsTitleLb.textColor = HexColorFromRGB(0xFFFFFF);
  222. // _userTodayEarningsTitleLb.textAlignment = NSTextAlignmentLeft;
  223. // _userTodayEarningsTitleLb.text = @"今日收益:";
  224. // }
  225. // return _userTodayEarningsTitleLb;
  226. //}
  227. //
  228. //- (UIImageView *)userTodayEarningsIcon{
  229. // if (!_userTodayEarningsIcon) {
  230. // _userTodayEarningsIcon = [[UIImageView alloc]init];
  231. // _userTodayEarningsIcon.image = ImageByName(@"");
  232. // }
  233. // return _userTodayEarningsIcon;
  234. //}
  235. //
  236. //- (UILabel *)userTodayEarningsContentLb{
  237. // if (!_userTodayEarningsContentLb) {
  238. // _userTodayEarningsContentLb = [[UILabel alloc]init];
  239. // _userTodayEarningsContentLb.font = LCBoldFont(13);
  240. // _userTodayEarningsContentLb.textColor = HexColorFromRGB(0xFFFFFF);
  241. // _userTodayEarningsContentLb.textAlignment = NSTextAlignmentLeft;
  242. // _userTodayEarningsContentLb.text = @"******";
  243. // }
  244. // return _userTodayEarningsContentLb;
  245. //}
  246. //
  247. //- (UIView *)userSevenDayEarningsView{
  248. // if (!_userSevenDayEarningsView) {
  249. // _userSevenDayEarningsView = [[UIView alloc]init];
  250. // }
  251. // return _userSevenDayEarningsView;
  252. //}
  253. //
  254. //- (UILabel *)userSevenDayEarningsTitleLb{
  255. // if (!_userSevenDayEarningsTitleLb) {
  256. // _userSevenDayEarningsTitleLb = [[UILabel alloc]init];
  257. // _userSevenDayEarningsTitleLb.font = LCFont(12);
  258. // _userSevenDayEarningsTitleLb.textColor = HexColorFromRGB(0xFFFFFF);
  259. // _userSevenDayEarningsTitleLb.textAlignment = NSTextAlignmentLeft;
  260. // _userSevenDayEarningsTitleLb.text = @"七日收益:";
  261. // }
  262. // return _userSevenDayEarningsTitleLb;
  263. //}
  264. //
  265. //- (UIImageView *)userSevenDayEarningsIcon{
  266. // if (!_userSevenDayEarningsIcon) {
  267. // _userSevenDayEarningsIcon = [[UIImageView alloc]init];
  268. // _userSevenDayEarningsIcon.image = ImageByName(@"");
  269. // }
  270. // return _userSevenDayEarningsIcon;
  271. //}
  272. //
  273. //- (UILabel *)userSevenDayEarningsContentLb{
  274. // if (!_userSevenDayEarningsContentLb) {
  275. // _userSevenDayEarningsContentLb = [[UILabel alloc]init];
  276. // _userSevenDayEarningsContentLb.font = LCBoldFont(13);
  277. // _userSevenDayEarningsContentLb.textColor = HexColorFromRGB(0xFFFFFF);
  278. // _userSevenDayEarningsContentLb.textAlignment = NSTextAlignmentLeft;
  279. // _userSevenDayEarningsContentLb.text = @"******";
  280. // }
  281. // return _userSevenDayEarningsContentLb;
  282. //}
  283. @end