在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

OpenHarmony應用場景 鴻蒙智能家居【1.0】

ArkUI詳解 ? 來源:鴻蒙實驗室 ? 作者:鴻蒙實驗室 ? 2022-07-13 09:24 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

應用場景:

智能家居

今天打造的這一款全新智能家庭控制系統,凸顯應用在智能控制和用戶體驗的特點,開創國內智能家居系統體驗新局面。新的系統主要應用在鴻蒙生態。

在開始之前大家可以先預覽一下我完成之后的效果。

智能家居中控

是不是很炫酷呢?

搭建OpenHarmony環境

完成本篇Codelab我們首先要完成開發環境的搭建,本示例以DaYu200開發板為例,參照以下步驟進行:

獲取OpenHarmony系統版本:標準系統解決方案(二進制)

以3.0版本為例:

img

搭建燒錄環境

完成DevEco Device Tool的安裝

完成Dayu200開發板的燒錄

搭建開發環境

開始前請參考工具準備 ,完成DevEco Studio的安裝和開發環境配置。

開發環境配置完成后,請參考使用工程向導 創建工程(模板選擇“Empty Ability”),選擇eTS語言開發。

工程創建完成后,選擇使用真機進行調測 。

相關概念

容器組件

Column

Row

Stack

基礎組件

Text

TextInput

Button

Image

Navigation

通用

邊框設置

尺寸設置

點擊控制

布局約束

背景設置

點擊事件

TS語法糖

好的接下來我將詳細講解如何制作

開發教學

創建好的 eTS工程目錄

新建工程的ETS目錄如下圖所示。

img

各個文件夾和文件的作用:

index.ets:用于描述UI布局、樣式、事件交互和頁面邏輯。

app.ets:用于全局應用邏輯和應用生命周期管理。

pages:用于存放所有組件頁面。

resources:用于存放資源配置文件。

接下來開始正文。

我們的主要操作都是在在pages目錄中,然后我將用不到10分鐘的時間,帶大家實現這個功能。

拆解

image-20220706230542588

根據設計圖,我們可以分層展示,用Column包裹,大致分為這幾步

image-20220706231016908

可以看下本頁的結構:

image-20220706232242915

再詳細一點:

image-20220706232343167

import

{

SettingDetails

}

from

'./common/SettingDetails'

;

import

router

from

'@ohos.router'

;

?

@

Entry

@

Component

struct

Index

{

@

State

title

:

string

=

'智能家居體驗'

@

State

message

:

string

=

'你現在想要打開那些設置?'

@

State

desc

:

string

=

'點擊所有適用的選項。這將幫助我們\n自定義您的主頁'

@

State

Number

:

String

[]

=

[

'0'

,

'1'

,

'2'

,

'3'

,

'4'

]

@

State

private

isSelect

:

boolean

=

true

;

?

build

() {

?

Column

() {

Text

(

this

.

title

)

.

fontSize

(

80

)

.

fontWeight

(

FontWeight

.

Bold

).

onClick

(()

=>

{

router

.

push

({

url

:

'pages/SensorScreen'

})

}).

margin

({

bottom

:

60

,

top

:

40

})

Text

(

this

.

message

)

.

fontSize

(

50

)

.

fontWeight

(

FontWeight

.

Bold

).

onClick

(()

=>

{

router

.

push

({

url

:

'pages/SensorScreen'

})

}).

margin

({

bottom

:

60

})

Text

(

this

.

desc

)

.

fontSize

(

30

)

.

textAlign

(

TextAlign

.

Center

)

.

fontWeight

(

FontWeight

.

Bold

)

.

onClick

(()

=>

{

?

})

.

margin

({

bottom

:

60

})

Row

() {

?

SettingDetails

({

image

:

"common/images/setting.png"

,

title

:

"Maintenance\nRequests"

,

isSelected

:

this

.

isSelect

!

})

?

SettingDetails

({

image

:

"common/images/grain.png"

,

title

:

"Integrations\n"

,

isSelected

:

this

.

isSelect

!

})

?

SettingDetails

({

image

:

"common/images/ic_highlight.png"

,

title

:

"Light\nControl"

,

isSelected

:

this

.

isSelect

!

})

?

}

Row

() {

SettingDetails

({

image

:

"common/images/opacity.png"

,

title

:

"Leak\nDetector"

,

isSelected

:

this

.

isSelect

!

})

SettingDetails

({

image

:

"common/images/ac_unit.png"

,

title

:

"Temperature\nControl"

,

isSelected

:

this

.

isSelect

!

})

SettingDetails

({

image

:

"common/images/key.png"

,

title

:

"Guest\nAccess"

,

isSelected

:

this

.

isSelect

!

})

?

?

}

Button

(

"NEXT"

)

.

fontSize

(

60

)

.

fontColor

(

Color

.

Black

)

.

width

(

600

)

.

height

(

100

)

.

backgroundColor

(

Color

.

Red

)

.

margin

({

top

:

100

})

.

onClick

(()

=>

{

router

.

push

({

url

:

'pages/SensorScreen'

})

})

}

.

width

(

'100%'

)

.

height

(

'100%'

).

backgroundColor

(

"#F5F5F5"

)

}

}

