-
Notifications
You must be signed in to change notification settings - Fork 0
/
WatchList.m
106 lines (79 loc) · 3.1 KB
/
WatchList.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
// WatchList.m
// DataModel
//
// Created by Travis Delly on 7/8/15.
// Copyright (c) 2015 Travis Delly. All rights reserved.
//
#import "WatchList.h"
#import "StaticCell.h"
#import "AppDelegate.h"
#import "ShowCaseTableView.h"
@interface WatchList ()
@property AppDelegate *sharedDelegate;
@end
@implementation WatchList
-(void)viewDidAppear:(BOOL)animated{
self.navigationController.navigationBarHidden = NO;
}
-(void)viewWillAppear:(BOOL)animated{
[self.tableView reloadData];
}
- (void)viewDidLoad {
[super viewDidLoad];
_sharedDelegate = [[UIApplication sharedApplication] delegate];
[self setup];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _sharedDelegate.userWatchList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
StaticCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[StaticCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
if(indexPath.row % 2 == 0){
cell.backgroundColor = [UIColor darkGrayColor];
} else {
cell.backgroundColor = [UIColor grayColor];
}
if(indexPath.row % 3 == 0){
cell.state.text = @"HOT!";
cell.state.textColor = [UIColor redColor];
} else {
cell.state.text = @"RISK!";
cell.state.textColor = [UIColor orangeColor];
}
cell.companyForCell = [[Company alloc] initWithDict:[_sharedDelegate.userWatchList objectAtIndex:indexPath.row]];
cell.textLabel.text = cell.companyForCell.StockLOGO;
cell.detailTextLabel.text = cell.companyForCell.StockExchange;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
StaticCell *cell = (StaticCell*)[self.tableView cellForRowAtIndexPath:indexPath];
NSMutableArray *data = [_sharedDelegate.helper find_company:cell.companyForCell.StockExchange for:cell.companyForCell.StockLOGO startDate:cell.companyForCell.startDate endDate:cell.companyForCell.endDate];
ShowCaseTableView *showPage = [[ShowCaseTableView alloc] init];
showPage.nameOfCompany = cell.companyForCell.StockLOGO;
showPage.theData = data;
[_sharedDelegate.navController pushViewController:showPage animated:YES];
}
//Setup
-(void)setup{
//Header and stuff
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 75)];
_header = [[_sharedDelegate customGUI] defaultLabel:@"Watch List"];
_header.textColor = [UIColor whiteColor];
_header.frame = CGRectMake(0, 10, self.view.frame.size.width, 35);
_header.adjustsFontSizeToFitWidth = YES;
headerView.backgroundColor = [UIColor blackColor];
[headerView addSubview:_header];
self.tableView.tableHeaderView = headerView;
}
@end