-
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 9 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,82 @@ | ||
| // 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::OnTouch(Dali::Actor actor, | ||
| const Dali::TouchEvent& event) { | ||
| const Dali::PointState::Type state = event.GetState(0); | ||
| if (Dali::PointState::DOWN == state) { | ||
| auto t = actor.GetProperty(Dali::Actor::Property::NAME).Get<std::string>(); | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| on_commit_(t); | ||
| OnHide(); | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return true; | ||
| } | ||
|
|
||
| void NuiAutofillPopup::OnHide() { | ||
bbrto21 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // TODO : There is a phenomenon where white traces remain for a while when | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // popup disappears. | ||
| popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN); | ||
| } | ||
|
|
||
| void NuiAutofillPopup::OnHidden() { | ||
| popup_.Unparent(); | ||
| popup_.Reset(); | ||
| } | ||
|
|
||
| void NuiAutofillPopup::PrepareAutofill() { | ||
| 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::OnHide); | ||
| popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::OnHidden); | ||
| 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::PopupAutofill(Dali::Actor* actor) { | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const auto& items = TizenAutofill::GetInstance().GetAutofillItems(); | ||
| if (items.size() > 0) { | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PrepareAutofill(); | ||
| Dali::Toolkit::TableView content = | ||
| Dali::Toolkit::TableView::New(items.size(), 1); | ||
| // content.SetCellPadding(Dali::Size(10.0f, 0)); | ||
JSUYA marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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) { | ||
| auto 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::OnTouch); | ||
| 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,38 @@ | ||
| // 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> | ||
|
Member
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 { | ||
|
|
||
| using OnCommit = std::function<void(std::string str)>; | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| using OnRendering = std::function<void()>; | ||
swift-kim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| class NuiAutofillPopup : public Dali::ConnectionTracker { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public: | ||
| bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& event); | ||
|
|
||
| void OnHide(); | ||
|
|
||
| void OnHidden(); | ||
|
|
||
| void PrepareAutofill(); | ||
|
|
||
| void PopupAutofill(Dali::Actor* actor); | ||
|
|
||
| void SetOnCommit(OnCommit callback) { on_commit_ = callback; } | ||
|
|
||
| private: | ||
| Dali::Toolkit::Popup popup_; | ||
| OnCommit on_commit_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.