OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/today_extension/url_table_cell.h" |
| 6 |
| 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/scoped_block.h" |
| 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" |
| 11 #import "ios/chrome/common/physical_web/physical_web_device.h" |
| 12 #import "ios/chrome/today_extension/notification_center_url_button.h" |
| 13 #include "ios/chrome/today_extension/ui_util.h" |
| 14 #include "net/base/escape.h" |
| 15 #include "ui/base/l10n/l10n_util.h" |
| 16 |
| 17 @implementation URLTableCell { |
| 18 base::scoped_nsobject<NotificationCenterURLButton> _button; |
| 19 } |
| 20 |
| 21 - (instancetype)initWithTitle:(NSString*)title |
| 22 url:(NSString*)url |
| 23 icon:(NSString*)icon |
| 24 leftInset:(CGFloat)leftInset |
| 25 reuseIdentifier:(NSString*)reuseIdentifier |
| 26 block:(URLActionBlock)block { |
| 27 self = [super initWithStyle:UITableViewCellStyleDefault |
| 28 reuseIdentifier:reuseIdentifier]; |
| 29 if (self) { |
| 30 _button.reset([[NotificationCenterURLButton alloc] initWithTitle:title |
| 31 url:url |
| 32 icon:icon |
| 33 leftInset:leftInset |
| 34 block:block]); |
| 35 [[self contentView] addSubview:_button]; |
| 36 |
| 37 // The button takes the whole frame. |
| 38 self.contentView.translatesAutoresizingMaskIntoConstraints = NO; |
| 39 _button.get().translatesAutoresizingMaskIntoConstraints = NO; |
| 40 [NSLayoutConstraint activateConstraints:@[ |
| 41 [_button.get().leadingAnchor |
| 42 constraintEqualToAnchor:[self contentView].leadingAnchor], |
| 43 [_button.get().trailingAnchor |
| 44 constraintEqualToAnchor:[self contentView].trailingAnchor], |
| 45 [_button.get().topAnchor |
| 46 constraintEqualToAnchor:[self contentView].topAnchor], |
| 47 [_button.get().bottomAnchor |
| 48 constraintEqualToAnchor:[self contentView].bottomAnchor], |
| 49 [self.leadingAnchor |
| 50 constraintEqualToAnchor:[self contentView].leadingAnchor], |
| 51 [self.trailingAnchor |
| 52 constraintEqualToAnchor:[self contentView].trailingAnchor], |
| 53 [self.topAnchor constraintEqualToAnchor:[self contentView].topAnchor], |
| 54 [self.bottomAnchor |
| 55 constraintEqualToAnchor:[self contentView].bottomAnchor] |
| 56 ]]; |
| 57 } |
| 58 return self; |
| 59 } |
| 60 |
| 61 - (void)setTitle:(NSString*)title url:(NSString*)url { |
| 62 [_button setTitle:title url:url]; |
| 63 } |
| 64 |
| 65 - (void)setSeparatorVisible:(BOOL)visible { |
| 66 [_button setSeparatorVisible:visible]; |
| 67 } |
| 68 |
| 69 @end |
OLD | NEW |