flutter-tizen / flutter-tizen

Flutter tools for Tizen
https://github.com/flutter-tizen
BSD 3-Clause "New" or "Revised" License
448 stars 64 forks source link

Tizen PlatformView support #459

Open JSUYA opened 1 year ago

JSUYA commented 1 year ago

Flutter provides a way to render Android and IOS views in Flutter apps.

android - https://docs.flutter.dev/development/platform-integration/android/platform-views iOS - https://docs.flutter.dev/development/platform-integration/ios/platform-views

In Tizen, there are no specific scenarios that require this feature yet. However, we are already implementing and using a part (minimum) of PlatformView in the webview_flutter_tizen plugin.

https://github.com/flutter-tizen/plugins/issues/399#issuecomment-1298139243 As discussed in this comment, if TizenView is supported as a widget for tizen embedding, we can use it to support "Hosting tizen views in Flutter app with Platform Views". (just in my opinion)

I have not yet reviewed the discussion of the relevant interfaces and the specific plan. I have a simple plan to write a POC that renders a TizenView(elm or NUI) based on the webview's TizenView.

If you have any comments on this, please share to me.

JSUYA commented 1 year ago

I made the Tizen PlatformView example mentioned above.

This only works for cpp apps.(now) Set build_tizen_platform_view_ declared in FlutterApp class and add TizenSurfaceView in dart. (Tizen"Surface"View is a temporary name.)

std::function<void(Evas_Object *)> build_tizen_platform_view_;
  bool OnCreate() {
    build_tizen_platform_view_ = [=](Evas_Object *window) {
      add_content(window); // elm_button_add(window);
    };

    if (FlutterApp::OnCreate()) {
      RegisterPlugins(this);
    }
    return IsRunning();
  }
}
import 'package:tizen_surface_view/tizen_surface_view.dart';
...
        body: Center(
          child: TizenSurfaceView(
                viewType: 'plugins.flutter.io/tizen_surface_view',
              ),
        ),
...

This was made using tizen efl's ecore_evas_buffer and elm_fake_win. It supports touch and key input, but it is not perfect. (software keyboard not yet supported) And since ecore_evas_buffer and performs sw rendering, there may be performance and sync problems that occur in pixel copy. I will think about more solutions and make a Pullreqeust as soon as the C# version is organized.

(The flutter app ui in gif took from the isolate example of flutter samples. / https://flutter.github.io/samples/isolate_example.html)

Plugin https://github.com/JSUYA/plugins/tree/dev/tizen_surface_view

flutter-tizen https://github.com/JSUYA/flutter-tizen/tree/dev/tizen_surface_view2 https://github.com/JSUYA/flutter-tizen/commit/0cf0e70666352ae653ed7a8965e575ca2e284974

embedder https://github.com/JSUYA/embedder/tree/dev/tizen_surface_view2 https://github.com/JSUYA/embedder/commit/85e9071e932884b2c2f83a369c8590e6509b2066