adaptive_charging_nudge.cc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2022 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. #include "ash/system/power/adaptive_charging_nudge.h"
  5. #include "ash/constants/notifier_catalogs.h"
  6. #include "ash/resources/vector_icons/vector_icons.h"
  7. #include "ash/strings/grit/ash_strings.h"
  8. #include "ash/style/dark_light_mode_controller_impl.h"
  9. #include "ash/system/tray/system_nudge_label.h"
  10. #include "ui/base/l10n/l10n_util.h"
  11. #include "ui/compositor/layer.h"
  12. #include "ui/views/controls/styled_label.h"
  13. namespace ash {
  14. namespace {
  15. // The size of the icon.
  16. constexpr int kIconSize = 60;
  17. // The spacing between the icon and label in the nudge view.
  18. constexpr int kIconLabelSpacing = 20;
  19. // The padding which separates the nudge's border with its inner contents.
  20. constexpr int kNudgePadding = 20;
  21. // The minimum width of the label.
  22. constexpr int kMinLabelWidth = 232;
  23. // Use a bigger font size than the default one.
  24. constexpr int kFontSizeDelta = 2;
  25. constexpr char kAdaptiveChargingNudgeName[] =
  26. "AdaptiveChargingEducationalNudge";
  27. } // namespace
  28. AdaptiveChargingNudge::AdaptiveChargingNudge()
  29. : SystemNudge(kAdaptiveChargingNudgeName,
  30. NudgeCatalogName::kAdaptiveCharging,
  31. kIconSize,
  32. kIconLabelSpacing,
  33. kNudgePadding) {}
  34. AdaptiveChargingNudge::~AdaptiveChargingNudge() = default;
  35. std::unique_ptr<SystemNudgeLabel> AdaptiveChargingNudge::CreateLabelView()
  36. const {
  37. std::u16string label_text = l10n_util::GetStringUTF16(
  38. IDS_ASH_ADAPTIVE_CHARGING_EDUCATIONAL_NUDGE_TEXT);
  39. auto label = std::make_unique<SystemNudgeLabel>(label_text, kMinLabelWidth);
  40. label->set_font_size_delta(kFontSizeDelta);
  41. return label;
  42. }
  43. const gfx::VectorIcon& AdaptiveChargingNudge::GetIcon() const {
  44. return DarkLightModeControllerImpl::Get()->IsDarkModeEnabled()
  45. ? kAdaptiveChargingNudgeDarkIcon
  46. : kAdaptiveChargingNudgeLightIcon;
  47. }
  48. std::u16string AdaptiveChargingNudge::GetAccessibilityText() const {
  49. // TODO(b:216035485): Calculate text for screen readers.
  50. return u"";
  51. }
  52. } // namespace ash