Since I started working on HarmonyOS development, Youlan Jun has been constantly seeking an elegant way to create pop-up Windows. I don't want to add components or initialize every page. I just want the loading animation or prompt pop-up window that pops up with just one sentence when I need it, simple and straightforward yet elegant.
Today, I'm going to officially share with you all this extremely simple and user-friendly tool. I named it yloadinghud. I can't wait to show you how good it is now:
No matter on which page or anywhere, when you need to load animations or text prompts, you can handle it with just one line of code. It's so elegant.
yloadinghud has also been uploaded to the ohpm repository. This article is not convenient to post the address. You can search for yloadinghud to view it.
The following introduces how to install and use this tool:
First, execute the command to install yloadinghud:
ohpm install yloadinghud
After the installation is completed, make a very simple configuration. Introduce the project in the EntryAbility.ets file:
import { yloadinghud } from 'yloadinghud/Index
Then add the following code in the onWindowStageCreate method:
yloadinghud.gloabalWindowStage = windowStage
Now you can use it freely throughout the entire project when you need to load animations:
yloadinghud.showLoading()
When the loading is completed and it is necessary to make the animation disappear:
yloadinghud.dismiss()
Except for the loading animation, all other prompt types have been designed to disappear automatically after 2.5 seconds. So you just need to play and don't worry about anything else.
For example, display a pop-up window with successful loading:
yloadinghud.showSuccess()
Pop-up window with failed loading:
yloadinghud.showError()
There are also ordinary text pop-ups without icon displays:
yloadinghud.showContent('请输入不少于8位的包含大小写字母和特殊字符串的密码')
yloadinghud is the first third-party library project contributed by Youlan Jun, hoping to bring convenience to a large number of HarmonyOS developers. Welcome everyone to use it and also welcome everyone to offer valuable suggestions to make it more perfect.
Top comments (0)