diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets index 71c2a68e10832e3f326cc9d975233e10470c4fa7..322ffd13a83b3e91c9ab038edcdca7049480df8e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/component/XComponentStruct.ets @@ -13,22 +13,44 @@ * limitations under the License. */ import Any from '../plugin/common/Any'; +import ApplicationInfoLoader from '../embedding/engine/loader/ApplicationInfoLoader'; import { BuilderParams, DVModelParameters } from '../view/DynamicView/dynamicView'; @Component struct XComponentStruct { private context: Any; + private applicationInfo = ApplicationInfoLoader.load(getContext()); dvModelParams: DVModelParameters = new DVModelParameters(); build() { - XComponent({ id: (this.dvModelParams as Record)["xComponentId"], type: XComponentType.SURFACE, libraryname: 'flutter'}) - .onLoad((context) => { - this.context = context; + // todo OS解决默认背景色后可以移除冗余重复代码,仅保留差异的backgroundColor属性条件配置 + if (this.applicationInfo.isDebugMode) { + XComponent({ + id: (this.dvModelParams as Record)["xComponentId"], + type: XComponentType.SURFACE, + libraryname: 'flutter' }) - .onDestroy(() => { + .onLoad((context) => { + this.context = context; + }) + .onDestroy(() => { + }) + .backgroundColor(Color.White) + } else { + XComponent({ + id: (this.dvModelParams as Record)["xComponentId"], + type: XComponentType.SURFACE, + libraryname: 'flutter' }) + .onLoad((context) => { + this.context = context; + }) + .onDestroy(() => { + }) + } } + } @Builder export function BuildXComponentStruct(buildParams: BuilderParams) { diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets index 84081fac925a2e72ad5d176f2c157bf4a6e0e177..bf2f16267bc5695c42a8adb18dbc6c747aeeb8fb 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/ohos/FlutterPage.ets @@ -26,6 +26,8 @@ import { } from '../../view/DynamicView/dynamicView'; import { createDVModelFromJson } from '../../view/DynamicView/dynamicViewJson'; import { FlutterView } from '../../view/FlutterView'; +import ApplicationInfoLoader from '../engine/loader/ApplicationInfoLoader'; +import FlutterApplicationInfo from '../engine/loader/FlutterApplicationInfo'; import KeyEventChannel from '../engine/systemchannels/KeyEventChannel'; import FlutterManager from './FlutterManager'; @@ -40,6 +42,7 @@ export struct FlutterPage { @Prop viewId: string = "" @Prop xComponentType: XComponentType = XComponentType.SURFACE private flutterView?: FlutterView | null + private applicationInfo = ApplicationInfoLoader.load(getContext()); aboutToAppear() { this.flutterView = FlutterManager.getInstance().getFlutterView(this.viewId); @@ -48,16 +51,32 @@ export struct FlutterPage { build() { Stack() { - XComponent({ id: this.viewId, type: this.xComponentType, libraryname: 'flutter' }) - .focusable(true) - .onLoad((context) => { - this.flutterView?.onSurfaceCreated() - Log.d(TAG, "XComponent onLoad "); - }) - .onDestroy(() => { - Log.d(TAG, "XComponent onDestroy "); - this.flutterView?.onSurfaceDestroyed() - }) + // todo OS解决默认背景色后可以移除冗余重复代码,仅保留差异的backgroundColor属性条件配置 + if (this.applicationInfo.isDebugMode) { + XComponent({ id: this.viewId, type: this.xComponentType, libraryname: 'flutter' }) + .focusable(true) + .onLoad((context) => { + this.flutterView?.onSurfaceCreated() + Log.d(TAG, "XComponent onLoad "); + }) + .onDestroy(() => { + Log.d(TAG, "XComponent onDestroy "); + this.flutterView?.onSurfaceDestroyed() + }) + .backgroundColor(Color.White) + } else { + XComponent({ id: this.viewId, type: this.xComponentType, libraryname: 'flutter' }) + .focusable(true) + .onLoad((context) => { + this.flutterView?.onSurfaceCreated() + Log.d(TAG, "XComponent onLoad "); + }) + .onDestroy(() => { + Log.d(TAG, "XComponent onDestroy "); + this.flutterView?.onSurfaceDestroyed() + }) + } + ForEach(this.rootDvModel!!, (child:Any) =>{ DynamicView({ model: child as DVModel,