Refine app settings view.

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

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

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

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

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

Loading…
Cancel
Save