Skip to content

Commit 0f5a10e

Browse files
committed
Implement tizen view nui's popup_ for autofill
1 parent 5d3d4b3 commit 0f5a10e

File tree

6 files changed

+128
-6
lines changed

6 files changed

+128
-6
lines changed

flutter/shell/platform/tizen/BUILD.gn

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ template("embedder") {
201201
defines += [ "AUTOFILL_SUPPORT" ]
202202
}
203203

204-
if (target_name != "flutter_tizen_wearable" && (major_version >= 7 || (major_version >= 6 && minor_version >= 5))) {
204+
if ((major_version >= 7 || (major_version >= 6 && minor_version >= 5)) && target_name != "flutter_tizen_wearable") {
205205
sources += [
206206
"flutter_tizen_nui.cc",
207207
"tizen_view_nui.cc",
208+
"nui_autofill_popup.cc",
208209
]
209210

210211
libs += [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include "flutter/shell/platform/tizen/nui_autofill_popup.h"
2+
3+
#include <dali-toolkit/dali-toolkit.h>
4+
#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
5+
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
6+
7+
#include "flutter/shell/platform/tizen/tizen_autofill.h"
8+
9+
#include "flutter/shell/platform/tizen/logger.h"
10+
11+
namespace flutter {
12+
bool NuiAutofillPopup::OnTouch(Dali::Actor actor,
13+
const Dali::TouchEvent& event) {
14+
const Dali::PointState::Type state = event.GetState(0);
15+
if (Dali::PointState::DOWN == state) {
16+
auto t = actor.GetProperty(Dali::Actor::Property::NAME).Get<std::string>();
17+
on_commit_(t);
18+
OnHide();
19+
}
20+
return true;
21+
}
22+
23+
void NuiAutofillPopup::OnHide() {
24+
// TODO : There is a phenomenon where white traces remain for a while when
25+
// popup disappears.
26+
popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN);
27+
}
28+
29+
void NuiAutofillPopup::OnHidden() {
30+
popup_.Unparent();
31+
popup_.Reset();
32+
}
33+
34+
void NuiAutofillPopup::PrepareAutofill() {
35+
popup_ = Dali::Toolkit::Popup::New();
36+
popup_.SetProperty(Dali::Actor::Property::NAME, "popup");
37+
popup_.SetProperty(Dali::Actor::Property::PARENT_ORIGIN,
38+
Dali::ParentOrigin::TOP_LEFT);
39+
popup_.SetProperty(Dali::Actor::Property::ANCHOR_POINT,
40+
Dali::AnchorPoint::TOP_LEFT);
41+
popup_.SetProperty(Dali::Toolkit::Popup::Property::TAIL_VISIBILITY, false);
42+
popup_.SetBackgroundColor(Dali::Color::WHITE_SMOKE);
43+
popup_.OutsideTouchedSignal().Connect(this, &NuiAutofillPopup::OnHide);
44+
popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::OnHidden);
45+
popup_.SetProperty(Dali::Toolkit::Popup::Property::BACKING_ENABLED, false);
46+
popup_.SetProperty(Dali::Toolkit::Popup::Property::AUTO_HIDE_DELAY, 2500);
47+
}
48+
49+
void NuiAutofillPopup::PopupAutofill(Dali::Actor* actor) {
50+
const auto& items = TizenAutofill::GetInstance().GetAutofillItems();
51+
if (items.size() > 0) {
52+
PrepareAutofill();
53+
Dali::Toolkit::TableView content =
54+
Dali::Toolkit::TableView::New(items.size(), 1);
55+
// content.SetCellPadding(Dali::Size(10.0f, 0));
56+
content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT,
57+
Dali::Dimension::ALL_DIMENSIONS);
58+
content.SetProperty(Dali::Actor::Property::PADDING,
59+
Dali::Vector4(10, 10, 0, 0));
60+
for (uint32_t i = 0; i < items.size(); ++i) {
61+
auto label = Dali::Toolkit::TextLabel::New(items[i]->label_);
62+
label.SetProperty(Dali::Actor::Property::NAME, items[i]->value_);
63+
label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY,
64+
Dali::Dimension::HEIGHT);
65+
label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR,
66+
Dali::Color::WHITE_SMOKE);
67+
label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f);
68+
label.TouchedSignal().Connect(this, &NuiAutofillPopup::OnTouch);
69+
content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0));
70+
content.SetFitHeight(i);
71+
}
72+
popup_.SetProperty(Dali::Actor::Property::SIZE,
73+
Dali::Vector2(140.0f, 35.0f * items.size()));
74+
popup_.SetContent(content);
75+
popup_.SetDisplayState(Dali::Toolkit::Popup::SHOWN);
76+
actor->Add(popup_);
77+
}
78+
}
79+
80+
} // namespace flutter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef EMBEDDER_NUI_AUTOFILL_POPUP_H_
6+
#define EMBEDDER_NUI_AUTOFILL_POPUP_H_
7+
8+
#include <dali-toolkit/devel-api/controls/popup/popup.h>
9+
10+
#include <functional>
11+
12+
namespace flutter {
13+
14+
using OnCommit = std::function<void(std::string str)>;
15+
using OnRendering = std::function<void()>;
16+
17+
class NuiAutofillPopup : public Dali::ConnectionTracker {
18+
public:
19+
bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& event);
20+
21+
void OnHide();
22+
23+
void OnHidden();
24+
25+
void PrepareAutofill();
26+
27+
void PopupAutofill(Dali::Actor* actor);
28+
29+
void SetOnCommit(OnCommit callback) { on_commit_ = callback; }
30+
31+
private:
32+
Dali::Toolkit::Popup popup_;
33+
OnCommit on_commit_;
34+
};
35+
36+
} // namespace flutter
37+
38+
#endif

