|
@@ -13,8 +13,19 @@ typedef NS_ENUM(NSInteger,EXAMSTATUS) {
|
|
|
EXAMSTATUS_SINGED, // 已签到
|
|
|
};
|
|
|
|
|
|
+typedef NS_ENUM(NSInteger, JOINBUTTONSTATUS) {
|
|
|
+ JOINBUTTONSTATUS_NOTSTART, // 未开始
|
|
|
+ JOINBUTTONSTATUS_WAIT, // 排队中
|
|
|
+ JOINBUTTONSTATUS_IN, // 进行中
|
|
|
+ JOINBUTTONSTATUS_FINISH, // 已结束
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
@interface WaitExamBottomView ()
|
|
|
|
|
|
+@property (nonatomic, assign) JOINBUTTONSTATUS buttonStatus;
|
|
|
+
|
|
|
+
|
|
|
@property (nonatomic, copy) JoinRoomAction callback;
|
|
|
|
|
|
@property (weak, nonatomic) IBOutlet UIButton *guideButton;
|
|
@@ -60,20 +71,20 @@ typedef NS_ENUM(NSInteger,EXAMSTATUS) {
|
|
|
|
|
|
if (self.status == EXAMSTATUS_SINGED) { // 已签到显示
|
|
|
if (self.sourceModel.recordFlag == 1 && self.sourceModel.finishedExam == 4) { // 录播考试开启中
|
|
|
- self.canJoinRoom = YES;
|
|
|
+ self.buttonStatus = JOINBUTTONSTATUS_IN;
|
|
|
[self.joinButton setTitle:@"录播考试" forState:UIControlStateNormal];
|
|
|
}
|
|
|
else if (self.sourceModel.recordFlag == 0 && self.sourceModel.finishedExam == 4) { // 录播考试结束
|
|
|
- self.canJoinRoom = NO;
|
|
|
+ self.buttonStatus = JOINBUTTONSTATUS_FINISH;
|
|
|
[self.joinButton setTitle:@"录播考试已结束" forState:UIControlStateNormal];
|
|
|
}
|
|
|
else if (self.sourceModel.finishedExam == 5) { // 考试已完成
|
|
|
- self.canJoinRoom = NO;
|
|
|
+ self.buttonStatus = JOINBUTTONSTATUS_FINISH;
|
|
|
[self.joinButton setTitle:@"考试已完成" forState:UIControlStateNormal];
|
|
|
}
|
|
|
else {
|
|
|
- self.canJoinRoom = self.sourceModel.classroomSwitch;
|
|
|
if (self.sourceModel.classroomSwitch == 0) {
|
|
|
+ self.buttonStatus = JOINBUTTONSTATUS_WAIT;
|
|
|
NSString *title = [NSString stringWithFormat:@"当前需要等待%.0f位考生",self.sourceModel.waitNum];
|
|
|
if (self.sourceModel.waitNum == 0) {
|
|
|
title = @"即将开始考试,请准备";
|
|
@@ -81,37 +92,60 @@ typedef NS_ENUM(NSInteger,EXAMSTATUS) {
|
|
|
[self.joinButton setTitle:title forState:UIControlStateNormal];
|
|
|
}
|
|
|
else {
|
|
|
+ self.buttonStatus = JOINBUTTONSTATUS_IN;
|
|
|
[self.joinButton setTitle:@"到你了,进入考场" forState:UIControlStateNormal];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else { // 未签到显示
|
|
|
- self.canJoinRoom = NO;
|
|
|
+ self.buttonStatus = JOINBUTTONSTATUS_NOTSTART;
|
|
|
[self.joinButton setTitle:@"进入考场" forState:UIControlStateNormal];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)setCanJoinRoom:(BOOL)canJoinRoom {
|
|
|
- _canJoinRoom = canJoinRoom;
|
|
|
- if (canJoinRoom) {
|
|
|
- self.joinButton.userInteractionEnabled = YES;
|
|
|
- [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_nomal"] forState:UIControlStateNormal];
|
|
|
- [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_highlight"] forState:UIControlStateHighlighted];
|
|
|
-
|
|
|
- [self.joinButton.layer addAnimation:[self alphaChange:2.0f] forKey:@"aAlpha"];
|
|
|
-
|
|
|
- self.hasAnimation = YES;
|
|
|
- }
|
|
|
- else {
|
|
|
- self.joinButton.userInteractionEnabled = NO;
|
|
|
- [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_unable"] forState:UIControlStateNormal];
|
|
|
- if (self.hasAnimation) {
|
|
|
- self.hasAnimation = NO;
|
|
|
- [self.joinButton.layer removeAnimationForKey:@"aAlpha"];
|
|
|
+- (void)setButtonStatus:(JOINBUTTONSTATUS)buttonStatus {
|
|
|
+ _buttonStatus = buttonStatus;
|
|
|
+ switch (buttonStatus) {
|
|
|
+ case JOINBUTTONSTATUS_NOTSTART: // 未开始
|
|
|
+ case JOINBUTTONSTATUS_FINISH: // 已结束
|
|
|
+ {
|
|
|
+ self.joinButton.userInteractionEnabled = NO;
|
|
|
+ [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_unable"] forState:UIControlStateNormal];
|
|
|
+ if (self.hasAnimation) {
|
|
|
+ self.hasAnimation = NO;
|
|
|
+ [self.joinButton.layer removeAnimationForKey:@"aAlpha"];
|
|
|
+ }
|
|
|
}
|
|
|
+ break;
|
|
|
+ case JOINBUTTONSTATUS_WAIT:
|
|
|
+ {
|
|
|
+ self.joinButton.userInteractionEnabled = NO;
|
|
|
+ [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_wait"] forState:UIControlStateNormal];
|
|
|
+ if (self.hasAnimation == NO) {
|
|
|
+ self.hasAnimation = YES;
|
|
|
+ [self.joinButton.layer addAnimation:[self alphaChange:2.0f] forKey:@"aAlpha"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case JOINBUTTONSTATUS_IN:
|
|
|
+ {
|
|
|
+ self.joinButton.userInteractionEnabled = YES;
|
|
|
+ [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_nomal"] forState:UIControlStateNormal];
|
|
|
+ [self.joinButton setBackgroundImage:[UIImage imageNamed:@"button_highlight"] forState:UIControlStateHighlighted];
|
|
|
+ if (self.hasAnimation == NO) {
|
|
|
+ self.hasAnimation = YES;
|
|
|
+ [self.joinButton.layer addAnimation:[self alphaChange:2.0f] forKey:@"aAlpha"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
- (void)operationCallback:(JoinRoomAction)callback {
|
|
|
if (callback) {
|
|
|
self.callback = callback;
|