OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/settings/cells/version_item.h" |
| 6 |
| 7 #include "ios/chrome/grit/ios_strings.h" |
| 8 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 10 #include "ui/base/l10n/l10n_util_mac.h" |
| 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 16 @implementation VersionItem |
| 17 |
| 18 @synthesize text = _text; |
| 19 |
| 20 - (instancetype)initWithType:(NSInteger)type { |
| 21 self = [super initWithType:type]; |
| 22 if (self) { |
| 23 self.accessibilityIdentifier = @"Version cell"; |
| 24 self.cellClass = [VersionCell class]; |
| 25 } |
| 26 return self; |
| 27 } |
| 28 |
| 29 #pragma mark CollectionViewItem |
| 30 |
| 31 - (void)configureCell:(VersionCell*)cell { |
| 32 [super configureCell:cell]; |
| 33 cell.textLabel.text = self.text; |
| 34 } |
| 35 |
| 36 @end |
| 37 |
| 38 @implementation VersionCell |
| 39 |
| 40 @synthesize textLabel = _textLabel; |
| 41 |
| 42 - (instancetype)initWithFrame:(CGRect)frame { |
| 43 self = [super initWithFrame:frame]; |
| 44 if (self) { |
| 45 self.isAccessibilityElement = YES; |
| 46 self.accessibilityTraits |= UIAccessibilityTraitButton; |
| 47 self.accessibilityHint = l10n_util::GetNSString(IDS_IOS_COPY_VERSION_HINT); |
| 48 |
| 49 _textLabel = [[UILabel alloc] init]; |
| 50 _textLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 51 _textLabel.backgroundColor = [UIColor clearColor]; |
| 52 _textLabel.textAlignment = NSTextAlignmentCenter; |
| 53 _textLabel.shadowOffset = CGSizeMake(1, 0); |
| 54 _textLabel.shadowColor = [UIColor whiteColor]; |
| 55 [self addSubview:_textLabel]; |
| 56 |
| 57 _textLabel.font = |
| 58 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; |
| 59 _textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 60 |
| 61 // Set up the constraints. |
| 62 [NSLayoutConstraint activateConstraints:@[ |
| 63 [_textLabel.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], |
| 64 [_textLabel.centerYAnchor constraintEqualToAnchor:self.centerYAnchor], |
| 65 ]]; |
| 66 |
| 67 self.shouldHideSeparator = YES; |
| 68 } |
| 69 return self; |
| 70 } |
| 71 |
| 72 - (NSString*)accessibilityLabel { |
| 73 return self.textLabel.text; |
| 74 } |
| 75 |
| 76 @end |
OLD | NEW |