123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- //
- // YMMineViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/4.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMMineViewController.h"
- #import "YMMineViewModel.h"
- #import "YMMineInfoView.h"
- #import "YMMineOpenMembershipView.h"
- #import "YMMineWealthView.h"
- #import "YMMineCommonFunctionsOneView.h"
- #import "YMMineCommonFunctionsTwoView.h"
- @interface YMMineViewController ()<UIScrollViewDelegate>
- /// 我的VM
- @property (nonatomic, strong) YMMineViewModel *viewModel;
- /// 背景图片视图
- @property (nonatomic, strong) UIImageView *backgroundImageView;
- /// 内容滚动视图
- @property (nonatomic, strong) UIScrollView *contentScrollView;
- /// 容器视图
- @property (nonatomic, strong) UIView *contentView;
- /// 信息视图
- @property (nonatomic, strong) YMMineInfoView *infoView;
- /// 开通会员视图
- @property (nonatomic, strong) YMMineOpenMembershipView *openMembershipView;
- /// 财富视图
- @property (nonatomic, strong) YMMineWealthView *wealthView;
- /// 常用功能一视图
- @property (nonatomic, strong) YMMineCommonFunctionsOneView *commonFunctionsOneView;
- /// 常用功能二视图
- @property (nonatomic, strong) YMMineCommonFunctionsTwoView *commonFunctionsTwoView;
- @end
- @implementation YMMineViewController
- @dynamic viewModel;
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavHidden:YES];
- self.view.backgroundColor = HexColorFromRGB(0xF3F4F6);
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
- [self.viewModel getMineInfoData];
- }
- - (UIStatusBarStyle)preferredStatusBarStyle {
- return UIStatusBarStyleLightContent;
- }
- - (void)ym_setupViews{
- //[self.view addSubview:self.backgroundImageView];
- [self.view addSubview:self.contentScrollView];
- [self.contentScrollView addSubview:self.contentView];
- [self.contentView addSubview:self.infoView];
- [self.contentView addSubview:self.openMembershipView];
- [self.contentView addSubview:self.wealthView];
- [self.contentView addSubview:self.commonFunctionsOneView];
- [self.contentView addSubview:self.commonFunctionsTwoView];
- [self.view setNeedsUpdateConstraints];
- [self.view updateConstraintsIfNeeded];
- }
- - (void)updateViewConstraints{
-
- // [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.top.equalTo(self.view);
- // make.left.equalTo(self.view);
- // make.right.equalTo(self.view);
- // make.height.mas_greaterThanOrEqualTo(adapt(306));
- // }];
-
- [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view);
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- make.bottom.equalTo(self.view).offset(-TabbarHeight);
- }];
-
- [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.contentScrollView);
- make.width.equalTo(self.contentScrollView.mas_width);
- }];
-
- [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- }];
-
- [self.openMembershipView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.infoView.mas_bottom).offset(adapt(0));
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- }];
-
- [self.wealthView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.openMembershipView.mas_bottom);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- }];
-
- [self.commonFunctionsOneView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.wealthView.mas_bottom);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- }];
-
- [self.commonFunctionsTwoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.commonFunctionsOneView.mas_bottom);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- make.bottom.equalTo(self.contentView);
- }];
-
- [super updateViewConstraints];
- }
- - (void)ym_bindViewModel{
- [self.infoView ym_bindViewModel:self.viewModel];
- [self.openMembershipView ym_bindViewModel:self.viewModel];
- [self.wealthView ym_bindViewModel:self.viewModel];
- [self.commonFunctionsOneView ym_bindViewModel:self.viewModel];
- [self.commonFunctionsTwoView ym_bindViewModel:self.viewModel];
-
- [self.viewModel getMineInfoData];
- }
- - (UIImageView *)backgroundImageView{
- if (!_backgroundImageView) {
- _backgroundImageView = [[UIImageView alloc]init];
- _backgroundImageView.image = ImageByName(@"mine_bg");
- }
- return _backgroundImageView;
- }
- - (UIScrollView *)contentScrollView{
- if (!_contentScrollView) {
- _contentScrollView = [[UIScrollView alloc] init];
- _contentScrollView.delegate = self;
- _contentScrollView.alwaysBounceVertical = YES;
- _contentScrollView.showsVerticalScrollIndicator = NO;
- _contentScrollView.showsHorizontalScrollIndicator = NO;
- _contentScrollView.backgroundColor = UIColor.clearColor;
- _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
- }
- return _contentScrollView;
- }
- - (UIView *)contentView{
- if (!_contentView) {
- _contentView = [[UIView alloc]init];
- }
- return _contentView;
- }
- - (YMMineInfoView *)infoView{
- if (!_infoView) {
- _infoView = [[YMMineInfoView alloc]init];
- }
- return _infoView;
- }
- - (YMMineOpenMembershipView *)openMembershipView{
- if (!_openMembershipView) {
- _openMembershipView = [[YMMineOpenMembershipView alloc] init];
- _openMembershipView.backgroundColor = UIColor.clearColor;
- }
- return _openMembershipView;
- }
- - (YMMineWealthView *)wealthView{
- if (!_wealthView) {
- _wealthView = [[YMMineWealthView alloc]init];
- _wealthView.backgroundColor = UIColor.clearColor;
- }
- return _wealthView;
- }
- - (YMMineCommonFunctionsOneView *)commonFunctionsOneView{
- if (!_commonFunctionsOneView) {
- _commonFunctionsOneView = [[YMMineCommonFunctionsOneView alloc]init];
- //_commonFunctionsOneView.layer.shadowColor = HexColorFromRGBA(0x000000,0.06).CGColor;
- //_commonFunctionsOneView.layer.shadowOffset = CGSizeMake(0,2);
- //_commonFunctionsOneView.layer.shadowOpacity = 1;
- //_commonFunctionsOneView.layer.shadowRadius = 4;
- [_commonFunctionsOneView addRectCorner:(UIRectCornerTopLeft | UIRectCornerTopRight) radius:20];
- }
- return _commonFunctionsOneView;
- }
- - (YMMineCommonFunctionsTwoView *)commonFunctionsTwoView{
- if (!_commonFunctionsTwoView) {
- _commonFunctionsTwoView = [[YMMineCommonFunctionsTwoView alloc]init];
- _commonFunctionsTwoView.layer.shadowColor = HexColorFromRGBA(0x000000,0.06).CGColor;
- _commonFunctionsTwoView.layer.shadowOffset = CGSizeMake(0,2);
- _commonFunctionsTwoView.layer.shadowOpacity = 1;
- _commonFunctionsTwoView.layer.shadowRadius = 4;
- }
- return _commonFunctionsTwoView;
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (scrollView.contentOffset.y < 0) {
- scrollView.contentOffset = CGPointZero;
- }
- }
- @end
|