Skip to content

Commit

Permalink
[Optimize]optimize demo UI
Browse files Browse the repository at this point in the history
  • Loading branch information
weng1252 committed Jun 21, 2017
1 parent 8567fc4 commit e4ff607
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
Binary file not shown.
8 changes: 0 additions & 8 deletions WZLBadgeDemo/TableViewDataSource.m
Expand Up @@ -62,14 +62,6 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
return headTitles[section];
}

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
if (section == [self.dataItems count] - 1) {
return @"Select cell to clear badge.";
}
return nil;
}

#pragma mark - delegate of UITableView
//to be simple, I also add delegate into datasource.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down
8 changes: 3 additions & 5 deletions WZLBadgeDemo/ViewController.m
Expand Up @@ -28,7 +28,6 @@ - (void)viewDidLoad {
[self loadTableViewDataSource];
}


#pragma mark -- private methods
- (void)setup
{
Expand Down Expand Up @@ -56,6 +55,7 @@ - (NSMutableArray *)prepareDataItems
NSMutableArray *staticBadges = [NSMutableArray array];
NSMutableArray *dynamicBadges = [NSMutableArray array];

// static badge configure
WBadgeStyle styles[] = {WBadgeStyleRedDot, WBadgeStyleNew, WBadgeStyleNumber, WBadgeStyleNumber};
for (NSInteger i = 0; i < sizeof(styles) / sizeof(styles[0]); i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
Expand All @@ -74,9 +74,7 @@ - (NSMutableArray *)prepareDataItems
[staticBadges addObject:btn];
}

// mutle tableview and collectionview to embed


// animating badge config
WBadgeAnimType animations[] = {WBadgeAnimTypeShake, WBadgeAnimTypeBounce, WBadgeAnimTypeBreathe, WBadgeAnimTypeScale};
for (NSInteger i = 0; i < sizeof(animations) / sizeof(animations[0]); i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
Expand Down Expand Up @@ -108,7 +106,7 @@ - (NSMutableArray *)prepareDataItems
#pragma mark - tableView delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([indexPath isEqual:[NSIndexPath indexPathForRow:0 inSection:2]]) {
[self presentViewController:[TableViewCollectionViewController new] animated:NO completion:nil];
[self.navigationController pushViewController:[TableViewCollectionViewController new] animated:YES];

}

Expand Down
6 changes: 3 additions & 3 deletions WZLBadgeDemo/examples/TableViewCollectionViewController.m
Expand Up @@ -9,7 +9,6 @@
#import "TableViewCollectionViewController.h"
#import "WZLBadgeImport.h"

//tableview 中有collectionView
@interface TableViewCollectionViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
Expand All @@ -24,6 +23,7 @@ @implementation TableViewCollectionViewController
- (void)viewDidLoad {
[super viewDidLoad];

self.title = @"test cell reuse";
self.view.backgroundColor = [UIColor whiteColor];

self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
Expand All @@ -50,7 +50,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class]) forIndexPath:indexPath];
cell.textLabel.text = @"hello words";
cell.textLabel.backgroundColor = [UIColor blueColor];
cell.textLabel.backgroundColor = [UIColor whiteColor];
cell.detailTextLabel.text = @"description text";
cell.detailTextLabel.backgroundColor = [UIColor greenColor];

Expand Down Expand Up @@ -81,7 +81,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 80.f;
return 60.f;
}

@end

0 comments on commit e4ff607

Please sign in to comment.