|
@@ -13,9 +13,15 @@
|
|
|
#import "DetailTabBarController.h"
|
|
#import "DetailTabBarController.h"
|
|
|
#import "RAUtils.h"
|
|
#import "RAUtils.h"
|
|
|
#import "KPICell.h"
|
|
#import "KPICell.h"
|
|
|
|
|
+#import "KPITableCell.h"
|
|
|
|
|
|
|
|
#define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
|
|
#define SHIP_CELL_IDENTIFIER @"ShippingStatusCell"
|
|
|
-#define KPI_CELL_IDENTIFIER @"KPICell"
|
|
|
|
|
|
|
+#define KPI_CELL_IDENTIFIER @"KPITableCell"
|
|
|
|
|
+
|
|
|
|
|
+typedef enum {
|
|
|
|
|
+ HomeModeRecent = 0,
|
|
|
|
|
+ HomeModeKPI = 1
|
|
|
|
|
+} HomeMode;
|
|
|
|
|
|
|
|
@interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate>
|
|
@interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate>
|
|
|
|
|
|
|
@@ -23,14 +29,16 @@
|
|
|
@property (strong, nonatomic) IBOutlet UITableView *shipTableView;
|
|
@property (strong, nonatomic) IBOutlet UITableView *shipTableView;
|
|
|
@property (strong, nonatomic) IBOutlet UISearchBar *shipSearchBar;
|
|
@property (strong, nonatomic) IBOutlet UISearchBar *shipSearchBar;
|
|
|
@property (nonatomic,strong) NSMutableArray *shipArray;
|
|
@property (nonatomic,strong) NSMutableArray *shipArray;
|
|
|
-@property (strong, nonatomic) IBOutlet UIButton *emptyBtn;
|
|
|
|
|
@property (nonatomic,strong) UIRefreshControl *refreshControl;
|
|
@property (nonatomic,strong) UIRefreshControl *refreshControl;
|
|
|
-@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *loadIndicator;
|
|
|
|
|
-@property (strong, nonatomic) IBOutlet UICollectionView *KPICollectionView;
|
|
|
|
|
|
|
+@property (nonatomic,strong) IBOutlet UITableView *KPITableView;
|
|
|
|
|
+@property (nonatomic,strong) UIRefreshControl *KPIRefresh;
|
|
|
|
|
|
|
|
@property (nonatomic,strong) NSMutableArray *KPIArray;
|
|
@property (nonatomic,strong) NSMutableArray *KPIArray;
|
|
|
@property (nonatomic,strong) NSArray *monthArray;
|
|
@property (nonatomic,strong) NSArray *monthArray;
|
|
|
|
|
|
|
|
|
|
+@property (nonatomic,assign) HomeMode mode;///<
|
|
|
|
|
+@property (nonatomic,assign) NSInteger currentKPI;
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@implementation HomeViewController
|
|
@implementation HomeViewController
|
|
@@ -43,19 +51,10 @@
|
|
|
} else {
|
|
} else {
|
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ self.currentKPI = 1;
|
|
|
self.segmentControl.tintColor = APGRAYCOLOR;
|
|
self.segmentControl.tintColor = APGRAYCOLOR;
|
|
|
|
|
|
|
|
- self.emptyBtn.layer.borderColor = [UIColor darkGrayColor].CGColor;
|
|
|
|
|
- self.emptyBtn.layer.borderWidth = 1.0f;
|
|
|
|
|
- self.emptyBtn.layer.cornerRadius = 10.0f;
|
|
|
|
|
- self.emptyBtn.layer.masksToBounds = YES;
|
|
|
|
|
- self.emptyBtn.hidden = YES;
|
|
|
|
|
-
|
|
|
|
|
- [self.loadIndicator stopAnimating];
|
|
|
|
|
-
|
|
|
|
|
[self registNotification];
|
|
[self registNotification];
|
|
|
- [self configureCollectionView];
|
|
|
|
|
[self configureTableView];
|
|
[self configureTableView];
|
|
|
self.shipSearchBar.delegate =self;
|
|
self.shipSearchBar.delegate =self;
|
|
|
|
|
|
|
@@ -67,6 +66,7 @@
|
|
|
// self.loadIndicator.layer.borderWidth = 0.3f;
|
|
// self.loadIndicator.layer.borderWidth = 0.3f;
|
|
|
// self.loadIndicator.color = [UIColor colorWithRed:43 / 255.0 green:43 / 255.0 blue:43 / 255.0 alpha:1.0];
|
|
// self.loadIndicator.color = [UIColor colorWithRed:43 / 255.0 green:43 / 255.0 blue:43 / 255.0 alpha:1.0];
|
|
|
// self.loadIndicator.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:0.9];
|
|
// self.loadIndicator.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:0.9];
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
- (void)didReceiveMemoryWarning {
|
|
@@ -84,6 +84,18 @@
|
|
|
if (self.shipArray.count == 0) {
|
|
if (self.shipArray.count == 0) {
|
|
|
[self loadData];
|
|
[self loadData];
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (self.mode == HomeModeKPI && self.KPIArray.count) {
|
|
|
|
|
+ NSString *str = [NSString stringWithFormat:@"%ld / %ld",self.currentKPI,self.KPIArray.count - 2];
|
|
|
|
|
+ self.parentViewController.title = str;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
+ [super viewWillDisappear:animated];
|
|
|
|
|
+
|
|
|
|
|
+ self.parentViewController.title = nil;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)clearNavigationbar {
|
|
- (void)clearNavigationbar {
|
|
@@ -120,22 +132,29 @@
|
|
|
self.shipTableView.tableFooterView = [UIView new];
|
|
self.shipTableView.tableFooterView = [UIView new];
|
|
|
|
|
|
|
|
[self.shipTableView registerNib:[UINib nibWithNibName:@"ShippingStatusCell" bundle:nil] forCellReuseIdentifier:SHIP_CELL_IDENTIFIER];
|
|
[self.shipTableView registerNib:[UINib nibWithNibName:@"ShippingStatusCell" bundle:nil] forCellReuseIdentifier:SHIP_CELL_IDENTIFIER];
|
|
|
- [self.shipTableView registerNib:[UINib nibWithNibName:@"KPIPieChartCell" bundle:nil] forCellReuseIdentifier:KPI_CELL_IDENTIFIER];
|
|
|
|
|
|
|
+ [self.shipTableView registerNib:[UINib nibWithNibName:@"KPITableCell" bundle:nil] forCellReuseIdentifier:KPI_CELL_IDENTIFIER];
|
|
|
|
|
|
|
|
-// self.shipTableView.canCancelContentTouches = NO;//是否可以中断touches
|
|
|
|
|
-// self.shipTableView.delaysContentTouches = NO;//是否延迟touches事件
|
|
|
|
|
|
|
|
|
|
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
|
|
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
|
|
|
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"loading data..."];
|
|
refresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"loading data..."];
|
|
|
[refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
|
|
[refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
|
|
|
[self.shipTableView addSubview:refresh];
|
|
[self.shipTableView addSubview:refresh];
|
|
|
self.refreshControl = refresh;
|
|
self.refreshControl = refresh;
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-- (void)configureCollectionView {
|
|
|
|
|
|
|
|
|
|
- UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.KPICollectionView.collectionViewLayout;
|
|
|
|
|
- layout.estimatedItemSize = self.KPICollectionView.bounds.size;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // KPI
|
|
|
|
|
+
|
|
|
|
|
+ self.KPITableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, w, CGFLOAT_MIN)];
|
|
|
|
|
+ self.KPITableView.tableFooterView = [UIView new];
|
|
|
|
|
+
|
|
|
|
|
+ [self.KPITableView registerNib:[UINib nibWithNibName:@"KPITableCell" bundle:nil] forCellReuseIdentifier:KPI_CELL_IDENTIFIER];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ UIRefreshControl *KPIRefresh = [[UIRefreshControl alloc] init];
|
|
|
|
|
+ KPIRefresh.attributedTitle = [[NSAttributedString alloc] initWithString:@"loading data..."];
|
|
|
|
|
+ [KPIRefresh addTarget:self action:@selector(KPIRefreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
|
|
|
|
|
+ [self.KPITableView addSubview:KPIRefresh];
|
|
|
|
|
+ self.KPIRefresh = KPIRefresh;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)registNotification {
|
|
- (void)registNotification {
|
|
@@ -188,73 +207,101 @@
|
|
|
// NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
|
|
// NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
|
|
|
|
|
|
|
|
// 避免重复刷新
|
|
// 避免重复刷新
|
|
|
- if (self.loadIndicator.isAnimating) {
|
|
|
|
|
|
|
+ if (self.refreshControl.isRefreshing) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// if (!self.refreshControl.isRefreshing) {
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
- [self.loadIndicator startAnimating];
|
|
|
|
|
|
|
+ [self.refreshControl beginRefreshing];
|
|
|
|
|
|
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
|
|
|
-// NSDictionary *json = [RANetwork requestHome];
|
|
|
|
|
|
|
+ NSDictionary *json = [RANetwork requestHome];
|
|
|
|
|
+
|
|
|
|
|
+// NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fake_home.json" ofType:nil]];
|
|
|
|
|
+// NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
|
|
|
|
|
|
|
|
- NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fake_home.json" ofType:nil]];
|
|
|
|
|
- NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
if (self.refreshControl.isRefreshing) {
|
|
if (self.refreshControl.isRefreshing) {
|
|
|
[self.refreshControl endRefreshing];
|
|
[self.refreshControl endRefreshing];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (self.loadIndicator.isAnimating) {
|
|
|
|
|
- [self.loadIndicator stopAnimating];
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
int result = [[json objectForKey:@"result"] intValue];
|
|
int result = [[json objectForKey:@"result"] intValue];
|
|
|
if (result == RESULT_TRUE) {
|
|
if (result == RESULT_TRUE) {
|
|
|
|
|
|
|
|
- self.monthArray = [json objectForKey:@"month"];
|
|
|
|
|
-
|
|
|
|
|
[self.shipArray removeAllObjects];
|
|
[self.shipArray removeAllObjects];
|
|
|
[self.shipArray addObjectsFromArray:[json objectForKey:@"container_list"]];
|
|
[self.shipArray addObjectsFromArray:[json objectForKey:@"container_list"]];
|
|
|
[self.shipTableView reloadData];
|
|
[self.shipTableView reloadData];
|
|
|
|
|
|
|
|
- [self.KPIArray removeAllObjects];
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ NSString *msg = [json objectForKey:@"err_msg"];
|
|
|
|
|
+ [RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
|
|
|
|
|
+ }
|
|
|
|
|
+ [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)loadKPIData {
|
|
|
|
|
+
|
|
|
|
|
+ if (self.KPIRefresh.isRefreshing) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [self.KPIRefresh beginRefreshing];
|
|
|
|
|
+
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary *json = [RANetwork requestKPI];
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+
|
|
|
|
|
+ if (self.KPIRefresh.isRefreshing) {
|
|
|
|
|
+ [self.KPIRefresh endRefreshing];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int result = [[json objectForKey:@"result"] intValue];
|
|
|
|
|
+ if (result == RESULT_TRUE) {
|
|
|
|
|
|
|
|
|
|
+ self.monthArray = [json objectForKey:@"month"];
|
|
|
|
|
+
|
|
|
|
|
+ [self.KPIArray removeAllObjects];
|
|
|
NSArray *kpiArr = [json objectForKey:@"KPI"];
|
|
NSArray *kpiArr = [json objectForKey:@"KPI"];
|
|
|
-// for (int i = 0; i < kpiArr.count; i++) {
|
|
|
|
|
-// NSMutableDictionary *item = [kpiArr objectAtIndex:i];
|
|
|
|
|
-// [self.KPIArray addObject:item];
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ [self.KPIArray addObject:[[kpiArr firstObject] mutableCopy]];
|
|
|
[self.KPIArray addObjectsFromArray:kpiArr];
|
|
[self.KPIArray addObjectsFromArray:kpiArr];
|
|
|
-
|
|
|
|
|
|
|
+ [self.KPIArray addObject:[[kpiArr lastObject] mutableCopy]];
|
|
|
|
|
|
|
|
- [self.KPICollectionView reloadData];
|
|
|
|
|
|
|
+
|
|
|
|
|
+ [self.KPITableView reloadData];
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
NSString *msg = [json objectForKey:@"err_msg"];
|
|
NSString *msg = [json objectForKey:@"err_msg"];
|
|
|
[RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
|
|
[RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
|
|
|
}
|
|
}
|
|
|
- self.emptyBtn.hidden = self.shipArray.count > 0;
|
|
|
|
|
- [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
|
|
|
|
|
|
|
+// self.emptyBtn.hidden = self.shipArray.count > 0;
|
|
|
|
|
+// [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Actinon
|
|
#pragma mark - Actinon
|
|
|
|
|
|
|
|
- (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
|
|
- (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
|
|
|
|
|
+
|
|
|
[self loadData];
|
|
[self loadData];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)KPIRefreshControlValueChanged:(UIRefreshControl *)refresh {
|
|
|
|
|
+ [self loadKPIData];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
- (void)searchItemClick:(id)sender {
|
|
- (void)searchItemClick:(id)sender {
|
|
|
|
|
|
|
|
ShipSearchController *searchVC = [ShipSearchController build];
|
|
ShipSearchController *searchVC = [ShipSearchController build];
|
|
@@ -263,20 +310,30 @@
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (IBAction)emptyBtnClick:(id)sender {
|
|
|
|
|
- self.emptyBtn.hidden = YES;
|
|
|
|
|
- [self loadData];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
- (IBAction)modeSegmentClick:(UISegmentedControl *)sender {
|
|
- (IBAction)modeSegmentClick:(UISegmentedControl *)sender {
|
|
|
|
|
|
|
|
if (sender.selectedSegmentIndex == 1) {
|
|
if (sender.selectedSegmentIndex == 1) {
|
|
|
|
|
+ self.mode = HomeModeKPI;
|
|
|
self.shipTableView.hidden = YES;
|
|
self.shipTableView.hidden = YES;
|
|
|
- self.KPICollectionView.hidden = NO;
|
|
|
|
|
|
|
+ self.KPITableView.hidden = NO;
|
|
|
|
|
+
|
|
|
|
|
+ if (self.KPIArray.count == 0) {
|
|
|
|
|
+ [self loadKPIData];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ NSString *str = [NSString stringWithFormat:@"%ld / %ld",self.currentKPI,self.KPIArray.count - 2];
|
|
|
|
|
+ self.parentViewController.title = str;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
- self.KPICollectionView.hidden = YES;
|
|
|
|
|
|
|
+ self.mode = HomeModeRecent;
|
|
|
|
|
+ self.KPITableView.hidden = YES;
|
|
|
self.shipTableView.hidden = NO;
|
|
self.shipTableView.hidden = NO;
|
|
|
|
|
+ self.parentViewController.title = nil;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self.shipTableView reloadData];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)switchMode:(id)sender {
|
|
- (void)switchMode:(id)sender {
|
|
@@ -306,7 +363,12 @@
|
|
|
#pragma mark - TableView DataSource && Delegate
|
|
#pragma mark - TableView DataSource && Delegate
|
|
|
|
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
|
- return self.shipArray.count;
|
|
|
|
|
|
|
+ if (self.shipTableView == tableView) {
|
|
|
|
|
+ return self.shipArray.count;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
@@ -315,21 +377,34 @@
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
- ShipingStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:SHIP_CELL_IDENTIFIER forIndexPath:indexPath];
|
|
|
|
|
-
|
|
|
|
|
- NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
|
|
|
|
|
-
|
|
|
|
|
- NSString *title = [item objectForKey:@"title"];
|
|
|
|
|
- NSString *icon = [item objectForKey:@"icon"];
|
|
|
|
|
- NSString *desc = [item objectForKey:@"description"];
|
|
|
|
|
- NSString *detail = [item objectForKey:@"detail"];
|
|
|
|
|
- NSString *date = [item objectForKey:@"date"];
|
|
|
|
|
- NSString *port = [item objectForKey:@"port"];
|
|
|
|
|
- NSInteger stage = [[item objectForKey:@"transport_stage"] integerValue];
|
|
|
|
|
-
|
|
|
|
|
- [[[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon] setTransportStage:stage];
|
|
|
|
|
|
|
+ if (self.shipTableView == tableView) {
|
|
|
|
|
+ ShipingStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:SHIP_CELL_IDENTIFIER forIndexPath:indexPath];
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary *item = [self.shipArray objectAtIndex:indexPath.section];
|
|
|
|
|
+
|
|
|
|
|
+ NSString *title = [item objectForKey:@"title"];
|
|
|
|
|
+ NSString *icon = [item objectForKey:@"icon"];
|
|
|
|
|
+ NSString *desc = [item objectForKey:@"description"];
|
|
|
|
|
+ NSString *detail = [item objectForKey:@"detail"];
|
|
|
|
|
+ NSString *date = [item objectForKey:@"date"];
|
|
|
|
|
+ NSString *port = [item objectForKey:@"port"];
|
|
|
|
|
+ NSInteger stage = [[item objectForKey:@"transport_stage"] integerValue];
|
|
|
|
|
+
|
|
|
|
|
+ [[[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon] setTransportStage:stage];
|
|
|
|
|
+
|
|
|
|
|
+ return cell;
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ KPITableCell *kpiCell = [tableView dequeueReusableCellWithIdentifier:KPI_CELL_IDENTIFIER forIndexPath:indexPath];
|
|
|
|
|
+ kpiCell.KPICollectionView.dataSource = self;
|
|
|
|
|
+ kpiCell.KPICollectionView.delegate = self;
|
|
|
|
|
+ [kpiCell.KPICollectionView reloadData];
|
|
|
|
|
+ if (self.KPIArray.count) {
|
|
|
|
|
+ [kpiCell.KPICollectionView setContentOffset:CGPointMake(self.currentKPI * kpiCell.KPICollectionView.bounds.size.width, 0) animated:NO];
|
|
|
|
|
+ }
|
|
|
|
|
+ return kpiCell;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return cell;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
|
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
|
@@ -347,6 +422,9 @@
|
|
|
//}
|
|
//}
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
|
|
|
|
+ if (self.shipTableView != tableView) {
|
|
|
|
|
+ return 0.f;
|
|
|
|
|
+ }
|
|
|
return 10;
|
|
return 10;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -355,11 +433,18 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
|
|
|
|
|
+ if (self.shipTableView != tableView) {
|
|
|
|
|
+ return tableView.bounds.size.height;
|
|
|
|
|
+ }
|
|
|
return 110;
|
|
return 110;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
|
|
+ if (self.shipTableView != tableView) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
// [params setObject:@"dumb" forKey:@"id"];
|
|
// [params setObject:@"dumb" forKey:@"id"];
|
|
@@ -418,7 +503,7 @@
|
|
|
|
|
|
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
|
|
- KPICell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:KPI_CELL_IDENTIFIER forIndexPath:indexPath];
|
|
|
|
|
|
|
+ KPICell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"KPICell" forIndexPath:indexPath];
|
|
|
NSMutableDictionary *item = [[self.KPIArray objectAtIndex:indexPath.item] mutableCopy];
|
|
NSMutableDictionary *item = [[self.KPIArray objectAtIndex:indexPath.item] mutableCopy];
|
|
|
[item setObject:self.monthArray forKey:@"month"];
|
|
[item setObject:self.monthArray forKey:@"month"];
|
|
|
[cell setInfoDic:item];
|
|
[cell setInfoDic:item];
|
|
@@ -433,48 +518,45 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
|
|
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
|
|
|
- return 5.0f;
|
|
|
|
|
|
|
+ return 0.0f;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
|
|
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
|
|
|
- return 5.0f;
|
|
|
|
|
|
|
+ return 0.0f;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - ScrollViewDelegate
|
|
#pragma mark - ScrollViewDelegate
|
|
|
|
|
|
|
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
|
-// if (scrollView == self.KPICollectionView) {
|
|
|
|
|
-// CGFloat w = scrollView.bounds.size.width;
|
|
|
|
|
-// CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
|
|
-// if (offsetX < w && offsetX >= 0) {
|
|
|
|
|
-// [self.KPICollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.KPIArray.count - 2 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
|
|
-// } else if (offsetX < (self.KPIArray.count * w) && offsetX >= ((self.KPIArray.count - 1) * w)) {
|
|
|
|
|
-// [self.KPICollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#pragma mark - KPIDelegate
|
|
|
|
|
-
|
|
|
|
|
-- (void)KPIWillShowPreItem {
|
|
|
|
|
- NSInteger index = [[self.KPICollectionView indexPathsForVisibleItems] firstObject].item;
|
|
|
|
|
- if (index == 0) {
|
|
|
|
|
- index = self.KPIArray.count - 1;
|
|
|
|
|
- } else {
|
|
|
|
|
- index--;
|
|
|
|
|
|
|
+ if (scrollView != self.shipTableView && [scrollView isKindOfClass:[UICollectionView class]]) {
|
|
|
|
|
+ UICollectionView *collectionView = (UICollectionView *)scrollView;
|
|
|
|
|
+ CGFloat w = scrollView.bounds.size.width;
|
|
|
|
|
+ CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
|
|
+ if (offsetX < w && offsetX >= 0) {
|
|
|
|
|
+ [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:self.KPIArray.count - 2 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
|
|
+ } else if (offsetX < (self.KPIArray.count * w) && offsetX >= ((self.KPIArray.count - 1) * w)) {
|
|
|
|
|
+ [collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- [self.KPICollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-- (void)KPIWillShowNextItem {
|
|
|
|
|
- NSInteger index = [[self.KPICollectionView indexPathsForVisibleItems] firstObject].item;
|
|
|
|
|
- if (index == self.KPIArray.count - 1) {
|
|
|
|
|
- index = 0;
|
|
|
|
|
- } else {
|
|
|
|
|
- index++;
|
|
|
|
|
|
|
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
|
|
|
+ if (scrollView != self.shipTableView && [scrollView isKindOfClass:[UICollectionView class]]) {
|
|
|
|
|
+// UICollectionView *collectionView = (UICollectionView *)scrollView;
|
|
|
|
|
+ CGFloat w = scrollView.bounds.size.width;
|
|
|
|
|
+ CGFloat offsetX = scrollView.contentOffset.x;
|
|
|
|
|
+ float f = floorf(offsetX / w);
|
|
|
|
|
+ NSInteger index = floorf(f + 0.5);
|
|
|
|
|
+ if (index == 0) {
|
|
|
|
|
+ index = self.KPIArray.count - 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (index == self.KPIArray.count - 1) {
|
|
|
|
|
+ index = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ self.currentKPI = index;
|
|
|
|
|
+ NSString *str = [NSString stringWithFormat:@"%ld / %ld",index,self.KPIArray.count - 2];
|
|
|
|
|
+ self.parentViewController.title = str;
|
|
|
}
|
|
}
|
|
|
- [self.KPICollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
@end
|