Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm |
| diff --git a/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm b/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm |
| index 48003841e5e842087ebc234347379bafe143ab22..ebbf1e4f3b337a3d79b978e71e5f6674f03d307f 100644 |
| --- a/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm |
| +++ b/ios/clean/chrome/browser/ui/toolbar/toolbar_view_controller.mm |
| @@ -21,6 +21,8 @@ namespace { |
| CGFloat kVerticalMargin = 5.0f; |
| // Stackview Horizontal Margin. |
| CGFloat kHorizontalMargin = 8.0f; |
| +// Progress Bar Height. |
| +CGFloat kProgressBarHeight = 2.0f; |
| } // namespace |
| @interface ToolbarViewController () |
| @@ -34,6 +36,7 @@ CGFloat kHorizontalMargin = 8.0f; |
| @property(nonatomic, strong) ToolbarButton* shareButton; |
| @property(nonatomic, strong) ToolbarButton* reloadButton; |
| @property(nonatomic, strong) ToolbarButton* stopButton; |
| +@property(nonatomic, strong) UIProgressView* progressBar; |
|
lpromero
2017/05/05 14:43:51
Why not an MDCProgressView like the current app?
sczs
2017/05/05 23:15:45
You're right, I've should've used that in the firs
|
| @end |
| @implementation ToolbarViewController |
| @@ -49,35 +52,44 @@ CGFloat kHorizontalMargin = 8.0f; |
| @synthesize shareButton = _shareButton; |
| @synthesize reloadButton = _reloadButton; |
| @synthesize stopButton = _stopButton; |
| +@synthesize progressBar = _progressBar; |
| - (instancetype)init { |
| self = [super init]; |
| if (self) { |
| [self setUpToolbarButtons]; |
| [self setUpLocationBarContainer]; |
| + [self setUpProgressBar]; |
| } |
| return self; |
| } |
| - (void)viewDidLoad { |
| self.view.backgroundColor = [UIColor lightGrayColor]; |
| - |
| [self addChildViewController:self.locationBarViewController |
| toSubview:self.locationBarContainer]; |
| + [self setUpToolbarStackView]; |
| + [self.view addSubview:self.stackView]; |
| + [self.view addSubview:self.progressBar]; |
| + [self setConstraints]; |
| +} |
| + |
| +#pragma mark - View Setup |
| - // Stack view to contain toolbar items. |
| +// Sets up the StackView that contains toolbar navigation items. |
| +- (void)setUpToolbarStackView { |
| self.stackView = [[UIStackView alloc] initWithArrangedSubviews:@[ |
| self.backButton, self.forwardButton, self.reloadButton, self.stopButton, |
| self.locationBarContainer, self.shareButton, self.tabSwitchStripButton, |
| self.tabSwitchGridButton, self.toolsMenuButton |
| ]]; |
| - [self updateAllButtonsVisibility]; |
| self.stackView.translatesAutoresizingMaskIntoConstraints = NO; |
| self.stackView.spacing = 16.0; |
| self.stackView.distribution = UIStackViewDistributionFill; |
| - [self.view addSubview:self.stackView]; |
| + [self updateAllButtonsVisibility]; |
| +} |
| - // Set constraints. |
| +- (void)setConstraints { |
| [self.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
| UIViewAutoresizingFlexibleHeight]; |
| [NSLayoutConstraint activateConstraints:@[ |
| @@ -91,6 +103,14 @@ CGFloat kHorizontalMargin = 8.0f; |
| [self.stackView.trailingAnchor |
| constraintEqualToAnchor:self.view.trailingAnchor |
| constant:-kHorizontalMargin], |
| + [self.progressBar.leadingAnchor |
| + constraintEqualToAnchor:self.view.leadingAnchor], |
| + [self.progressBar.trailingAnchor |
| + constraintEqualToAnchor:self.view.trailingAnchor], |
| + [self.progressBar.bottomAnchor |
| + constraintEqualToAnchor:self.view.bottomAnchor], |
| + [self.progressBar.heightAnchor |
| + constraintEqualToConstant:kProgressBarHeight], |
| ]]; |
| } |
| @@ -173,6 +193,13 @@ CGFloat kHorizontalMargin = 8.0f; |
| self.locationBarContainer = locationBarContainer; |
| } |
| +- (void)setUpProgressBar { |
| + UIProgressView* progressBar = |
| + [[UIProgressView alloc] initWithFrame:CGRectZero]; |
| + progressBar.translatesAutoresizingMaskIntoConstraints = NO; |
| + self.progressBar = progressBar; |
| +} |
| + |
| #pragma mark - View Controller Containment |
| - (void)addChildViewController:(UIViewController*)viewController |
| @@ -226,9 +253,6 @@ CGFloat kHorizontalMargin = 8.0f; |
| #pragma mark - ToolbarWebStateConsumer |
| -- (void)setCurrentPageText:(NSString*)text { |
| -} |
| - |
| - (void)setCanGoForward:(BOOL)canGoForward { |
| self.forwardButton.enabled = canGoForward; |
| // Update the visibility since the Forward button will be hidden on |
| @@ -246,6 +270,15 @@ CGFloat kHorizontalMargin = 8.0f; |
| [self updateAllButtonsVisibility]; |
| } |
| +- (void)setProgress:(double)progress { |
| + if (progress == 0 || progress == 1.0) { |
| + self.progressBar.hidden = YES; |
|
lpromero
2017/05/05 14:43:51
MDCProgressView allows you to animate the progress
sczs
2017/05/05 23:15:45
Didn't intend this to be a PLACEHOLDER. Switched t
|
| + return; |
| + } |
| + self.progressBar.hidden = NO; |
| + self.progressBar.progress = progress; |
| +} |
| + |
| #pragma mark - ZoomTransitionDelegate |
| - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { |