Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion flutter/shell/platform/tizen/channels/platform_view_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace flutter {
namespace {

constexpr char kChannelName[] = "flutter/platform_views";
constexpr int kLayoutDirectionLtr = 0;
constexpr int kLayoutDirectionRtl = 1;

} // namespace

Expand Down Expand Up @@ -112,6 +114,8 @@ void PlatformViewChannel::HandleMethodCall(
OnResize(arguments, std::move(result));
} else if (method == "touch") {
OnTouch(arguments, std::move(result));
} else if (method == "setDirection") {
OnSetDirection(arguments, std::move(result));
} else {
FT_LOG(Warn) << "Unimplemented method: " << method;
result->NotImplemented();
Expand All @@ -131,8 +135,9 @@ void PlatformViewChannel::OnCreate(
EncodableValueHolder<int> view_id(map, "id");
EncodableValueHolder<double> width(map, "width");
EncodableValueHolder<double> height(map, "height");
EncodableValueHolder<int> direction(map, "direction");

if (!view_type || !view_id || !width || !height) {
if (!view_type || !view_id || !width || !height || !direction) {
result->Error("Invalid arguments");
return;
}
Expand All @@ -154,6 +159,7 @@ void PlatformViewChannel::OnCreate(
PlatformView* view = iter->second->Create(
*view_id, *width * pixel_ratio_, *height * pixel_ratio_, byte_message);
if (view) {
view->SetDirection(*direction);
views_[*view_id] = view;
result->Success(EncodableValue(view->GetTextureId()));
} else {
Expand Down Expand Up @@ -315,4 +321,41 @@ void PlatformViewChannel::OnTouch(
result->Success();
}

void PlatformViewChannel::OnSetDirection(
const EncodableValue* arguments,
std::unique_ptr<MethodResult<EncodableValue>>&& result) {
auto* map = std::get_if<EncodableMap>(arguments);
if (!map) {
result->Error("Invalid arguments");
return;
}

EncodableValueHolder<int> view_id(map, "id");
EncodableValueHolder<int> direction(map, "direction");

if (!view_id || !direction) {
result->Error("Invalid arguments");
return;
}
if (!ValidateDirection(*direction)) {
result->Error(
"Trying to set unknown direction value: " + std::to_string(*direction) +
"(view id: " + std::to_string(*view_id) + ")");
return;
}

PlatformView* view = FindViewById(*view_id);
if (!view) {
result->Error("Can't find view id");
return;
}

view->SetDirection(*direction);
result->Success();
}

bool PlatformViewChannel::ValidateDirection(int direction) {
return direction == kLayoutDirectionLtr || direction == kLayoutDirectionRtl;
}

} // namespace flutter
3 changes: 3 additions & 0 deletions flutter/shell/platform/tizen/channels/platform_view_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class PlatformViewChannel {
void RemoveViewIfExists(int view_id);
void ClearViews();
void ClearViewFactories();
bool ValidateDirection(int direction);

void HandleMethodCall(const MethodCall<EncodableValue>& call,
std::unique_ptr<MethodResult<EncodableValue>> result);
Expand All @@ -59,6 +60,8 @@ class PlatformViewChannel {
std::unique_ptr<MethodResult<EncodableValue>>&& result);
void OnTouch(const EncodableValue* arguments,
std::unique_ptr<MethodResult<EncodableValue>>&& result);
void OnSetDirection(const EncodableValue* arguments,
std::unique_ptr<MethodResult<EncodableValue>>&& result);

std::unique_ptr<MethodChannel<EncodableValue>> channel_;
std::map<std::string, std::unique_ptr<PlatformViewFactory>> view_factories_;
Expand Down