Skip to content

Commit abd12b9

Browse files
authored
Add touch events of platform view channel for tizen (flutter-tizen#8)
* Send a event type, a button type and platform view's positions to a platform view which is registered for platformview factory
1 parent f15e3e4 commit abd12b9

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

shell/platform/tizen/channels/platform_view_channel.cc

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include "platform_view_channel.h"
55

66
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/plugin_registrar.h"
7-
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h"
87
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_message_codec.h"
8+
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/standard_method_codec.h"
99
#include "flutter/shell/platform/common/cpp/json_method_codec.h"
1010
#include "flutter/shell/platform/tizen/logger.h"
1111
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
@@ -52,6 +52,17 @@ flutter::EncodableMap extractMapFromMap(
5252
return flutter::EncodableMap();
5353
}
5454

55+
flutter::EncodableList extractListFromMap(
56+
const flutter::EncodableValue& arguments, const char* key) {
57+
if (std::holds_alternative<flutter::EncodableMap>(arguments)) {
58+
flutter::EncodableMap values = std::get<flutter::EncodableMap>(arguments);
59+
flutter::EncodableValue value = values[flutter::EncodableValue(key)];
60+
if (std::holds_alternative<flutter::EncodableList>(value))
61+
return std::get<flutter::EncodableList>(value);
62+
}
63+
return flutter::EncodableList();
64+
}
65+
5566
PlatformViewChannel::PlatformViewChannel(flutter::BinaryMessenger* messenger)
5667
: channel_(
5768
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
@@ -126,8 +137,23 @@ void PlatformViewChannel::HandleMethodCall(
126137
it->second->resize(width, height);
127138
result->NotImplemented();
128139
} else if (method == "touch") {
129-
LoggerD("PlatformViewChannel touch");
130-
result->NotImplemented();
140+
int type, button;
141+
double x, y, dx, dy;
142+
143+
flutter::EncodableList event = extractListFromMap(arguments, "event");
144+
if (event.size() != 6) {
145+
result->Error("Invalid Arguments");
146+
return;
147+
}
148+
type = std::get<int>(event[0]);
149+
button = std::get<int>(event[1]);
150+
x = std::get<double>(event[2]);
151+
y = std::get<double>(event[3]);
152+
dx = std::get<double>(event[4]);
153+
dy = std::get<double>(event[5]);
154+
155+
it->second->touch(type, button, x, y, dx, dy);
156+
result->Success();
131157
} else if (method == "setDirection") {
132158
LoggerD("PlatformViewChannel setDirection");
133159
result->NotImplemented();

shell/platform/tizen/public/flutter_platform_view.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class PlatformView {
2323
flutter::PluginRegistrar* getPluginRegistrar() { return registrar_; }
2424
virtual void dispose() = 0;
2525
virtual void resize(double width, double height) = 0;
26-
virtual void touch() = 0;
26+
virtual void touch(int type, int button, double x, double y, double dx,
27+
double dy) = 0;
2728
virtual void setDirection(int direction) = 0;
2829
virtual void clearFocus() = 0;
2930

0 commit comments

Comments
 (0)