Commit f98a4a32 authored by gambard's avatar gambard Committed by Commit Bot

[iOS] Merge Settings multilines cells

Several cells were very similar in settings. This CL is a first attempt
to merge them.
It removes the CardMultilineItem and EncryptionItem, using the
TableViewTextItem instead.

Bug: 925357
Change-Id: I53b787a3a362696eec3112981b90093e45f314ca
Reviewed-on: https://chromium-review.googlesource.com/c/1443012
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#627988}
parent 71d81bd2
......@@ -10,16 +10,12 @@ source_set("cells") {
"autofill_data_item.mm",
"byo_textfield_item.h",
"byo_textfield_item.mm",
"card_multiline_item.h",
"card_multiline_item.mm",
"clear_browsing_data_constants.h",
"clear_browsing_data_constants.mm",
"clear_browsing_data_item.h",
"clear_browsing_data_item.mm",
"copied_to_chrome_item.h",
"copied_to_chrome_item.mm",
"encryption_item.h",
"encryption_item.mm",
"passphrase_error_item.h",
"passphrase_error_item.mm",
"settings_cells_constants.h",
......@@ -77,10 +73,8 @@ source_set("unit_tests") {
sources = [
"autofill_data_item_unittest.mm",
"byo_textfield_item_unittest.mm",
"card_multiline_item_unittest.mm",
"clear_browsing_data_item_unittest.mm",
"copied_to_chrome_item_unittest.mm",
"encryption_item_unittest.mm",
"passphrase_error_item_unittest.mm",
"settings_multiline_detail_item_unittest.mm",
"text_and_error_item_unittest.mm",
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_CARD_MULTILINE_ITEM_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_CARD_MULTILINE_ITEM_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// Item to display a multiline text, presented in the card style.
@interface CardMultilineItem : TableViewItem
// The text to display.
@property(nonatomic, copy) NSString* text;
@end
@interface CardMultilineCell : UITableViewCell
// UILabel corresponding to |text| from the item.
@property(nonatomic, readonly, strong) UILabel* textLabel;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_CARD_MULTILINE_ITEM_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Padding used on the leading and trailing edges of the cell.
const CGFloat kHorizontalPadding = 16;
// Padding used on the top and bottom edges of the cell.
const CGFloat kVerticalPadding = 16;
} // namespace
@implementation CardMultilineItem
@synthesize text = _text;
- (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type];
if (self) {
self.cellClass = [CardMultilineCell class];
}
return self;
}
#pragma mark TableViewItem
- (void)configureCell:(CardMultilineCell*)cell
withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = self.text;
}
@end
@implementation CardMultilineCell
@synthesize textLabel = _textLabel;
- (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UIView* contentView = self.contentView;
_textLabel = [[UILabel alloc] init];
_textLabel.translatesAutoresizingMaskIntoConstraints = NO;
_textLabel.numberOfLines = 0;
_textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_textLabel.adjustsFontForContentSizeCategory = YES;
[contentView addSubview:_textLabel];
// Set up the constraints.
[NSLayoutConstraint activateConstraints:@[
[_textLabel.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor
constant:kHorizontalPadding],
[_textLabel.trailingAnchor
constraintEqualToAnchor:contentView.trailingAnchor
constant:-kHorizontalPadding],
]];
AddOptionalVerticalPadding(contentView, _textLabel, kVerticalPadding);
}
return self;
}
// Implements -layoutSubviews as per instructions in documentation for
// +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:].
- (void)layoutSubviews {
[super layoutSubviews];
// Adjust the text label preferredMaxLayoutWidth when the parent's width
// changes, for instance on screen rotation.
CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds);
self.textLabel.preferredMaxLayoutWidth = parentWidth - 2 * kHorizontalPadding;
// Re-layout with the new preferred width to allow the label to adjust its
// height.
[super layoutSubviews];
}
@end
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
using CardMultilineItemTest = PlatformTest;
// Tests that the text is honoured after a call to |configureCell:|.
TEST_F(CardMultilineItemTest, ConfigureCell) {
CardMultilineItem* item = [[CardMultilineItem alloc] initWithType:0];
NSString* text = @"Test Disclaimer";
item.text = text;
id cell = [[[item cellClass] alloc] init];
ASSERT_TRUE([cell isMemberOfClass:[CardMultilineCell class]]);
CardMultilineCell* disclaimerCell = static_cast<CardMultilineCell*>(cell);
EXPECT_FALSE(disclaimerCell.textLabel.text);
[item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]];
EXPECT_NSEQ(text, disclaimerCell.textLabel.text);
}
// Tests that the text label of an CardMultilineCell spans multiple
// lines.
TEST_F(CardMultilineItemTest, MultipleLines) {
CardMultilineCell* cell = [[CardMultilineCell alloc] init];
EXPECT_EQ(0, cell.textLabel.numberOfLines);
}
} // namespace
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_ENCRYPTION_ITEM_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_ENCRYPTION_ITEM_H_
#import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// Item displaying possible options in the Sync Encryption screen.
@interface EncryptionItem : TableViewItem
// The text to display.
@property(nonatomic, copy) NSString* text;
// Whether or not the cell is enabled. Disabled cells are drawn with dimmed
// text.
@property(nonatomic, assign, getter=isEnabled) BOOL enabled;
@end
// The cell associated to |EncryptionCell|.
@interface EncryptionCell : UITableViewCell
// UILabel corresponding to |text| from the item.
@property(nonatomic, readonly, strong) UILabel* textLabel;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_ENCRYPTION_ITEM_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation EncryptionItem
@synthesize text = _text;
@synthesize enabled = _enabled;
- (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type];
if (self) {
self.cellClass = [EncryptionCell class];
self.enabled = YES;
self.accessibilityTraits |= UIAccessibilityTraitButton;
}
return self;
}
- (void)configureCell:(EncryptionCell*)cell
withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler];
cell.textLabel.text = self.text;
cell.textLabel.textColor =
self.enabled ? [UIColor blackColor]
: UIColorFromRGB(kTableViewSecondaryLabelLightGrayTextColor);
}
@end
@implementation EncryptionCell
@synthesize textLabel = _textLabel;
- (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.isAccessibilityElement = YES;
_textLabel = [[UILabel alloc] init];
_textLabel.translatesAutoresizingMaskIntoConstraints = NO;
_textLabel.numberOfLines = 0;
_textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_textLabel.adjustsFontForContentSizeCategory = YES;
[self.contentView addSubview:_textLabel];
// Set up the constraints.
[NSLayoutConstraint activateConstraints:@[
[_textLabel.leadingAnchor
constraintEqualToAnchor:self.contentView.leadingAnchor
constant:kTableViewHorizontalSpacing],
[_textLabel.trailingAnchor
constraintEqualToAnchor:self.contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
]];
AddOptionalVerticalPadding(self.contentView, _textLabel,
kTableViewLargeVerticalSpacing);
}
return self;
}
- (void)prepareForReuse {
[super prepareForReuse];
self.textLabel.text = nil;
}
#pragma mark - UIAccessibility
- (NSString*)accessibilityLabel {
return self.textLabel.text;
}
@end
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
using EncryptionItemTest = PlatformTest;
// Tests that the text label, enabled status and accessory type are set properly
// after a call to |configureCell:|.
TEST_F(EncryptionItemTest, ConfigureCell) {
EncryptionItem* item = [[EncryptionItem alloc] initWithType:0];
EncryptionCell* cell = [[[item cellClass] alloc] init];
EXPECT_TRUE([cell isMemberOfClass:[EncryptionCell class]]);
EXPECT_NSEQ(nil, cell.textLabel.text);
NSString* text = @"Test text";
UIColor* enabledColor = cell.textLabel.textColor;
item.text = text;
item.enabled = NO;
item.accessoryType = UITableViewCellAccessoryCheckmark;
[item configureCell:cell withStyler:[[ChromeTableViewStyler alloc] init]];
EXPECT_NSEQ(text, cell.textLabel.text);
EXPECT_NE(enabledColor, cell.textLabel.textColor);
EXPECT_EQ(UITableViewCellAccessoryCheckmark, cell.accessoryType);
}
} // namespace
......@@ -6,7 +6,6 @@
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_multiline_detail_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.h"
#import "ios/chrome/browser/ui/table_view/table_view_model.h"
......@@ -71,7 +70,7 @@ TEST_F(ImportDataTableViewControllerTest, TestModelSignedIn) {
CheckController();
ASSERT_EQ(2, NumberOfSections());
EXPECT_EQ(1, NumberOfItemsInSection(0));
CardMultilineItem* item = GetTableViewItem(0, 0);
SettingsMultilineDetailItem* item = GetTableViewItem(0, 0);
EXPECT_NSEQ(
l10n_util::GetNSStringF(IDS_IOS_OPTIONS_IMPORT_DATA_HEADER,
base::SysNSStringToUTF16(@"fromEmail@gmail.com")),
......@@ -97,7 +96,7 @@ TEST_F(ImportDataTableViewControllerTest, TestModelSignedOut) {
CheckController();
ASSERT_EQ(2, NumberOfSections());
EXPECT_EQ(1, NumberOfItemsInSection(0));
CardMultilineItem* item = GetTableViewItem(0, 0);
SettingsMultilineDetailItem* item = GetTableViewItem(0, 0);
EXPECT_NSEQ(
l10n_util::GetNSStringF(IDS_IOS_OPTIONS_IMPORT_DATA_HEADER,
base::SysNSStringToUTF16(@"fromEmail@gmail.com")),
......
......@@ -30,7 +30,6 @@
#import "ios/chrome/browser/ui/payments/cells/autofill_profile_item.h"
#import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
#import "ios/chrome/browser/ui/payments/cells/price_item.h"
#import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h"
#import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h"
#import "ios/chrome/browser/ui/settings/cells/legacy/legacy_account_signin_item.h"
#import "ios/chrome/browser/ui/settings/cells/legacy/legacy_settings_detail_item.h"
......
......@@ -86,6 +86,7 @@ source_set("unit_tests") {
"//ios/chrome/browser/ui/settings/cells/legacy",
"//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/ui/table_view:test_support",
"//ios/chrome/browser/ui/table_view/cells",
"//ios/web/public/test",
"//testing/gtest",
"//ui/base",
......
......@@ -23,12 +23,12 @@
#include "ios/chrome/browser/sync/sync_setup_service.h"
#include "ios/chrome/browser/sync/sync_setup_service_factory.h"
#import "ios/chrome/browser/ui/settings/cells/byo_textfield_item.h"
#import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h"
#import "ios/chrome/browser/ui/settings/cells/passphrase_error_item.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h"
#import "ios/chrome/browser/ui/settings/utils/settings_utils.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -189,9 +189,10 @@ const CGFloat kSpinnerButtonPadding = 18;
// Returns a passphrase message item.
- (TableViewItem*)passphraseMessageItem {
CardMultilineItem* item =
[[CardMultilineItem alloc] initWithType:ItemTypeMessage];
TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeMessage];
item.text = self.headerMessage;
item.enabled = NO;
return item;
}
......
......@@ -20,9 +20,9 @@
#include "ios/chrome/browser/sync/sync_setup_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service_mock.h"
#import "ios/chrome/browser/ui/settings/cells/byo_textfield_item.h"
#import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h"
#import "ios/chrome/browser/ui/settings/passphrase_table_view_controller_test.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -105,7 +105,7 @@ TEST_F(SyncEncryptionPassphraseTableViewControllerTest, TestModel) {
EXPECT_EQ(1, NumberOfSections());
EXPECT_EQ(2, NumberOfItemsInSection(0));
// Passphrase message item.
CardMultilineItem* item = GetTableViewItem(0, 0);
TableViewTextItem* item = GetTableViewItem(0, 0);
EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY),
item.text);
// Passphrase items.
......
......@@ -19,15 +19,16 @@
#include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#import "ios/chrome/browser/sync/sync_observer_bridge.h"
#import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
#import "ios/chrome/browser/ui/settings/sync/sync_create_passphrase_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/sync/sync_encryption_passphrase_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/utils/settings_utils.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "ios/chrome/browser/ui/table_view/table_view_model.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "url/gurl.h"
......@@ -154,18 +155,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
return footerView;
}
- (BOOL)tableView:(UITableView*)tableView
shouldHighlightRowAtIndexPath:(NSIndexPath*)indexPath {
TableViewItem* item = [self.tableViewModel itemAtIndexPath:indexPath];
if (item.type == ItemTypePassphrase || item.type == ItemTypeAccount) {
EncryptionItem* encryptionItem =
base::mac::ObjCCastStrict<EncryptionItem>(item);
// Don't perform any action if the cell isn't enabled.
return encryptionItem.isEnabled;
}
return YES;
}
- (void)tableView:(UITableView*)tableView
didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
DCHECK_EQ(indexPath.section,
......@@ -173,12 +162,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
sectionForSectionIdentifier:SectionIdentifierEncryption]);
TableViewItem* item = [self.tableViewModel itemAtIndexPath:indexPath];
if ([item respondsToSelector:@selector(isEnabled)] &&
![item performSelector:@selector(isEnabled)]) {
// Don't perform any action if the cell isn't enabled.
return;
}
switch (item.type) {
case ItemTypePassphrase: {
DCHECK(browser_sync::ProfileSyncService::IsSyncAllowedByFlag());
......@@ -226,10 +209,14 @@ typedef NS_ENUM(NSInteger, ItemType) {
text:(NSString*)text
checked:(BOOL)checked
enabled:(BOOL)enabled {
EncryptionItem* item = [[EncryptionItem alloc] initWithType:type];
TableViewTextItem* item = [[TableViewTextItem alloc] initWithType:type];
item.accessibilityTraits |= UIAccessibilityTraitButton;
item.text = text;
item.accessoryType = checked ? UITableViewCellAccessoryCheckmark
: UITableViewCellAccessoryNone;
item.textColor =
enabled ? [UIColor blackColor]
: UIColorFromRGB(kTableViewSecondaryLabelLightGrayTextColor);
item.enabled = enabled;
return item;
}
......
......@@ -13,7 +13,7 @@
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ios/web/public/test/test_web_thread_bundle.h"
......@@ -84,11 +84,11 @@ TEST_F(SyncEncryptionTableViewControllerTest, TestModel) {
NSInteger const kSection = 0;
EXPECT_EQ(2, NumberOfItemsInSection(kSection));
EncryptionItem* accountItem = GetTableViewItem(kSection, 0);
TableViewTextItem* accountItem = GetTableViewItem(kSection, 0);
EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_BASIC_ENCRYPTION_DATA),
accountItem.text);
EncryptionItem* passphraseItem = GetTableViewItem(kSection, 1);
TableViewTextItem* passphraseItem = GetTableViewItem(kSection, 1);
EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_FULL_ENCRYPTION_DATA),
passphraseItem.text);
}
......
......@@ -13,7 +13,6 @@
#import "ios/chrome/browser/ui/settings/cells/account_sign_in_item.h"
#import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h"
#import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h"
#import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_detail_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
......@@ -60,7 +59,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeURLWithSupplementalText,
ItemTypeURLWithBadgeImage,
ItemTypeTextSettingsDetail,
ItemTypeEncryption,
ItemTypeLinkFooter,
ItemTypeDetailText,
ItemTypeAccountSignInItem,
......@@ -227,25 +225,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
[model addItem:imageDetailTextItem
toSectionWithIdentifier:SectionIdentifierSettings];
EncryptionItem* encryptionChecked =
[[EncryptionItem alloc] initWithType:ItemTypeEncryption];
encryptionChecked.text =
@"These two cells have exactly the same text, but one has a checkmark "
@"and the other does not. They should lay out identically, and the "
@"presence of the checkmark should not cause the text to reflow.";
encryptionChecked.accessoryType = UITableViewCellAccessoryCheckmark;
[model addItem:encryptionChecked
toSectionWithIdentifier:SectionIdentifierSettings];
EncryptionItem* encryptionUnchecked =
[[EncryptionItem alloc] initWithType:ItemTypeEncryption];
encryptionUnchecked.text =
@"These two cells have exactly the same text, but one has a checkmark "
@"and the other does not. They should lay out identically, and the "
@"presence of the checkmark should not cause the text to reflow.";
[model addItem:encryptionUnchecked
toSectionWithIdentifier:SectionIdentifierSettings];
TableViewLinkHeaderFooterItem* linkFooter =
[[TableViewLinkHeaderFooterItem alloc] initWithType:ItemTypeLinkFooter];
linkFooter.text =
......
......@@ -25,6 +25,10 @@
// If set to YES, |text| will be shown as "••••••" with fixed length.
@property(nonatomic, assign) BOOL masked;
// Whether this item is enabled. If it is not enabled, the corresponding cell
// has its user interaction disabled. Enabled by default.
@property(nonatomic, assign, getter=isEnabled) BOOL enabled;
@end
// UITableViewCell that displays a text label.
......
......@@ -28,6 +28,7 @@ const CGFloat kLabelCellVerticalSpacing = 11.0;
self = [super initWithType:type];
if (self) {
self.cellClass = [TableViewTextCell class];
_enabled = YES;
}
return self;
}
......@@ -71,6 +72,8 @@ const CGFloat kLabelCellVerticalSpacing = 11.0;
}
cell.textLabel.textAlignment =
self.textAlignment ? self.textAlignment : NSTextAlignmentLeft;
cell.userInteractionEnabled = self.enabled;
}
@end
......@@ -128,6 +131,7 @@ const CGFloat kLabelCellVerticalSpacing = 11.0;
- (void)prepareForReuse {
[super prepareForReuse];
self.checked = NO;
self.userInteractionEnabled = YES;
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment