ScanHistoryViewController.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // ScanHistoryViewController.m
  3. // HMLG Scan Order
  4. //
  5. // Created by Rui Zhang on 3/29/22.
  6. // Copyright © 2022 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "ScanHistoryViewController.h"
  9. #import "ScanListCell.h"
  10. #import "RASingleton.h"
  11. #import "RADataProvider.h"
  12. @interface ScanHistoryViewController ()
  13. @end
  14. @implementation ScanHistoryViewController
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. // Do any additional setup after loading the view.
  18. // [self refreshStock];
  19. }
  20. - (IBAction)onUpdateStock:(id)sender {
  21. [RADataProvider updateStock:self];
  22. }
  23. - (void)viewWillAppear:(BOOL)animated
  24. {
  25. [super viewWillAppear:animated];
  26. self.labelStock.text = [RADataProvider queryStockUpdateTime];
  27. }
  28. -(void) refreshStock
  29. {
  30. // NSDictionary *addressDic1 = [[NSUserDefaults standardUserDefaults] valueForKey:@"ScanStock"];
  31. // if (addressDic1) {
  32. // NSString* updatetime=addressDic1[@"updatetime"];
  33. // self.labelStock.text = updatetime;
  34. // }
  35. //
  36. self.labelStock.text = [RADataProvider queryStockUpdateTime];
  37. [self.tableview reloadData];
  38. }
  39. /*
  40. #pragma mark - Navigation
  41. // In a storyboard-based application, you will often want to do a little preparation before navigation
  42. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  43. // Get the new view controller using [segue destinationViewController].
  44. // Pass the selected object to the new view controller.
  45. }
  46. */
  47. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  48. return RASingleton.sharedInstance.scan_list.count;
  49. }
  50. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  51. // return 166.0f;
  52. UILabel * label = [UILabel new];
  53. NSMutableArray* arr = RASingleton.sharedInstance.scan_list;
  54. NSMutableDictionary* model = arr[indexPath.row];
  55. label.frame = CGRectMake(0, 0, tableView.frame.size.width-32, 0);
  56. label.text = model[@"description"];
  57. label.font = [UIFont systemFontOfSize:15];
  58. label.numberOfLines=0;
  59. label.lineBreakMode = NSLineBreakByWordWrapping;
  60. // double s = label.font.pointSize;
  61. // NSLog(label.text);
  62. // CGSize s=[label sizeThatFits:CGSizeMake(tableView.frame.size.width-32, 0)];
  63. [label sizeToFit];
  64. return label.frame.size.height+112;
  65. }
  66. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  67. {
  68. ScanListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ScanListCell"];
  69. if (!cell) {
  70. cell = [[ScanListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ScanListCell"];
  71. }
  72. NSMutableArray* arr = RASingleton.sharedInstance.scan_list;
  73. [cell setModelJson:arr[indexPath.row]];
  74. cell.labelStock.text = [RADataProvider queryStock:cell.labelModel.text];
  75. return cell;
  76. }
  77. //#pragma mark - TableView Delegate
  78. /*
  79. #pragma mark - Navigation
  80. // In a storyboard-based application, you will often want to do a little preparation before navigation
  81. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  82. // Get the new view controller using [segue destinationViewController].
  83. // Pass the selected object to the new view controller.
  84. }
  85. */
  86. //- (IBAction)onAddToCart:(id)sender {
  87. //
  88. // [self dismissViewControllerAnimated:true completion:^{
  89. // if(self.returnValue)
  90. // self.returnValue(self.modellist);
  91. // }];
  92. //
  93. //
  94. //}
  95. #pragma mark - RA_NOTIFICAITON
  96. -(void) refresh_ui
  97. {
  98. [self.tableview reloadData];
  99. }
  100. -(void) reload_data {
  101. [self.tableview reloadData];
  102. }
  103. @end