|
@@ -25,12 +25,24 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
- [self configSubviews];
|
|
|
|
|
|
- [self.deviceTypeModel fetchDeviceTypeList];
|
|
|
+ [self p_getDeviceTypes];
|
|
|
}
|
|
|
|
|
|
-- (void)configSubviews {
|
|
|
+#pragma mark - Load Data
|
|
|
+- (void)p_getDeviceTypes {
|
|
|
+ [RDSHudShower showWithStatus:@"加载中..."];
|
|
|
+ [self.deviceTypeModel rds_fetchDeviceTypeListFinished:^(NSError * _Nullable error) {
|
|
|
+ [RDSHudShower dismissHUD];
|
|
|
+ if (error) {
|
|
|
+ [RDSHudShower showBottomToast:error.localizedDescription];
|
|
|
+ } else {
|
|
|
+ [self p_configSubviews];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)p_configSubviews {
|
|
|
self.navigationItem.title = @"选择设备";
|
|
|
|
|
|
self.pagerBar = [[TYTabPagerBar alloc] init];
|
|
@@ -81,12 +93,12 @@
|
|
|
|
|
|
#pragma mark - TYTabPagerBarDataSource
|
|
|
- (NSInteger)numberOfItemsInPagerTabBar {
|
|
|
- return self.pagerBarTitleArray.count;
|
|
|
+ return self.deviceTypeModel.deviceTypeList.count;
|
|
|
}
|
|
|
|
|
|
- (UICollectionViewCell<TYTabPagerBarCellProtocol> *)pagerTabBar:(TYTabPagerBar *)pagerTabBar cellForItemAtIndex:(NSInteger)index {
|
|
|
UICollectionViewCell<TYTabPagerBarCellProtocol> *cell = [pagerTabBar dequeueReusableCellWithReuseIdentifier:[TYTabPagerBarCell cellIdentifier] forIndex:index];
|
|
|
- NSString *title = self.pagerBarTitleArray[index];
|
|
|
+ NSString *title = [self.deviceTypeModel getDeviceNameWithIndex:index];
|
|
|
cell.titleLabel.text = title;
|
|
|
return cell;
|
|
|
}
|
|
@@ -106,7 +118,10 @@
|
|
|
}
|
|
|
|
|
|
- (UIViewController *)pagerController:(TYPagerController *)pagerController controllerForIndex:(NSInteger)index prefetching:(BOOL)prefetching {
|
|
|
- return [[RDSSelectDeviceSubVC alloc] init];
|
|
|
+ RDSSelectDeviceSubVC *selectDeviceSubVC = [[RDSSelectDeviceSubVC alloc] init];
|
|
|
+ RDSDeviceTypeModel *deviceTypeModel = self.deviceTypeModel.deviceTypeList[index];
|
|
|
+ [selectDeviceSubVC reloadDataWithDataSource:deviceTypeModel.children];
|
|
|
+ return selectDeviceSubVC;
|
|
|
}
|
|
|
|
|
|
#pragma mark - TYPagerControllerDelegate
|