More UI updates for iOS 7 style feedback

This commit is contained in:
Andreas Linde
2013-09-10 18:08:24 +02:00
parent 2d3e1c503d
commit a0af921da4
4 changed files with 142 additions and 71 deletions

View File

@@ -75,8 +75,8 @@
NSInteger _userButtonSection; NSInteger _userButtonSection;
} }
- (id)init { - (instancetype)initWithStyle:(UITableViewStyle)style {
if ((self = [super init])) { if ((self = [super initWithStyle:style])) {
_manager = [BITHockeyManager sharedHockeyManager].feedbackManager; _manager = [BITHockeyManager sharedHockeyManager].feedbackManager;
_deleteButtonSection = -1; _deleteButtonSection = -1;
@@ -125,13 +125,13 @@
[self.tableView setBackgroundColor:[UIColor colorWithRed:0.82 green:0.84 blue:0.84 alpha:1]]; [self.tableView setBackgroundColor:[UIColor colorWithRed:0.82 green:0.84 blue:0.84 alpha:1]];
[self.tableView setSeparatorColor:[UIColor colorWithRed:0.79 green:0.79 blue:0.79 alpha:1]]; [self.tableView setSeparatorColor:[UIColor colorWithRed:0.79 green:0.79 blue:0.79 alpha:1]];
} else { } else {
[self.tableView setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]]; // [self.tableView setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
} }
if ([self.manager isPreiOS7Environment]) { if ([self.manager isPreiOS7Environment]) {
self.view.backgroundColor = DEFAULT_BACKGROUNDCOLOR; self.view.backgroundColor = DEFAULT_BACKGROUNDCOLOR;
} else { } else {
self.view.backgroundColor = DEFAULT_BACKGROUNDCOLOR_OS7; // self.view.backgroundColor = DEFAULT_BACKGROUNDCOLOR_OS7;
} }
id refreshClass = NSClassFromString(@"UIRefreshControl"); id refreshClass = NSClassFromString(@"UIRefreshControl");
@@ -381,21 +381,21 @@
#pragma mark - Table view data source #pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSInteger rows = 2; NSInteger sections = 2;
_deleteButtonSection = -1; _deleteButtonSection = -1;
_userButtonSection = -1; _userButtonSection = -1;
if ([self.manager isManualUserDataAvailable] || [self.manager didAskUserData]) { if ([self.manager isManualUserDataAvailable] || [self.manager didAskUserData]) {
_userButtonSection = rows; _userButtonSection = sections;
rows++; sections++;
} }
if ([self.manager numberOfMessages] > 0) { if ([self.manager numberOfMessages] > 0) {
_deleteButtonSection = rows; _deleteButtonSection = sections;
rows++; sections++;
} }
return rows; return sections;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -406,6 +406,32 @@
} }
} }
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (![self.manager isPreiOS7Environment]) {
if (section == 0) {
return 30;
}
}
return [super tableView:tableView heightForHeaderInSection:section];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if (![self.manager isPreiOS7Environment] && section == 0) {
UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 30.0f)];
UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(16.0f, 5.0f, self.view.frame.size.width - 32.0f, 25.0f)];
textLabel.text = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListLastUpdated"),
[self.manager lastCheck] ? [self.lastUpdateDateFormatter stringFromDate:[self.manager lastCheck]] : BITHockeyLocalizedString(@"HockeyFeedbackListNeverUpdated")];
textLabel.font = [UIFont systemFontOfSize:10];
textLabel.textColor = DEFAULT_TEXTCOLOR;
[containerView addSubview:textLabel];
return containerView;
}
return [super tableView:tableView viewForHeaderInSection:section];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MessageCell"; static NSString *CellIdentifier = @"MessageCell";
static NSString *LastUpdateIdentifier = @"LastUpdateCell"; static NSString *LastUpdateIdentifier = @"LastUpdateCell";
@@ -413,7 +439,7 @@
static NSString *ButtonBottomIdentifier = @"ButtonBottomCell"; static NSString *ButtonBottomIdentifier = @"ButtonBottomCell";
static NSString *ButtonDeleteIdentifier = @"ButtonDeleteCell"; static NSString *ButtonDeleteIdentifier = @"ButtonDeleteCell";
if (indexPath.section == 0 && indexPath.row == 1) { if (indexPath.section == 0 && indexPath.row == 1 && ![self.manager isPreiOS7Environment]) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LastUpdateIdentifier]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LastUpdateIdentifier];
if (!cell) { if (!cell) {
@@ -452,10 +478,19 @@
cell.textLabel.font = [UIFont systemFontOfSize:14]; cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.textLabel.numberOfLines = 0; cell.textLabel.numberOfLines = 0;
cell.accessoryType = UITableViewCellAccessoryNone; cell.accessoryType = UITableViewCellAccessoryNone;
if ([self.manager isPreiOS7Environment]) {
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else {
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
} }
// button // button
NSString *titleString = nil;
SEL actionSelector = nil;
UIColor *titleColor = BIT_RGBCOLOR(35, 111, 251);
UIButton *button = nil; UIButton *button = nil;
if ([self.manager isPreiOS7Environment]) { if ([self.manager isPreiOS7Environment]) {
button = [UIButton buttonWithType:UIButtonTypeCustom]; button = [UIButton buttonWithType:UIButtonTypeCustom];
@@ -470,38 +505,32 @@
[button setTitleColor:BUTTON_TEXTCOLOR forState:UIControlStateNormal]; [button setTitleColor:BUTTON_TEXTCOLOR forState:UIControlStateNormal];
[button setTitleShadowColor:BUTTON_TEXTCOLOR_SHADOW forState:UIControlStateNormal]; [button setTitleShadowColor:BUTTON_TEXTCOLOR_SHADOW forState:UIControlStateNormal];
} else {
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
button = [UIButton buttonWithType:UIButtonTypeSystem];
#endif
} }
if (indexPath.section == 0) { if (indexPath.section == 0) {
topGap = 22; topGap = 22;
if ([self.manager numberOfMessages] == 0) { if ([self.manager numberOfMessages] == 0) {
[button setTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButonWriteFeedback") forState:UIControlStateNormal]; titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButonWriteFeedback");
} else { } else {
[button setTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButonWriteResponse") forState:UIControlStateNormal]; titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButonWriteResponse");
} }
[button addTarget:self action:@selector(newFeedbackAction:) forControlEvents:UIControlEventTouchUpInside]; actionSelector = @selector(newFeedbackAction:);
} else if (indexPath.section == _userButtonSection) { } else if (indexPath.section == _userButtonSection) {
topGap = 6.0f; topGap = 6.0f;
NSString *title = @"";
if ([self.manager requireUserName] == BITFeedbackUserDataElementRequired || if ([self.manager requireUserName] == BITFeedbackUserDataElementRequired ||
([self.manager requireUserName] == BITFeedbackUserDataElementOptional && [self.manager userName] != nil) ([self.manager requireUserName] == BITFeedbackUserDataElementOptional && [self.manager userName] != nil)
) { ) {
title = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataWithName"), [self.manager userName] ?: @"-"]; titleString = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataWithName"), [self.manager userName] ?: @"-"];
} else if ([self.manager requireUserEmail] == BITFeedbackUserDataElementRequired || } else if ([self.manager requireUserEmail] == BITFeedbackUserDataElementRequired ||
([self.manager requireUserEmail] == BITFeedbackUserDataElementOptional && [self.manager userEmail] != nil) ([self.manager requireUserEmail] == BITFeedbackUserDataElementOptional && [self.manager userEmail] != nil)
) { ) {
title = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataWithEmail"), [self.manager userEmail] ?: @"-"]; titleString = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataWithEmail"), [self.manager userEmail] ?: @"-"];
} else if ([self.manager requireUserName] == BITFeedbackUserDataElementOptional) { } else if ([self.manager requireUserName] == BITFeedbackUserDataElementOptional) {
title = BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataSetName"); titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataSetName");
} else { } else {
title = BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataSetEmail"); titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButonUserDataSetEmail");
} }
[button setTitle:title forState:UIControlStateNormal]; actionSelector = @selector(setUserDataAction:);
[button addTarget:self action:@selector(setUserDataAction:) forControlEvents:UIControlEventTouchUpInside];
} else { } else {
topGap = 0.0f; topGap = 0.0f;
if ([self.manager isPreiOS7Environment]) { if ([self.manager isPreiOS7Environment]) {
@@ -513,18 +542,27 @@
[button setTitleColor:BUTTON_DELETE_TEXTCOLOR forState:UIControlStateNormal]; [button setTitleColor:BUTTON_DELETE_TEXTCOLOR forState:UIControlStateNormal];
[button setTitleShadowColor:BUTTON_DELETE_TEXTCOLOR_SHADOW forState:UIControlStateNormal]; [button setTitleShadowColor:BUTTON_DELETE_TEXTCOLOR_SHADOW forState:UIControlStateNormal];
} else {
[button setTitleColor:BUTTON_DELETE_BACKGROUNDCOLOR forState:UIControlStateNormal];
} }
[button setTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButonDeleteAllMessages") forState:UIControlStateNormal]; titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButonDeleteAllMessages");
[button addTarget:self action:@selector(deleteAllMessagesAction:) forControlEvents:UIControlEventTouchUpInside]; titleColor = BIT_RGBCOLOR(251, 35, 35);
actionSelector = @selector(deleteAllMessagesAction:);
} }
if ([self.manager isPreiOS7Environment]) {
if (titleString)
[button setTitle:titleString forState:UIControlStateNormal];
if (actionSelector)
[button addTarget:self action:actionSelector forControlEvents:UIControlEventTouchUpInside];
[button setFrame: CGRectMake( 10.0f, topGap + 12.0f, cell.frame.size.width - 20.0f, 42.0f)]; [button setFrame: CGRectMake( 10.0f, topGap + 12.0f, cell.frame.size.width - 20.0f, 42.0f)];
[cell addSubview:button]; [cell addSubview:button];
} else {
cell.textLabel.text = titleString;
cell.textLabel.textColor = titleColor;
}
if ([self.manager isPreiOS7Environment]) {
// status label or shadow lines // status label or shadow lines
if (indexPath.section == 0) { if (indexPath.section == 0) {
UILabel *statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 6, cell.frame.size.width, 28)]; UILabel *statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 6, cell.frame.size.width, 28)];
@@ -549,6 +587,7 @@
lineView1.autoresizingMask = UIViewAutoresizingFlexibleWidth; lineView1.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[cell addSubview:lineView1]; [cell addSubview:lineView1];
} }
}
return cell; return cell;
} else { } else {
@@ -577,10 +616,15 @@
cell.labelText.delegate = self; cell.labelText.delegate = self;
cell.labelText.userInteractionEnabled = YES; cell.labelText.userInteractionEnabled = YES;
if (
[self.manager isPreiOS7Environment] ||
(![self.manager isPreiOS7Environment] && indexPath.row != 0)
) {
UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 1)]; UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cell.frame.size.width, 1)];
lineView1.backgroundColor = BORDER_COLOR; lineView1.backgroundColor = BORDER_COLOR;
lineView1.autoresizingMask = UIViewAutoresizingFlexibleWidth; lineView1.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[cell addSubview:lineView1]; [cell addSubview:lineView1];
}
return cell; return cell;
} }
@@ -611,10 +655,16 @@
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0 ) { if (indexPath.section == 0 ) {
if ([self.manager isPreiOS7Environment])
return 87; return 87;
else
return 44;
} }
if (indexPath.section >= 2) { if (indexPath.section >= 2) {
if ([self.manager isPreiOS7Environment])
return 65; return 65;
else
return 44;
} }
BITFeedbackMessage *message = [self.manager messageAtIndex:indexPath.row]; BITFeedbackMessage *message = [self.manager messageAtIndex:indexPath.row];
@@ -623,6 +673,17 @@
return [BITFeedbackListViewCell heightForRowWithMessage:message tableViewWidth:self.view.frame.size.width]; return [BITFeedbackListViewCell heightForRowWithMessage:message tableViewWidth:self.view.frame.size.width];
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (![self.manager isPreiOS7Environment]) {
if (indexPath.section == 0) {
[self newFeedbackAction:self];
} else if (indexPath.section == _userButtonSection) {
[self setUserDataAction:self];
} else if (indexPath.section == _deleteButtonSection) {
[self deleteAllMessagesAction:self];
}
}
}
#pragma mark - BITAttributedLabelDelegate #pragma mark - BITAttributedLabelDelegate

