当前位置:网站首页>Constantly changing the emergency dialing of harmonyos ETS during the new year
Constantly changing the emergency dialing of harmonyos ETS during the new year
2022-06-24 17:33:00 【Harmonyos technology community】
The Spring Festival keeps changing , This article is being attended 「 Project starlight - Spring festival activities 」
author : Chenlongjia
Preface
I have been learning about the official documents of Hongmeng , Learning is mainly based on JS Extended classes web Development paradigm , As the development documents are constantly updated ,SDK It's also updated to 8, With TS Has been widely used , So I came into contact with people based on TS Extended classes web Development paradigm , That is to say ArkUI. This article is mainly based on ArkUI Implementation of a small project , It can also be said to be a demo, Mainly through ETS Complete some interface related 、 Simple data communication and interaction .
Effect display

Create project
Start by opening devEco Studio Editor , Find... In the upper left corner File–>New–>New project, Then go to the following page , The most annoying thing about using the editor for the first time should be sdk The problem of , First ETS The project must require SDK7 The above can be used , So if you have failed to create children's shoes, please check your SDK Is the version correct .

Project framework
| Catalog | describe |
|---|---|
| src | The source code main folder of the project |
| components | Storage folder of public components |
| Model | The storage folder of the primary data source |
| pages | Project page folder |
| app.ets | Entry documents for the project |
| resources | Applied resource folder ( character string 、 picture 、 Audio etc. ) |
| config.json | Application profile |
Data model construction
1. Define an interface to constrain urgentDialList
2. structure initializeOnStartup Method to initialize the page data
Mainly related to the state variable decorator
| Decorator | describe |
|---|---|
| @State | State attributes owned by components . whenever @State When the variable of decoration changes , The component will be re rendered and updated UI |
| @Link | A component depends on certain state properties owned by its parent component . Whenever the data in any component is updated , The status of the other component is updated , Both parent and child components will be re rendered . |
| @Prop | It works in a similar way @Link, Only the changes made by the child component will not be synchronized to the parent component , It belongs to one-way transmission . |
What I want to say here is about @Link Follow @Prop Can transfer component data , But by @Prop Decorated variable , The parent component cannot modify the data , Because this will destroy the unidirectionality of the data , and @Link It's two-way data binding , Data can be re rendered and modified .
It mainly involves function nodes
- Open the pop-up box to get the geographical location
- Jump to the emergency dial page
- Incoming and outgoing calls from the dial-up keyboard
- Gesture event sliding call emergency number
Main tool function classes
1.showToast function
effect : It is mainly used to show the bullet box , Here we need to introduce a bag from hongmengli (import prompt from ‘@system.prompt’
2.routerPage function
effect : Mainly used for page Jump , Here we need to introduce a bag from hongmengli (import routerfrom ‘@system.router’
Component encapsulation
keyword Components
The keyboard assembly mainly uses Grid Palace layout , It is recommended to use this kind of layout similar to the keyboard or the Jiugong grid grid Layout ,
Using grid containers , Two dimensional layout , Divide containers into " That's ok " and " Column ", Generate cells , Then designate " Where the project is " Cells of , You can combine different meshes at will , Make all kinds of layouts .
But be careful ,Text Components can only be used to display strings , So if you want to show the numbers, you need to pass toString() Change my , This is a small problem I encountered before .
urgentList Components
This component is mainly used to render the emergency dial list , stay ArkUI in , The main use of forEach To traverse the data , Display the page .
urgentListItem Components
Gesture events are used in this component , adopt PanGesture() Medium onActionEnd、onActionStart、onActionUpdate Three methods to control the distance triggered by gestures , When this.offsetX Above a certain critical value , Slide to change the menu layout or content layout left Offset , The gesture lifts the completion offset to update the view .
1. First , Gesture events will be used , By judging the offset of gesture sliding offsetX To control the color change after sliding
gesture():gesture: GestureType,mask?: GestureMask
Hongmeng system provides the following Gesture type :
| LongPressGesture | Long press gesture |
|---|---|
| PanGesture | Pan gestures |
| PinchGesture | Kneading gestures |
| RotationGesture | Rotating gestures |
2. Respond to gesture events
- Components through gesture Method to bind a gesture object , The gesture operation can be responded to by the event provided by the gesture object . Such as through TapGesture Object's onAction Event response click event .
When the response event is over , Turn off the timer to turn off the slide , Reset effect .
positionInfoDialog Components
The function point : Ask if you want to get the geographic location automatically , If continue , The current geographical location is displayed , If you cancel, close the pop-up box , Displays the initial value
summary
This article is just a rough use of ArkUI Simple layout of the page and interaction of events , It does not involve too complex logical function business .
Hongmeng still has a long way to go , Youth is just right , The story is not over , And we are on the way of exploration . If you want to learn more about Hongmeng Ecology , You can refer to : ArkUI
Project source code
https://gitee.com/chen_longjia/ark-ui-emergency
For more original content, please pay attention to : China soft International HarmonyOS Technical team
Beginner to master 、 Skills to cases , Systematic sharing HarmonyOS Development technology , Welcome to contribute and subscribe , Let's move forward hand in hand to build Hongmeng ecology .
Want to know more about Hongmeng , Please visit :
51CTO Hongmeng technology community jointly built with Huawei officials
https://harmonyos.51cto.com/#bkwz

边栏推荐
- Yupi made an AI programming nickname generator!
- Erc-721 Standard Specification
- This time, talk about the dry goods of industrial Internet | TVP technology closed door meeting
- 2021-04-02: given a square or rectangular matrix, zigzag printing can be realized.
- Several schemes of traffic exposure in kubernetes cluster
- Tiktok Kwai, e-commerce enters the same river
- Litamin: SLAM Based on geometric approximation of normal distribution
- How to troubleshoot and solve the problem that the ultra-low delay security live broadcast system webrtc client plays no audio in the browser?
- Create a green city and 3D visualization of digital twin natural gas stations
- The RTSP video image intelligent analysis platform easynvr cascades to the superior platform through the national standard for playback optimization
猜你喜欢

Why do you develop middleware when you are young? "You can choose your own way"

The 'ng' entry cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Check the spelling of the name. If you include a path, make sure the path is correct, and then

MySQL learning -- table structure of SQL test questions

Error reported after NPM I

Etching process flow for PCB fabrication
Using consistent hash algorithm in Presto to enhance the data cache locality of dynamic clusters

Mengyou Technology: tiktok current limiting? Teach you to create popular copywriting + popular background music selection

LC 300. Longest increasing subsequence
随机推荐
Use py-mysql2pgsql to synchronize MySQL data to Greenplum
Yiwen teaches you to understand the stack operation in go
构建跨公链平台解决DApp开发问题
Issue 003 how to detect whether a sticky positioned element is in a pinned state
[2021 taac & Ti-One] FAQs related to preliminary round computing resources
Three simple steps to quickly complete order data processing through workflow (ASW)
zblog系统实现前台调用当天发布文章数量的教程
Erc-721 Standard Specification
Use BPF to count network traffic
主链系统发展解析
[play with Tencent cloud] play with cloud database mysql
Mengyou Technology: tiktok current limiting? Teach you to create popular copywriting + popular background music selection
Go collaboration and pipeline to realize asynchronous batch consumption scheduling task
"Competition" and "opportunity" hidden in security operation in the cloud Era
As for IOT safety, 20 CSOs from major manufacturers say
Elastic searchable snapshot function (frozen Tier 3)
03. Tencent cloud IOT device side learning -- overview of mqtt control package
Why do you develop middleware when you are young? "You can choose your own way"
Etching process flow for PCB fabrication
网站SEO排名越做越差是什么原因造成的?