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

Side by Side Diff: ash/common/system/chromeos/network/vpn_list_view.cc

Issue 2530763002: [ash-md] Adjusts layout of lists with sticky header rows to match specs (Closed)
Patch Set: [ash-md] Adjusts layout of lists with sticky header rows to match specs (cleanup of shill) Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/network/vpn_list_view.h" 5 #include "ash/common/system/chromeos/network/vpn_list_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 private: 102 private:
103 DISALLOW_COPY_AND_ASSIGN(VPNListProviderEntry); 103 DISALLOW_COPY_AND_ASSIGN(VPNListProviderEntry);
104 }; 104 };
105 105
106 // A list entry that represents a VPN provider with Material Design. 106 // A list entry that represents a VPN provider with Material Design.
107 class VPNListProviderEntryMd : public views::ButtonListener, 107 class VPNListProviderEntryMd : public views::ButtonListener,
108 public views::View { 108 public views::View {
109 public: 109 public:
110 VPNListProviderEntryMd(ViewClickListener* parent, 110 VPNListProviderEntryMd(ViewClickListener* parent,
111 bool top_item,
111 const std::string& name, 112 const std::string& name,
112 int button_accessible_name_id) 113 int button_accessible_name_id)
113 : parent_(parent) { 114 : parent_(parent) {
115 // TODO(varkha): Make this a sticky section header.
114 SetLayoutManager(new views::FillLayout); 116 SetLayoutManager(new views::FillLayout);
115 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 117 TriView* tri_view = TrayPopupUtils::CreateSubHeaderRowView();
116 tri_view->SetContainerVisible(TriView::Container::START, false);
117 AddChildView(tri_view); 118 AddChildView(tri_view);
118 119
120 // Sets up the border. When the provider header is the first item in the
121 // list (i.e. when the list was empty before adding the provider row) there
122 // is already |kMenuSeparatorVerticalPadding| padding at the top of the
123 // scroll contents, so only add that padding when the list was not |empty|.
124 // TODO(varkha): Delete this special handling when we allow the header to be
125 // sticky and just use ConfigureAsStickyHeader() instead.
126 tri_view->SetBorder(
127 views::CreateEmptyBorder(top_item ? 0 : kMenuSeparatorVerticalPadding,
128 0, kMenuSeparatorVerticalPadding, 0));
129
119 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); 130 views::Label* label = TrayPopupUtils::CreateDefaultLabel();
120 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER); 131 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER);
121 style.SetupLabel(label); 132 style.SetupLabel(label);
122 label->SetText(base::ASCIIToUTF16(name)); 133 label->SetText(base::ASCIIToUTF16(name));
123 tri_view->AddView(TriView::Container::CENTER, label); 134 tri_view->AddView(TriView::Container::CENTER, label);
124 135
125 gfx::ImageSkia icon = gfx::CreateVectorIcon(kSystemMenuAddConnectionIcon, 136 gfx::ImageSkia icon = gfx::CreateVectorIcon(kSystemMenuAddConnectionIcon,
126 style.GetIconColor()); 137 style.GetIconColor());
127 SystemMenuButton* add_vpn_button = 138 SystemMenuButton* add_vpn_button =
128 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, icon, 139 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, icon,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 views::View* entry(new VPNListNetworkEntry(this, network)); 453 views::View* entry(new VPNListNetworkEntry(this, network));
443 container()->AddChildView(entry); 454 container()->AddChildView(entry);
444 network_view_service_path_map_[entry] = network->path(); 455 network_view_service_path_map_[entry] = network->path();
445 list_empty_ = false; 456 list_empty_ = false;
446 } 457 }
447 458
448 void VPNListView::AddProviderAndNetworks( 459 void VPNListView::AddProviderAndNetworks(
449 const VPNProvider& vpn_provider, 460 const VPNProvider& vpn_provider,
450 const chromeos::NetworkStateHandler::NetworkStateList& networks) { 461 const chromeos::NetworkStateHandler::NetworkStateList& networks) {
451 // Add a visual separator, unless this is the topmost entry in the list. 462 // Add a visual separator, unless this is the topmost entry in the list.
452 if (!list_empty_) { 463 if (!list_empty_)
453 views::Separator* const separator = 464 container()->AddChildView(TrayPopupUtils::CreateListSubHeaderSeparator());
454 new views::Separator(views::Separator::HORIZONTAL);
455 separator->SetColor(kBorderLightColor);
456 container()->AddChildView(separator);
457 } else {
458 list_empty_ = false;
459 }
460 std::string vpn_name = 465 std::string vpn_name =
461 vpn_provider.third_party 466 vpn_provider.third_party
462 ? vpn_provider.third_party_provider_name 467 ? vpn_provider.third_party_provider_name
463 : l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_VPN_BUILT_IN_PROVIDER); 468 : l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_VPN_BUILT_IN_PROVIDER);
464 469
465 // Add a list entry for the VPN provider. 470 // Add a list entry for the VPN provider.
466 views::View* provider_view = nullptr; 471 views::View* provider_view = nullptr;
467 if (UseMd()) { 472 if (UseMd()) {
468 provider_view = new VPNListProviderEntryMd( 473 provider_view = new VPNListProviderEntryMd(
469 this, vpn_name, IDS_ASH_STATUS_TRAY_ADD_CONNECTION); 474 this, list_empty_, vpn_name, IDS_ASH_STATUS_TRAY_ADD_CONNECTION);
470 } else { 475 } else {
471 provider_view = new VPNListProviderEntry(this, vpn_name); 476 provider_view = new VPNListProviderEntry(this, vpn_name);
472 } 477 }
473 container()->AddChildView(provider_view); 478 container()->AddChildView(provider_view);
474 provider_view_map_[provider_view] = vpn_provider; 479 provider_view_map_[provider_view] = vpn_provider;
480 list_empty_ = false;
475 // Add the networks belonging to this provider, in the priority order returned 481 // Add the networks belonging to this provider, in the priority order returned
476 // by shill. 482 // by shill.
477 for (const chromeos::NetworkState* const& network : networks) { 483 for (const chromeos::NetworkState* const& network : networks) {
478 if (VpnProviderMatchesNetwork(vpn_provider, *network)) 484 if (VpnProviderMatchesNetwork(vpn_provider, *network))
479 AddNetwork(network); 485 AddNetwork(network);
480 } 486 }
481 } 487 }
482 488
483 void VPNListView::AddProvidersAndNetworks( 489 void VPNListView::AddProvidersAndNetworks(
484 const chromeos::NetworkStateHandler::NetworkStateList& networks) { 490 const chromeos::NetworkStateHandler::NetworkStateList& networks) {
(...skipping 15 matching lines...) Expand all
500 } 506 }
501 } 507 }
502 508
503 // Add providers without any configured networks, in the order that the 509 // Add providers without any configured networks, in the order that the
504 // providers were returned by the extensions system. 510 // providers were returned by the extensions system.
505 for (const VPNProvider& provider : providers) 511 for (const VPNProvider& provider : providers)
506 AddProviderAndNetworks(provider, networks); 512 AddProviderAndNetworks(provider, networks);
507 } 513 }
508 514
509 } // namespace ash 515 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/network_list_md.cc ('k') | ash/common/system/tray/tray_details_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698