@interface CommonViewController ()<UITextFieldDelegate>//,UITableViewDelegate,UITableViewDataSource>
{
APIFactory *fireAPI;
Supportive *support;
MBProgressHUD *HUD;
BOOL blinkStatus;
}
@end
@implementation CommonViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
- (void)viewDidLoad
{
[super viewDidLoad];
fireAPI = [[APIFactory alloc] init];
support = [[Supportive alloc] init];
self.dbManager = [[DBManager alloc] initWithDatabaseFilename:@"IntelliDealer.sqlite"];
self.dataArray = [[NSMutableArray alloc]init];
self.strVC=@"OrderViewController";
[self setNavigationBar];
if (self.epcCartOrder.count==0) {
lblBadge.hidden = YES;
badgeImgView.hidden = YES;
}
else{
lblBadge.hidden = NO;
badgeImgView.hidden = NO;
}
}
-(void)setNavigationBar{
NSString *query1;
query1 =[NSString stringWithFormat:@"SELECT * FROM Dealer_Spare_Order WHERE spareOrderListId=%d ORDER BY spareAddTime DESC",[[[UICKeyChainStore keyChainStore] stringForKey:@"DealerEnableOrderList"] intValue]];
self.epcCartOrder = [[NSMutableArray alloc] initWithArray:[self.dbManager loadDataFromDB:query1]];
[Supportive ShowLog:[NSString stringWithFormat:@"no of rows => %lu",(unsigned long)self.epcCartOrder.count]];
self.navigationController.navigationBarHidden = YES;
CustomTitleView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 768, iPhoneX ? 100:70)];
CustomTitleView.backgroundColor = [UIColor colorWithRed:231/255.f green:66/255.f blue:57/255.f alpha:1.0f];
backButton =[UIButton buttonWithType:UIButtonTypeCustom];
[backButton addTarget:self action:@selector(didclickOnBackButton) forControlEvents:UIControlEventTouchUpInside];
backButtonImage = [UIImageView new];
menuButton =[UIButton buttonWithType:UIButtonTypeCustom];
menuButton.tag = 100;
[menuButton addTarget:self action:@selector(didclickOnMenuButton) forControlEvents:UIControlEventTouchUpInside];
lblDealerName = [[UILabel alloc] init];
lblDealerName.numberOfLines=3;
lblDealerName.text= [[UICKeyChainStore keyChainStore] stringForKey:@"DealerName"];
lblDealerName.textAlignment=NSTextAlignmentCenter;
lblDealerName.textColor = [UIColor whiteColor];
lblDealerName.backgroundColor=[UIColor clearColor];
lblDealerName.userInteractionEnabled=NO;
btnDealerName =[UIButton buttonWithType:UIButtonTypeCustom];
[btnDealerName addTarget:self action:@selector(didclickOnDealerName) forControlEvents:UIControlEventTouchUpInside];
[btnDealerName addSubview:lblDealerName];
addToCartButton =[UIButton buttonWithType:UIButtonTypeCustom];
[addToCartButton addTarget:self action:@selector(didclickOnAddToCartButtonButton) forControlEvents:UIControlEventTouchUpInside];
addToCartButtonImage = [UIImageView new];
[self.view addSubview:CustomTitleView];
[CustomTitleView addSubview:backButtonImage];
[CustomTitleView addSubview:backButton];
[CustomTitleView addSubview:menuButton];
[CustomTitleView addSubview:btnDealerName];
//[CustomTitleView addSubview:cartButton];
[CustomTitleView addSubview:addToCartButtonImage];
[CustomTitleView addSubview:addToCartButton];
if(UI_USER_INTERFACE_IDIOM () == UIUserInterfaceIdiomPad) {
[backButton setFrame:CGRectMake(0, 8, 45, 60)];
// [backButton setImage:[UIImage imageNamed:@"back_arrow"] forState:UIControlStateNormal];
[backButtonImage setFrame:CGRectMake(0, 18, 40, 40)];
[backButtonImage setImage:[UIImage imageNamed:@"back_arrow"]];
[menuButton setFrame:CGRectMake(50, 18, 40, 40)];
[menuButton setImage:[UIImage imageNamed:@"ipadnavigatio"] forState:UIControlStateNormal];
[btnDealerName setFrame:CGRectMake(100, 24, 590, 30)];
[lblDealerName setFrame:CGRectMake(0, 0, 590, 30)];
[lblDealerName setTextAlignment:NSTextAlignmentCenter];
lblDealerName.font = [UIFont fontWithName:@"Arial" size:22];
[addToCartButton setFrame:CGRectMake(690, 10, 70, 60)];
[addToCartButtonImage setFrame:CGRectMake(700, 23, 40, 38)];
[addToCartButtonImage setImage:[UIImage imageNamed:@"ipadaddtocart"]];
badgeImgView = [[UIImageView alloc]init];
//badgeImgView.hidden =YES;
badgeImgView.image = [UIImage imageNamed:@"order_bg"];
lblBadge = [[UILabel alloc] init];
if (self.epcCartOrder.count<10) {
badgeImgView.frame =CGRectMake(36,9, 23, 23);
lblBadge.frame = CGRectMake(7, 0, 23, 23);
}
else{
badgeImgView.frame =CGRectMake(38,9, 25, 25);
lblBadge.frame = CGRectMake(4, 0, 25, 25);
}
/*important--------- */
lblBadge.textColor = [UIColor whiteColor];
lblBadge.font = [UIFont fontWithName:@"Arial" size:15];
lblBadge.backgroundColor=[UIColor clearColor];
lblBadge.textColor=[UIColor whiteColor];
lblBadge.userInteractionEnabled=NO;
//lblBadge.hidden = YES;
lblBadge.text=[NSString stringWithFormat:@"%lu", (unsigned long)self.epcCartOrder.count];
//[CustomTitleView addSubview:_textFieldSearch];
[addToCartButtonImage addSubview: badgeImgView];
[badgeImgView addSubview:lblBadge];
[addToCartButton addSubview: badgeImgView];
}
else if (UI_USER_INTERFACE_IDIOM () == UIUserInterfaceIdiomPhone){
double customViewWidth = self.view.frame.size.width - 40;
[backButton setFrame:CGRectMake(5, iPhoneX ? 20:10, 40, 60)];
// [backButton setImage:[UIImage imageNamed:@"back_arrow"] forState:UIControlStateNormal];
[backButtonImage setFrame:CGRectMake(10, iPhoneX ? 55:25, 35, 35)];
[backButtonImage setImage:[UIImage imageNamed:@"back_arrow"]];
[menuButton setFrame:CGRectMake(50, iPhoneX ? 55:25, 35, 35)];
[menuButton setImage:[UIImage imageNamed:@"ipadnavigatio.png"] forState:UIControlStateNormal];
[btnDealerName setFrame:CGRectMake(90, iPhoneX ? 50:20, 180, 51)];
[lblDealerName setFrame:CGRectMake(0, 0, 180, 51)];
lblDealerName.font = [UIFont fontWithName:@"Arial" size:15];
[addToCartButton setFrame:CGRectMake(customViewWidth - 8, iPhoneX ? 55:15, 50, 55)];
[addToCartButtonImage setFrame:CGRectMake(customViewWidth , iPhoneX ? 60:30, 30, 30)];
[addToCartButtonImage setImage:[UIImage imageNamed:@"ipadaddtocart"]];
badgeImgView = [[UIImageView alloc]init];
badgeImgView.image = [UIImage imageNamed:@"order_bg"];
lblBadge = [[UILabel alloc] init];
lblBadge.textColor = [UIColor whiteColor];
lblBadge.font = [UIFont fontWithName:@"Arial" size:15];
lblBadge.backgroundColor=[UIColor clearColor];
lblBadge.textColor=[UIColor whiteColor];
lblBadge.userInteractionEnabled=NO;
lblBadge.text=[NSString stringWithFormat:@"%lu", (unsigned long)self.epcCartOrder.count];
[addToCartButtonImage addSubview: badgeImgView];
[badgeImgView addSubview:lblBadge];
[addToCartButton addSubview: badgeImgView];
if (self.epcCartOrder.count<10) {
badgeImgView.frame=CGRectMake(28, iPhoneX ? 1:9, 20, 20);
lblBadge.frame = CGRectMake(6, 0, 20, 20);
}
else{
badgeImgView.frame=CGRectMake(28, 6, 22, 22);
lblBadge.frame = CGRectMake(2, 0, 22, 22);
}
//lblBadge.center = badgeImgView.center;
/*important--------- */
// [CustomTitleView addSubview:_textFieldSearch];
}
}