Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Unified Diff: ui/message_center/views/notification_view_md.cc

Issue 2922903002: Add List notification support to new-style notification. (Closed)
Patch Set: Revert item to black title and grey message. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/message_center/views/notification_view_md.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/views/notification_view_md.cc
diff --git a/ui/message_center/views/notification_view_md.cc b/ui/message_center/views/notification_view_md.cc
index d8b64defbcc427a886f99b737449cf58b6b46f99..f83c682843fd765e3f5efa1e87f1ae20855cc7ae 100644
--- a/ui/message_center/views/notification_view_md.cc
+++ b/ui/message_center/views/notification_view_md.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
fukino 2017/06/13 05:48:24 seems unnecessary?
tetsui 2017/06/13 05:52:39 Done.
#include "ui/base/cursor/cursor.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/size.h"
@@ -90,6 +91,41 @@ const gfx::ImageSkia GetProductIcon() {
return gfx::CreateVectorIcon(kProductIcon, kSmallImageColor);
}
+// ItemView ////////////////////////////////////////////////////////////////////
+
+// ItemViews are responsible for drawing each list notification item's title and
+// message next to each other within a single column.
+class ItemView : public views::View {
+ public:
+ explicit ItemView(const message_center::NotificationItem& item);
+ ~ItemView() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ItemView);
+};
+
+ItemView::ItemView(const message_center::NotificationItem& item) {
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(),
+ message_center::kItemTitleToMessagePadding));
+
+ views::Label* title = new views::Label(item.title);
+ title->set_collapse_when_hidden(true);
+ title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ title->SetEnabledColor(message_center::kRegularTextColor);
+ title->SetBackgroundColor(message_center::kDimTextBackgroundColor);
+ AddChildView(title);
+
+ views::Label* message = new views::Label(item.message);
+ message->set_collapse_when_hidden(true);
+ message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ message->SetEnabledColor(message_center::kDimTextColor);
+ message->SetBackgroundColor(message_center::kDimTextBackgroundColor);
+ AddChildView(message);
+}
+
+ItemView::~ItemView() {}
+
} // anonymous namespace
// ////////////////////////////////////////////////////////////
@@ -140,6 +176,9 @@ void NotificationViewMD::CreateOrUpdateViews(const Notification& notification) {
CreateOrUpdateCloseButtonView(notification);
CreateOrUpdateSettingsButtonView(notification);
UpdateViewForExpandedState(expanded_);
+
+ // Needed when CreateOrUpdateListItemViews is called for update.
+ left_content_->Layout();
}
NotificationViewMD::NotificationViewMD(MessageCenterController* controller,
@@ -347,6 +386,8 @@ void NotificationViewMD::CreateOrUpdateMessageView(
} else {
message_view_->SetText(text);
}
+
+ message_view_->SetVisible(notification.items().empty());
}
void NotificationViewMD::CreateOrUpdateProgressBarView(
@@ -356,7 +397,17 @@ void NotificationViewMD::CreateOrUpdateProgressBarView(
void NotificationViewMD::CreateOrUpdateListItemViews(
const Notification& notification) {
- // TODO(yoshiki): Implement this.
+ for (auto* item_view : item_views_)
+ delete item_view;
+ item_views_.clear();
+
+ const std::vector<NotificationItem>& items = notification.items();
+
+ for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
+ ItemView* item_view = new ItemView(items[i]);
+ item_views_.push_back(item_view);
+ left_content_->AddChildView(item_view);
+ }
}
void NotificationViewMD::CreateOrUpdateIconView(
@@ -485,6 +536,10 @@ bool NotificationViewMD::IsExpandable() {
if (image_view_)
return true;
+ // Expandable if there are multiple list items.
+ if (item_views_.size() > 1)
+ return true;
+
// TODO(fukino): Expandable if both progress bar and message exist.
return false;
@@ -507,6 +562,9 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) {
if (image_container_)
image_container_->SetVisible(expanded);
actions_row_->SetVisible(expanded && actions_row_->has_children());
+ for (size_t i = 1; i < item_views_.size(); ++i) {
+ item_views_[i]->SetVisible(expanded);
+ }
}
void NotificationViewMD::UpdateControlButtonsVisibility() {
« no previous file with comments | « ui/message_center/views/notification_view_md.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698