Skip to content

Commit 5d3d4b3

Browse files
committed
Implement tizen view elementary's ctxpopup_ for autofill
1 parent 5566608 commit 5d3d4b3

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

flutter/shell/platform/tizen/tizen_view_elementary.cc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <string>
99

1010
#include "flutter/shell/platform/tizen/logger.h"
11+
#include "flutter/shell/platform/tizen/tizen_autofill.h"
1112
#include "flutter/shell/platform/tizen/tizen_view_event_handler_delegate.h"
1213

1314
namespace flutter {
@@ -354,6 +355,34 @@ void TizenViewElementary::PrepareInputMethod() {
354355
[this]() { view_delegate_->OnComposeEnd(); });
355356
input_method_context_->SetOnCommit(
356357
[this](std::string str) { view_delegate_->OnCommit(str); });
358+
#ifdef AUTOFILL_SUPPORT
359+
ctxpopup_ = elm_ctxpopup_add(container_);
360+
361+
input_method_context_->SetOnPopupAutofillContext([this]() {
362+
if (TizenAutofill::GetInstance().GetAutofillItems().size() > 0) {
363+
for (auto& item : TizenAutofill::GetInstance().GetAutofillItems()) {
364+
elm_ctxpopup_item_append(
365+
ctxpopup_, item->label_.c_str(), nullptr,
366+
[](void* data, Evas_Object* obj, void* event_info) {
367+
AutofillItem* item = static_cast<AutofillItem*>(data);
368+
TizenAutofill::GetInstance().OnCommit(item->value_);
369+
evas_object_hide(obj);
370+
},
371+
item.get());
372+
}
373+
}
374+
// TODO : Change ctxpopup's position to focused input field.
375+
evas_object_move(ctxpopup_, 0, 0);
376+
evas_object_show(ctxpopup_);
377+
});
378+
379+
evas_object_event_callback_add(
380+
ctxpopup_, EVAS_CALLBACK_HIDE,
381+
[](void* data, Evas* e, Evas_Object* obj, void* event_info) {
382+
elm_ctxpopup_clear(obj);
383+
},
384+
nullptr);
385+
#endif
357386
}
358387

359388
} // namespace flutter

flutter/shell/platform/tizen/tizen_view_elementary.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class TizenViewElementary : public TizenView {
5151
Evas_Object* parent_ = nullptr;
5252
Evas_Object* container_ = nullptr;
5353
Evas_Object* image_ = nullptr;
54+
#ifdef AUTOFILL_SUPPORT
55+
Evas_Object* ctxpopup_ = nullptr;
56+
#endif
5457

5558
std::unordered_map<Evas_Callback_Type, Evas_Object_Event_Cb>
5659
evas_object_callbacks_;

0 commit comments

Comments
 (0)