具體布局

具體布局設計到一些細節的地方,例如間隔,邊框,當前組件尺寸設置等一些特殊情況,基本上就是嵌套,一層一層去實現。

代碼結構

image-20220706231113785

編碼

Index.ets

import

{

SettingDetails

}

from

'./common/SettingDetails'

;

import

router

from

'@ohos.router'

;

?

@

Entry

@

Component

struct

Index

{

@

State

title

:

string

=

'智能家居體驗'

@

State

message

:

string

=

'你現在想要打開那些設置?'

@

State

desc

:

string

=

'點擊所有適用的選項。這將幫助我們\n自定義您的主頁'

@

State

Number

:

String

[]

=

[

'0'

,

'1'

,

'2'

,

'3'

,

'4'

]

@

State

private

isSelect

:

boolean

=

true

;

?

build

() {

?

Column

() {

Text

(

this

.

title

)

.

fontSize

(

80

)

.

fontWeight

(

FontWeight

.

Bold

).

onClick

(()

=>

{

router

.

push

({

url

:

'pages/SensorScreen'

})

}).

margin

({

bottom

:

60

,

top

:

40

})

Text

(

this

.

message

)

.

fontSize

(

50

)

.

fontWeight

(

FontWeight

.

Bold

).

onClick

(()

=>

{

router

.

push

({

url

:

'pages/SensorScreen'

})

}).

margin

({

bottom

:

60

})

Text

(

this

.

desc

)

.

fontSize

(

30

)

.

textAlign

(

TextAlign

.

Center

)

.

fontWeight

(

FontWeight

.

Bold

)

.

onClick

(()

=>

{

?

})

.

margin

({

bottom

:

60

})

Row

() {

?

SettingDetails

({

image

:

"common/images/setting.png"

,

title

:

"Maintenance\nRequests"

,

isSelected

:

this

.

isSelect

!

})

?

SettingDetails

({

image

:

"common/images/grain.png"

,

title

:

"Integrations\n"

,

isSelected

:

this

.

isSelect

!

})

?

SettingDetails

({

image

:

"common/images/ic_highlight.png"

,

title

:

"Light\nControl"

,

isSelected

:

this

.

isSelect

!

})

?

}

Row

() {

SettingDetails

({

image

:

"common/images/opacity.png"

,

title

:

"Leak\nDetector"

,

isSelected

:

this

.

isSelect

!

})

SettingDetails

({

image

:

"common/images/ac_unit.png"

,

title

:

"Temperature\nControl"

,

isSelected

:

this

.

isSelect

!

})

SettingDetails

({

image

:

"common/images/key.png"

,

title

:

"Guest\nAccess"

,

isSelected

:

this

.

isSelect

!

})

?

?

}

Button

(

"NEXT"

)

.

fontSize

(

60

)

.

fontColor

(

Color

.

Black

)

.

width

(

600

)

.

height

(

100

)

.

backgroundColor

(

Color

.

Red

)

.

margin

({

top

:

100

})

.

onClick

(()

=>

{

router

.

push

({

url

:

'pages/SensorScreen'

})

})

}

.

width

(

'100%'

)

?

.

height

(

'100%'

).

backgroundColor

(

"#F5F5F5"

)

}

}

image-20220706230620896

針對這一頁:首先是頭部

image-20220706232459401

代碼如下:

Row() {

?

Image($r("app.media.logo"))

.objectFit(ImageFit.Contain)

.width(200)

.height(200)

.borderRadius(21)

?

Column() {

Text('June 14, 2022')

.fontSize(40).opacity(0.4)

.fontWeight(FontWeight.Bold)

Text('Good Morning,\nJianGuo',)

.fontSize(60)

.fontWeight(FontWeight.Bold)

}

?

?

}