flutter/shell/platform/tizen/tizen_input_method_context.cc

-4
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ void TizenInputMethodContext::ShowInputPanel() {
259259
FT_ASSERT(imf_context_);
260260
ecore_imf_context_input_panel_show(imf_context_);
261261
ecore_imf_context_focus_in(imf_context_);
262-
int x = 0, y = 0, w = 0, h = 0;
263-
264-
ecore_imf_context_input_panel_geometry_get(imf_context_, &x, &y, &w, &h);
265-
FT_LOG(Error) << x << " " << y << " " << w << " " << h;
266262
}
267263

268264
void TizenInputMethodContext::HideInputPanel() {

flutter/shell/platform/tizen/tizen_view_nui.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "flutter/shell/platform/tizen/tizen_view_nui.h"
66

77
#include <dali/devel-api/common/stage.h>
8-
98
#include <string>
109

1110
#include "flutter/shell/platform/tizen/logger.h"
@@ -112,6 +111,12 @@ void TizenViewNui::PrepareInputMethod() {
112111
[this]() { view_delegate_->OnComposeEnd(); });
113112
input_method_context_->SetOnCommit(
114113
[this](std::string str) { view_delegate_->OnCommit(str); });
114+
115+
input_method_context_->SetOnPopupAutofillContext(
116+
[this]() { autofill_.PopupAutofill(image_view_); });
117+
118+
autofill_.SetOnCommit(
119+
[this](std::string str) { view_delegate_->OnCommit(str); });
115120
}
116121

117122
void TizenViewNui::RenderOnce() {

flutter/shell/platform/tizen/tizen_view_nui.h

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <memory>
1414

15+
#include "flutter/shell/platform/tizen/nui_autofill_popup.h"
1516
#include "flutter/shell/platform/tizen/tizen_view.h"
1617

1718
namespace flutter {
@@ -66,6 +67,7 @@ class TizenViewNui : public TizenView {
6667
Dali::NativeImageSourceQueuePtr native_image_queue_;
6768
int32_t default_window_id_;
6869
std::unique_ptr<Dali::EventThreadCallback> rendering_callback_;
70+
NuiAutofillPopup autofill_;
6971
};
7072

7173
} // namespace flutter

0 commit comments

Comments
 (0)