YMMineViewController.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //
  2. // YMMineViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMineViewController.h"
  9. #import "YMMineViewModel.h"
  10. #import "YMMineInfoView.h"
  11. #import "YMMineOpenMembershipView.h"
  12. #import "YMMineWealthView.h"
  13. #import "YMMineCommonFunctionsOneView.h"
  14. #import "YMMineCommonFunctionsTwoView.h"
  15. @interface YMMineViewController ()
  16. /// 我的VM
  17. @property (nonatomic, strong) YMMineViewModel *viewModel;
  18. /// 背景图片视图
  19. @property (nonatomic, strong) UIImageView *backgroundImageView;
  20. /// 内容滚动视图
  21. @property (nonatomic, strong) UIScrollView *contentScrollView;
  22. /// 容器视图
  23. @property (nonatomic, strong) UIView *contentView;
  24. /// 信息视图
  25. @property (nonatomic, strong) YMMineInfoView *infoView;
  26. /// 开通会员视图
  27. @property (nonatomic, strong) YMMineOpenMembershipView *openMembershipView;
  28. /// 财富视图
  29. @property (nonatomic, strong) YMMineWealthView *wealthView;
  30. /// 常用功能一视图
  31. @property (nonatomic, strong) YMMineCommonFunctionsOneView *commonFunctionsOneView;
  32. /// 常用功能二视图
  33. @property (nonatomic, strong) YMMineCommonFunctionsTwoView *commonFunctionsTwoView;
  34. @end
  35. @implementation YMMineViewController
  36. @dynamic viewModel;
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. [self setNavHidden:YES];
  40. }
  41. - (void)viewDidAppear:(BOOL)animated{
  42. [super viewDidAppear:animated];
  43. [self.viewModel getMineInfoData];
  44. }
  45. - (UIStatusBarStyle)preferredStatusBarStyle {
  46. return UIStatusBarStyleLightContent;
  47. }
  48. - (void)ym_setupViews{
  49. [self.view addSubview:self.backgroundImageView];
  50. [self.view addSubview:self.contentScrollView];
  51. [self.contentScrollView addSubview:self.contentView];
  52. [self.contentView addSubview:self.infoView];
  53. [self.contentView addSubview:self.openMembershipView];
  54. [self.contentView addSubview:self.wealthView];
  55. [self.contentView addSubview:self.commonFunctionsOneView];
  56. [self.contentView addSubview:self.commonFunctionsTwoView];
  57. [self.view setNeedsUpdateConstraints];
  58. [self.view updateConstraintsIfNeeded];
  59. }
  60. - (void)updateViewConstraints{
  61. [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.equalTo(self.view);
  63. make.left.equalTo(self.view);
  64. make.right.equalTo(self.view);
  65. make.height.mas_greaterThanOrEqualTo(adapt(306));
  66. }];
  67. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.top.equalTo(self.view);
  69. make.left.equalTo(self.view);
  70. make.right.equalTo(self.view);
  71. make.bottom.equalTo(self.view).offset(-TabbarHeight);
  72. }];
  73. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.edges.equalTo(self.contentScrollView);
  75. make.width.equalTo(self.contentScrollView.mas_width);
  76. }];
  77. [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.equalTo(self.contentView);
  79. make.left.equalTo(self.contentView);
  80. make.right.equalTo(self.contentView);
  81. }];
  82. [self.openMembershipView mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.top.equalTo(self.infoView.mas_bottom).offset(adapt(0));
  84. make.left.equalTo(self.contentView);
  85. make.right.equalTo(self.contentView);
  86. }];
  87. [self.wealthView mas_makeConstraints:^(MASConstraintMaker *make) {
  88. make.top.equalTo(self.openMembershipView.mas_bottom);
  89. make.left.equalTo(self.contentView);
  90. make.right.equalTo(self.contentView);
  91. }];
  92. [self.commonFunctionsOneView mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.top.equalTo(self.wealthView.mas_bottom);
  94. make.left.equalTo(self.contentView);
  95. make.right.equalTo(self.contentView);
  96. }];
  97. [self.commonFunctionsTwoView mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.top.equalTo(self.commonFunctionsOneView.mas_bottom);
  99. make.left.equalTo(self.contentView);
  100. make.right.equalTo(self.contentView);
  101. make.bottom.equalTo(self.contentView);
  102. }];
  103. [super updateViewConstraints];
  104. }
  105. - (void)ym_bindViewModel{
  106. [self.infoView ym_bindViewModel:self.viewModel];
  107. [self.openMembershipView ym_bindViewModel:self.viewModel];
  108. [self.wealthView ym_bindViewModel:self.viewModel];
  109. [self.commonFunctionsOneView ym_bindViewModel:self.viewModel];
  110. [self.commonFunctionsTwoView ym_bindViewModel:self.viewModel];
  111. [self.viewModel getMineInfoData];
  112. }
  113. - (UIImageView *)backgroundImageView{
  114. if (!_backgroundImageView) {
  115. _backgroundImageView = [[UIImageView alloc]init];
  116. _backgroundImageView.image = ImageByName(@"mine_bg");
  117. }
  118. return _backgroundImageView;
  119. }
  120. - (UIScrollView *)contentScrollView{
  121. if (!_contentScrollView) {
  122. _contentScrollView = [[UIScrollView alloc] init];
  123. _contentScrollView.alwaysBounceVertical = YES;
  124. _contentScrollView.showsVerticalScrollIndicator = NO;
  125. _contentScrollView.showsHorizontalScrollIndicator = NO;
  126. _contentScrollView.backgroundColor = UIColor.clearColor;
  127. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  128. }
  129. return _contentScrollView;
  130. }
  131. - (UIView *)contentView{
  132. if (!_contentView) {
  133. _contentView = [[UIView alloc]init];
  134. }
  135. return _contentView;
  136. }
  137. - (YMMineInfoView *)infoView{
  138. if (!_infoView) {
  139. _infoView = [[YMMineInfoView alloc]init];
  140. }
  141. return _infoView;
  142. }
  143. - (YMMineOpenMembershipView *)openMembershipView{
  144. if (!_openMembershipView) {
  145. _openMembershipView = [[YMMineOpenMembershipView alloc] init];
  146. _openMembershipView.backgroundColor = UIColor.clearColor;
  147. }
  148. return _openMembershipView;
  149. }
  150. - (YMMineWealthView *)wealthView{
  151. if (!_wealthView) {
  152. _wealthView = [[YMMineWealthView alloc]init];
  153. _wealthView.backgroundColor = UIColor.clearColor;
  154. }
  155. return _wealthView;
  156. }
  157. - (YMMineCommonFunctionsOneView *)commonFunctionsOneView{
  158. if (!_commonFunctionsOneView) {
  159. _commonFunctionsOneView = [[YMMineCommonFunctionsOneView alloc]init];
  160. //_commonFunctionsOneView.layer.shadowColor = HexColorFromRGBA(0x000000,0.06).CGColor;
  161. //_commonFunctionsOneView.layer.shadowOffset = CGSizeMake(0,2);
  162. //_commonFunctionsOneView.layer.shadowOpacity = 1;
  163. //_commonFunctionsOneView.layer.shadowRadius = 4;
  164. [_commonFunctionsOneView addRectCorner:(UIRectCornerTopLeft | UIRectCornerTopRight) radius:20];
  165. }
  166. return _commonFunctionsOneView;
  167. }
  168. - (YMMineCommonFunctionsTwoView *)commonFunctionsTwoView{
  169. if (!_commonFunctionsTwoView) {
  170. _commonFunctionsTwoView = [[YMMineCommonFunctionsTwoView alloc]init];
  171. _commonFunctionsTwoView.layer.shadowColor = HexColorFromRGBA(0x000000,0.06).CGColor;
  172. _commonFunctionsTwoView.layer.shadowOffset = CGSizeMake(0,2);
  173. _commonFunctionsTwoView.layer.shadowOpacity = 1;
  174. _commonFunctionsTwoView.layer.shadowRadius = 4;
  175. }
  176. return _commonFunctionsTwoView;
  177. }
  178. @end