-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
312 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
example/ohos/entry/src/main/ets/constants/RouterConstants.ets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class RouterNameConstants { | ||
static readonly FLUTTER_DIALOG: string = 'pages/FlutterUIDialog'; | ||
static readonly FLUTTER_PAGE: string = 'pages/FlutterUIPage'; | ||
static readonly NATIVE_PAGE: string = 'pages/NativePage'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
example/ohos/entry/src/main/ets/pages/FlutterUIComponent.ets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Curves from '@ohos.curves' | ||
import hilog from '@ohos.hilog'; | ||
import { FlutterBoostEntry } from '@ohos/flutter_boost'; | ||
import { FlutterPage, FlutterView } from '@ohos/flutter_ohos'; | ||
|
||
const TAG: string = "FlutterUIComponent"; | ||
@Component | ||
export struct FlutterUIComponent { | ||
@Prop uri: string; | ||
@Prop params: Record<string, Object>; | ||
|
||
private flutterEntry: FlutterBoostEntry | null = null; | ||
private flutterView?: FlutterView; | ||
private effect: object = | ||
TransitionEffect.OPACITY | ||
.combine(TransitionEffect.move(TransitionEdge.END)).animation({curve: Curves.springMotion()}); | ||
|
||
aboutToAppear() { | ||
this.flutterEntry = new FlutterBoostEntry(getContext(this), { | ||
uri: this.uri, | ||
params: this.params, | ||
}); | ||
this.flutterEntry.aboutToAppear(); | ||
this.flutterView = this.flutterEntry.getFlutterView(); | ||
hilog.info(0x0000, TAG, 'Component(#%{public}s) aboutToAppear===', this.uri); | ||
} | ||
|
||
aboutToDisappear() { | ||
hilog.info(0x0000, TAG, 'Component(#%{public}s) aboutToDisappear===', this.uri); | ||
this.flutterEntry?.aboutToDisappear() | ||
} | ||
|
||
onPageShow() { | ||
hilog.info(0x0000, TAG, 'Component(#%{public}s) onPageShow===', this.uri); | ||
this.flutterEntry?.onPageShow() | ||
} | ||
|
||
onPageHide() { | ||
hilog.info(0x0000, TAG, 'Component(#%{public}s) onPageHide===', this.uri); | ||
this.flutterEntry?.onPageHide() | ||
} | ||
|
||
build() { | ||
Stack() { | ||
FlutterPage({ viewId: this.flutterView?.getId() }) | ||
} | ||
.onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { | ||
if (isVisible) { | ||
this.onPageShow(); | ||
} else { | ||
this.onPageHide(); | ||
} | ||
}) | ||
.transition(this.effect) | ||
} | ||
} |
Oops, something went wrong.