diff --git a/SCTrelloNavigation.xcodeproj/project.pbxproj b/SCTrelloNavigation.xcodeproj/project.pbxproj index 21c89a6..a8a6d3d 100644 --- a/SCTrelloNavigation.xcodeproj/project.pbxproj +++ b/SCTrelloNavigation.xcodeproj/project.pbxproj @@ -7,18 +7,18 @@ objects = { /* Begin PBXBuildFile section */ - F068ED671BEAF1FD00C18B86 /* UINavigationBar+Awesome.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED661BEAF1FD00C18B86 /* UINavigationBar+Awesome.m */; settings = {ASSET_TAGS = (); }; }; - F068ED6B1BEAF77200C18B86 /* TrelloListTabView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED6A1BEAF77200C18B86 /* TrelloListTabView.m */; settings = {ASSET_TAGS = (); }; }; - F068ED6F1BEAF88300C18B86 /* TrelloListItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED6E1BEAF88300C18B86 /* TrelloListItem.m */; settings = {ASSET_TAGS = (); }; }; - F068ED721BEAF92800C18B86 /* UIViewExt.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED711BEAF92800C18B86 /* UIViewExt.m */; settings = {ASSET_TAGS = (); }; }; - F068ED751BEAF9D100C18B86 /* TrelloListItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED741BEAF9D100C18B86 /* TrelloListItemView.m */; settings = {ASSET_TAGS = (); }; }; - F068ED791BEB356100C18B86 /* TrelloListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED781BEB356100C18B86 /* TrelloListView.m */; settings = {ASSET_TAGS = (); }; }; - F068ED7C1BEBACA400C18B86 /* TrelloView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED7B1BEBACA400C18B86 /* TrelloView.m */; settings = {ASSET_TAGS = (); }; }; - F068ED7F1BEC503900C18B86 /* TrelloListTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED7E1BEC503900C18B86 /* TrelloListTableView.m */; settings = {ASSET_TAGS = (); }; }; - F068ED821BEC65D800C18B86 /* UIImage+ImageWithColor.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED811BEC65D800C18B86 /* UIImage+ImageWithColor.m */; settings = {ASSET_TAGS = (); }; }; - F068ED851BEC948800C18B86 /* TrelloListIconView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED841BEC948800C18B86 /* TrelloListIconView.m */; settings = {ASSET_TAGS = (); }; }; - F068ED881BECA1A700C18B86 /* TrelloListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED871BECA1A700C18B86 /* TrelloListTableViewCell.m */; settings = {ASSET_TAGS = (); }; }; - F068ED8B1BECA43C00C18B86 /* TrelloListCellItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED8A1BECA43C00C18B86 /* TrelloListCellItem.m */; settings = {ASSET_TAGS = (); }; }; + F068ED671BEAF1FD00C18B86 /* UINavigationBar+Awesome.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED661BEAF1FD00C18B86 /* UINavigationBar+Awesome.m */; }; + F068ED6B1BEAF77200C18B86 /* TrelloListTabView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED6A1BEAF77200C18B86 /* TrelloListTabView.m */; }; + F068ED6F1BEAF88300C18B86 /* TrelloListItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED6E1BEAF88300C18B86 /* TrelloListItem.m */; }; + F068ED721BEAF92800C18B86 /* UIViewExt.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED711BEAF92800C18B86 /* UIViewExt.m */; }; + F068ED751BEAF9D100C18B86 /* TrelloListItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED741BEAF9D100C18B86 /* TrelloListItemView.m */; }; + F068ED791BEB356100C18B86 /* TrelloListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED781BEB356100C18B86 /* TrelloListView.m */; }; + F068ED7C1BEBACA400C18B86 /* TrelloView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED7B1BEBACA400C18B86 /* TrelloView.m */; }; + F068ED7F1BEC503900C18B86 /* TrelloListTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED7E1BEC503900C18B86 /* TrelloListTableView.m */; }; + F068ED821BEC65D800C18B86 /* UIImage+ImageWithColor.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED811BEC65D800C18B86 /* UIImage+ImageWithColor.m */; }; + F068ED851BEC948800C18B86 /* TrelloListIconView.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED841BEC948800C18B86 /* TrelloListIconView.m */; }; + F068ED881BECA1A700C18B86 /* TrelloListTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED871BECA1A700C18B86 /* TrelloListTableViewCell.m */; }; + F068ED8B1BECA43C00C18B86 /* TrelloListCellItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F068ED8A1BECA43C00C18B86 /* TrelloListCellItem.m */; }; F0C932841BEAE8C2006845CF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C932831BEAE8C2006845CF /* main.m */; }; F0C932871BEAE8C2006845CF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C932861BEAE8C2006845CF /* AppDelegate.m */; }; F0C9328A1BEAE8C2006845CF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0C932891BEAE8C2006845CF /* ViewController.m */; }; diff --git a/SCTrelloNavigation/Info.plist b/SCTrelloNavigation/Info.plist index 2da7e57..1875ee0 100644 --- a/SCTrelloNavigation/Info.plist +++ b/SCTrelloNavigation/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1 CFBundleSignature ???? CFBundleVersion diff --git a/SCTrelloNavigation/TrelloListTabView.h b/SCTrelloNavigation/TrelloListTabView.h index 003ee4e..b004ab9 100644 --- a/SCTrelloNavigation/TrelloListTabView.h +++ b/SCTrelloNavigation/TrelloListTabView.h @@ -17,11 +17,19 @@ @property (strong,nonatomic) NSMutableArray *listItemViews; @property (nonatomic) NSInteger selectedIndex; +/** + * 是否是缩略图模式 BOOL value to indicate whether the tab view is in brief mode or not. + */ @property (nonatomic) BOOL isBriefMode; + +/** + * 是否是折叠模式 BOOL value to indicate whether the tab view is folded or not. + */ @property (nonatomic) BOOL isFoldedMode; @property (copy) void (^HeaderDidSwitchCallBack)(); - (id)initWithFrame:(CGRect)frame withListArray:(NSArray *)listItems; - (void)selectBoardAtIndex:(NSInteger)index; +- (void)reloadData; @end diff --git a/SCTrelloNavigation/TrelloListTabView.m b/SCTrelloNavigation/TrelloListTabView.m index ce757c9..118b636 100644 --- a/SCTrelloNavigation/TrelloListTabView.m +++ b/SCTrelloNavigation/TrelloListTabView.m @@ -55,6 +55,29 @@ - (void)initSubViews } } +- (void)reloadData +{ + self.contentSize = CGSizeMake(70.0f + self.listItems.count * 30.0f, self.height); + for(TrelloListItemView *view in self.listItemViews) + { + [view removeFromSuperview]; + } + [self.listItemViews removeAllObjects]; + + CGFloat nextX = 70.0f; + for(TrelloListItem *t_item in self.listItems) + { + TrelloListItemView *view = [[TrelloListItemView alloc]initWithItem:t_item]; + CGRect frame = view.frame; + frame.origin.x = nextX; + view.frame = frame; + nextX += view.width; + [self addSubview:view]; + [self.listItemViews addObject:view]; + } + [self selectBoardAtIndex:self.selectedIndex]; +} + - (void)selectBoardAtIndex:(NSInteger)index { [UIView animateWithDuration:0.2f animations:^{ diff --git a/SCTrelloNavigation/TrelloListTableView.m b/SCTrelloNavigation/TrelloListTableView.m index 9cb5ace..56b45c7 100644 --- a/SCTrelloNavigation/TrelloListTableView.m +++ b/SCTrelloNavigation/TrelloListTableView.m @@ -16,6 +16,12 @@ - (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style listItem:(Trello if(self) { self.listItem = item; + self.backgroundColor = [UIColor clearColor]; + self.layer.cornerRadius = 5.0f; + self.layer.masksToBounds = YES; + self.separatorStyle = UITableViewCellSeparatorStyleNone; + self.showsHorizontalScrollIndicator = NO; + self.showsVerticalScrollIndicator = NO; UIView *t_view = [[UIView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, self.width, 30.0f)]; t_view.backgroundColor = Global_trelloGray; diff --git a/SCTrelloNavigation/TrelloListView.h b/SCTrelloNavigation/TrelloListView.h index f73bf09..f894e80 100644 --- a/SCTrelloNavigation/TrelloListView.h +++ b/SCTrelloNavigation/TrelloListView.h @@ -30,4 +30,5 @@ @property (copy) void (^HeaderDidFoldedCallBack)(); - (id)initWithFrame:(CGRect)frame index:(NSInteger)index listArray:(NSArray *)listItems; +- (void)reloadData; @end diff --git a/SCTrelloNavigation/TrelloListView.m b/SCTrelloNavigation/TrelloListView.m index 593b040..f99d95d 100644 --- a/SCTrelloNavigation/TrelloListView.m +++ b/SCTrelloNavigation/TrelloListView.m @@ -35,38 +35,12 @@ - (id)initWithFrame:(CGRect)frame index:(NSInteger)index listArray:(NSArray *)li self.listItems = [listItems mutableCopy]; - self.tableView = [[TrelloListTableView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, ScreenWidth - 60.0f, self.height) style:UITableViewStylePlain listItem:[listItems objectAtIndex:0]]; - - //注:这里高度加30是随便加的,高度会在往上滑动的过程中修复 - - //注:换成grouped效果也不错 = = - - _tableView.tag = 10001; - _tableView.delegate = self; - _tableView.dataSource = self; - _tableView.backgroundColor = [UIColor clearColor]; - _tableView.layer.cornerRadius = 5.0f; - _tableView.layer.masksToBounds = YES; - _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _tableView.showsHorizontalScrollIndicator = NO; - _tableView.showsVerticalScrollIndicator = NO; - [self addSubview:_tableView]; - - [self.visibleTableViewArray addObject:_tableView]; - - CGFloat nextX = self.tableView.right + 15.0f; - for(NSInteger i=1;i<5;i++) + CGFloat nextX = 0.0f; + for(NSInteger i=0;i=self.listItems.count) + { + TrelloListTableView *t_tableView = (TrelloListTableView *)[self.visibleTableViewArray objectAtIndex:i]; + [t_tableView removeFromSuperview]; + [indexSet addIndex:i]; + } + else + { + TrelloListTableView *t_tableView = (TrelloListTableView *)[self.visibleTableViewArray objectAtIndex:i]; + t_tableView.listItem = [self.listItems objectAtIndex:i]; + [t_tableView reloadData]; + } + } + [self.visibleTableViewArray removeObjectsAtIndexes:indexSet]; + } + else + { + self.contentSize = CGSizeMake(self.listItems.count * (ScreenWidth - 45.0f), self.height); + + for(NSInteger i=0;i=currentTableViewNumber) + { + TrelloListTableView *t_tableView = [[TrelloListTableView alloc]initWithFrame:CGRectMake(nextX, 0.0f, ScreenWidth - 60.0f, self.height) style:UITableViewStylePlain listItem:[self.listItems objectAtIndex:i]]; + t_tableView.delegate = self; + t_tableView.dataSource = self; + [self addSubview:t_tableView]; + + nextX = t_tableView.right + 15.0f; + [self.visibleTableViewArray addObject:t_tableView]; + } + else + { + TrelloListTableView *t_tableView = (TrelloListTableView *)[self.visibleTableViewArray objectAtIndex:i]; + t_tableView.listItem = [self.listItems objectAtIndex:i]; + [t_tableView reloadData]; + nextX = t_tableView.right + 15.0f; + } } - break; } } +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [(TrelloListTableView *)tableView listItem].rowNumber; +} + - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - switch (tableView.tag) { - case 10001: - { - return 1; - } - break; - default: - { - return 1; - } - break; - } + return 1; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - switch (tableView.tag) { - case 10001: - { - return 60.0f; - } - break; - default: - { - return 60.0f; - } - break; - } + return 60.0f; } - (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section diff --git a/SCTrelloNavigation/TrelloView.h b/SCTrelloNavigation/TrelloView.h index 482d9a0..f0ee204 100644 --- a/SCTrelloNavigation/TrelloView.h +++ b/SCTrelloNavigation/TrelloView.h @@ -11,13 +11,116 @@ #import "TrelloListTabView.h" #import "TrelloListView.h" #import "TrelloListTableView.h" +#import "TrelloListCellItem.h" +#import + +@class TrelloView; + +/** + * Each board has a parameter called Level, which refers to the height of rectangle displayed in the tab view above + */ +typedef NS_ENUM(NSInteger, SCTrelloBoardLevel) { + /** + * 1x + */ + SCTrelloBoardLevel1 = 0, + /** + * 2x + */ + SCTrelloBoardLevel2, + /** + * 3x + */ + SCTrelloBoardLevel3, + /** + * 4x + */ + SCTrelloBoardLevel4, + /** + * 5x + */ + SCTrelloBoardLevel5 +}; + +@protocol TrelloDataSource + +@required + +/** + * Return how many boards that you are going to display + * + * @param trelloView target trelloView + * + * @return NSInteger + */ +- (NSInteger)numberForBoardsInTrelloView:(TrelloView *)trelloView; + +/** + * Return how many rows each board is going to display + * + * @param trelloView target trelloView + * @param index index of the target trelloView + * + * @return NSInteger + */ +- (NSInteger)numberForRowsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index; + +/** + * Return the item that each row in each board is going to display. + * You can extend the TrelloListCellItem model to whatever you want, just customizing your own cell in table view datasource + * Enjoy yourself :) + * + * @param trelloView target trelloView + * @param index index of the target trelloView + * @param rowIndex index of the target row + * + * @return TrelloListCellItem + */ +- (TrelloListCellItem *)itemForRowsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index atRowIndex:(NSInteger)rowIndex; + +/** + * Return title of each board + * + * @param trelloView target trelloView + * @param index index of the target trelloView + * + * @return NSInteger + */ +- (NSString *)titleForBoardsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index; + +/** + * Return the level of each board + * + * @param trelloView target trelloView + * @param index index of the target trelloView + * + * @return SCTrelloBoardLevel + */ +- (SCTrelloBoardLevel)levelForRowsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index; + +@end @interface TrelloView : UIView -@property (nonatomic,strong) TrelloListTabView *tabView; -@property (nonatomic,strong) TrelloListView *listView; +@property (nonatomic, strong) TrelloListTabView *tabView; +@property (nonatomic, strong) TrelloListView *listView; @property (nonatomic) BOOL isFoldedMode; +@property (nonatomic, weak) id dataSource; + +/** + * Init method for newer version + * + * @param frame frame + * @param dataSource dataSource + * + * @return + */ +- (id)initWithFrame:(CGRect)frame dataSource:(id)dataSource; -- (id)initWithFrame:(CGRect)frame listArray:(NSArray *)listItems; - (void)switchMode; + +/** + * Dynamic refresh data source using this method + */ +- (void)reloadData; @end diff --git a/SCTrelloNavigation/TrelloView.m b/SCTrelloNavigation/TrelloView.m index c553818..f082ddb 100644 --- a/SCTrelloNavigation/TrelloView.m +++ b/SCTrelloNavigation/TrelloView.m @@ -13,98 +13,138 @@ @interface TrelloView () @implementation TrelloView -- (id)initWithFrame:(CGRect)frame listArray:(NSArray *)listItems +#pragma mark - Init method +- (id)initWithFrame:(CGRect)frame dataSource:(id)dataSource { self = [super initWithFrame:frame]; if(self) { - self.isFoldedMode = NO; - - self.tabView = [[TrelloListTabView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, ScreenWidth, 100.0f) withListArray:listItems]; - _tabView.backgroundColor = Global_trelloBlue; - [_tabView selectBoardAtIndex:0]; - - __weak TrelloView *weakSelf = self; - _tabView.HeaderDidSwitchCallBack = ^{ - [weakSelf switchMode]; - }; - - [self addSubview:_tabView]; + self.dataSource = dataSource; + [self initSubViewsWithItems:[self listItemArrayFromDataSource]]; + } + return self; +} + +- (void)reloadData +{ + NSMutableArray *items = [self listItemArrayFromDataSource]; + self.tabView.listItems = items; + self.listView.listItems = items; + [self animationBackToBriefMode]; + //... + [self.tabView reloadData]; + [self.listView reloadData]; +} + +- (NSMutableArray *)listItemArrayFromDataSource +{ + NSInteger boardNumber = [self.dataSource respondsToSelector:@selector(numberForBoardsInTrelloView:)] ? [self.dataSource numberForBoardsInTrelloView:self] : 0; + NSMutableArray *listItems = [NSMutableArray array]; + + for(NSInteger i=0;i - -@property (nonatomic,strong) TrelloView *trelloView; +@interface ViewController : UIViewController +@property (nonatomic, strong) TrelloView *trelloView; +@property (nonatomic, strong) NSMutableArray *dataArray; @end diff --git a/SCTrelloNavigation/ViewController.m b/SCTrelloNavigation/ViewController.m index 4b45ea0..e42319f 100644 --- a/SCTrelloNavigation/ViewController.m +++ b/SCTrelloNavigation/ViewController.m @@ -14,47 +14,23 @@ - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = Global_trelloDeepBlue; - UIBarButtonItem *search = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(search:)]; search.tintColor = [UIColor whiteColor]; self.navigationItem.rightBarButtonItem = search; // Do any additional setup after loading the view, typically from a nib. - TrelloListCellItem *cell_item_1_1 = [[TrelloListCellItem alloc] initWithContent:@"Login and Register function" image:nil type:SCTrelloCellItemGreen]; - TrelloListCellItem *cell_item_1_2 = [[TrelloListCellItem alloc] initWithContent:@"Upload and downLoad pictures" image:nil type:SCTrelloCellItemYellow]; - TrelloListCellItem *cell_item_1_3 = [[TrelloListCellItem alloc] initWithContent:@"Have a pleasant afternoon" image:[UIImage imageNamed:@"testImage3"] type:SCTrelloCellItemRed]; - - TrelloListCellItem *cell_item_2_1 = [[TrelloListCellItem alloc] initWithContent:@"This is a Trello Navigation Demo" image:nil type:SCTrelloCellItemGreen]; - TrelloListCellItem *cell_item_2_2 = [[TrelloListCellItem alloc] initWithContent:@"Some of it have been organized" image:nil type:SCTrelloCellItemYellow]; - TrelloListCellItem *cell_item_2_3 = [[TrelloListCellItem alloc] initWithContent:@"Use it as a Library" image:nil type:SCTrelloCellItemRed]; - TrelloListCellItem *cell_item_2_4 = [[TrelloListCellItem alloc] initWithContent:@"Displayed content is random created" image:nil type:SCTrelloCellItemYellowAndOrange]; - - TrelloListCellItem *cell_item_3_1 = [[TrelloListCellItem alloc] initWithContent:@"Make the interface more beautiful" image:nil type:SCTrelloCellItemGreen]; - TrelloListCellItem *cell_item_3_2 = [[TrelloListCellItem alloc] initWithContent:@"This feels awesome" image:[UIImage imageNamed:@"testImage2"] type:SCTrelloCellItemYellowAndOrange]; - - TrelloListCellItem *cell_item_4_1 = [[TrelloListCellItem alloc] initWithContent:@"Test this first demo" image:nil type:SCTrelloCellItemGreen]; - TrelloListCellItem *cell_item_4_2 = [[TrelloListCellItem alloc] initWithContent:@"Push project to github" image:nil type:SCTrelloCellItemYellow]; - TrelloListCellItem *cell_item_4_3 = [[TrelloListCellItem alloc] initWithContent:@"Have a pleasant afternoon" image:[UIImage imageNamed:@"testImage1"] type:SCTrelloCellItemRed]; - - NSMutableArray *t_array_1 = [NSMutableArray arrayWithObjects:cell_item_1_1,cell_item_1_2,cell_item_1_3, nil]; - NSMutableArray *t_array_2 = [NSMutableArray arrayWithObjects:cell_item_2_1,cell_item_2_2,cell_item_2_3,cell_item_2_4, nil]; - NSMutableArray *t_array_3 = [NSMutableArray arrayWithObjects:cell_item_3_1,cell_item_3_2, nil]; - NSMutableArray *t_array_4 = [NSMutableArray arrayWithObjects:cell_item_4_1,cell_item_4_2,cell_item_4_3, nil]; - - TrelloListItem *item_1 = [[TrelloListItem alloc]initWithTitle:@"BACKLOG" level:3 rowNumber:3 rowItems:t_array_1]; - TrelloListItem *item_2 = [[TrelloListItem alloc]initWithTitle:@"BRIEFS" level:5 rowNumber:4 rowItems:t_array_2]; - TrelloListItem *item_3 = [[TrelloListItem alloc]initWithTitle:@"DESIGN" level:2 rowNumber:2 rowItems:t_array_3]; - TrelloListItem *item_4 = [[TrelloListItem alloc]initWithTitle:@"USER TESTING" level:4 rowNumber:3 rowItems:t_array_4]; - TrelloListItem *item_5 = [[TrelloListItem alloc]initWithTitle:@"PRODUCT" level:3 rowNumber:2 rowItems:t_array_3]; + [self importDataArray]; // 初始化其实只要一句话的 - self.trelloView = [[TrelloView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, ScreenWidth, ScreenHeight) listArray:@[item_1,item_2,item_3,item_4,item_5]]; + self.trelloView = [[TrelloView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, ScreenWidth, ScreenHeight) dataSource:self]; [self.view addSubview:_trelloView]; } - (void)search:(id)sender { - //[_trelloView switchMode]; + // Test for reload data +// [self.dataArray removeLastObject]; +// [self.trelloView reloadData]; } - (void)viewWillAppear:(BOOL)animated @@ -75,4 +51,119 @@ - (void)didReceiveMemoryWarning { // Dispose of any resources that can be recreated. } +#pragma mark - TrelloDataSource Method +- (NSInteger)numberForBoardsInTrelloView:(TrelloView *)trelloView +{ + return self.dataArray.count; +} + +- (NSInteger)numberForRowsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index +{ + switch (index) { + case 0: + case 3: + return 3; + break; + case 2: + case 4: + return 2; + break; + case 1: + return 4; + break; + default: + return 0; + break; + } +} + +- (TrelloListCellItem *)itemForRowsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index atRowIndex:(NSInteger)rowIndex; +{ + // If you want to dynamic customize your cell, you can extend the TrelloListCellItem Class to meet more requirements of your own and customize your dataArray + return [[self.dataArray objectAtIndex:index] objectAtIndex:rowIndex]; +} + +- (NSString *)titleForBoardsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index +{ + switch (index) { + case 0: + { + return @"BACKLOG"; + } + break; + case 1: + { + return @"BRIEFS"; + } + break; + case 2: + { + return @"DESIGN"; + } + break; + case 3: + { + return @"USER TESTING"; + } + break; + case 4: + { + return @"PRODUCT"; + } + break; + default: + return nil; + break; + } +} + +- (SCTrelloBoardLevel)levelForRowsInTrelloView:(TrelloView *)trelloView atBoardIndex:(NSInteger)index +{ + switch (index) { + case 0: + return SCTrelloBoardLevel3; + break; + case 3: + return SCTrelloBoardLevel4; + break; + case 2: + return SCTrelloBoardLevel2; + break; + case 4: + return SCTrelloBoardLevel3; + break; + case 1: + return SCTrelloBoardLevel5; + break; + default: + return SCTrelloBoardLevel1; + break; + } +} + +- (void)importDataArray +{ + TrelloListCellItem *cell_item_1_1 = [[TrelloListCellItem alloc] initWithContent:@"Login and Register function" image:nil type:SCTrelloCellItemGreen]; + TrelloListCellItem *cell_item_1_2 = [[TrelloListCellItem alloc] initWithContent:@"Upload and downLoad pictures" image:nil type:SCTrelloCellItemYellow]; + TrelloListCellItem *cell_item_1_3 = [[TrelloListCellItem alloc] initWithContent:@"Have a pleasant afternoon" image:[UIImage imageNamed:@"testImage3"] type:SCTrelloCellItemRed]; + + TrelloListCellItem *cell_item_2_1 = [[TrelloListCellItem alloc] initWithContent:@"This is a Trello Navigation Demo" image:nil type:SCTrelloCellItemGreen]; + TrelloListCellItem *cell_item_2_2 = [[TrelloListCellItem alloc] initWithContent:@"Some of it have been organized" image:nil type:SCTrelloCellItemYellow]; + TrelloListCellItem *cell_item_2_3 = [[TrelloListCellItem alloc] initWithContent:@"Use it as a Library" image:nil type:SCTrelloCellItemRed]; + TrelloListCellItem *cell_item_2_4 = [[TrelloListCellItem alloc] initWithContent:@"Displayed content is random created" image:nil type:SCTrelloCellItemYellowAndOrange]; + + TrelloListCellItem *cell_item_3_1 = [[TrelloListCellItem alloc] initWithContent:@"Make the interface more beautiful" image:nil type:SCTrelloCellItemGreen]; + TrelloListCellItem *cell_item_3_2 = [[TrelloListCellItem alloc] initWithContent:@"This feels awesome" image:[UIImage imageNamed:@"testImage2"] type:SCTrelloCellItemYellowAndOrange]; + + TrelloListCellItem *cell_item_4_1 = [[TrelloListCellItem alloc] initWithContent:@"Test this first demo" image:nil type:SCTrelloCellItemGreen]; + TrelloListCellItem *cell_item_4_2 = [[TrelloListCellItem alloc] initWithContent:@"Push project to github" image:nil type:SCTrelloCellItemYellow]; + TrelloListCellItem *cell_item_4_3 = [[TrelloListCellItem alloc] initWithContent:@"Have a pleasant afternoon" image:[UIImage imageNamed:@"testImage1"] type:SCTrelloCellItemRed]; + + NSMutableArray *t_array_1 = [NSMutableArray arrayWithObjects:cell_item_1_1,cell_item_1_2,cell_item_1_3, nil]; + NSMutableArray *t_array_2 = [NSMutableArray arrayWithObjects:cell_item_2_1,cell_item_2_2,cell_item_2_3,cell_item_2_4, nil]; + NSMutableArray *t_array_3 = [NSMutableArray arrayWithObjects:cell_item_3_1,cell_item_3_2, nil]; + NSMutableArray *t_array_4 = [NSMutableArray arrayWithObjects:cell_item_4_1,cell_item_4_2,cell_item_4_3, nil]; + + self.dataArray = [NSMutableArray arrayWithObjects:t_array_1,t_array_2,t_array_3,t_array_4,t_array_3, nil]; +} @end