Commit adf5498b authored by Melissa Zhang's avatar Melissa Zhang Committed by Commit Bot

[Sharesheet] Add grey separators.

This CL adds grey separators to SharesheetBubbleView to align
with mocks. Screenshot included in bug.

Bug: 1147724
Change-Id: I50e0a2eb058ddfe2c8c1ca1b4df079d4d1aba4ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2532536
Commit-Queue: Melissa Zhang <melzhang@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826546}
parent 70e3528f
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "ui/views/controls/button/image_button_factory.h" #include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/controls/scroll_view.h" #include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/separator.h"
#include "ui/views/controls/styled_label.h" #include "ui/views/controls/styled_label.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
...@@ -145,10 +146,10 @@ void SharesheetBubbleView::ShowBubble( ...@@ -145,10 +146,10 @@ void SharesheetBubbleView::ShowBubble(
auto scroll_view = std::make_unique<views::ScrollView>(); auto scroll_view = std::make_unique<views::ScrollView>();
scroll_view->SetContents(MakeScrollableTargetView(std::move(targets))); scroll_view->SetContents(MakeScrollableTargetView(std::move(targets)));
scroll_view->ClipHeightTo(kTargetViewHeight, kTargetViewExpandedHeight); scroll_view->ClipHeightTo(kTargetViewHeight, kTargetViewExpandedHeight);
scroll_view->SetProperty(views::kMarginsKey, gfx::Insets(0, kSpacing));
// TODO(crbug.com/1097623) Update grey border lines.
main_view_->AddChildView(std::move(scroll_view)); main_view_->AddChildView(std::move(scroll_view));
expand_button_separator_ =
main_view_->AddChildView(std::make_unique<views::Separator>());
expand_button_ = expand_button_ =
main_view_->AddChildView(std::make_unique<SharesheetExpandButton>( main_view_->AddChildView(std::make_unique<SharesheetExpandButton>(
base::BindRepeating(&SharesheetBubbleView::ExpandButtonPressed, base::BindRepeating(&SharesheetBubbleView::ExpandButtonPressed,
...@@ -171,6 +172,7 @@ void SharesheetBubbleView::ShowBubble( ...@@ -171,6 +172,7 @@ void SharesheetBubbleView::ShowBubble(
width_ = kDefaultBubbleWidth; width_ = kDefaultBubbleWidth;
height_ = kNoExtensionBubbleHeight; height_ = kNoExtensionBubbleHeight;
expand_button_->SetVisible(false); expand_button_->SetVisible(false);
expand_button_separator_->SetVisible(false);
} }
UpdateAnchorPosition(); UpdateAnchorPosition();
} }
...@@ -179,11 +181,13 @@ std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView( ...@@ -179,11 +181,13 @@ std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView(
std::vector<TargetInfo> targets) { std::vector<TargetInfo> targets) {
// Set up default and expanded views. // Set up default and expanded views.
auto default_view = std::make_unique<views::View>(); auto default_view = std::make_unique<views::View>();
default_view->SetProperty(views::kMarginsKey, gfx::Insets(0, kSpacing));
auto* default_layout = auto* default_layout =
default_view->SetLayoutManager(std::make_unique<views::GridLayout>()); default_view->SetLayoutManager(std::make_unique<views::GridLayout>());
SetUpTargetColumnSet(default_layout); SetUpTargetColumnSet(default_layout);
auto expanded_view = std::make_unique<views::View>(); auto expanded_view = std::make_unique<views::View>();
expanded_view->SetProperty(views::kMarginsKey, gfx::Insets(0, kSpacing));
auto* expanded_layout = auto* expanded_layout =
expanded_view->SetLayoutManager(std::make_unique<views::GridLayout>()); expanded_view->SetLayoutManager(std::make_unique<views::GridLayout>());
SetUpTargetColumnSet(expanded_layout); SetUpTargetColumnSet(expanded_layout);
...@@ -194,19 +198,18 @@ std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView( ...@@ -194,19 +198,18 @@ std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView(
/* resize_percent */ kStretchy, /* resize_percent */ kStretchy,
views::GridLayout::ColumnSize::kUsePreferred, views::GridLayout::ColumnSize::kUsePreferred,
/* fixed_width */ 0, /* min_width */ 0); /* fixed_width */ 0, /* min_width */ 0);
// Add Extended View Title // Add Extended View Title
expanded_layout->AddPaddingRow(views::GridLayout::kFixedSize, expanded_layout->AddPaddingRow(views::GridLayout::kFixedSize,
kExpandViewPaddingTop); kExpandViewPaddingTop);
expanded_layout->StartRow(views::GridLayout::kFixedSize, kColumnSetIdTitle, expanded_layout->StartRow(views::GridLayout::kFixedSize, kColumnSetIdTitle,
kExpandViewTitleLabelHeight); kExpandViewTitleLabelHeight);
auto* app_list_label = auto* apps_list_label =
expanded_layout->AddView(std::make_unique<views::Label>( expanded_layout->AddView(std::make_unique<views::Label>(
l10n_util::GetStringUTF16(IDS_SHARESHEET_APPS_LIST_LABEL))); l10n_util::GetStringUTF16(IDS_SHARESHEET_APPS_LIST_LABEL)));
app_list_label->SetFontList(gfx::FontList(kExpandViewTitleFont)); apps_list_label->SetFontList(gfx::FontList(kExpandViewTitleFont));
app_list_label->SetLineHeight(kExpandViewTitleLabelHeight); apps_list_label->SetLineHeight(kExpandViewTitleLabelHeight);
app_list_label->SetEnabledColor(kShareTargetTitleColor); apps_list_label->SetEnabledColor(kShareTargetTitleColor);
app_list_label->SetHorizontalAlignment(gfx::ALIGN_CENTER); apps_list_label->SetHorizontalAlignment(gfx::ALIGN_CENTER);
expanded_layout->AddPaddingRow(views::GridLayout::kFixedSize, expanded_layout->AddPaddingRow(views::GridLayout::kFixedSize,
kExpandViewPaddingBottom); kExpandViewPaddingBottom);
...@@ -220,10 +223,15 @@ std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView( ...@@ -220,10 +223,15 @@ std::unique_ptr<views::View> SharesheetBubbleView::MakeScrollableTargetView(
views::BoxLayout::Orientation::kVertical)); views::BoxLayout::Orientation::kVertical));
layout->set_main_axis_alignment(views::BoxLayout::MainAxisAlignment::kCenter); layout->set_main_axis_alignment(views::BoxLayout::MainAxisAlignment::kCenter);
default_view_ = scrollable_view->AddChildView(std::move(default_view)); default_view_ = scrollable_view->AddChildView(std::move(default_view));
expanded_view_separator_ =
scrollable_view->AddChildView(std::make_unique<views::Separator>());
expanded_view_separator_->SetProperty(views::kMarginsKey,
gfx::Insets(0, kSpacing));
expanded_view_ = scrollable_view->AddChildView(std::move(expanded_view)); expanded_view_ = scrollable_view->AddChildView(std::move(expanded_view));
// Expanded view is not visible by default. // Expanded view is not visible by default.
expanded_view_->SetVisible(false); expanded_view_->SetVisible(false);
expanded_view_separator_->SetVisible(false);
return scrollable_view; return scrollable_view;
} }
...@@ -399,7 +407,12 @@ void SharesheetBubbleView::ExpandButtonPressed() { ...@@ -399,7 +407,12 @@ void SharesheetBubbleView::ExpandButtonPressed() {
expand_button_->SetExpandedView(); expand_button_->SetExpandedView();
else else
expand_button_->SetDefaultView(); expand_button_->SetDefaultView();
// Scrollview has separators that overlaps with |expand_button_separator_|
// to create a double line when both are visible, so when scrollview is
// expanded we hide our separator.
expand_button_separator_->SetVisible(!show_expanded_view_);
expanded_view_->SetVisible(show_expanded_view_); expanded_view_->SetVisible(show_expanded_view_);
expanded_view_separator_->SetVisible(show_expanded_view_);
ResizeBubble(kDefaultBubbleWidth, show_expanded_view_ ? kExpandedBubbleHeight ResizeBubble(kDefaultBubbleWidth, show_expanded_view_ ? kExpandedBubbleHeight
: kDefaultBubbleHeight); : kDefaultBubbleHeight);
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
namespace views { namespace views {
class GridLayout; class GridLayout;
class Separator;
} }
namespace sharesheet { namespace sharesheet {
...@@ -86,6 +87,10 @@ class SharesheetBubbleView : public views::BubbleDialogDelegateView { ...@@ -86,6 +87,10 @@ class SharesheetBubbleView : public views::BubbleDialogDelegateView {
views::View* default_view_ = nullptr; views::View* default_view_ = nullptr;
views::View* expanded_view_ = nullptr; views::View* expanded_view_ = nullptr;
views::View* share_action_view_ = nullptr; views::View* share_action_view_ = nullptr;
// Separator that appears above the expand button.
views::Separator* expand_button_separator_ = nullptr;
// Separator between the default_view and the expanded_view.
views::Separator* expanded_view_separator_ = nullptr;
views::View* parent_view_ = nullptr; views::View* parent_view_ = nullptr;
SharesheetExpandButton* expand_button_ = nullptr; SharesheetExpandButton* expand_button_ = nullptr;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment