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

Side by Side Diff: chrome/browser/ui/views/payments/editor_view_controller.cc

Issue 2692923011: [Payments] Adjust the UI fit the mocks better (Closed)
Patch Set: adds ascii art Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/views/payments/editor_view_controller.h" 5 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" 12 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h"
13 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" 13 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h"
14 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" 14 #include "chrome/browser/ui/views/payments/payment_request_views_util.h"
15 #include "chrome/browser/ui/views/payments/validating_combobox.h" 15 #include "chrome/browser/ui/views/payments/validating_combobox.h"
16 #include "chrome/browser/ui/views/payments/validating_textfield.h" 16 #include "chrome/browser/ui/views/payments/validating_textfield.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "components/payments/payment_request.h" 18 #include "components/payments/payment_request.h"
19 #include "components/strings/grit/components_strings.h" 19 #include "components/strings/grit/components_strings.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/border.h" 22 #include "ui/views/border.h"
22 #include "ui/views/controls/button/label_button.h" 23 #include "ui/views/controls/button/label_button.h"
23 #include "ui/views/controls/button/md_text_button.h" 24 #include "ui/views/controls/button/md_text_button.h"
24 #include "ui/views/controls/label.h" 25 #include "ui/views/controls/label.h"
25 #include "ui/views/controls/styled_label.h" 26 #include "ui/views/controls/styled_label.h"
26 #include "ui/views/controls/textfield/textfield.h" 27 #include "ui/views/controls/textfield/textfield.h"
27 #include "ui/views/layout/box_layout.h" 28 #include "ui/views/layout/box_layout.h"
28 #include "ui/views/layout/grid_layout.h" 29 #include "ui/views/layout/grid_layout.h"
29 #include "ui/views/view.h" 30 #include "ui/views/view.h"
30 31
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 71 }
71 72
72 return CreatePaymentView( 73 return CreatePaymentView(
73 CreateSheetHeaderView( 74 CreateSheetHeaderView(
74 true, l10n_util::GetStringUTF16( 75 true, l10n_util::GetStringUTF16(
75 IDS_PAYMENT_REQUEST_CREDIT_CARD_EDITOR_ADD_TITLE), 76 IDS_PAYMENT_REQUEST_CREDIT_CARD_EDITOR_ADD_TITLE),
76 this), 77 this),
77 std::move(content_view)); 78 std::move(content_view));
78 } 79 }
79 80
81 // Adds the "required fields" label in disabled text, to obtain this result.
82 // +---------------------------------------------------------+
83 // | "* indicates required fields" | CANCEL | DONE |
84 // +---------------------------------------------------------+
85 std::unique_ptr<views::View> EditorViewController::CreateLeadingFooterView() {
86 std::unique_ptr<views::View> content_view = base::MakeUnique<views::View>();
87
88 views::BoxLayout* layout =
89 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
90 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_START);
91 layout->set_cross_axis_alignment(
92 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
93 content_view->SetLayoutManager(layout);
94
95 // Adds the "* indicates a required field" label in "disabled" grey text.
96 std::unique_ptr<views::Label> label = base::MakeUnique<views::Label>(
97 l10n_util::GetStringUTF16(IDS_PAYMENTS_REQUIRED_FIELD_MESSAGE));
98 label->SetDisabledColor(label->GetNativeTheme()->GetSystemColor(
99 ui::NativeTheme::kColorId_LabelDisabledColor));
100 label->SetEnabled(false);
101 content_view->AddChildView(label.release());
102 return content_view;
103 }
104
80 std::unique_ptr<views::Button> EditorViewController::CreatePrimaryButton() { 105 std::unique_ptr<views::Button> EditorViewController::CreatePrimaryButton() {
81 std::unique_ptr<views::Button> button( 106 std::unique_ptr<views::Button> button(
82 views::MdTextButton::CreateSecondaryUiBlueButton( 107 views::MdTextButton::CreateSecondaryUiBlueButton(
83 this, l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON))); 108 this, l10n_util::GetStringUTF16(IDS_DONE)));
84 button->set_tag(static_cast<int>(EditorViewControllerTags::SAVE_BUTTON)); 109 button->set_tag(static_cast<int>(EditorViewControllerTags::SAVE_BUTTON));
85 button->set_id(static_cast<int>(DialogViewID::EDITOR_SAVE_BUTTON)); 110 button->set_id(static_cast<int>(DialogViewID::EDITOR_SAVE_BUTTON));
86 return button; 111 return button;
87 } 112 }
88 113
89 void EditorViewController::ButtonPressed(views::Button* sender, 114 void EditorViewController::ButtonPressed(views::Button* sender,
90 const ui::Event& event) { 115 const ui::Event& event) {
91 switch (sender->tag()) { 116 switch (sender->tag()) {
92 case static_cast<int>(EditorViewControllerTags::SAVE_BUTTON): 117 case static_cast<int>(EditorViewControllerTags::SAVE_BUTTON):
93 if (ValidateModelAndSave()) 118 if (ValidateModelAndSave())
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // |combobox| will now be owned by |row|. 183 // |combobox| will now be owned by |row|.
159 layout->AddView(combobox); 184 layout->AddView(combobox);
160 } else { 185 } else {
161 NOTREACHED(); 186 NOTREACHED();
162 } 187 }
163 188
164 return row; 189 return row;
165 } 190 }
166 191
167 } // namespace payments 192 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698