-
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
5 changed files
with
84 additions
and
1 deletion.
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
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
53 changes: 53 additions & 0 deletions
53
example/ohos/entry/src/main/ets/platform_view/SimpleTextView.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,53 @@ | ||
import common from '@ohos.app.ability.common'; | ||
import PlatformView from '@ohos/flutter_ohos/src/main/ets/plugin/platform/PlatformView'; | ||
import { DVModel } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicView'; | ||
import { createDVModelFromJson } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicViewJson'; | ||
|
||
export class SimpleTextView extends PlatformView { | ||
private viewId: number; | ||
private model: DVModel; | ||
|
||
constructor(context: common.Context, viewId: number, args: ESObject) { | ||
super() | ||
this.viewId = viewId; | ||
this.model = this.createDVModel(); | ||
} | ||
|
||
private createDVModel(): DVModel { | ||
return createDVModelFromJson( | ||
{ | ||
compType: "Column", | ||
attributes: { | ||
backgroundColor: '#F1F3F5', | ||
height: '100%', | ||
width: '100%' | ||
}, | ||
children: [ | ||
{ | ||
compType: "Text", | ||
attributes: { | ||
value: "PlatformView: #" + this.viewId.toString(), | ||
fontSize: 18, | ||
}, | ||
}, | ||
{ | ||
compType: "Text", | ||
attributes: { | ||
value: "Hi, there! I'm from ArkUI.", | ||
fontColor: '#0D9FFB', | ||
fontSize: 18, | ||
marginTop: 20, | ||
}, | ||
} | ||
], | ||
} | ||
); | ||
} | ||
|
||
getView(): DVModel { | ||
return this.model; | ||
} | ||
|
||
dispose(): void { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
example/ohos/entry/src/main/ets/platform_view/SimpleTextViewFactory.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,17 @@ | ||
import common from '@ohos.app.ability.common'; | ||
import { | ||
PlatformView, | ||
PlatformViewFactory, | ||
StandardMessageCodec | ||
} from '@ohos/flutter_ohos'; | ||
import { SimpleTextView } from './SimpleTextView'; | ||
|
||
export class SimpleTextViewFactory extends PlatformViewFactory { | ||
constructor() { | ||
super(StandardMessageCodec.INSTANCE); | ||
} | ||
|
||
public create(context: common.Context, viewId: number, args: Object): PlatformView { | ||
return new SimpleTextView(context, viewId, args); | ||
} | ||
} |