-
Notifications
You must be signed in to change notification settings - Fork 9
Advanced text input options #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 14 commits
eb1278f
116154b
c959aa0
ff9486d
aa6623b
5566608
5d3d4b3
0f5a10e
aa1c87d
6b0a2d8
5821267
7978db9
9f93270
5aca9c2
f37e3fd
9f3b843
704c6b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "flutter/shell/platform/tizen/nui_autofill_popup.h" | ||
|
|
||
| #include <dali-toolkit/dali-toolkit.h> | ||
| #include <dali-toolkit/devel-api/controls/table-view/table-view.h> | ||
| #include <dali-toolkit/public-api/controls/text-controls/text-label.h> | ||
|
|
||
| #include "flutter/shell/platform/tizen/tizen_autofill.h" | ||
|
|
||
| namespace flutter { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| bool NuiAutofillPopup::Touched(Dali::Actor actor, | ||
| const Dali::TouchEvent& event) { | ||
| const Dali::PointState::Type state = event.GetState(0); | ||
| if (Dali::PointState::DOWN == state) { | ||
| std::string text = | ||
| actor.GetProperty(Dali::Actor::Property::NAME).Get<std::string>(); | ||
| on_commit_(text); | ||
| popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| void NuiAutofillPopup::Hidden() { | ||
| // TODO(Swanseo0): There is a phenomenon where white traces remain for a | ||
| // while when popup disappears. | ||
| popup_.Unparent(); | ||
| popup_.Reset(); | ||
| } | ||
|
|
||
| void NuiAutofillPopup::OutsideTouched() { | ||
| popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN); | ||
| } | ||
|
|
||
| void NuiAutofillPopup::Prepare() { | ||
| popup_ = Dali::Toolkit::Popup::New(); | ||
| popup_.SetProperty(Dali::Actor::Property::NAME, "popup"); | ||
| popup_.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, | ||
| Dali::ParentOrigin::TOP_LEFT); | ||
| popup_.SetProperty(Dali::Actor::Property::ANCHOR_POINT, | ||
| Dali::AnchorPoint::TOP_LEFT); | ||
| popup_.SetProperty(Dali::Toolkit::Popup::Property::TAIL_VISIBILITY, false); | ||
| popup_.SetBackgroundColor(Dali::Color::WHITE_SMOKE); | ||
| popup_.OutsideTouchedSignal().Connect(this, | ||
| &NuiAutofillPopup::OutsideTouched); | ||
| popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::Hidden); | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| popup_.SetProperty(Dali::Toolkit::Popup::Property::BACKING_ENABLED, false); | ||
| popup_.SetProperty(Dali::Toolkit::Popup::Property::AUTO_HIDE_DELAY, 2500); | ||
JSUYA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void NuiAutofillPopup::Show(Dali::Actor* actor) { | ||
| const std::vector<std::unique_ptr<AutofillItem>>& items = | ||
| TizenAutofill::GetInstance().GetResponseItems(); | ||
| if (!items.empty()) { | ||
| Prepare(); | ||
| Dali::Toolkit::TableView content = | ||
| Dali::Toolkit::TableView::New(items.size(), 1); | ||
| content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, | ||
| Dali::Dimension::ALL_DIMENSIONS); | ||
| content.SetProperty(Dali::Actor::Property::PADDING, | ||
| Dali::Vector4(10, 10, 0, 0)); | ||
| for (uint32_t i = 0; i < items.size(); ++i) { | ||
| Dali::Toolkit::TextLabel label = | ||
| Dali::Toolkit::TextLabel::New(items[i]->label_); | ||
| label.SetProperty(Dali::Actor::Property::NAME, items[i]->value_); | ||
| label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY, | ||
| Dali::Dimension::HEIGHT); | ||
| label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR, | ||
| Dali::Color::WHITE_SMOKE); | ||
| label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f); | ||
|
||
| label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched); | ||
| content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0)); | ||
| content.SetFitHeight(i); | ||
| } | ||
| popup_.SetProperty(Dali::Actor::Property::SIZE, | ||
| Dali::Vector2(140.0f, 35.0f * items.size())); | ||
JSUYA marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| popup_.SetContent(content); | ||
| popup_.SetDisplayState(Dali::Toolkit::Popup::SHOWN); | ||
| actor->Add(popup_); | ||
| } | ||
| } | ||
|
|
||
| } // namespace flutter | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef EMBEDDER_NUI_AUTOFILL_POPUP_H_ | ||
| #define EMBEDDER_NUI_AUTOFILL_POPUP_H_ | ||
|
|
||
| #include <dali-toolkit/devel-api/controls/popup/popup.h> | ||
|
|
||
| #include <functional> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing includes? #include <dali/public-api/dali-core.h>
#include <string>Please consult me or @bbrto21 on how to organize includes in the implementation file ( |
||
|
|
||
| namespace flutter { | ||
|
|
||
| class NuiAutofillPopup : public Dali::ConnectionTracker { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public: | ||
| void Prepare(); | ||
|
|
||
| void Show(Dali::Actor* actor); | ||
|
|
||
| void SetOnCommit(std::function<void(const std::string&)> callback) { | ||
| on_commit_ = callback; | ||
| } | ||
|
|
||
| private: | ||
| void Hidden(); | ||
|
|
||
| void OutsideTouched(); | ||
|
|
||
| bool Touched(Dali::Actor actor, const Dali::TouchEvent& event); | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Dali::Toolkit::Popup popup_; | ||
| std::function<void(const std::string&)> on_commit_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.