1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93

ash / system / nearby_share / nearby_share_detailed_view_impl.h [blame]

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

#ifndef ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_DETAILED_VIEW_IMPL_H_
#define ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_DETAILED_VIEW_IMPL_H_

#include "ash/ash_export.h"
#include "ash/system/nearby_share/nearby_share_detailed_view.h"
#include "ash/system/tray/tray_detailed_view.h"
#include "base/memory/weak_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"

namespace views {
class Button;
class View;
}  // namespace views

namespace ash {

class HoverHighlightView;
class NearbyShareDelegate;
class RoundedContainer;
class Switch;

class ASH_EXPORT NearbyShareDetailedViewImpl : public NearbyShareDetailedView,
                                               public TrayDetailedView {
  METADATA_HEADER(NearbyShareDetailedViewImpl, TrayDetailedView)

 public:
  explicit NearbyShareDetailedViewImpl(
      DetailedViewDelegate* detailed_view_delegate);
  NearbyShareDetailedViewImpl(const NearbyShareDetailedViewImpl&) = delete;
  NearbyShareDetailedViewImpl& operator=(const NearbyShareDetailedViewImpl&) =
      delete;
  ~NearbyShareDetailedViewImpl() override;

  // NearbyShareDetailedView:
  views::View* GetAsView() override;

 private:
  friend class NearbyShareDetailedViewImplTest;

  // TrayDetailedView:
  void CreateExtraTitleRowButtons() override;
  void HandleViewClicked(views::View* view) override;

  void CreateIsEnabledContainer();
  void CreateVisibilitySelectionContainer();
  void CreateYourDevicesRow();
  void CreateContactsRow();
  void CreateHiddenRow();
  void CreateVisibilityRow(HoverHighlightView* visibility_row,
                           const gfx::VectorIcon& vector_icon,
                           const std::u16string& label,
                           const std::u16string& sublabel);
  void CreateEveryoneRow();

  void FormatEveryoneRow(const ui::ColorId color_id,
                         const bool in_high_visibility,
                         const bool is_row_enabled);
  void FormatVisibilitySelectionContainer(const bool in_high_visibility);

  void OnSettingsButtonClicked();
  void OnQuickShareToggleClicked();
  void OnYourDevicesSelected();
  void OnContactsSelected();
  void OnHiddenSelected();
  void OnEveryoneToggleClicked();

  void SetCheckCircle(const bool in_high_visibility);

  raw_ptr<views::Button> settings_button_ = nullptr;
  raw_ptr<RoundedContainer> is_enabled_container_ = nullptr;
  raw_ptr<HoverHighlightView> toggle_row_ = nullptr;
  // TODO(brandosocarras, b/360150790): use `toggle_switch_` in this class, not
  // just in utest.
  raw_ptr<Switch> quick_share_toggle_ = nullptr;
  raw_ptr<RoundedContainer> visibility_selection_container_ = nullptr;
  raw_ptr<HoverHighlightView> your_devices_row_ = nullptr;
  raw_ptr<HoverHighlightView> contacts_row_ = nullptr;
  raw_ptr<HoverHighlightView> hidden_row_ = nullptr;
  raw_ptr<HoverHighlightView> everyone_row_ = nullptr;
  raw_ptr<Switch> everyone_toggle_ = nullptr;

  const raw_ptr<NearbyShareDelegate> nearby_share_delegate_;

  base::WeakPtrFactory<NearbyShareDetailedViewImpl> weak_factory_{this};
};

}  // namespace ash

#endif  // ASH_SYSTEM_NEARBY_SHARE_NEARBY_SHARE_DETAILED_VIEW_IMPL_H_