dark_light_mode_nudge.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/style/dark_light_mode_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/ash_color_provider.h"
  9. #include "ash/wm/tablet_mode/tablet_mode_controller.h"
  10. #include "ui/base/l10n/l10n_util.h"
  11. #include "ui/compositor/layer.h"
  12. #include "ui/views/controls/label.h"
  13. namespace ash {
  14. namespace {
  15. // The size of the dark light mode icon.
  16. constexpr int kIconSize = 20;
  17. // The minimum width of the label.
  18. constexpr int kMinLabelWidth = 200;
  19. // The spacing between the icon and label in the nudge view.
  20. constexpr int kIconLabelSpacing = 16;
  21. // The padding which separates the nudge's border with its inner contents.
  22. constexpr int kNudgePadding = 16;
  23. constexpr char kDarkLightModeNudgeName[] = "DarkLightModeEducationalNudge";
  24. } // namespace
  25. DarkLightModeNudge::DarkLightModeNudge()
  26. : SystemNudge(kDarkLightModeNudgeName,
  27. NudgeCatalogName::kDarkLightMode,
  28. kIconSize,
  29. kIconLabelSpacing,
  30. kNudgePadding) {}
  31. DarkLightModeNudge::~DarkLightModeNudge() = default;
  32. std::unique_ptr<SystemNudgeLabel> DarkLightModeNudge::CreateLabelView() const {
  33. return std::make_unique<SystemNudgeLabel>(GetAccessibilityText(),
  34. kMinLabelWidth);
  35. }
  36. const gfx::VectorIcon& DarkLightModeNudge::GetIcon() const {
  37. return kUnifiedMenuDarkModeIcon;
  38. }
  39. std::u16string DarkLightModeNudge::GetAccessibilityText() const {
  40. return l10n_util::GetStringUTF16(
  41. TabletMode::Get()->InTabletMode()
  42. ? IDS_ASH_DARK_LIGHT_MODE_EDUCATIONAL_NUDGE_IN_TABLET_MODE
  43. : IDS_ASH_DARK_LIGHT_MODE_EDUCATIONAL_NUDGE_IN_CLAMSHELL_MODE);
  44. }
  45. } // namespace ash