|
@@ -6,24 +6,36 @@
|
|
//
|
|
//
|
|
|
|
|
|
#import "MusicRoomGroupViewController.h"
|
|
#import "MusicRoomGroupViewController.h"
|
|
-#import <RecordCheckManager.h>
|
|
|
|
-#import "KSPremissionAlert.h"
|
|
|
|
-#import "OnlineClassManager.h"
|
|
|
|
-#import "HomeworkDetailModel.h"
|
|
|
|
|
|
+#import "CourseGroupNavView.h"
|
|
|
|
+#import "JXCategoryView.h"
|
|
|
|
+#import "JXPagerListRefreshView.h"
|
|
|
|
+#import "MusicRoomGroupHeadView.h"
|
|
|
|
+#import "ProgramCourseGroupBodyView.h"
|
|
|
|
+#import "CourseGroupDetailModel.h"
|
|
|
|
+#import "CourseGroupPlanAlertView.h"
|
|
|
|
+#import "MusicRoomStudentPageView.h"
|
|
|
|
|
|
-@interface MusicRoomGroupViewController ()
|
|
|
|
|
|
+@interface MusicRoomGroupViewController ()<JXPagerViewDelegate,JXCategoryViewDelegate,JXPagerMainTableViewGestureDelegate>
|
|
|
|
|
|
-@property (nonatomic, strong) NSString *courseId;
|
|
|
|
|
|
+@property (nonatomic, strong) NSMutableArray *listViewArray;
|
|
|
|
|
|
-@property (nonatomic, strong) NSString *studentId;
|
|
|
|
|
|
+@property (nonatomic, strong) CourseGroupNavView *navView;
|
|
|
|
|
|
-@property (nonatomic, assign) NSInteger joinRoomBeforeTime; // 上课开始时间
|
|
|
|
|
|
+@property (nonatomic, assign) NSInteger headHeight;
|
|
|
|
|
|
-@property (nonatomic, assign) NSInteger quitRomeEndTime; // 下课截止时间
|
|
|
|
|
|
+@property (nonatomic, assign) NSInteger topViewHeight;
|
|
|
|
|
|
-@property (nonatomic, strong) HomeworkDetailModel *homeworkModel;
|
|
|
|
|
|
+@property (nonatomic, strong) MusicRoomGroupHeadView *infoView;
|
|
|
|
|
|
-@property (nonatomic, strong) OnlineClassManager *classManager;
|
|
|
|
|
|
+@property (nonatomic, assign) BOOL isFirstLoad;
|
|
|
|
+
|
|
|
|
+@property (nonatomic, strong) CourseGroupDetailModel *detailModel;
|
|
|
|
+
|
|
|
|
+@property (nonatomic, assign) NSInteger enterStartTime; // 开课前可进入时间配置(分钟)
|
|
|
|
+
|
|
|
|
+@property (nonatomic, assign) NSInteger quitEndTime; // 结束后退出时间配置(分钟)
|
|
|
|
+
|
|
|
|
+@property (nonatomic, strong) UIImageView *bgImageView;
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
@@ -32,85 +44,266 @@
|
|
- (void)viewDidLoad {
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
// Do any additional setup after loading the view.
|
|
|
|
+ self.ks_prefersNavigationBarHidden = YES;
|
|
|
|
+ [self configUI];
|
|
|
|
+ self.isFirstLoad = YES;
|
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(forceScroll) name:@"UITextViewScroll" object:nil];
|
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enableScroll) name:@"UITextViewEndScroll" object:nil];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)tryJoinRoom {
|
|
|
|
-
|
|
|
|
- NSDateFormatter *dateFormatter = [NSObject getDateformatter];
|
|
|
|
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
|
|
- NSDate *beginDate = [dateFormatter dateFromString:self.homeworkModel.startTime];
|
|
|
|
- NSDate *endDate = [dateFormatter dateFromString:self.homeworkModel.endTime];
|
|
|
|
- NSDate *currentDate = [NSDate date];
|
|
|
|
- NSTimeInterval beginTimeInterval = [beginDate timeIntervalSinceDate:currentDate];
|
|
|
|
- NSTimeInterval endTimeInterval = [currentDate timeIntervalSinceDate:endDate];
|
|
|
|
- if (beginTimeInterval <= self.joinRoomBeforeTime * 60 && endTimeInterval < 0) {
|
|
|
|
- [self joinClassRoom];
|
|
|
|
- }
|
|
|
|
- else if (endTimeInterval > 0) {
|
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"该课程已结束"];
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- NSString *tipsString = [NSString stringWithFormat:@"课程还未开始,请在上课前%zd分钟进入", self.joinRoomBeforeTime];
|
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:tipsString];
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+- (void)forceScroll {
|
|
|
|
+ self.pagerView.mainTableView.scrollEnabled = NO;
|
|
}
|
|
}
|
|
|
|
|
|
-// 加入房间
|
|
|
|
-- (void)joinClassRoom {
|
|
|
|
|
|
+- (void)enableScroll {
|
|
|
|
+ self.pagerView.mainTableView.scrollEnabled = YES;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)configUI {
|
|
|
|
+ [self.scrollView removeFromSuperview];
|
|
|
|
+ UIImage *bgImage = [UIImage imageNamed:@"courseDetail_bg"];
|
|
|
|
+ NSInteger height = (NSInteger)(bgImage.size.height / bgImage.size.width * KPortraitWidth);
|
|
|
|
+ self.bgImageView = [[UIImageView alloc] initWithImage:bgImage];
|
|
|
|
+ self.bgImageView.frame = CGRectMake(0, 0, KPortraitWidth, height);
|
|
|
|
+ [self.view addSubview:self.bgImageView];
|
|
|
|
|
|
- // 加入房间前判断摄像头和麦克风逻辑
|
|
|
|
- [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
|
|
|
|
- [self afterCheckCameraCheckMic:type];
|
|
|
|
|
|
+ [self.view addSubview:self.navView];
|
|
|
|
+ CGFloat navHeight = [CourseGroupNavView getViewHeight];
|
|
|
|
+ [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
+ make.left.right.top.mas_equalTo(self.view);
|
|
|
|
+ make.height.mas_equalTo(navHeight);
|
|
}];
|
|
}];
|
|
|
|
+ self.headHeight = 44.0f;
|
|
|
|
+ self.titles = @[@"课程列表",@"上课学生"];
|
|
|
|
+ [self configCategoryView:navHeight];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)afterCheckCameraCheckMic:(PREMISSIONTYPE)cameraType {
|
|
|
|
- [RecordCheckManager checkMicPermissionAvaiableCallback:^(PREMISSIONTYPE type) {
|
|
|
|
- if (type == PREMISSIONTYPE_YES && cameraType == PREMISSIONTYPE_YES) {
|
|
|
|
- // 判断是否进行课前检测
|
|
|
|
- [self.classManager joinRoomWithId:self.courseId subjectName:self.homeworkModel.subjectName classEndTime:self.homeworkModel.endTime inViewController:self];
|
|
|
|
|
|
+- (void)requestCourseInfo {
|
|
|
|
+
|
|
|
|
+ [KSNetworkingManager getCourseGroupDetailRequest:KS_POST courseGroupId:self.courseGroupId success:^(NSDictionary * _Nonnull dic) {
|
|
|
|
+ if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
|
+ NSDictionary *parm = [dic ks_dictionaryValueForKey:@"data"];
|
|
|
|
+ self.detailModel = [[CourseGroupDetailModel alloc] initWithDictionary:parm];
|
|
|
|
+ // 配置信息
|
|
|
|
+ NSDictionary *config = [[dic ks_dictionaryValueForKey:@"data"] ks_dictionaryValueForKey:@"sysConfig"];
|
|
|
|
+ self.enterStartTime = [config ks_integerValueForKey:@"pianoStartTime"];
|
|
|
|
+ self.quitEndTime = [config ks_integerValueForKey:@"pianoEndTime"];
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- NSString *content = @"";
|
|
|
|
- CHECKDEVICETYPE checkType = CHECKDEVICETYPE_BOTH;
|
|
|
|
- if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_NO) {
|
|
|
|
- content = @"请开启相机和麦克风访问权限";
|
|
|
|
- checkType = CHECKDEVICETYPE_BOTH;
|
|
|
|
- }
|
|
|
|
- else if (cameraType == PREMISSIONTYPE_NO && type == PREMISSIONTYPE_YES) {
|
|
|
|
- content = @"请开启相机访问权限";
|
|
|
|
- checkType = CHECKDEVICETYPE_CAMREA;
|
|
|
|
- }
|
|
|
|
- else if (cameraType == PREMISSIONTYPE_YES && type == PREMISSIONTYPE_NO) {
|
|
|
|
- content = @"请开启麦克风访问权限";
|
|
|
|
- checkType = CHECKDEVICETYPE_MIC;
|
|
|
|
- }
|
|
|
|
- [self showAlertWithMessage:content type:checkType];
|
|
|
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
|
|
}
|
|
}
|
|
|
|
+ [self refreshHeadView];
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+ [self refreshHeadView];
|
|
}];
|
|
}];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)refreshHeadView {
|
|
|
|
+ [self refreshListPage];
|
|
|
|
+ self.topViewHeight = [MusicRoomGroupHeadView getViewHeightWithPlanString:self.detailModel.coursePlan];
|
|
|
|
+ [self.infoView configWithSource:self.detailModel];
|
|
|
|
+ [self.pagerView reloadData];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)configCategoryView:(NSInteger)topHeight {
|
|
|
|
+
|
|
|
|
+ _categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, topHeight, KPortraitWidth, self.headHeight)];
|
|
|
|
+ self.categoryView.titles = self.titles;
|
|
|
|
+ self.categoryView.delegate = self;
|
|
|
|
+ self.categoryView.titleFont = [UIFont systemFontOfSize:16.0f];
|
|
|
|
+ self.categoryView.titleSelectedFont = [UIFont systemFontOfSize:16.0f weight:UIFontWeightSemibold];
|
|
|
|
+ self.categoryView.titleSelectedColor = HexRGB(0x333333);
|
|
|
|
+ self.categoryView.titleColor = HexRGB(0x666666);
|
|
|
|
+ self.categoryView.titleColorGradientEnabled = YES;
|
|
|
|
+
|
|
|
|
+ JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
|
|
|
+ lineView.indicatorColor = THEMECOLOR;
|
|
|
|
+ lineView.indicatorWidth = 16;
|
|
|
|
+ lineView.indicatorHeight = 4;
|
|
|
|
+ self.categoryView.indicators = @[lineView];
|
|
|
|
|
|
|
|
+ _pagerView = [self preferredPagingView];
|
|
|
|
+ self.pagerView.frame = CGRectMake(0, topHeight, KPortraitWidth, KPortraitHeight - topHeight);
|
|
|
|
+ self.pagerView.backgroundColor = [UIColor clearColor];
|
|
|
|
+ self.pagerView.mainTableView.backgroundColor = [UIColor clearColor];
|
|
|
|
+ self.pagerView.listContainerView.backgroundColor = [UIColor clearColor];
|
|
|
|
+ self.pagerView.mainTableView.gestureDelegate = self;
|
|
|
|
+ self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
|
|
|
|
+ self.pagerView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
|
|
|
|
+ [self.view addSubview:self.pagerView];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
|
|
|
|
- [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
|
|
|
|
-
|
|
|
|
- } confirm:^{
|
|
|
|
- [self openSettingView];
|
|
|
|
- }];
|
|
|
|
|
|
+- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
+ [super viewDidAppear:animated];
|
|
|
|
+ self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
+ [super viewWillAppear:animated];
|
|
|
|
+ self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
|
|
|
+ // 刷新课程详情
|
|
|
|
+ [self requestCourseInfo];
|
|
|
|
+ if (self.isFirstLoad == NO) {
|
|
|
|
+ [self refreshListPage];
|
|
|
|
+ }
|
|
|
|
+ self.isFirstLoad = NO;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)refreshListPage {
|
|
|
|
+ id value = self.listViewArray[0];
|
|
|
|
+ if ([value isKindOfClass:[ProgramCourseGroupBodyView class]]) {
|
|
|
|
+ ProgramCourseGroupBodyView *listView = (ProgramCourseGroupBodyView *)value;
|
|
|
|
+ listView.enterStartTime = self.enterStartTime;
|
|
|
|
+ listView.quitEndTime = self.quitEndTime;
|
|
|
|
+ [listView beginFirstRefresh];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (JXPagerView *)preferredPagingView {
|
|
|
|
+ return [[JXPagerListRefreshView alloc] initWithDelegate:self];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma mark - JXPagerViewDelegate
|
|
|
|
+
|
|
|
|
+- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
|
|
+ return self.infoView;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|
|
|
+ return self.topViewHeight;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
|
|
+ return self.headHeight;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
|
|
+ return self.categoryView;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
|
|
|
+ //和categoryView的item数量一致
|
|
|
|
+ return self.titles.count;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
|
|
|
+ if (index == 0) {
|
|
|
|
+ ProgramCourseGroupBodyView *listView = [[ProgramCourseGroupBodyView alloc] init];
|
|
|
|
+ listView.naviController = self.navigationController;
|
|
|
|
+ listView.selectIndex = index;
|
|
|
|
+ listView.courseGroupId = self.courseGroupId;
|
|
|
|
+ listView.courseType = COURSE_GROUP_TYPE_MUSICROOM;
|
|
|
|
+ [self.listViewArray replaceObjectAtIndex:index withObject:listView];
|
|
|
|
+ self.listViewArray[index] = listView;
|
|
|
|
+ [listView beginFirstRefresh];
|
|
|
|
+ return listView;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ MusicRoomStudentPageView *listView = [[MusicRoomStudentPageView alloc] init];
|
|
|
|
+ listView.naviController = self.navigationController;
|
|
|
|
+ listView.selectIndex = index;
|
|
|
|
+ listView.courseGroupId = self.courseGroupId;
|
|
|
|
+ [self.listViewArray replaceObjectAtIndex:index withObject:listView];
|
|
|
|
+ self.listViewArray[index] = listView;
|
|
|
|
+ [listView beginFirstRefresh];
|
|
|
|
+ return listView;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
|
|
|
|
|
|
|
|
+ NSLog(@"sscroll content offset y %f", scrollView.contentOffset.y);
|
|
|
|
+ CGFloat height = self.topViewHeight;
|
|
|
|
+ CGFloat space = scrollView.contentOffset.y;
|
|
|
|
+ if (space > 100) {
|
|
|
|
+ CGFloat rate = (space - 100) / (height - 100);
|
|
|
|
+ NSLog(@"rate ---------%f",rate);
|
|
|
|
+ self.navView.backgroundColor = HexRGBAlpha(0xffffff, rate);
|
|
|
|
+ if (rate == 1) {
|
|
|
|
+ self.bgImageView.hidden = YES;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ self.bgImageView.hidden = NO;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ self.navView.backgroundColor = [UIColor clearColor];
|
|
|
|
+ self.bgImageView.hidden = NO;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma mark - JXPagerMainTableViewGestureDelegate
|
|
|
|
+
|
|
|
|
+- (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
|
|
+ //禁止categoryView左右滑动的时候,上下和左右都可以滚动
|
|
|
|
+ if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
|
|
|
|
+ return NO;
|
|
|
|
+ }
|
|
|
|
+ return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
|
}
|
|
}
|
|
|
|
|
|
-- (void)openSettingView {
|
|
|
|
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+- (void)dealloc {
|
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark ----- lazying
|
|
#pragma mark ----- lazying
|
|
-- (OnlineClassManager *)classManager {
|
|
|
|
- if (!_classManager) {
|
|
|
|
- _classManager = [[OnlineClassManager alloc] init];
|
|
|
|
|
|
+
|
|
|
|
+- (CourseGroupNavView *)navView {
|
|
|
|
+ if (!_navView) {
|
|
|
|
+ _navView = [CourseGroupNavView sharedInstance];
|
|
|
|
+ MJWeakSelf;
|
|
|
|
+ [_navView configWithNavTitle:@"VIP定制课设置" callback:^{
|
|
|
|
+ [weakSelf backAction];
|
|
|
|
+ }];
|
|
|
|
+ }
|
|
|
|
+ return _navView;
|
|
|
|
+}
|
|
|
|
+- (NSMutableArray *)listViewArray {
|
|
|
|
+ if (!_listViewArray) {
|
|
|
|
+ _listViewArray = [NSMutableArray arrayWithArray:@[@"",@""]];
|
|
|
|
+ }
|
|
|
|
+ return _listViewArray;
|
|
|
|
+}
|
|
|
|
+- (MusicRoomGroupHeadView *)infoView {
|
|
|
|
+ if (!_infoView) {
|
|
|
|
+ _infoView =[MusicRoomGroupHeadView sharedInstance];
|
|
|
|
+ MJWeakSelf;
|
|
|
|
+ [_infoView programActionCallback:^{
|
|
|
|
+ [weakSelf showModifyPlanView];
|
|
|
|
+ }];
|
|
}
|
|
}
|
|
- return _classManager;
|
|
|
|
|
|
+ return _infoView;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+- (void)showModifyPlanView {
|
|
|
|
+ CourseGroupPlanAlertView *alert = [CourseGroupPlanAlertView sharedInstance];
|
|
|
|
+ MJWeakSelf;
|
|
|
|
+ [alert configWithDesc:self.detailModel.coursePlan callback:^(NSString * _Nullable planString) {
|
|
|
|
+ [weakSelf submitAction:planString];
|
|
|
|
+ }];
|
|
|
|
+ [alert showInView:self.view];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)submitAction:(NSString *)planString {
|
|
|
|
+ [LOADING_MANAGER showHUD];
|
|
|
|
+ [KSNetworkingManager updateCoursePlanRequset:KS_POST courseGroupId:self.courseGroupId coursePlan:planString success:^(NSDictionary * _Nonnull dic) {
|
|
|
|
+ [LOADING_MANAGER removeHUD];
|
|
|
|
+ if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
|
+ [self requestCourseInfo];
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
+ [LOADING_MANAGER removeHUD];
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
/*
|
|
/*
|
|
#pragma mark - Navigation
|
|
#pragma mark - Navigation
|
|
|
|
|