|
8 | 8 | #include <string> |
9 | 9 |
|
10 | 10 | #include "flutter/shell/platform/tizen/logger.h" |
| 11 | +#include "flutter/shell/platform/tizen/tizen_autofill.h" |
11 | 12 | #include "flutter/shell/platform/tizen/tizen_view_event_handler_delegate.h" |
12 | 13 |
|
13 | 14 | namespace flutter { |
@@ -354,6 +355,34 @@ void TizenViewElementary::PrepareInputMethod() { |
354 | 355 | [this]() { view_delegate_->OnComposeEnd(); }); |
355 | 356 | input_method_context_->SetOnCommit( |
356 | 357 | [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 |
357 | 386 | } |
358 | 387 |
|
359 | 388 | } // namespace flutter |
0 commit comments