View File

@@ -150,7 +150,11 @@
#pragma mark - Feedback Modal UI #pragma mark - Feedback Modal UI
- (BITFeedbackListViewController *)feedbackListViewController:(BOOL)modal { - (BITFeedbackListViewController *)feedbackListViewController:(BOOL)modal {
if ([self isPreiOS7Environment]) {
return [[BITFeedbackListViewController alloc] initWithModalStyle:modal]; return [[BITFeedbackListViewController alloc] initWithModalStyle:modal];
} else {
return [[BITFeedbackListViewController alloc] initWithStyle:UITableViewStyleGrouped modal:modal];
}
} }
- (void)showFeedbackListView { - (void)showFeedbackListView {

View File

@@ -12,6 +12,7 @@
@property (nonatomic, readwrite) BOOL modalAnimated; @property (nonatomic, readwrite) BOOL modalAnimated;
- (id)initWithModalStyle:(BOOL)modal; - (instancetype)initWithModalStyle:(BOOL)modal;
- (instancetype)initWithStyle:(UITableViewStyle)style modal:(BOOL)modal;
@end @end

View File

@@ -16,8 +16,8 @@
} }
- (id)init { - (instancetype)initWithStyle:(UITableViewStyle)style {
self = [super init]; self = [super initWithStyle:style];
if (self) { if (self) {
_modalAnimated = YES; _modalAnimated = YES;
_modal = NO; _modal = NO;
@@ -25,8 +25,8 @@
return self; return self;
} }
- (id)initWithModalStyle:(BOOL)modal { - (instancetype)initWithStyle:(UITableViewStyle)style modal:(BOOL)modal {
self = [self init]; self = [self initWithStyle:style];
if (self) { if (self) {
_modal = modal; _modal = modal;
@@ -41,6 +41,11 @@
return self; return self;
} }
- (instancetype)initWithModalStyle:(BOOL)modal {
self = [self initWithStyle:UITableViewStylePlain modal:modal];
return self;
}
#pragma mark - View lifecycle #pragma mark - View lifecycle