//
//  TourComboBoxBottomView.m
//  TakeTours
//
//  Created by Vae on 2019/1/17.
//

#import "TourComboBoxBottomView.h"
#import "Vars.h"
#import "SDK.h"
#import <BlocksKit/UIView+BlocksKit.h>

@interface TourComboBoxBottomView()
@property (weak, nonatomic) IBOutlet UIView *rightView;
@property (weak, nonatomic) IBOutlet UIImageView *destinationImageView;
@property (weak, nonatomic) IBOutlet UILabel *selectedLabel;
@property (weak, nonatomic) IBOutlet UIButton *completeButton;
@end

@implementation TourComboBoxBottomView

-(void)awakeFromNib{
	[super awakeFromNib];
	
	[self.completeButton setBackgroundColor:[Vars defaultTintColor]];
	[self.completeButton setTitle:IMLocalizedString(@"Complete") forState:UIControlStateNormal];
	[self.completeButton addTarget:self action:@selector(completedSelect) forControlEvents:UIControlEventTouchUpInside];
	
	self.rightView.userInteractionEnabled = YES;
	UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showSelectedCity)];
	self.rightView.gestureRecognizers = @[tapGesture];
	
	UIView *dotView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 15)];
	dotView.layer.cornerRadius = CGRectGetWidth(dotView.frame) / 2.0;
	[dotView setBackgroundColor:[UIColor orangeColor]];
	[self.destinationImageView addSubview:dotView];
	dotView.center = CGPointMake(CGRectGetWidth(self.destinationImageView.frame), 0);
	
	self.countLabel = [[UILabel alloc] init];
	self.countLabel.textColor = [UIColor whiteColor];
	self.countLabel.text = @"0";
	self.countLabel.font = [UIFont systemFontOfSize:12];
	[dotView addSubview:self.countLabel];
	self.countLabel.frame = dotView.bounds;
	self.countLabel.textAlignment = NSTextAlignmentCenter;
	
	self.selectedLabel.text = [NSString stringWithFormat:IMLocalizedString(@"%d Selected"), 0];
}

-(void)showSelectedCity{
	if (self.tapLeftView) {
		self.tapLeftView();
	}
}

-(void)completedSelect{
	if (self.completeSelect) {
		self.completeSelect();
	}
}

-(void)changeSelectedCitycount:(NSInteger)count{
	self.selectedLabel.text = [NSString stringWithFormat:IMLocalizedString(@"%d Selected"), count];
	self.countLabel.text = [NSString stringWithFormat:@"%d",count];
}


@end
