ipad的竖屏在哪里设置,ipad平板怎么设置为竖屏

首页 > 实用技巧 > 作者:YD1662023-07-31 08:33:38

c 层支持后,在调用dart侧的入口函数时,带上application_id,传递到Dart侧的入口main函数

bool DartIsolate::InvokeEntryPointInSharedIsolate(
std::unique_ptr<PlatformConfiguration> platform_configuration,
std::optional<std::string> library_name,
std::optional<std::string> entrypoint,
const std::vector<std::string>& args) {
tonic::DartState::Scope scope(this);
int64_t application_id = platform_configuration->application_id;

....

if (!InvokeMainEntrypoint(user_entrypoint_function, entrypoint_args,
application_id)) {
return false;
}

return true;
}

Dart代码单例问题

在原来Fltuter引擎framework层中存在多个单例如window,BindingsPlatformDispatcher,如何解决不同Application访问自己的单例?

使用Application.current获取当前application后再访问具体单例对象。以window为例

SingletonFlutterWindow get window => Application.current.get(
SingletonFlutterWindow,
=> SingletonFlutterWindow._(0, PlatformDispatcher.instance)
);

再dart层的渲染计算后,最终还会将渲染树数据调用回到的c层。在回调到c函数时,也需要带上applicationId

// platform_configuration.cc
void Render(Dart_NativeArguments args) {
UIDartState::ThrowIfUIOperationsProhibited;
Dart_Handle exception = ptr;
int64_t application_id =
tonic::DartConverter<int>::FromArguments(args, 1, exception);
Scene* scene =
tonic::DartConverter<Scene*>::FromArguments(args, 2, exception);
if (exception) {
Dart_ThrowException(exception);
return;
}
UIDartState::Current
->platform_configuration(application_id)
->client
->Render(scene);
}

自此从flutter的Dart函数入口,到dart函数内部调用渲染流程,最后调用回到c 层,都有applicatinId去标识不同的引擎。

这样就做到多个引擎之间既能渲染相互隔离,但内部又能访问的结果。

总结

最后看下完成后的效果视频截图

横竖屏切换

ipad的竖屏在哪里设置,ipad平板怎么设置为竖屏(17)

分屏导航模式

ipad的竖屏在哪里设置,ipad平板怎么设置为竖屏(18)

分屏比价模式

ipad的竖屏在哪里设置,ipad平板怎么设置为竖屏(19)

Flutter多引擎特性除了能应用到iPad场景外,还能应用到Android折叠屏场景。目前这部分的工作也在有序过程中。自定义NavigationViewController以及Flutter引擎的修改工作,也会在性能稳定后开源到社区共建。

闲鱼iPad版发布工作还在紧张灰度中,欢迎大家继续关注。

引用资料

supporting multiple windows on ipad https://developer.apple.com/documentation/uikit/uiscenedelegate/supporting_multiple_windows_on_ipad

Light weight Flutter engine :https://docs.google.com/document/d/1NwiZPWHd1te46eP2GWwIezDV9CdMQkODAMuF5kWdtLw/edit# https://developer.apple.com/documentation/uikit/view_controllers/creating_a_custom_container_view_controller

https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html

ipad的竖屏在哪里设置,ipad平板怎么设置为竖屏(20)

上一页12345下一页

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.