当前位置:网站首页>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

边栏推荐
- Leveldb source code analysis -- version management
- [version upgrade] Tencent cloud firewall version 2.1.0 was officially released!
- Live broadcast Preview - on April 1, I made an appointment with you to explore tcapulusdb with Tencent cloud
- From file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql The GPG key to retrieve the key source "MySQL 5.7 community server" is installed, but not applicable to
- A tutorial on how the zblog system obtains user related information based on user ID
- Operation and maintenance guide | cos back source setting practice
- 网站SEO排名越做越差是什么原因造成的?
- Release! Tencent IOA and Tencent sky screen were selected into the first batch of certified products of domestic digital trusted services
- Using easyjson to improve the efficiency of serialization transmission
- How to use rdbtools to analyze redis large keys
猜你喜欢
Using consistent hash algorithm in Presto to enhance the data cache locality of dynamic clusters

Etching process flow for PCB fabrication

MySQL learning -- table structure of SQL test questions

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

LC 300. Longest increasing subsequence

Error reported after NPM I

Mengyou Technology: tiktok current limiting? Teach you to create popular copywriting + popular background music selection
随机推荐
Can yangjianyun's new media operation in 2021 bear all the expectations of the enterprise's private domain traffic demand?
Tencent security officially released the IOT security capability map
2021-04-02: given a square or rectangular matrix, zigzag printing can be realized.
Kubernetes 1.20.5 helm installation Jenkins
How to convert XML to HL7
H265/webvr video web page without plug-in player easyplayer Solution to the problem of cumulative delay of FLV video played by JS
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
Three simple steps to quickly complete order data processing through workflow (ASW)
Industrial security experts talk about how to guarantee the safety of data elements in the rapid development of digital economy?
03. Tencent cloud IOT device side learning -- overview of mqtt control package
zblog系统实现前台调用当天发布文章数量的教程
As for IOT safety, 20 CSOs from major manufacturers say
See through the new financial report of Tencent music, online music needs b+c
Uncover the secrets of Tencent R & D! 30% of the demand will be responded within 1 day!
Development of block hash game guessing system (mature code)
The problem is as big as the middle stage
[kotlin] constructor summary
Explanation of pod DNS configuration & cases of DNS resolution failure
Learn typescript with VAM (phase 1)
Release! Tencent IOA and Tencent sky screen were selected into the first batch of certified products of domestic digital trusted services