Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3865)

Unified Diff: ios/chrome/browser/ui/settings/cells/version_item.mm

Issue 2589583003: Upstream Chrome on iOS source code [7/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/settings/cells/version_item.mm
diff --git a/ios/chrome/browser/ui/settings/cells/version_item.mm b/ios/chrome/browser/ui/settings/cells/version_item.mm
new file mode 100644
index 0000000000000000000000000000000000000000..cb8b3cfc6367947f261945f4d1794457de2e314f
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/cells/version_item.mm
@@ -0,0 +1,76 @@
+// 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/version_item.h"
+
+#include "ios/chrome/grit/ios_strings.h"
+#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
+#import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h"
+#include "ui/base/l10n/l10n_util_mac.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation VersionItem
+
+@synthesize text = _text;
+
+- (instancetype)initWithType:(NSInteger)type {
+ self = [super initWithType:type];
+ if (self) {
+ self.accessibilityIdentifier = @"Version cell";
+ self.cellClass = [VersionCell class];
+ }
+ return self;
+}
+
+#pragma mark CollectionViewItem
+
+- (void)configureCell:(VersionCell*)cell {
+ [super configureCell:cell];
+ cell.textLabel.text = self.text;
+}
+
+@end
+
+@implementation VersionCell
+
+@synthesize textLabel = _textLabel;
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ self.isAccessibilityElement = YES;
+ self.accessibilityTraits |= UIAccessibilityTraitButton;
+ self.accessibilityHint = l10n_util::GetNSString(IDS_IOS_COPY_VERSION_HINT);
+
+ _textLabel = [[UILabel alloc] init];
+ _textLabel.translatesAutoresizingMaskIntoConstraints = NO;
+ _textLabel.backgroundColor = [UIColor clearColor];
+ _textLabel.textAlignment = NSTextAlignmentCenter;
+ _textLabel.shadowOffset = CGSizeMake(1, 0);
+ _textLabel.shadowColor = [UIColor whiteColor];
+ [self addSubview:_textLabel];
+
+ _textLabel.font =
+ [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14];
+ _textLabel.textColor = [[MDCPalette greyPalette] tint900];
+
+ // Set up the constraints.
+ [NSLayoutConstraint activateConstraints:@[
+ [_textLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor],
+ [_textLabel.centerYAnchor constraintEqualToAnchor:self.centerYAnchor],
+ ]];
+
+ self.shouldHideSeparator = YES;
+ }
+ return self;
+}
+
+- (NSString*)accessibilityLabel {
+ return self.textLabel.text;
+}
+
+@end
« no previous file with comments | « ios/chrome/browser/ui/settings/cells/version_item.h ('k') | ios/chrome/browser/ui/settings/cells/version_item_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698