其次是個人信息,包括頭像等信息:

image-20220706232621793

代碼如下:

?

接下來就是溫度和濕度

image-20220706232715798

代碼如下:

ow

({

space

:

120

}) {

Column

() {

Text

(

'40°'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

.

fontWeight

(

FontWeight

.

Bold

)

Text

(

'TEMPERATURE'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

}.

margin

({

left

:

60

})

?

Column

() {

Text

(

'59%'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

.

fontWeight

(

FontWeight

.

Bold

)

Text

(

'HUMIDITY'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

}.

margin

({

right

:

60

})

}.

margin

({

top

:

20

})

SensorScreen.ets

import

{

HomeDetails

}

from

'./common/homedetails'

;

// second.ets

import

router

from

'@ohos.router'

;

?

@

Entry

@

Component

struct

Second

{

@

State

message

:

string

=

'Hi there'

@

State

private

isSelect

:

boolean

=

true

;

?

build

() {

?

Column

() {

Row

() {

?

Image

(

$r

(

"app.media.back"

))

.

objectFit

(

ImageFit

.

Contain

)

.

width

(

80

)

.

height

(

80

)

.

onClick

(()

=>

{

router

.

back

()

})

?

Blank

()

?

Text

(

'Home'

)

.

fontSize

(

45

)

.

fontWeight

(

FontWeight

.

Bold

)

?

?

Blank

()

Image

(

$r

(

"app.media.notifications_none"

))

.

objectFit

(

ImageFit

.

Contain

)

.

width

(

80

)

.

height

(

80

)

.

onClick

(()

=>

{

router

.

back

()

})

?

}

?

.

width

(

'100%'

)

?

Row

() {

?

Image

(

$r

(

"app.media.logo"

))

.

objectFit

(

ImageFit

.

Contain

)

.

width

(

200

)

.

height

(

200

)

.

borderRadius

(

21

)

?

Column

() {

Text

(

'June 14, 2022'

)

.

fontSize

(

40

).

opacity

(

0.4

)

.

fontWeight

(

FontWeight

.

Bold

)

Text

(

'Good Morning,\nJianGuo'

,)

.

fontSize

(

60

)

.

fontWeight

(

FontWeight

.

Bold

)

}

?

?

}

?

Row

({

space

:

120

}) {

Column

() {

Text

(

'40°'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

.

fontWeight

(

FontWeight

.

Bold

)

Text

(

'TEMPERATURE'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

}.

margin

({

left

:

60

})

?

Column

() {

Text

(

'59%'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

.

fontWeight

(

FontWeight

.

Bold

)

Text

(

'HUMIDITY'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

}.

margin

({

right

:

60

})

}.

margin

({

top

:

20

})

?

?

Row

() {

HomeDetails

({})

?

HomeDetails

({

image

:

"common/images/lightbull.png"

,

isSelected

:

this

.

isSelect

!

})

?

}

?

Row

() {

?

?

HomeDetails

({

image

:

"common/images/opacity.png"

})

HomeDetails

({

image

:

"common/images/yytem0.png"

})

?

?

}

?

Row

(){

Column

(){

Text

(

'ADD'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

.

fontWeight

(

FontWeight

.

Bold

)

Text

(

'NEW CONTROL'

,)

.

fontSize

(

40

).

opacity

(

0.4

)

}

Blank

()

?

Image

(

$r

(

"app.media.add"

))

.

objectFit

(

ImageFit

.

Contain

)

.

width

(

100

)

.

height

(

100

)

.

borderRadius

(

21

).

margin

({

right

:

40

})

?

}.

border

({

color

:

Color

.

White

,

width

:

8

,

radius

:

20

}).

width

(

"88%"

).

height

(

150

)

?

}.

width

(

"100%"

)

.

height

(

'100%'

).

backgroundColor

(

"#F5F5F5"

)

}

}

我們可以對,下面的這塊進行封裝

image-20220706231310224

代碼如下

@

Entry

@

Component

export

struct

SettingDetails

{

@

State

private

image

:

string

=

"common/images/setting.png"

@

State

private

title

:

string

=

"Maintenance\nRequests"

@

State

private

isSelected

:

boolean

=

true

;

?

build

() {

?

?

Column

() {

Image

(

this

.

image

)

.

objectFit

(

ImageFit

.

Contain

)

.

width

(

140

)

.

height

(

120

)

.

margin

(

20

)

.

border

({

width

:

12

,

color

:

this

.

isSelected

?

Color

.

White

:

Color

.

Red

,

radius

:

20

})

.

onClick

(()

=>

{

this

.

isSelected

=

!

this

.

isSelected

;

})

Text

(

this

.

title

).

fontSize

(

32

).

width

(

200

).

textAlign

(

TextAlign

.

Center

)

}

}}

我們可以對,下面的這塊進行封裝

image-20220706231425068image-20220706232810459

代碼如下

@

Entry

@

Component

export

struct

SettingDetails

{

@

State

private

image

:

string

=

"common/images/setting.png"

@

State

private

title

:

string

=

"Maintenance\nRequests"

@

State

private

isSelected

:

boolean

=

true

;

?

build

() {

?

?

Column

() {

Image

(

this

.

image

)

.

objectFit

(

ImageFit

.

Contain

)

.

width

(

140

)

.

height

(

120

)

.

margin

(

20

)

.

border

({

width

:

12

,

color

:

this

.

isSelected

?

Color

.

White

:

Color

.

Red

,

radius

:

20

})

.

onClick

(()

=>

{

this

.

isSelected

=

!

this

.

isSelected

;

})

Text

(

this

.

title

).

fontSize

(

32

).

width

(

200

).

textAlign

(

TextAlign

.

Center

)

}

}}

最后就是底部

image-20220706232904753

代碼如下:

Row(){

Column(){

Text('ADD',)

.fontSize(40).opacity(0.4)

.fontWeight(FontWeight.Bold)

Text('NEW CONTROL',)

.fontSize(40).opacity(0.4)

}

Blank()

Image($r("app.media.add"))

.objectFit(ImageFit.Contain)

.width(100)

.height(100)

.borderRadius(21).margin({right:40})

}.border({

color:Color.White,

width:8,

radius:20

}).width("88%").height(150)

恭喜你

在本文中,通過實現智聯汽車App示例,我主要為大家講解了如下ArkUI(基于TS擴展的類Web開發范式)組件,以及路由跳轉。

容器組件

Column

Row

Stack

基礎組件

Text

Button

Image

Navigation

通用

邊框設置

尺寸設置

點擊控制

布局約束

背景設置

點擊事件

TS語法糖

希望通過本教程,各位開發者可以對以上基礎組件具有更深刻的認識。

后面的計劃:

智能互聯

硬件交互

動畫交互

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 智能家居
    +關注

    關注

    1934

    文章

    9791

    瀏覽量

    190399
  • HarmonyOS
    +關注

    關注

    80

    文章

    2118

    瀏覽量

    32803
  • OpenHarmony
    +關注

    關注

    29

    文章

    3848

    瀏覽量

    18507
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    #硬聲創作季 #某些喜歡 #智能家居智能家居角度看鴻蒙 #鴻蒙

    智能家居鴻蒙
    Hello,World!
    發布于 :2022年11月02日 11:36:24

    智能攝像機 引領智能家居潮流

    直至如今,整個市場還沒有一家能夠形成較大的規模。之所以他們還難以實現市場規模化的成績,進而代表他們身處品類帶動整個智能家居行業的發展,和他們的產品應用場景與應用頻率還不夠高有著很大關系。與之相比,近期
    發表于 12-28 17:33

    選擇智能家居的幾點理由?

    。2.便利隨著物聯網、云計算、無線通信等新技術的發展,智能家居得到了快速發展更大的方便了人們的生活。智能家居能讓用戶利用智能手機來控制家中的設備,實現遠程控制、場景控制、聯動控制和定時
    發表于 01-30 16:45

    未來智能家居場景分哪種類型?

    升至2018年的約4.9億部,其中運動監測、移動醫療、智能手表類將成為最主要的可穿戴產品形態。   隨著科學技術發展,人們生活的場景類型可能不會大幅增加,但切換變化卻只會更頻繁,隨之適應人們使用習慣的LivingLab智能家居
    發表于 02-01 14:51

    邁入智能場景時代!2018年智能家居能否迎來爆點時刻?

    去年,智能門鎖和智能音箱作為智能家居領域的兩個熱銷產品橫空出世。同期,智能家居企業關注的重點由單品轉入到了智能
    發表于 04-17 13:38

    選擇智能家居的幾點理由。

    的發展,智能家居得到了快速發展更大的方便了人們的生活。智能家居能讓用戶利用智能手機來控制家中的設備,實現遠程控制、場景控制、聯動控制和定時控制等功能。紅外線遙控開關通過遠程控制,用戶可
    發表于 04-18 15:51

    【HarmonyOS HiSpark Wi-Fi IoT HarmonyOS 智能家居套件試用 】金典智能家居

    項目名稱:金典智能家居試用計劃:申請理由本人在智能家居領域有5年多的學習和開發經驗,曾參與金典智能家居產品的開發,產品包括門鎖,加濕器,智能燈等,產品支持過近程遠程協議,wifi,藍牙
    發表于 09-25 10:09

    【HarmonyOS HiSpark Wi-Fi IoT HarmonyOS 智能家居套件試用 】基于鴻蒙OS系統的智能家居智能安防系統

    項目名稱:基于鴻蒙OS系統的智能家居智能安防系統試用計劃:申請理由本人在嵌入式開發領域有7年多的學習和開發經驗,并且從業以來一直從事智能家居類產品的開發,曾設計基于zigbee協議的
    發表于 10-29 14:33

    【HarmonyOS HiSpark Wi-Fi IoT HarmonyOS 智能家居套件試用 】智能家居項目

    項目名稱:智能家居項目試用計劃:本人基于興趣愛好,具有飛凌、瑞芯微、全志開發板學習和開發經驗,成功移植、調試安裝。具有全志、瑞芯微智能芯片開發能力。想借助發燒友論壇和參與鴻蒙硬件的學習和設計。項目
    發表于 10-29 14:46

    【HarmonyOS HiSpark Wi-Fi IoT HarmonyOS 智能家居套件試用 】智能家庭

    項目名稱:智能家庭試用計劃:探索鴻蒙智能家居方面的應用場景和效果
    發表于 10-29 15:13

    【HarmonyOS HiSpark Wi-Fi IoT HarmonyOS 智能家居套件試用 】智能家居(冰箱)

    項目名稱:智能家居(冰箱)試用計劃:測試,熟悉鴻蒙系統
    發表于 10-29 15:13

    智能家居的應用研究現狀 精選資料分享

    電子設備發展快。智能家居的四大應用場景智能家電、家用安防、照明系統和連接控制設備。物聯網技術是智能家居的基礎,家...
    發表于 07-19 09:08

    【直播回顧】OpenHarmony知識賦能六期第一課—OpenHarmony智能家居項目介紹

    6月16日晚上19點,知識賦能第六期第一節課 《OpenHarmony智能家居項目介紹》 ,在OpenHarmony開發者成長計劃社群內成功舉行。本次直播是“OpenHarmony開源
    發表于 06-17 11:08

    中軟國際智能家居中控屏通過OpenHarmony兼容性測評

    ,獲頒OpenHarmony生態產品兼容性證書。 家居中控屏是智能家居場景的控制中心,也是智慧家居解決方案中人與設備間溝通的重要橋梁,此次
    的頭像 發表于 12-26 20:20 ?1794次閱讀

    什么是Matter 1.0?它將如何顛覆智能家居

    什么是Matter 1.0?它將如何顛覆智能家居
    的頭像 發表于 11-28 17:25 ?1066次閱讀
    什么是Matter <b class='flag-5'>1.0</b>?它將如何顛覆<b class='flag-5'>智能家居</b>?
    主站蜘蛛池模板: 日日搞夜夜操 | 国产专区青青草原亚洲 | 美女视频黄视大全视频免费网址 | 久久久五月 | 日韩亚洲欧洲在线rrrr片 | 国产亚洲美女精品久久久2020 | 免费看黄视频 | 日本三级免费 | 午夜综合网| 天天躁夜夜躁狠狠躁2021西西 | 国产―笫一页―浮力影院xyz | 69xxxx日本老师 | 国产免费福利网站 | 黄频免费 | 狠狠色噜噜狠狠狠狠999米奇 | 国产理论视频 | 久久精品网站免费观看 | 99久久99久久久精品齐齐鬼色 | 四虎亚洲国产成人久久精品 | 久久99热不卡精品免费观看 | 成人激情在线 | 日本黄视频网站 | 国产福利在线免费 | 亚洲综合久久久久久888 | 夜夜操天天射 | 欧美一区二区三区四区在线观看 | 欧美男人的天堂 | 狠狠色狠狠色 | 天天干天天色综合 | 午夜激情影视 | 日日射天天射 | 欧美亚洲h在线一区二区 | 九色综合网 | 国产成人在线播放视频 | 韩日中文字幕 | 色婷婷久 | 黄色大片网站 | 天堂资源吧 | 毛片一级黄色 | 亚洲色五月 | 欧美日韩高清一本大道免费 |