//
//  CommandClassControlNodeView.h
//  kneet2
//
//  Created by Jason Lee on 11/5/15.
//  Copyright © 2015 ntels. All rights reserved.
//

#import "JDObject.h"

@class ItemSubModel;

@class CustomButton;
@class CustomLabel;

@protocol CommandClassControlNodeViewDelegate <NSObject>

@optional
- (void)didControlNodeAction:(id)sender;

@end

@interface CommandClassControlNodeView : UIView {
    
@protected
    __weak ItemSubModel *_subItem;
    NSString *_cmdClsValue;
    BOOL _nodeEnable;
}

@property (weak, nonatomic) id <CommandClassControlNodeViewDelegate> delegate;
@property (weak, nonatomic) ItemSubModel *subItem;
@property (weak, nonatomic) CmdClsValueModel *selectedCmdClsValue;
@property (assign, nonatomic) BOOL nodeEnable;

+ (CommandClassControlNodeView *)viewForCommandClass:(CmdClsType)cmdClsType;

- (CGSize)sizeForIntrinsic;
- (CGSize)sizeForIntrinsicForItemCount:(NSInteger)count;

@end




@interface CommandClassControlNodeValveView : CommandClassControlNodeView

@property (weak, nonatomic) IBOutlet CustomButton *btnOpen;
@property (weak, nonatomic) IBOutlet CustomButton *btnClose;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnOpenWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnCloseWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnSpace;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnSameWidth;

- (IBAction)btnOpenTouched:(id)sender;
- (IBAction)btnCloseTouched:(id)sender;

@end

@interface CommandClassControlNodeSwitchBinaryView : CommandClassControlNodeView

@property (weak, nonatomic) IBOutlet CustomButton *btnOn;
@property (weak, nonatomic) IBOutlet CustomButton *btnOff;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnOnWidth;

- (IBAction)btnOnTouched:(id)sender;
- (IBAction)btnOffTouched:(id)sender;

@end

@interface CommandClassControlNodeSensorBinaryView : CommandClassControlNodeSwitchBinaryView

@end

@interface CommandClassControlNodeSwitchMultiLevelView : CommandClassControlNodeView

@property (weak, nonatomic) IBOutlet CustomButton *btnMultiLevel;

- (IBAction)btnMutilLevelTouched:(id)sender;

@end

@interface CommandClassControlNodeSensorMultiLevelView: CommandClassControlNodeSwitchMultiLevelView

@end

@interface CommandClassControlNodeBatteryView : CommandClassControlNodeSwitchMultiLevelView

@end

@interface CommandClassControlNodeMeterView : CommandClassControlNodeSwitchMultiLevelView

@end
