| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // HomeModeUpdateViewController.m
- //
- //
- // Created by Jason Lee on 10/30/15.
- //
- //
- #import "JDObject.h"
- #import "CustomButton.h"
- #import "CustomLabel.h"
- #import "CustomImageView.h"
- #import "RequestHandler.h"
- #import "JDJSONModel.h"
- #import "HomeModeUpdateViewController.h"
- #import "ModeModel.h"
- @interface HomeModeUpdateViewController () {
- }
- @end
- #pragma mark - Class Definition
- @implementation HomeModeUpdateViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self initUI];
- [self prepareViewDidLoad];
- }
- - (void)initUI {
-
- NSString *message = nil, *highlightMessage = nil;
- NSString *btnTitle = nil;
- if ([_mode.modeId isEqualToString:HOME_MODE_HOME]) {
- btnTitle = @"귀가";
- highlightMessage = @"잘 돌아왔어요!";
- message = @"쾌적한 귀가모드를 \r실행할까요?";
-
- } else if ([_mode.modeId isEqualToString:HOME_MODE_AWAY]) {
- btnTitle = @"외출";
- highlightMessage = @"안녕히 다녀오세요!";
- message = @"안전한 외출모드를 \r실행할까요?";
-
- } else if ([_mode.modeId isEqualToString:HOME_MODE_MORNING]) {
- btnTitle = @"기상";
- highlightMessage = @"좋은 아침!";
- message = @"상쾌한 기상모드를\r실행할까요?";
-
- } else if ([_mode.modeId isEqualToString:HOME_MODE_NIGHT]) {
- btnTitle = @"취침";
- highlightMessage = @"잘 자요!";
- message = @"편안한 취침모드를 \r실행할까요?";
-
- }
-
- [_btnExecute setTitle:btnTitle forState:UIControlStateNormal];
- _lblMessage.text = [NSString stringWithFormat:@"%@/r/r%@", highlightMessage, message];
- [_lblMessage setColor:kUITextColor02 text:highlightMessage];
-
- _btnSetting.hidden = [JDFacade facade].loginUser.level < 90;
-
- //TODO : set icon;
- }
- - (void)prepareViewDidLoad {
-
- }
- #pragma mark - Main Logic
- - (void)requestChangeHomeMode {
- NSString *modeTitle = [NSString stringWithFormat:@"%@ 모드", _mode.modeName];
- _lblMessage.text = [NSString stringWithFormat:@"%@\r\r실행 중입니다.", modeTitle];
- [_lblMessage setColor:kUITextColor02 text:modeTitle];
-
- NSString *path = [NSString stringWithFormat:API_POST_DASHBOARD_MODE_CHANGE, _mode.modeId];
-
- [[RequestHandler handler] sendAsyncPostRequestAPIPath:path parameters:nil modelClass:[JDJSONModel class] completion:^(id responseObject) {
-
- if ([[JDFacade facade].currentViewController isEqual:self]) {
- [self setContentsForComplete];
- }
-
- [[JDFacade facade] toast:[NSString stringWithFormat:@"%@ 상태가 되었습니다", _mode.modeName]];
-
- } failure:^(id errorObject) {
- JDErrorModel *error = (JDErrorModel *)errorObject;
- [[JDFacade facade] alert:error.errorMessage];
- }];
- }
- - (void)setContentsForComplete {
-
- NSString *highlightMessage = nil;
- highlightMessage = [NSString stringWithFormat:@"%@ 상태가 되었습니다.", _mode.modeName];
- //TODO : chagne button image
- }
- #pragma mark - UI Events
- - (IBAction)btnExecuteTouched:(id)sender {
- [self requestChangeHomeMode];
- }
- - (IBAction)btnSettingTouched:(id)sender {
-
- }
- - (IBAction)btnCloseTouched:(id)sender {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark - MemoryWarning
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|