Refine app settings view.

pull/1/head
Matthew Chen 7 years ago
parent 20d1d11259
commit f6eb8dfe72

@ -137,39 +137,38 @@
[weakSelf showAdvanced];
}]];
} else {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
cell.textLabel.text = NSLocalizedString(@"NETWORK_STATUS_HEADER", @"");
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UILabel *accessoryLabel = [UILabel new];
accessoryLabel.font = [UIFont ows_regularFontWithSize:18.f];
if (TSAccountManager.sharedInstance.isDeregistered) {
accessoryLabel.text = NSLocalizedString(
@"NETWORK_STATUS_DEREGISTERED", @"Error indicating that this device is no longer registered.");
accessoryLabel.textColor = [UIColor ows_redColor];
} else {
switch ([TSSocketManager sharedManager].state) {
case SocketManagerStateClosed:
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @"");
accessoryLabel.textColor = [UIColor ows_redColor];
break;
case SocketManagerStateConnecting:
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @"");
accessoryLabel.textColor = [UIColor ows_yellowColor];
break;
case SocketManagerStateOpen:
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @"");
accessoryLabel.textColor = [UIColor ows_greenColor];
break;
}
}
[accessoryLabel sizeToFit];
cell.accessoryView = accessoryLabel;
return cell;
}
actionBlock:nil]];
[section addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = NSLocalizedString(@"NETWORK_STATUS_HEADER", @"");
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UILabel *accessoryLabel = [UILabel new];
accessoryLabel.font = [UIFont ows_regularFontWithSize:18.f];
if (TSAccountManager.sharedInstance.isDeregistered) {
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_DEREGISTERED",
@"Error indicating that this device is no longer registered.");
accessoryLabel.textColor = [UIColor ows_redColor];
} else {
switch ([TSSocketManager sharedManager].state) {
case SocketManagerStateClosed:
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @"");
accessoryLabel.textColor = [UIColor ows_redColor];
break;
case SocketManagerStateConnecting:
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @"");
accessoryLabel.textColor = [UIColor ows_yellowColor];
break;
case SocketManagerStateOpen:
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @"");
accessoryLabel.textColor = [UIColor ows_greenColor];
break;
}
}
[accessoryLabel sizeToFit];
cell.accessoryView = accessoryLabel;
return cell;
}
actionBlock:nil]];
}
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE",
@ -251,7 +250,7 @@
{
return [OWSTableItem
itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -276,7 +275,7 @@
- (UITableViewCell *)profileHeaderCell
{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -316,7 +315,7 @@
NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager localProfileName];
if (localProfileName.length > 0) {
titleLabel.text = localProfileName;
titleLabel.textColor = [UIColor blackColor];
titleLabel.textColor = [UIColor ows_themeForegroundColor];
titleLabel.font = [UIFont ows_dynamicTypeTitle2Font];
} else {
titleLabel.text = NSLocalizedString(
@ -331,7 +330,7 @@
const CGFloat kSubtitlePointSize = 12.f;
UILabel *subtitleLabel = [UILabel new];
subtitleLabel.textColor = [UIColor ows_darkGrayColor];
subtitleLabel.textColor = [UIColor ows_themeSecondaryColor];
subtitleLabel.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize];
subtitleLabel.attributedText = [[NSAttributedString alloc]
initWithString:[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:[TSAccountManager

@ -215,6 +215,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[self updateReminderViews];
}
#pragma mark - Theme
- (void)themeDidChange:(id)notification
{
OWSAssertIsOnMainThread();
@ -223,8 +225,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[self.tableView reloadData];
}
#pragma mark - Theme
- (void)applyTheme
{
OWSAssertIsOnMainThread();

@ -52,6 +52,8 @@ typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)(void);
@property (nonatomic, weak) UIViewController *tableViewController;
+ (UITableViewCell *)newCell;
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell

@ -4,6 +4,7 @@
#import "OWSTableViewController.h"
#import "OWSNavigationController.h"
#import "UIColor+OWS.h"
#import "UIFont+OWS.h"
#import "UIView+OWS.h"
@ -97,6 +98,15 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
@implementation OWSTableItem
+ (UITableViewCell *)newCell
{
UITableViewCell *cell = [UITableViewCell new];
cell.backgroundColor = [UIColor ows_themeBackgroundColor];
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor ows_themeForegroundColor];
return cell;
}
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(title.length > 0);
@ -163,10 +173,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.accessoryType = accessoryType;
return cell;
};
@ -198,7 +206,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
reuseIdentifier:@"UITableViewCellStyleValue1"];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.textColor = [UIColor ows_themeForegroundColor];
cell.detailTextLabel.text = detailText;
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;
@ -223,10 +231,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
}
};
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
};
@ -252,10 +258,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
return cell;
};
return item;
@ -267,13 +271,14 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
// These cells look quite different.
//
// Smaller font.
cell.textLabel.font = [UIFont ows_regularFontWithSize:15.f];
// Soft color.
// TODO: Theme, review with design.
cell.textLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
// Centered.
cell.textLabel.textAlignment = NSTextAlignmentCenter;
@ -298,10 +303,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.userInteractionEnabled = NO;
return cell;
};
@ -315,14 +318,12 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
UILabel *accessoryLabel = [UILabel new];
accessoryLabel.text = accessoryText;
accessoryLabel.textColor = [UIColor lightGrayColor];
accessoryLabel.textColor = [UIColor ows_themeSecondaryColor];
accessoryLabel.font = [UIFont ows_regularFontWithSize:16.0f];
accessoryLabel.textAlignment = NSTextAlignmentRight;
[accessoryLabel sizeToFit];
@ -352,10 +353,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new];
__weak id weakTarget = target;
item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new];
UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
UISwitch *cellSwitch = [UISwitch new];
cell.accessoryView = cellSwitch;
@ -460,6 +459,18 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
[self.tableView autoPinEdgesToSuperviewEdges];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kOWSTableCellIdentifier];
[self applyTheme];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange:)
name:NSNotificationNameThemeDidChange
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillAppear:(BOOL)animated
@ -672,6 +683,24 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
[self.delegate tableViewWillBeginDragging];
}
#pragma mark - Theme
- (void)themeDidChange:(id)notification
{
OWSAssertIsOnMainThread();
[self applyTheme];
[self.tableView reloadData];
}
- (void)applyTheme
{
OWSAssertIsOnMainThread();
self.view.backgroundColor = UIColor.ows_themeBackgroundColor;
self.tableView.backgroundColor = UIColor.ows_themeBackgroundColor;
}
@end
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save