// // StockViewController.m // HMLG Scan Order // // Created by Rui Zhang on 6/21/22. // Copyright © 2022 United Software Applications, Inc. All rights reserved. // #import "StockViewController.h" #import "StockTableViewCell.h" #import "DefaultTableHeaderView.h" #import "DefaultAppearance.h" #import "const.h" #import "RAUtils.h" @interface StockViewController () @end @implementation StockViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (IBAction)onSubmit:(id)sender { NSMutableDictionary* models = [NSMutableDictionary new]; models[@"count"] = @(self.idata.count+self.bdata.count+self.sdata.count); models[@"title"] =@"Model Information"; int count=0; for(int i=0;i=3) // return; // } // else // { // if(indexPath.section==0&&[tableView numberOfRowsInSection:indexPath.section]<=1) // return; // } // int between = 1; NSUInteger curr = [[NSDate date] timeIntervalSince1970]; if(indexPath.row==self.lasttap.row&&indexPath.section==self.lasttap.section) { if (curr-self.taptime<1) { DebugLog(@"double click!"); self.lasttap =nil; NSMutableArray * from; NSMutableArray * to ; int section; if(indexPath.section==0) { from = self.idata; to = self.bdata; section = 1; } else { from = self.bdata; to = self.idata; section = 0; } NSIndexPath * toIndexPath = [NSIndexPath indexPathForRow:0 inSection:section]; // NSIndexPath * headerIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section]; // NSIndexPath * headerIndexPath1 = toIndexPath; id content=from[indexPath.row]; [tableView beginUpdates]; [from removeObjectAtIndex:indexPath.row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [to insertObject:content atIndex:0]; [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:toIndexPath] withRowAnimation:UITableViewRowAnimationFade]; [tableView endUpdates]; // [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath] withRowAnimation:UITableViewRowAnimationFade]; // [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath1] withRowAnimation:UITableViewRowAnimationFade]; [tableView reloadData]; } self.taptime = curr; } else { self.taptime = curr; self.lasttap = indexPath; } } // //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section //{ //// return [super tableview:tableView viewForHeaderInSection:section]; // NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"]; // if(value==nil) // value=@""; // unsigned long color = strtoul([value UTF8String],0,16); // // // NSString* btntitle=nil ; // NSString*labeltitle = nil; // // // labeltitle= [self tableView:tableView titleForHeaderInSection:section]; // // // DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)]; // // myView.backgroundColor = [UIColor whiteColor];//UIColorFromRGB(0x996633);; // myView.layer.shadowPath =[UIBezierPath bezierPathWithRect:myView.bounds].CGPath; // myView.layer.shadowColor = [UIColor blackColor].CGColor; // myView.layer.shadowOffset = CGSizeMake(0, 0); // myView.layer.shadowOpacity = 0.5; // myView.layer.shadowRadius = 2.0; // // int linespace=0; // if(section==0) // linespace=11; // // // // // UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5.5+linespace, 200, 20)]; // titlelabel.textColor=UIColorFromRGB(color);//[UIColor whiteColor]; // titlelabel.backgroundColor = [UIColor clearColor]; // titlelabel.text=NSLocalizedString(labeltitle, nil); // titlelabel.font = [UIFont boldSystemFontOfSize:20]; // [titlelabel sizeToFit]; // [myView addSubview:titlelabel]; // // // // UILabel *contactlabel = [[UILabel alloc] initWithFrame:CGRectMake(300, 0, 90, 22)]; // // contactlabel.textColor=[UIColor whiteColor]; // // contactlabel.backgroundColor = [UIColor clearColor]; // // contactlabel.text=NSLocalizedString(@"Contact", nil); // // [contactlabel sizeToFit]; // // [myView addSubview:contactlabel]; // // // // // // UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(400, 0, 90, 22)]; // // modellabel.textColor=[UIColor whiteColor]; // // modellabel.backgroundColor = [UIColor clearColor]; // // modellabel.text=NSLocalizedString(@"Model", nil); // // [modellabel sizeToFit]; // // [myView addSubview:modellabel]; // // // // UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(500, 0, 90, 22)]; // // pricelabel.textColor=[UIColor whiteColor]; // // pricelabel.backgroundColor = [UIColor clearColor]; // // pricelabel.text=NSLocalizedString(@"Price", nil); // // [pricelabel sizeToFit]; // // [myView addSubview:pricelabel]; // // // // // // // // UILabel *timelabel = [[UILabel alloc] initWithFrame:CGRectMake(630, 0, 90, 22)]; // // timelabel.textColor=[UIColor whiteColor]; // // timelabel.backgroundColor = [UIColor clearColor]; // // timelabel.text=NSLocalizedString(@"Create time", nil); // // [timelabel sizeToFit]; // // [myView addSubview:timelabel]; // // // // // // // // UILabel *statuslabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 60, 22)]; // // statuslabel.textColor=[UIColor whiteColor]; // // statuslabel.backgroundColor = [UIColor clearColor]; // // statuslabel.text=NSLocalizedString(@"Status", nil); // // [statuslabel sizeToFit]; // // [myView addSubview:statuslabel]; // // // myView.backgroundColor = UIColor.lightGrayColor; //// UIColor * c=myView.backgroundColor; // return myView; //} - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if(section==0) return @"In Stock"; else if(section==1) return @"Backorder"; else return @"Backorder-Showroom"; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(section==0) return _idata.count; else if(section==1) return _bdata.count; else return _sdata.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { StockTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StockTableViewCell"]; if (!cell) { cell = [[StockTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"StockTableViewCell"]; } NSArray* arr; if(indexPath.section==0) { arr = self.idata; cell.btnMove.hidden = false; } else if(indexPath.section==1) { arr = self.bdata; cell.btnMove.hidden = true; } else { arr = self.sdata; cell.btnMove.hidden = true; } cell.labelModel.text = arr[indexPath.row][@"model"]; cell.labelETD.text = arr[indexPath.row][@"etd"]; cell.labelQTY.text = [arr[indexPath.row][@"count"] stringValue]; return cell; } //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section //{ // if(section==0) // return 44; // return 44; //} /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end