Commit 827deeb5 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Adding implementation of AccountSigninItem for UITableView

AccountSigninItem uses SettingsImageDetailTextCell to display the
UI.

Change-Id: I225f1967287ead71297cb9b0873fb7b14552e8d9
Reviewed-on: https://chromium-review.googlesource.com/c/1392962
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619942}
parent d3c41a2c
......@@ -4,6 +4,8 @@
source_set("cells") {
sources = [
"account_sign_in_item.h",
"account_sign_in_item.mm",
"autofill_data_item.h",
"autofill_data_item.mm",
"byo_textfield_item.h",
......@@ -61,6 +63,8 @@ source_set("cells") {
"//ios/chrome/browser/ui/icons",
"//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/signin",
"//ios/third_party/material_roboto_font_loader_ios",
"//ui/base",
]
......
// Copyright 2018 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_ACCOUNT_SIGN_IN_ITEM_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_ACCOUNT_SIGN_IN_ITEM_H_
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// Item to display a non-personnalized sign-in cell.
@interface AccountSignInItem : TableViewItem
// Title for the sign-in cell (required).
@property(nonatomic, strong) NSString* text;
// Subtitle for the sign-in cell.
@property(nonatomic, strong) NSString* detailText;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_ACCOUNT_SIGN_IN_ITEM_H_
// Copyright 2018 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/account_sign_in_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_cell.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#include "ios/public/provider/chrome/browser/signin/signin_resources_provider.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
// Account profile picture size.
const CGFloat kAccountProfilePhotoDimension = 40.0f;
} // namespace
@implementation AccountSignInItem
- (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type];
if (self) {
self.cellClass = [SettingsImageDetailTextCell class];
self.accessibilityTraits |= UIAccessibilityTraitButton;
}
return self;
}
#pragma mark - CollectionViewItem
- (void)configureCell:(SettingsImageDetailTextCell*)cell
withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler];
DCHECK(self.text);
cell.textLabel.text = self.text;
cell.detailTextLabel.text = self.detailText;
cell.image = CircularImageFromImage(ios::GetChromeBrowserProvider()
->GetSigninResourcesProvider()
->GetDefaultAvatar(),
kAccountProfilePhotoDimension);
}
@end
......@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/authentication/cells/table_view_signin_promo_item.h"
#import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h"
#import "ios/chrome/browser/ui/icons/chrome_icon.h"
#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"
......@@ -58,6 +59,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeEncryption,
ItemTypeLinkFooter,
ItemTypeDetailText,
ItemTypeAccountSignInItem,
ItemTypeSettingsSwitch1,
ItemTypeSettingsSwitch2,
ItemTypeSyncSwitch,
......@@ -181,6 +183,13 @@ typedef NS_ENUM(NSInteger, ItemType) {
[model addItem:settingsDetailItemLong
toSectionWithIdentifier:SectionIdentifierSettings];
AccountSignInItem* accountSignInItem =
[[AccountSignInItem alloc] initWithType:ItemTypeAccountSignInItem];
accountSignInItem.text = @"Account sign-in cell";
accountSignInItem.detailText = @"Get cool stuff on all your devices";
[model addItem:accountSignInItem
toSectionWithIdentifier:SectionIdentifierSettings];
SettingsSwitchItem* settingsSwitchItem =
[[SettingsSwitchItem alloc] initWithType:ItemTypeSettingsSwitch1];
settingsSwitchItem.text = @"This is a settings switch item";
......
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