Settings: Adjust the section header display.

Update the section header label style and layout.
This commit is contained in:
giomfo 2016-08-11 13:59:17 +02:00
parent 36fc1cd743
commit 154f0e8eb3
3 changed files with 68 additions and 67 deletions

View file

@ -134,7 +134,7 @@
<scene sceneID="4CK-43-kSo">
<objects>
<tableViewController id="1TJ-Md-cjN" customClass="SettingsViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="etG-ZU-b2r">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="24" sectionFooterHeight="24" id="etG-ZU-b2r">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.93725490196078431" green="0.93725490196078431" blue="0.95686274509803926" alpha="1" colorSpace="calibratedRGB"/>

View file

@ -197,6 +197,8 @@ NSString *const kRoomSettingsAdvancedCellViewIdentifier = @"kRoomSettingsAdvance
roomAddresses = [NSMutableArray array];
self.tableView.backgroundColor = kVectorColorLightGrey;
[self.tableView registerClass:MXKTableViewCellWithLabelAndSwitch.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndSwitch defaultReuseIdentifier]];
[self.tableView registerClass:MXKTableViewCellWithLabelAndMXKImageView.class forCellReuseIdentifier:[MXKTableViewCellWithLabelAndMXKImageView defaultReuseIdentifier]];
@ -1585,6 +1587,17 @@ NSString *const kRoomSettingsAdvancedCellViewIdentifier = @"kRoomSettingsAdvance
return nil;
}
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
if ([view isKindOfClass:UITableViewHeaderFooterView.class])
{
// Customize label style
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view;
tableViewHeaderFooterView.textLabel.textColor = kVectorTextColorBlack;
tableViewHeaderFooterView.textLabel.font = [UIFont systemFontOfSize:15];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == ROOM_SETTINGS_BANNED_USERS_SECTION_INDEX && bannedMembers.count == 0)

View file

@ -1015,6 +1015,56 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
return cell;
}
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX)
{
return NSLocalizedStringFromTable(@"settings_user_settings", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX)
{
return NSLocalizedStringFromTable(@"settings_notifications_settings", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX)
{
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
if (session.ignoredUsers.count)
{
return NSLocalizedStringFromTable(@"settings_ignored_users", @"Vector", nil);
}
else
{
// Hide this section
return nil;
}
}
else if (section == SETTINGS_SECTION_ADVANCED_INDEX)
{
return NSLocalizedStringFromTable(@"settings_advanced", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_OTHER_INDEX)
{
return NSLocalizedStringFromTable(@"settings_other", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_LABS_INDEX)
{
return NSLocalizedStringFromTable(@"settings_labs", @"Vector", nil);
}
return nil;
}
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section
{
if ([view isKindOfClass:UITableViewHeaderFooterView.class])
{
// Customize label style
UITableViewHeaderFooterView *tableViewHeaderFooterView = (UITableViewHeaderFooterView*)view;
tableViewHeaderFooterView.textLabel.textColor = kVectorTextColorBlack;
tableViewHeaderFooterView.textLabel.font = [UIFont systemFontOfSize:15];
}
}
#pragma mark - UITableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
@ -1039,13 +1089,9 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
return 50;
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == SETTINGS_SECTION_SIGN_OUT_INDEX)
{
return 30;
}
else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX)
if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX)
{
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
if (session.ignoredUsers.count == 0)
@ -1054,8 +1100,8 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
return SECTION_TITLE_PADDING_WHEN_HIDDEN;
}
}
return 60;
return [super tableView:tableView heightForHeaderInSection:section];
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
@ -1073,64 +1119,6 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
return [super tableView:tableView heightForFooterInSection:section];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *sectionHeader = [[UIView alloc] initWithFrame:[tableView rectForHeaderInSection:section]];
sectionHeader.backgroundColor = kVectorColorLightGrey;
if (section == SETTINGS_SECTION_SIGN_OUT_INDEX)
{
return sectionHeader;
}
UILabel *sectionLabel = [[UILabel alloc] init];
sectionLabel.font = [UIFont boldSystemFontOfSize:16];
sectionLabel.backgroundColor = [UIColor clearColor];
if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX)
{
sectionLabel.text = NSLocalizedStringFromTable(@"settings_user_settings", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX)
{
sectionLabel.text = NSLocalizedStringFromTable(@"settings_notifications_settings", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX)
{
MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
if (session.ignoredUsers.count)
{
sectionLabel.text = NSLocalizedStringFromTable(@"settings_ignored_users", @"Vector", nil);
}
else
{
// Hide this section
sectionHeader = nil;
}
}
else if (section == SETTINGS_SECTION_ADVANCED_INDEX)
{
sectionLabel.text = NSLocalizedStringFromTable(@"settings_advanced", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_OTHER_INDEX)
{
sectionLabel.text = NSLocalizedStringFromTable(@"settings_other", @"Vector", nil);
}
else if (section == SETTINGS_SECTION_LABS_INDEX)
{
sectionLabel.text = NSLocalizedStringFromTable(@"settings_labs", @"Vector", nil);
}
if (sectionHeader)
{
[sectionLabel sizeToFit];
sectionLabel.frame = CGRectMake(10, sectionHeader.frame.size.height - sectionLabel.frame.size.height - 5, sectionHeader.frame.size.width - 20, sectionLabel.frame.size.height);
[sectionHeader addSubview:sectionLabel];
}
return sectionHeader;
}
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (self.tableView == aTableView)