Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引擎接口重构,修改相关代码 #2110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 0 additions & 4 deletions example/ohos/entry/src/main/ets/entryability/EntryAbility.ets
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,15 @@ export default class EntryAbility extends UIAbility implements FlutterBoostDeleg

async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate');
FlutterManager.getInstance().pushUIAbility(this)
}

onDestroy(): void {
hilog.info(0x0000, TAG, '%{public}s', 'Ability onDestroy');
FlutterManager.getInstance().popUIAbility(this)
}

// Main window is created, set main page for this ability
onWindowStageCreate(windowStage: window.WindowStage): void {
hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate');
FlutterManager.getInstance().pushWindowStage(this, windowStage)

let applicationInfo = ApplicationInfoLoader.load(this.context);
const options: FlutterBoostSetupOptions = new FlutterBoostSetupOptionsBuilder()
Expand Down Expand Up @@ -124,7 +121,6 @@ export default class EntryAbility extends UIAbility implements FlutterBoostDeleg
// Main window is destroyed, release UI related resources
onWindowStageDestroy(): void {
hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageDestroy');
FlutterManager.getInstance().popWindowStage(this)
}

// Ability has brought to foreground
Expand Down
3 changes: 2 additions & 1 deletion example/ohos/entry/src/main/ets/pages/FlutterUIComponent.ets
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { common } from '@kit.AbilityKit';
import Curves from '@ohos.curves'
import hilog from '@ohos.hilog';
import { FlutterBoostEntry } from 'flutter_boost';
Expand All @@ -18,7 +19,7 @@ export struct FlutterUIComponent {

async aboutToAppear() {
hilog.info(0x0000, TAG, 'Component(#%{public}s) aboutToAppear===', this.uri);
this.flutterEntry = new FlutterBoostEntry(getContext(this),
this.flutterEntry = new FlutterBoostEntry(getContext(this) as common.UIAbilityContext,
//!!!这里的uri、params这两个属性的名字必须跟example中的保持一致 !!!
{ uri: this.uri, params: this.params },
false,
Expand Down
5 changes: 3 additions & 2 deletions example/ohos/entry/src/main/ets/pages/FlutterUIDialog.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

import { common } from '@kit.AbilityKit';
import Curves from '@ohos.curves'
import hilog from '@ohos.hilog';
import { FlutterBoostEntry } from 'flutter_boost';
Expand All @@ -42,7 +42,8 @@ export struct FlutterUIDialog {

async aboutToAppear() {
hilog.info(0x0000, TAG, "aboutToAppear===");
this.flutterEntry = new FlutterBoostEntry(getContext(this), this.routerOptions, /*isDialog*/true);
let context = getContext(this) as common.UIAbilityContext;
this.flutterEntry = new FlutterBoostEntry(context, this.routerOptions, /*isDialog*/true);
await this.flutterEntry.aboutToAppear();
// The |aboutToAppear| method is called first,
// followed by the |getFlutterView| method.
Expand Down
5 changes: 3 additions & 2 deletions example/ohos/entry/src/main/ets/pages/FlutterUIPage.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

import { common } from '@kit.AbilityKit';
import hilog from '@ohos.hilog';
import { FlutterBoostEntry } from 'flutter_boost';
import { FlutterPage, FlutterView } from '@ohos/flutter_ohos';
Expand All @@ -43,7 +43,8 @@ export struct FlutterUIPage {

async aboutToAppear() {
hilog.info(0x0000, TAG, "aboutToAppear===");
this.flutterEntry = new FlutterBoostEntry(getContext(this), this.routerOptions, false, this.onPopCallback);
let context = getContext(this) as common.UIAbilityContext;
this.flutterEntry = new FlutterBoostEntry(context, this.routerOptions, false, this.onPopCallback);
await this.flutterEntry.aboutToAppear();
// The |aboutToAppear| method is called first,
// followed by the |getFlutterView| method.
Expand Down
7 changes: 3 additions & 4 deletions ohos/src/main/ets/components/containers/FlutterBoostEntry.ets
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

import { common } from '@kit.AbilityKit';
import { FlutterEntry, PlatformPlugin, } from '@ohos/flutter_ohos';
import { FlutterViewContainer } from './FlutterViewContainer';
import { LifecycleStage } from './Lifecycle';
Expand All @@ -39,14 +39,14 @@ export default class FlutterBoostEntry extends FlutterEntry implements FlutterVi
private isAttached: boolean = false
private platformPlugin?: PlatformPlugin | null
private stage?: LifecycleStage;
private thisContext: Context;
private thisContext: common.UIAbilityContext;
private routerOptions: ESObject;
private isDialogMode: boolean;
private routeStack: NavPathStack | null = null;
private isStackPopping: boolean = false
private onPopCallback?: (result: Record<string, Object>) => void;

constructor(context: Context, routerOptions: ESObject, isDialog?: boolean, onPop?: (result: Record<string, Object>) => void) {
constructor(context: common.UIAbilityContext, routerOptions: ESObject, isDialog?: boolean, onPop?: (result: Record<string, Object>) => void) {
super(context);

this.thisContext = context;
Expand Down Expand Up @@ -338,7 +338,6 @@ export default class FlutterBoostEntry extends FlutterEntry implements FlutterVi
if (!this.platformPlugin) {
this.platformPlugin = this.providePlatformPlugin(this.getFlutterEngine()!);
this.platformPlugin?.initWindow();
this.platformPlugin?.setUIAbilityContext(this.getAbility().context);
}
}

Expand Down