mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
ohos: Add toast prompt (#33621)
* ohos: Add toast prompt Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> * ohos: Add toast on `load_ended` Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> * Apply review feedback Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> --------- Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com> Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
f2f5614ad6
commit
9fcfe09e51
2 changed files with 70 additions and 22 deletions
|
@ -1,12 +1,14 @@
|
|||
import { common } from '@kit.AbilityKit';
|
||||
import display from '@ohos.display';
|
||||
import deviceInfo from '@ohos.deviceInfo';
|
||||
import promptAction from '@ohos.promptAction';
|
||||
|
||||
interface ServoXComponentInterface {
|
||||
loadURL(url: string): void;
|
||||
goBack(): void;
|
||||
goForward(): void;
|
||||
registerURLcallback(callback: (url: string) => void): void;
|
||||
registerPromptToastCallback(callback: (msg: string) => void): void
|
||||
initServo(options: InitOpts): void;
|
||||
}
|
||||
|
||||
|
@ -40,6 +42,13 @@ function get_device_type(): string {
|
|||
return device_type;
|
||||
}
|
||||
|
||||
function prompt_toast(msg: string) {
|
||||
promptAction.showToast({
|
||||
message: msg,
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
|
||||
// Use the getShared API to obtain the LocalStorage instance shared by stage.
|
||||
let storage = LocalStorage.getShared()
|
||||
|
||||
|
@ -107,6 +116,7 @@ struct Index {
|
|||
console.info('New URL from native: ', new_url)
|
||||
this.urlToLoad = new_url
|
||||
})
|
||||
this.xComponentContext.registerPromptToastCallback(prompt_toast)
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue