// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "ios/chrome/browser/download/ui/download_manager_state_view.h"

#import "ios/chrome/browser/shared/ui/symbols/symbols.h"
#import "ios/chrome/common/ui/colors/semantic_color_names.h"

namespace {

// Fixed size of the view.
const CGFloat kViewSize = 28;

}  // namespace

@implementation DownloadManagerStateView

#pragma mark - UIView

- (CGSize)intrinsicContentSize {
  return CGSizeMake(kViewSize, kViewSize);
}

#pragma mark - Public

- (void)setState:(DownloadManagerState)state {
  switch (state) {
    case DownloadManagerState::kNotStarted:
      self.image = SymbolTemplateWithPointSize(SymbolDownloadPromptFill,
                                               kSymbolDownloadInfobarPointSize);
      self.tintColor = [UIColor colorNamed:kBlueColor];
      break;
    case DownloadManagerState::kInProgress:
      self.image = SymbolTemplateWithPointSize(
          SymbolDownloadDocFill, kSymbolDownloadSmallInfobarPointSize);
      self.tintColor = [UIColor colorNamed:kGrey400Color];
      break;
    case DownloadManagerState::kSucceeded:
    case DownloadManagerState::kFailed:
    case DownloadManagerState::kFailedNotResumable:
      self.image = SymbolTemplateWithPointSize(SymbolDownloadDocFill,
                                               kSymbolDownloadInfobarPointSize);
      self.tintColor = [UIColor colorNamed:kGrey400Color];
      break;
  }
}

@end
