Explore DialogV3 in HarmonyOS

Introduction

Kongzue themes

Background

iOS Theme
Material theme
MIUI theme

Step by Step Implementation

Ability Template
Project Setup
dependencies {implementation fileTree(dir: 'libs', include: ['*.har'])
implementation 'io.openharmony.tpc.thirdlib:DialogV3:1.0.0'
testCompile 'junit:junit:4.12'
}
// set the theme IOS,Material,kongzue or MIUI
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
// set the mode light or dark
DialogSettings.theme = DialogSettings.THEME.LIGHT;
// Onclick display the messege
InputDialog.build(getContext())
//set the prompt messege
.setTitle("prompt").setMessage("Please
enter the password(123456)")
//set input text to show in prompt messge
.setInputText("111111")
.setOkButton("ok", new
OnInputDialogButtonClickListener(){
@Override public boolean onClick(String inputStr)
{
// check validation of input string
if (inputStr.equals("123456")) {
TipDialog.show(getContext(), "success!",
TipDialog.TYPE.SUCCESS);
return false;
}
else {
TipDialog.show(getContext(), "Incorrect
password", TipDialog.TYPE.ERROR);
return true;
}
}
})
.setCancelButton("cancel")
//Hint for helping user
.setHintText("Please enter the password")
.setInputInfo(new InputInfo()
//maximum length of the input string
.setMAX_LENGTH(6)
)
.setCancelable(true)
.show(getContext());
Input Dialog Box
// set the theme IOS,Material,kongzue or MIUI
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
// set the mode light or dark
DialogSettings.theme = DialogSettings.THEME.LIGHT;
// Onclick Wait Dialog crash will apper with messege
MessageDialog.show(getContext(), "Tips", "Crash Messege", "cancel")
.setMessageTextInfo(new TextInfo().setGravity(TextAlignment.LEFT))
.setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override public boolean onClick()
{
WaitDialog.show(getContext(),
"Preparing to crash...");
WaitDialog.show(getContext(), "Please wait...");
EventHandler handler = new EventHandler(
EventRunner.getMainEventRunner());
handler.postTask(new Runnable() {
@Override public void run()
{
getUITaskDispatcher().asyncDispatch(() -> {
TipDialog.show(getContext(), "success", TipDialog.TYPE.SUCCESS)
.setOnDismissListener(new OnDismissListener() {
@Override public void onDismiss()
{
// jump(MainActivity.class);
Crash DialogBox Display
// set the theme IOS,Material,kongzue or MIUI
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
// set the mode light or dark
DialogSettings.theme = DialogSettings.THEME.LIGHT;
// set the the items to be presesnt in share dialog
itemList.add(new ShareDialog.Item(
getContext(), ResourceTable.Media_img_email_ios,
"email"));
itemList.add(new ShareDialog.Item(
getContext(), ResourceTable.Media_img_qq_ios, "QQ"));
// Show the shared content
ShareDialog.show(getContext(), itemList, (shareDialog,
index, item) -> {
toast("Clicked:" + item.getText());
return false;
Share DialogBox Display

List of public APIs for app developers

Public APIs

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store