| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- //
- // BundleModelViewController.m
- // RedAnt ERP Mobile
- //
- // Created by Ray on 10/31/15.
- // Copyright © 2015 United Software Applications, Inc. All rights reserved.
- //
- #import "BundleModelViewController.h"
- #import "const.h"
- #import "BundleModelCell.h"
- #import "DefaultTableHeaderView.h"
- #import "DefaultAppearance.h"
- #define DEF_CELL_HEIGHT 44
- //#define DEF_TABLE_HEIGHT 44
- //#define LINE_WIDTH 0
- //#define CELL_MARGIN 0
- #define LABEL_MARGIN 11
- @interface BundleModelViewController ()
- @end
- @implementation BundleModelViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
-
- self.navigationItem.title=@"Bundle Items";
-
-
-
-
- UIBarButtonItem *closeButton = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"close"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector( onCloseClick:)];
- //[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Close", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onCloseClick:)];
- // closeButton.title = @"Close";
-
- self.navigationItem.rightBarButtonItem = closeButton;
-
- // Do any additional setup after loading the view.
- }
- - (void)onCloseClick:(UIButton *)sender {
-
-
- [self dismissViewControllerAnimated:true completion:nil];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #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.
- }
- */
- #pragma mark - Table view data source
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- {
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- NSString* value = [item_json valueForKey:@"description"];
-
-
- float width = 254;
- width-=40;
- CGSize constraintkey = CGSizeMake(width-2*LABEL_MARGIN, 10.0f);//key label width is 40% cell width;
-
-
- CGRect frame;
- frame.size = constraintkey;
- frame.origin.x=0;
- frame.origin.y=0;
-
- RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
- [rtlabel setText: value];
- CGSize optimumSize = [rtlabel optimumSize];
- float height = optimumSize.height;
- height = MAX(height+2*LABEL_MARGIN, DEF_CELL_HEIGHT);
-
-
- return height;
- }
- //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- //{
- // return 0;
- //}
- //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- //{
- // return 0;
- //}
- //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // return myView;
- //
- //}
- //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- //{
- // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
- //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
- //// titleLabel.textColor=[UIColor whiteColor];
- //// titleLabel.backgroundColor = [UIColor clearColor];
- //// if(section==0)
- //// titleLabel.text=NSLocalizedString(@"display_items", nil);
- //// else
- //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
- //// [titleLabel sizeToFit];
- //// [myView addSubview:titleLabel];
- ////
- // return myView;
- //}
- //
- //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
- // if(section==0)
- // return nil;
- // else
- // return @"detail section";
- //}
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 33;
- }
- - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
- {
-
-
- NSString* value =[DefaultAppearance get_noneappearance_value:@"DefaultTableHeaderView" valuename:@"title_text_color"];
-
- if(value==nil)
- value=@"";
- unsigned long color = strtoul([value UTF8String],0,16);
-
- DefaultTableHeaderView* myView = [[DefaultTableHeaderView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
- // myView.backgroundColor = UIColorFromRGB(0x996633);
-
- myView.layer.shadowColor = [UIColor blackColor].CGColor;
- myView.layer.shadowOffset = CGSizeMake(0, 0);
- myView.layer.shadowOpacity = 0.5;
- myView.layer.shadowRadius = 2.0;
-
- UILabel *modellabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 5.5, 90, 22)];
- modellabel.textColor=UIColorFromRGB(color);
- modellabel.backgroundColor = [UIColor clearColor];
- modellabel.text=NSLocalizedString(@"Model", nil);
- [modellabel sizeToFit];
- [myView addSubview:modellabel];
-
- UILabel *description = [[UILabel alloc] initWithFrame:CGRectMake(200, 5.5, 90, 22)];
- description.textColor=UIColorFromRGB(color);
- description.backgroundColor = [UIColor clearColor];
- description.text=NSLocalizedString(@"Description", nil);
- [description sizeToFit];
- [myView addSubview:description];
-
-
- UILabel *qtylabel = [[UILabel alloc] initWithFrame:CGRectMake(400, 5.5, 90, 22)];
- qtylabel.textColor=UIColorFromRGB(color);
- qtylabel.backgroundColor = [UIColor clearColor];
- qtylabel.text=NSLocalizedString(@"QTY", nil);
- [qtylabel sizeToFit];
- [myView addSubview:qtylabel];
-
- UILabel *pricelabel = [[UILabel alloc] initWithFrame:CGRectMake(450, 5.5, 90, 22)];
- pricelabel.textColor=UIColorFromRGB(color);
- pricelabel.backgroundColor = [UIColor clearColor];
- pricelabel.text=NSLocalizedString(@"Unit Price", nil);
- [pricelabel sizeToFit];
- [myView addSubview:pricelabel];
-
-
-
-
-
-
-
- //
- return myView;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- // NSDictionary * item_json = [self.content_data objectForKey:@"items"];
- int count =[[self.content_data valueForKey:@"count"] intValue];
- return count;
-
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- // if(tableView==self.itemListTable)
- // {
-
-
-
- NSString *CellIdentifier = @"BundleModelCell";
- BundleModelCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- NSDictionary * item_json = [self.content_data objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
-
- cell.labelModel.text = [item_json valueForKey:@"model"];
- cell.labelPrice.text=[NSString stringWithFormat:@"$ %.2f",[[item_json valueForKey:@"unit_price"] floatValue]];
- cell.labelQTY.text=[NSString stringWithFormat:@"%d",[[item_json valueForKey:@"modulus"] intValue]];
-
- cell.labelDescription.text = [item_json valueForKey:@"description"];
- cell.backgroundColor = [UIColor whiteColor];
- return cell;
- // }
- // else
- // {
- // NSString *CellIdentifier = @"OrderInfoListItem";
- // UITableViewCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
- // return cell;
- // }
- }
- @end
|