//
//  JSFacade.h
//  kneet2
//
//  Created by Created by Jason Lee on 10/1/15.
//  Copyright (c) 2015 ntels. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "Common.h"
#import "Definitions.h"
#import "CommonUtil.h"


//Categories
#import "NSArray-Addtions.h"
#import "NSDictionary-Additions.h"
#import "NSString-Addtions.h"
#import "NSDate+Utilities.h"
#import "UIView+Additions.h"
#import "UITableView+EnumarateCells.h"
#import "TargetConditionals.h"

//Common UI
#import "CustomAlertView.h"
//OpenSource
//#import "ReactiveCocoa.h"

#import "AppDelegate.h"

#import "LoginModel.h"
#import "ModeModel.h"

@class MainViewController;

typedef void(^JDFacadeCompletionCallBackHandler)(void);
typedef void(^JDFacadeFailureCallBackHandler)(void);

@interface JDFacade : NSObject

@property (strong, nonatomic) NSString *deviceUUID;   //local uuid
@property (strong, nonatomic) NSString *APNSToken;    //APNS 토큰
@property (strong, nonatomic) NSString *deviceHostName; //호스트네임

@property (strong, nonatomic) LoginModel *loginUser;

@property (strong, nonatomic) NSArray<ModeModel> *modeList;
@property (assign, nonatomic) KNMenuId wishMenuId;

@property (assign, nonatomic) BOOL hasLoggedIn;

//Local Temporary Variables
@property (strong, nonatomic) NSString *tmpHomegrpName;
@property (strong, nonatomic) NSString *tmpEmailId;
@property (strong, nonatomic) NSString *tmpPassword;

//tasks
@property (weak, nonatomic) NSOperation *currentOperation;

@property (weak, nonatomic) MainViewController *mainViewController;

//Local Temporary Variables

+ (JDFacade *)facade;
- (AppDelegate *)appDelegate;

//Screens
- (UIViewController *)currentViewController;
- (id)viewControllerOnNaviationController:(Class)viewControllerClass;
- (id)viewControllerOnPresentingViewController:(UIViewController *)vc viewControllerClass:(Class)viewControllerClass;

//Keychain Wrapper
- (void)storeObjectToKeychain:(id)object forKey:(NSString *)aKey;
- (id)objectForKeyFromKeychain:(NSString *)aKey;
- (void)removeObjectAtKeychain:(NSString *)aKey;

//UserDefautls - Local Store
- (void)storeObjectToUserDefaults:(id)object forKey:(NSString *)aKey;
- (id)objectForKeyFromUserDefaults:(NSString *)aKey;

//loading
- (void)loadIndicator:(BOOL)showIndicator allowUserInteraction:(BOOL)allowUserInteracton;
- (void)loadIndicatorWhileExecutingBlock:(dispatch_block_t)block;
- (void)showLoadingWhileExecutingBlock:(dispatch_block_t)block completionHandler:(JDFacadeCompletionCallBackHandler)completion;


//alert
- (void)alert:(NSString *)message;
- (void)warn:(NSString *)message;
- (void)alert:(NSString *)message completionHander:(JDFacadeCompletionCallBackHandler)completion;
- (void)alertTitle:(NSString *)title message:(NSString *)message;
- (void)alertTitle:(NSString *)title message:(NSString *)message completionHander:(JDFacadeCompletionCallBackHandler)completion;

- (void)confirm:(NSString *)message completion:(CustomAlertViewCallBackHandler)completion;
- (void)confirmTitle:(NSString *)title message:(NSString *)message completion:(CustomAlertViewCallBackHandler)completion;

- (void)retryAlert:(NSString *)message target:(id)target selector:(SEL)selector;
- (void)retryAlert:(NSString *)message target:(id)target selector:(SEL)selector arguments:(id)arguments,... NS_REQUIRES_NIL_TERMINATION;
- (void)retryAlert:(NSString *)message completionHander:(JDFacadeCompletionCallBackHandler)handler;

- (void)fireLocalNotification:(NSString *)message;
- (void)toast:(NSString *)message;

//Control UI
- (id)getRadioButtonStatus:(id)object;
- (void)setRadioButtonStatus:(id)status object:(id)object;

- (id)getCheckBoxStatus:(id)object;
- (void)setCheckBoxStatus:(id)status object:(id)object;

- (void)presentViewControllerByPush:(UIViewController *)vc;
- (void)presentViewControllerByPush:(UIViewController *)vc pvc:(UIViewController *)pvc;
- (void)dismissViewControllerByPush:(UIViewController *)vc;
- (void)dismissViewControllerByPush:(UIViewController *)vc completion:(JDFacadeCompletionCallBackHandler)completion;
- (void)dismissAllViewControllers;
- (void)dismissModalStack:(BOOL)animated completion:(JDFacadeCompletionCallBackHandler)completion;

//Biz Logic
- (void)checkHomeHubStatus;

//UI Flow
- (void)gotoLoginView;
- (void)gotoLoginViewWithExpiring;
- (void)logout;
- (void)loadInvitationView;
- (void)gotoHomeHubRegistration;

- (void)gotoStartHome:(BOOL)canGoBack;
//- (void)gotoTutorial:(BOOL)isCalledFromMenu;

- (void)gotoWishMenu:(KNMenuId)menuId;
- (void)gotoWishMenu:(KNMenuId)menuId completion:(JDFacadeCompletionCallBackHandler)completion;
//- (void)updateHomegrpListForLoginUser:(JDFacadeCompletionCallBackHandler)completion;
- (void)updateLoginInfo:(JDFacadeCompletionCallBackHandler)completion;


- (void)alertLocationServiceDisabled;
- (void)alertCameraPermissionDisabled;

//Debug
- (BOOL)redirectNSLog;
- (void)showFlex;

@end
