123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //
- // YXFamilyInfoViewController.m
- // Temperature
- //
- // Created by TC on 2025/2/16.
- //
- #import "YXFamilyInfoViewController.h"
- #import "ScrollMenuView.h"
- #import "YXFamilyViewController.h"
- #import "YXAddFamilyViewController.h"
- @interface YXFamilyInfoViewController ()<ScrollMenuViewDelegate>
- @property(nonatomic,assign) NSInteger selectIndex;
- @property(nonatomic,strong) ScrollMenuView *menuView;
- @property(nonatomic,strong) NSMutableArray *titleArray;
- @end
- @implementation YXFamilyInfoViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.navigationItem.title = @"我的家庭";
- self.view.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"];
- [self addRightItem];
-
- self.titleArray = [[NSMutableArray alloc]initWithCapacity:5];
-
- [self createMenuView];
-
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self p_getHomeList];
- }
- - (void)p_getHomeList
- {
- RDS_WEAKSELF(weakSelf)
- [RDSHudShower showWithStatus:@"正在获取" autoDismiss:NO];
- [RDSHomeModel rds_getHomeListIsAdmin:YES finished:^(NSError * _Nullable error) {
- [RDSHudShower dismissHUD];
-
- [weakSelf.titleArray removeAllObjects];
- for (int i = 0; i < TheDataManager.homes.count; i++) {
- RDSHomeModel *model = TheDataManager.homes[i];
- [weakSelf.titleArray addObject:model.name];
-
- if ([model.record_id isEqualToString:TheDataManager.current_home_id]) {
- weakSelf.selectIndex = i;
- }
- }
- [weakSelf setSubViews];
- [weakSelf.menuView changeViewWithAnimate:self.selectIndex];
- }];
- }
- -(void)addRightItem
- {
- UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [rightBtn setImage:[UIImage imageNamed:@"my_family_add"] forState:UIControlStateNormal];
- [rightBtn addTarget:self action:@selector(rightBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
- self.navigationItem.rightBarButtonItem = rightItem;
- }
- -(void)rightBtnAction:(UIButton *)btn
- {
- YXAddFamilyViewController *addVc = [[YXAddFamilyViewController alloc]init];
- [self.navigationController pushViewController:addVc animated:YES];
- }
- -(void)createMenuView
- {
- ScrollMenuView *menuView = [[ScrollMenuView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - kNavHeight - kSafeBottomHeight)];
- menuView.delegate = self;
- menuView.backgroundColor = [UIColor whiteColor];
- menuView.backColor = [UIColor whiteColor];
- menuView.normalColor = [UIColor colorWithHexString:@"#999999"];
- menuView.selectColor = [UIColor colorWithHexString:@"#333333"];
- [self.view addSubview:menuView];
- self.menuView = menuView;
- }
- -(void)setSubViews
- {
- self.menuView.titleArray = self.titleArray;
- NSMutableArray *viewsArray = [[NSMutableArray alloc]init];
-
- for (int i = 0; i < TheDataManager.homes.count; i++) {
- YXFamilyViewController *fVc = [[YXFamilyViewController alloc]init];
- fVc.model = TheDataManager.homes[i];
- [self addChildViewController:fVc];
-
- fVc.updateFamilyInfo = ^{
- [self p_getHomeList];
- };
-
- UIView *view = fVc.view;
- view.backgroundColor = [UIColor colorWithHexString:@"#F9F9F9"];
- [viewsArray addObject:view];
- }
- self.menuView.subArray = viewsArray;
-
- [self.menuView setScrollMenuView];
- }
- -(void)scrollMenuViewAtIndexPath:(NSInteger)index
- {
- self.selectIndex = index;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|