mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
ohos: Add back and fwd button to vendored app (#33511)
25372340
added back and forward apis to the ohos servoshell.157e28c5
vendored the ohos demo ArkTS app into the servo repo, but did not include the back and forward buttons, which were added in the meantime. This commit adds the missing back and forward buttons to the ArkTS code. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
188fa329eb
commit
d3d6a22d27
1 changed files with 31 additions and 10 deletions
|
@ -3,6 +3,8 @@ import deviceInfo from '@ohos.deviceInfo';
|
|||
|
||||
interface ServoXComponentInterface {
|
||||
loadURL(url: string): void;
|
||||
goBack(): void;
|
||||
goForward(): void;
|
||||
registerURLcallback(callback: (url: string) => void): void;
|
||||
initServo(options: InitOpts): void;
|
||||
}
|
||||
|
@ -48,15 +50,34 @@ struct Index {
|
|||
|
||||
build() {
|
||||
Column() {
|
||||
TextInput({placeholder:'URL',text: $$this.urlToLoad})
|
||||
.type(InputType.Normal)
|
||||
.onChange((value) => {
|
||||
this.urlToLoad = value
|
||||
})
|
||||
.onSubmit((EnterKeyType)=>{
|
||||
this.xComponentContext?.loadURL(this.urlToLoad)
|
||||
console.info('Load URL: ', this.urlToLoad)
|
||||
})
|
||||
Row() {
|
||||
Button('⇦').backgroundColor(Color.White)
|
||||
.fontColor(Color.Black)
|
||||
.fontWeight(FontWeight.Bolder)
|
||||
.width('12%')
|
||||
.fontSize(12)
|
||||
.onClick(()=>{
|
||||
this.xComponentContext?.goBack()
|
||||
})
|
||||
Button('⇨').backgroundColor(Color.White)
|
||||
.fontColor(Color.Black)
|
||||
.fontWeight(FontWeight.Bolder)
|
||||
.fontSize(12)
|
||||
.width('12%')
|
||||
.onClick(()=> {
|
||||
this.xComponentContext?.goForward()
|
||||
})
|
||||
TextInput({placeholder:'URL',text: $$this.urlToLoad})
|
||||
.type(InputType.Normal)
|
||||
.width('76%')
|
||||
.onChange((value) => {
|
||||
this.urlToLoad = value
|
||||
})
|
||||
.onSubmit((EnterKeyType)=>{
|
||||
this.xComponentContext?.loadURL(this.urlToLoad)
|
||||
console.info('Load URL: ', this.urlToLoad)
|
||||
})
|
||||
}
|
||||
XComponent(this.xComponentAttrs)
|
||||
.focusable(true)
|
||||
.onLoad((xComponentContext) => {
|
||||
|
@ -65,7 +86,7 @@ struct Index {
|
|||
url: this.urlToLoad,
|
||||
deviceType: get_device_type(),
|
||||
osFullName: deviceInfo.osFullName,
|
||||
displayDensity: get_density()
|
||||
displayDensity: get_density(),
|
||||
}
|
||||
this.xComponentContext.initServo(init_options)
|
||||
this.xComponentContext.registerURLcallback((new_url) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue