【Sample】【基础能力】组件及布局能力增强

Signed-off-by: 13415019609 <minyin.weng@unionman.com.cn>
This commit is contained in:
13415019609 2023-08-25 11:02:35 +08:00
parent d02aab8189
commit 25afe5bac0
35 changed files with 2574 additions and 664 deletions

View File

@ -173,6 +173,8 @@ entry/src/main/ets/
| | | | |---GaugeSample.ets // 仪表盘
| | | |---loadingProgressSample
| | | | |---LoadingProgressSample.ets
| | | |---listSample // 列表
| | | | |---ListSample.ets
| | | |---marqueeSample
| | | | |---MarqueeSample.ets // 跑马灯
| | | |---radioSample
@ -202,6 +204,8 @@ entry/src/main/ets/
| | | | |---NavigationSample.ets // 导航
| | | | |---NavigationSecondPage.ets
| | | | |---NavigationThirdPage.ets
| | | |---navRouterSample
| | | | |---NavRouterSample.ets // 导航
| | | |---stepperAndStepperItemSample
| | | | |---StepperAndStepperItemSample.ets // 步骤导航器
| | | |---tabContentSample
@ -368,6 +372,8 @@ entry/src/main/ets/
| | | | |---ScaleSample.ets // 缩放
| | | |---shapeCropSample
| | | | |---ShapeCropSample.ets // 形状裁剪
| | | |---safeAreaSample
| | | | |---SafeAreaSample.ets // 安全区域
| | | |---sizeSample
| | | | |---SizeSample.ets // 尺寸
| | | |---transformSample

View File

@ -56,6 +56,8 @@ struct FloatingWindowSample {
Column() {
TitleBar({ title: $r('app.string.Floating_window') })
.id('target')
TextInput({ placeholder: $r('app.string.avoiding_input_method_testing') })
.width('95%').height(50).enableKeyboardOnFocus(false).id('test_input')
Row() {
Row() {
FloatingWindowComponent()

View File

@ -152,6 +152,10 @@ const INFORMATION_PRESENTATION_AND_DYNAMIC_EFFECTS: ThirdLevelCategory =
title: $r('app.string.qrcode_title'),
url: 'pages/components/informationPresentationAndDynamicEffects/qrCodeSample/QRCodeSample'
},
{
title: $r('app.string.list'),
url: 'pages/components/informationPresentationAndDynamicEffects/listSample/ListSample'
},
{
title: $r('app.string.loading_progress'),
url: 'pages/components/informationPresentationAndDynamicEffects/loadingProgressSample/LoadingProgressSample'
@ -329,6 +333,10 @@ const NAVIGATION: ThirdLevelCategory =
image: $r('app.media.ic_navigation'),
title: $r('app.string.navigation'),
childNodes : [
{
title: $r('app.string.navRouter_title'),
url: 'pages/components/navigation/navRouterSample/NavRouterSample'
},
{
title: $r('app.string.navigation_title'),
url: 'pages/components/navigation/navigationSample/NavigationSample'

View File

@ -51,11 +51,22 @@ struct RefreshSample {
@State mFriction: number = 62
private dataArray: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@Builder refreshBuilder() {
Column() {
Text($r('app.string.auxiliary_refresh_refreshing'))
.fontSize(16)
}
.alignItems(HorizontalAlign.Center)
.justifyContent(FlexAlign.Center)
.padding(16)
.borderRadius(12)
}
build() {
Column() {
TitleBar({ title: $r('app.string.auxiliary_refresh') })
Column() {
Refresh({ refreshing: $$this.isRefreshing, offset: this.mOffset, friction: this.mFriction }) {
Refresh({ refreshing: $$this.isRefreshing, offset: this.mOffset, friction: this.mFriction, builder:this.refreshBuilder }) {
Scroll() {
Column() {
ForEach(this.dataArray, (item) => {
@ -69,10 +80,11 @@ struct RefreshSample {
Blank(6)
})
}.width('80%')
}.width('100%')
}.width('100%')
.height(300)
}
.width('100%')
.height(300)
.onRefreshing(() => {
setTimeout(() => {

View File

@ -33,6 +33,9 @@ import { TitleBar } from '../../../../common/TitleBar'
@Entry
@Component
struct CounterSample {
@State mEnableInc: boolean = true
@State mEnableDec: boolean = true
@State enableCount: number = 0
@State count: number = 0
@State imageCount: number = 0
private images: Resource[] = [$r('app.media.ic_button_circle_add'), $r('app.media.ic_blank_and_divider'),
@ -71,6 +74,39 @@ struct CounterSample {
this.imageCount--
})
}.cardStyle()
Text('EnableInc And EnableDec')
.leftTitleStyle()
Column() {
Row() {
Text('enableInc')
.fontSize(15)
Checkbox()
.id('inc')
.select(this.mEnableInc)
.onChange((value) => {
this.mEnableInc = value
})
Text('enableDec')
.fontSize(15)
Checkbox()
.id('dec')
.select(this.mEnableDec)
.onChange((value) => {
this.mEnableDec = value
})
}.alignSelf(ItemAlign.Start)
Counter() {
Text(this.enableCount.toString())
}.onInc(() => {
this.enableCount++
})
.onDec(() => {
this.enableCount--
})
.enableDec(this.mEnableDec)
.enableInc(this.mEnableInc)
}.cardStyle()
}
.backgroundColor($r('app.color.background_light_gray'))
.height('100%')

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TitleBar } from '../../../../common/TitleBar'
@Extend(Text) function leftTitleStyle() {
.fontColor($r('app.color.font_color_shallow'))
.fontSize(18)
.height(22)
.alignSelf(ItemAlign.Start)
.margin({ left: 12, bottom: 8 })
}
@Extend(Column) function cardStyle() {
.backgroundColor(Color.White)
.borderRadius(24)
.width('100%')
.padding(12)
.margin({ bottom: 12 })
}
@Entry
@Component
struct ListSample {
@State arr: number[] = [0, 1, 2, 3, 4]
@Builder itemEnd() {
Row() {
Button('Delete').margin('4vp')
Button('Set').margin('4vp')
}.padding('4vp').justifyContent(FlexAlign.SpaceEvenly)
}
build() {
Column() {
TitleBar({ title: $r('app.string.list') })
Text($r('app.string.delete_list_item'))
.leftTitleStyle()
Column() {
List({ space: 10 }) {
ForEach(this.arr, (item) => {
ListItem() {
Text('item' + item)
.width('100%')
.height(100)
.fontSize(16)
.textAlign(TextAlign.Center)
.borderRadius(10)
.backgroundColor(0xFFFFFF)
}
.transition({ type: TransitionType.Delete, opacity: 0 })
.swipeAction({
end: {
useDefaultDeleteAnimation: true,
onDelete: () => {
animateTo({ duration: 1000 }, () => {
let index = this.arr.indexOf(item)
this.arr.splice(index, 1)
})
},
deleteAreaDistance: 80,
}
})
}, item => item)
}
}
.cardStyle()
.width('100%')
}
.height('100%')
.width('100%')
.backgroundColor($r('app.color.background_light_gray'))
.padding({ left: 20, right: 20 })
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { TitleBar } from '../../../../common/TitleBar'
import { getStringData } from '../../../../data/ResourceDataHandle'
@Entry
@Component
struct NavRouterSample {
private arr: number[] = [1, 2, 3];
build() {
Column() {
TitleBar({ title: $r('app.string.navRouter_title') })
Navigation() {
List({ space: 12 }) {
ForEach(this.arr, (item) => {
ListItem() {
NavRouter() {
Text(getStringData($r('app.string.nav_router')) + item)
.width("100%")
.height(72)
.backgroundColor('#FFFFFF')
.borderRadius(24)
.fontSize(16)
.fontWeight(500)
.textAlign(TextAlign.Center)
NavDestination() {
Text("NavDestinationContent" + item)
}
.title("NavDestinationTitle" + item)
}
}
.id('Navigation'+item)
}, item => item)
}
.width("90%")
.margin({ top: 12 })
}
.title("主标题")
.mode(NavigationMode.Stack)
.menus([
{value: "", icon: "./image/ic_public_search.svg", action: ()=> {}},
{value: "", icon: "./image/ic_public_add.svg", action: ()=> {}},
{value: "", icon: "./image/ic_public_add.svg", action: ()=> {}},
{value: "", icon: "./image/ic_public_add.svg", action: ()=> {}},
{value: "", icon: "./image/ic_public_add.svg", action: ()=> {}}
])
.toolBar({items: [
{value: "func", icon: "./image/ic_public_highlights.svg", action: ()=> {}},
{value: "func", icon: "./image/ic_public_highlights.svg", action: ()=> {}},
{value: "func", icon: "./image/ic_public_highlights.svg", action: ()=> {}}
]})
}
.height('100%')
.width('100%')
.backgroundColor('#F1F3F5')
}
}

View File

@ -17,13 +17,14 @@ import { TitleBar } from '../../../../common/TitleBar'
@Extend(Text) function leftTitleStyle() {
.fontColor($r('app.color.sub_title_color'))
.fontSize(14)
.fontSize(18)
.height(22)
.alignSelf(ItemAlign.Start)
.margin({ left: 12, top: 12 })
.margin({ left: 12, bottom: 8 })
}
@Extend(Column) function cardStyle() {
.margin({ bottom: 12 })
.backgroundColor(Color.White)
.borderRadius(24)
.width('100%')
@ -53,6 +54,8 @@ struct ScrollSample {
build() {
Column() {
TitleBar({ title: $r('app.string.scroll_name') })
Scroll() {
Column() {
Text($r('app.string.scroll_horizontal'))
.leftTitleStyle()
Column() {
@ -80,9 +83,30 @@ struct ScrollSample {
.width('100%')
.height(200)
}.cardStyle()
}.backgroundColor($r('app.color.background_light_gray'))
Text($r('app.string.avoiding_input_method_testing'))
.leftTitleStyle()
Column() {
TextInput({ placeholder: $r('app.string.avoiding_input_method_testing') })
.width('95%').height(50).enableKeyboardOnFocus(false).id('test_input')
Scroll() {
Image($r('app.media.banner'))
.width('100%')
.height('150%')
.objectFit(ImageFit.Contain)
}
.id('avoiding_input_scroll')
.scrollable(ScrollDirection.Vertical)
.width('100%')
.height(200)
}.cardStyle()
.margin({ bottom: 80 })
}
.constraintSize({ minHeight: '100%' })
}
.backgroundColor($r('app.color.background_light_gray'))
.width('100%')
.height('100%')
.padding({ left: 20, right: 20 })
}
}
}

View File

@ -24,6 +24,8 @@ export struct PropertiesControlPanel {
@Link loop: boolean;
@Link autoPlay: boolean;
@Link interval: number;
@Link nextMarginLength: number;
@Link prevMarginLength: number;
build() {
Column() {
@ -60,6 +62,22 @@ export struct PropertiesControlPanel {
testId:"swiper_005"
})
CommonItemSlider({
changeValue: $nextMarginLength,
min: 0,
max: 50,
name: $r('app.string.swiper_next_margin'),
testId:"swiper_008"
})
CommonItemSlider({
changeValue: $prevMarginLength,
min: 0,
max: 50,
name: $r('app.string.swiper_previous_margin'),
testId:"swiper_009"
})
CommonItemSelect({
name: $r('app.string.swiper_properties_duration'),
selects: ['400', '1000', '2000'],

View File

@ -45,6 +45,8 @@ struct SwiperSample {
@State loop: boolean = false;
@State autoPlay: boolean = false;
@State interval : number = 1000;
@State nextMarginLength: number = 0
@State prevMarginLength: number = 0
private controller: SwiperController = new SwiperController();
private data: number[] = [];
@ -77,6 +79,8 @@ struct SwiperSample {
}
})
}
.nextMargin(this.nextMarginLength)
.prevMargin(this.prevMarginLength)
.disableSwipe(this.isDisableSwipe)
.itemSpace(this.itemSpace)
.vertical(this.isVertical)
@ -122,7 +126,9 @@ struct SwiperSample {
duration: $duration,
loop: $loop,
autoPlay: $autoPlay,
interval : $interval
interval : $interval,
nextMarginLength: $nextMarginLength,
prevMarginLength: $prevMarginLength
})
}
.backgroundStyle()

View File

@ -47,7 +47,7 @@ struct SearchSample {
Text('onCopy:' + this.copyValue).fontSize(18).margin(15)
Text('onCut:' + this.cutValue).fontSize(18).margin(15)
Text('onPaste:' + this.pasteValue).fontSize(18).margin(15)
Search({ value: this.changeValue, placeholder: 'Type to search...', controller: this.controller })
Search({ value: this.changeValue, placeholder: $r('app.string.search_placeholder'), controller: this.controller })
.searchButton('SEARCH')
.id('search_001')
.width('95%')

View File

@ -16,13 +16,13 @@
import { CommonItemSlider, CommonItemSelect, CommonItemColorSelect } from '../../../../common/AttributeModificationTool'
import { selectData } from '../../ComponentData'
import { getStringArrayData } from '../../../../data/ResourceDataHandle'
import { TestType } from '@ohos/hypium'
@Component
export struct ChangePanel {
@Link letterSpacing: number
@Link decoration: TextDecorationType
@Link decorationColor: Color
@Link lineHeight: number
build() {
Column() {
@ -31,7 +31,15 @@ export struct ChangePanel {
min: 0,
max: 12,
name: $r('app.string.span_letter_spacing'),
testId: `span_001`,
testId:'Slider1'
})
CommonItemSlider({
changeValue: $lineHeight,
min: 0,
max: 100,
name: $r('app.string.span_line_height'),
testId:'Slider2'
})
CommonItemSelect({
@ -51,14 +59,12 @@ export struct ChangePanel {
default:
this.decoration = TextDecorationType.None
}
},
testId: `test_itemSelect`
}
})
CommonItemColorSelect({
name: $r('app.string.span_decoration_color'),
selectColor: $decorationColor,
testId: `test_colorSelect`
selectColor: $decorationColor
})
}
}

View File

@ -32,6 +32,7 @@ struct SpanSample {
@State decoration: TextDecorationType = TextDecorationType.None
@State textCase: TextCase = TextCase.Normal
@State decorationColor: Color = Color.Red
@State lineHeight: number = 3
build() {
Column() {
@ -59,25 +60,47 @@ struct SpanSample {
Column() {
Text() {
Span($r('app.string.span_text_decoration'))
.fontSize(20)
.font({
size: 20
})
.height(50)
.lineHeight(this.lineHeight)
.decoration({
type: this.decoration, // Decoration type
color: this.decorationColor // Line color
})
Span($r('app.string.span_text_spacing'))
.fontSize(20)
.font({
size: 20
})
.lineHeight(this.lineHeight)
.letterSpacing(this.letterSpacing) // Letter spacing
}
.height(50)
.height(60)
.fontSize(50)
ChangePanel({
letterSpacing: $letterSpacing,
decoration: $decoration,
decorationColor: $decorationColor
decorationColor: $decorationColor,
lineHeight: $lineHeight
})
}
.backgroundStyle()
IntroductionTitle({ introduction: $r('app.string.span_inherits_text_attribute') })
Column() {
Text() {
Span($r('app.string.span_does_not_inherit_text_attribute'))
.fontSize(20)
.height(50)
Span($r('app.string.span_inherits_text_attribute'))
}
.height(70)
.fontSize(10)
}
.backgroundStyle()
.margin({ bottom: 80 })
}
.constraintSize({ minHeight: '100%' }) // Let the minHeight of the component cover screen at least

View File

@ -18,6 +18,7 @@ import ShowToast from '../../../../util/ShowToast';
import { TitleBar } from '../../../../common/TitleBar';
import { LEFT_PADDING, RIGHT_PADDING } from '../../ComponentData';
import { textAreaControlPanel } from './ChangePanel';
import Logger from '../../../../util/Logger'
@Extend(Column) function cardStyle() {
.borderRadius(24)
@ -29,6 +30,11 @@ import {textAreaControlPanel} from './ChangePanel';
@Entry
@Component
struct TextAreaSample {
@State startSelect: number = 0
@State endSelect: number = 0
@State maxSelect: number = 0
@State selects: string[] = ['0']
private select: number = 1
@State textAreaSet: string = '';
@State placeholderColor: Color = Color.Blue;
@State textAlign: TextAlign = TextAlign.Start;
@ -36,7 +42,6 @@ struct TextAreaSample {
@State copyOptions: CopyOptions = CopyOptions.None;
controller: TextAreaController = new TextAreaController();
build() {
Column() {
TitleBar({ title: $r('app.string.textarea_title') })
@ -60,8 +65,13 @@ struct TextAreaSample {
.margin(20)
.fontSize(16)
.enableKeyboardOnFocus(false)
.onChange(()=>{
.onChange((value: string) => {
ShowToast.shortToast('The input have changed.')
this.textAreaSet = value
this.maxSelect = value.length
for (let i = 0;i < this.maxSelect; i++) {
this.selects[i] = i.toString()
}
})
.onCopy(() => {
ShowToast.shortToast('copy')
@ -74,9 +84,52 @@ struct TextAreaSample {
})
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.textarea_control') })
Column() {
textAreaControlPanel({placeholderColor:$placeholderColor,textAlign:$textAlign,caretColor:$caretColor,copyOption:$copyOptions})
textAreaControlPanel({
placeholderColor: $placeholderColor,
textAlign: $textAlign,
caretColor: $caretColor,
copyOption: $copyOptions
})
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.text_area_set_text_selection') })
Column() {
Row() {
Text($r('app.string.text_input_set_text_selection_start_select'))
Column() {
TextPicker({ range: this.selects, selected: this.select })
.onChange((value: string, index: number) => {
this.startSelect = parseInt(value)
Logger.info(`Picker item changed, value: ${value}, index: ${index}`)
})
}
.height(90)
.width(100)
Text($r('app.string.text_input_set_text_selection_end_select'))
Column() {
TextPicker({ range: this.selects, selected: this.select })
.onChange((value: string, index: number) => {
this.endSelect = parseInt(value)
Logger.info(`Picker item changed, value: ${value}, index: ${index}`)
})
}
.id('end_select')
.height(90)
.width(100)
Button($r('app.string.text_area_set_text_selection'))
.id('button_to_select')
.onClick(() => {
this.controller.setTextSelection(this.startSelect, this.endSelect)
Logger.info(`startSelect: ${this.startSelect}, endSelect: ${this.endSelect}`)
})
}
.justifyContent(FlexAlign.SpaceAround)
.width('100%')
}.cardStyle()
}
.width('100%')

View File

@ -16,6 +16,7 @@
import { CommonItemSelect } from '../../../../common/AttributeModificationTool';
import { IntroductionTitle } from '../../../../common/IntroductionTitle';
import ShowToast from '../../../../util/ShowToast';
import Logger from '../../../../util/Logger';
import { TitleBar } from '../../../../common/TitleBar';
@Extend(Column) function backgroundStyle() {
@ -35,9 +36,16 @@ struct TextInputSample {
@State inputType: InputType = InputType.Normal
@State inputContent: string = ''
@State typePlaceholder: Resource = $r('app.string.text_input_normal_type')
@State inputSelectContent: string = ''
@State startSelect: number = 0
@State endSelect: number = 0
@State maxSelect: number = 0
@State selects: string[] = ['0']
private select: number = 1
private maxLength: number = 12
private context: any = getContext(this)
private inputController: TextInputController = new TextInputController()
private inputSelectController: TextInputController = new TextInputController()
build() {
Column() {
@ -189,6 +197,53 @@ struct TextInputSample {
}
})
}
IntroductionTitle({ introduction: $r('app.string.text_input_set_text_selection') })
Column() {
TextInput({ controller: this.inputSelectController })
.enableKeyboardOnFocus(false)
.id('test_input_to_select')
.onChange((value: string) => {
this.inputSelectContent = value
this.maxSelect = value.length
for (let i = 0;i < this.maxSelect; i++) {
this.selects[i] = i.toString()
}
})
Row() {
Text($r('app.string.text_input_set_text_selection_start_select'))
Column() {
TextPicker({ range: this.selects, selected: this.select })
.onChange((value: string, index: number) => {
this.startSelect = parseInt(value)
Logger.info(`Picker item changed, value: ${value}, index: ${index}`)
})
}
.height(90)
.width(100)
Text($r('app.string.text_input_set_text_selection_end_select'))
Column() {
TextPicker({ range: this.selects, selected: this.select })
.onChange((value: string, index: number) => {
this.endSelect = parseInt(value)
Logger.info(`Picker item changed, value: ${value}, index: ${index}`)
})
.id('end_select')
}
.height(90)
.width(100)
Button($r('app.string.text_area_set_text_selection'))
.id('button_to_select')
.onClick(() => {
this.inputSelectController.setTextSelection(this.startSelect, this.endSelect)
Logger.info(`startSelect: ${this.startSelect}, endSelect: ${this.endSelect}`)
})
}
.justifyContent(FlexAlign.SpaceAround)
.width('100%')
}
.backgroundStyle()
.margin({ bottom: 70 })
}
.constraintSize({ minHeight: '100%' }) // Let the minHeight of the component cover screen at least

View File

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { CommonItemSlider, CommonItemSelect, CommonItemColorSelect } from '../../../../common/AttributeModificationTool';
import { CommonItemSlider, CommonItemSelect, CommonItemColorSelect } from '../../../../common/AttributeModificationTool'
@Component
export struct ChangeTextCase {

View File

@ -13,8 +13,9 @@
* limitations under the License.
*/
import { ChangeTextCase, ChangeTextAttribute } from './ChangePanel';
import { TitleBar } from '../../../../common/TitleBar';
import measure from '@ohos.measure'
import { ChangeTextCase, ChangeTextAttribute } from './ChangePanel'
import { TitleBar } from '../../../../common/TitleBar'
@Extend(Column) function backgroundStyle() {
.size({ width: '100%' })
@ -31,12 +32,16 @@ struct TextSample {
@State lineHeight: number = 23
@State textMaxLines: number = -1
@State letterSpacing: number = 2
@State fontColor: Color = Color.Blue
@State fontColor: string = '#FF000000'
@State textCase: TextCase = TextCase.Normal
@State textAlign: TextAlign = TextAlign.Start
@State textOverFlow: TextOverflow = TextOverflow.None
@State styleForDecorative: TextDecorationType = TextDecorationType.None
@State textContent: Resource = $r('app.string.text_content')
textSize : SizeOptions = measure.measureTextSize({
textContent: $r('app.string.text_content'),
})
build() {
Column() {
@ -66,6 +71,33 @@ struct TextSample {
textOverFlow: $textOverFlow,
styleForDecorative: $styleForDecorative,
})
Row(){
Text($r('app.string.text_width'))
Blank()
Text(this.textSize.width.toString() + ' px')
.width(150)
.fontSize(20)
.textAlign(TextAlign.Center)
}
.size({ width: '100%', height: 42 })
.padding({ left: 0 , right: 0 })
.borderRadius(0 )
.backgroundColor( Color.Transparent)
Row(){
Text($r('app.string.text_height'))
Blank()
Text(this.textSize.height.toString() + ' px')
.width(150)
.fontSize(20)
.textAlign(TextAlign.Center)
}
.size({ width: '100%', height: 42 })
.padding({ left: 0 , right: 0 })
.borderRadius(0 )
.backgroundColor( Color.Transparent)
}
.backgroundStyle()

View File

@ -24,6 +24,15 @@ import { TitleBar } from '../../../../common/TitleBar';
.justifyContent(FlexAlign.SpaceBetween)
}
@Extend(Column) function columnStyle() {
.width('100%')
.borderRadius(24)
.margin({ top: 8, bottom: 8 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
.padding(15)
}
@Extend(Button) function buttonStyle() {
.margin(8)
.fontSize(16)
@ -34,6 +43,8 @@ import { TitleBar } from '../../../../common/TitleBar';
@Entry
@Component
struct ListDialogSample {
private mTextInputController: TextInputController = new TextInputController()
build() {
Column() {
TitleBar({ title: $r('app.string.action_sheet_dialog') })
@ -384,7 +395,65 @@ struct ListDialogSample {
.id('sheet_click_contentButton')
}
.rowStyle()
IntroductionTitle({ introduction: $r('app.string.avoiding_input_method_testing') })
Column() {
Row() {
TextInput({
controller: this.mTextInputController,
placeholder: $r('app.string.avoiding_input_method_testing')
})
.layoutWeight(1).height(50).id('test_input')
}.rowStyle()
Row() {
Button($r('app.string.alert_dialog_bottom'))
.id('btn_test_input')
.buttonStyle()
.onClick(() => {
this.mTextInputController.setTextSelection(1, 2)
ActionSheet.show(
{
title: $r('app.string.alert_dialog_prompt'),
message: $r('app.string.alert_dialog_bottom'),
confirm: {
value: $r('app.string.alert_dialog_confirm'),
action: () => {
ShowToast.shortToast($r('app.string.alert_dialog_bottom'));
}
},
sheets: [
{
title: $r('app.string.text_picker_text_apple'),
action: () => {
ShowToast.shortToast($r('app.string.text_picker_text_apple'));
}
},
{
title: $r('app.string.text_picker_text_banana'),
action: () => {
ShowToast.shortToast($r('app.string.text_picker_text_banana'));
}
},
{
title: $r('app.string.text_picker_text_peach'),
action: () => {
ShowToast.shortToast($r('app.string.text_picker_text_peach'));
}
}
],
cancel: () => {
ShowToast.shortToast($r('app.string.alert_dialog_cancel'));
},
alignment: DialogAlignment.Bottom
}
);
})
.id('sheet_bottomButton')
}.rowStyle()
}.columnStyle().margin({ bottom: 80 })
}
.padding(12)
.constraintSize({ minHeight: '100%' })
}
}

View File

@ -24,6 +24,15 @@ import { TitleBar } from '../../../../common/TitleBar'
.justifyContent(FlexAlign.SpaceBetween)
}
@Extend(Column) function columnStyle() {
.width('100%')
.borderRadius(24)
.margin({ top: 8, bottom: 8 })
.justifyContent(FlexAlign.SpaceBetween)
.backgroundColor(Color.White)
.padding(15)
}
@Extend(Button) function buttonStyle() {
.margin(8)
.fontSize(16)
@ -36,6 +45,8 @@ import { TitleBar } from '../../../../common/TitleBar'
@Entry
@Component
struct WarningDialogSample {
private mTextInputController: TextInputController = new TextInputController()
build() {
Column() {
TitleBar({ title: $r('app.string.alert_dialog') })
@ -249,7 +260,7 @@ struct WarningDialogSample {
cancel: () => {
ShowToast.shortToast($r('app.string.alert_dialog_cancel'))
},
offset: { dx: 20, dy: 30 }
offset: { dx: 20, dy: 150 }
}
)
}).id('test_lowRightButton')
@ -323,7 +334,44 @@ struct WarningDialogSample {
}).id('test_4GridButton')
}
.rowStyle()
IntroductionTitle({ introduction: $r('app.string.avoiding_input_method_testing') })
Column() {
Row() {
TextInput({
controller: this.mTextInputController,
placeholder: $r('app.string.avoiding_input_method_testing')
})
.layoutWeight(1).height(50).id('test_input')
}.rowStyle()
Row() {
Button($r('app.string.alert_dialog_bottom'))
.buttonStyle()
.onClick(() => {
this.mTextInputController.setTextSelection(1, 2)
AlertDialog.show(
{
title: $r('app.string.alert_dialog_prompt'),
message: $r('app.string.alert_dialog_bottom'),
confirm: {
value: $r('app.string.alert_dialog_confirm'),
backgroundColor: $r('app.color.background_grey'),
action: () => {
ShowToast.shortToast($r('app.string.alert_dialog_bottom'))
}
},
cancel: () => {
ShowToast.shortToast($r('app.string.alert_dialog_cancel'))
},
alignment: DialogAlignment.Bottom
}
)
}).id('test_bottomButton')
}.rowStyle()
}.columnStyle().margin({ bottom: 80 })
}
.padding(12)
.constraintSize({ minHeight: '100%' })
}
}

View File

@ -17,6 +17,11 @@ import { SecondLevelCategory, ThirdLevelCategory } from '../../model/Categorical
const GRAPHIC_TRANSFORMATION: ThirdLevelCategory[] =
[
{
image: $r('app.media.ic_prop_background'),
title: $r('app.string.safe_area'),
url: 'pages/universal/properties/safeAreaSample/SafeAreaSample'
},
{
image: $r('app.media.ic_prop_background'),
title: $r('app.string.prop_foreground'),
@ -257,7 +262,7 @@ export let visibileTypes: { value: Resource }[] =
export let placementsNameData = ['TopLeft', 'Top', 'TopRight', 'RightTop', 'Right', 'RightBottom', 'LeftTop', 'Left', 'LeftBottom', 'BottomLeft', 'Bottom', 'BottomRight']
export let hitTestModeNameData = ['Default', 'Block', 'Transparent', 'None']
export let hoverEffectNameData = ['None', 'Highlight', 'Auto', 'Scale']
export let pointerStyleNameData = ['DEFAULT', 'EAST', 'WEST', 'SOUTH','NORTH','WEST_EAST','NORTH_SOUTH','NORTH_EAST','NORTH_WEST','SOUTH_EAST','SOUTH_WEST','NORTH_EAST_SOUTH_WEST','NORTH_WEST_SOUTH_EAST','CROSS','CURSOR_COPY','CURSOR_FORBID','COLOR_SUCKER','HAND_GRABBING','HAND_OPEN','HAND_POINTING','HELP','MOVE','RESIZE_LEFT_RIGHT','RESIZE_UP_DOWN','SCREENSHOT_CHOOSE','SCREENSHOT_CURSOR','TEXT_CURSOR','ZOOM_IN','ZOOM_OUT','MIDDLE_BTN_EAST','MIDDLE_BTN_WEST','MIDDLE_BTN_SOUTH','MIDDLE_BTN_NORTH','MIDDLE_BTN_NORTH_SOUTH','MIDDLE_BTN_NORTH_EAST','MIDDLE_BTN_NORTH_WEST','MIDDLE_BTN_SOUTH_EAST','MIDDLE_BTN_SOUTH_WEST','MIDDLE_BTN_NORTH_SOUTH_WEST_EAST']
export let selectImageSizeData: Resource[] = [$r('app.string.background_image_size_cover'), $r('app.string.background_image_size_contain')]

View File

@ -15,6 +15,7 @@
import { IntroductionTitle } from '../../../../common/IntroductionTitle';
import { TitleBar } from '../../../../common/TitleBar';
import Logger from '../../../../util/Logger';
@Extend(Row) function rowStyle() {
.borderRadius(24)
@ -22,13 +23,23 @@ import { TitleBar } from '../../../../common/TitleBar';
.backgroundColor(Color.White)
.margin({ left: 12, right: 12 })
}
@Extend(Column) function columnStyle() {
.borderRadius(24)
.width('100%')
.backgroundColor(Color.White)
.margin({ left: 12, right: 12 })
}
@Entry
@Component
struct GridSettingsSample {
@State Number: String[] = ['0', '1', '2', '3']
build() {
Column() {
TitleBar({ title: $r('app.string.grid_settings') })
Scroll() {
Column() {
IntroductionTitle({ introduction: $r('app.string.grid_settings_useSize') })
Column() {
GridContainer() {
@ -113,8 +124,41 @@ struct GridSettingsSample {
.height(200)
}
.width('100%')
IntroductionTitle({ introduction: $r('app.string.grid_edgeEffect_spring') })
Column() {
Grid() {
ForEach(this.Number, (day: string) => {
ForEach(this.Number, (day: string) => {
GridItem() {
Text(day)
.fontSize(16)
.backgroundColor(0x66bbb2cb)
.width('100%')
.height(80)
.textAlign(TextAlign.Center)
}
}, day => day)
}, day => day)
}
.columnsTemplate('1fr 1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.edgeEffect(EdgeEffect.Spring)
.onScrollIndex((first: number) => {
Logger.info(first.toString())
})
.width('90%')
.backgroundColor(0x66b6c5d1)
.height(300)
.scrollBar(BarState.On)
}
.columnStyle()
}
.constraintSize({ minHeight: '100%' })
.padding(12)
}
}
.height('100%')
.width('100%')
.backgroundColor($r('app.color.background_shallow_grey'))
}

View File

@ -13,11 +13,15 @@
* limitations under the License.
*/
import { TitleBar } from '../../../../common/TitleBar'
import pointer from '@ohos.multimodalInput.pointer'
import promptAction from '@ohos.prompt'
import prompt from '@ohos.prompt'
import window from '@ohos.window'
import { TitleBar } from '../../../../common/TitleBar'
import { getStringData } from '../../../../data//ResourceDataHandle'
import { placementsNameData, hitTestModeNameData, hoverEffectNameData } from '../../UniversialData'
import { placementsNameData, hitTestModeNameData, hoverEffectNameData, pointerStyleNameData } from '../../UniversialData'
import Logger from '../../../../util/Logger'
import measure from '@ohos.measure'
@Extend(Text) function leftTitleStyle() {
.fontColor($r('app.color.sub_title_color'))
@ -50,6 +54,7 @@ import { placementsNameData, hitTestModeNameData, hoverEffectNameData } from '..
@Entry
@Component
struct Interaction {
@State isMask: boolean = false
@State buttonIsDisabled: boolean = false
@State listIsDisabled: boolean = false
@State alertText: string = ''
@ -65,27 +70,32 @@ struct Interaction {
@State mComponentDisabled: boolean = false
@State mComponentFocused: boolean = false
@State mTabIndex: number = 0
@State mHoverEffect: HoverEffect = HoverEffect.None;
@State mHoverEffect: HoverEffect = HoverEffect.None
@State mPointerStyle: pointer.PointerStyle = pointer.PointerStyle.DEFAULT
private mTouchableTestResult: string = ''
private mToastTimer = null
private mMenuLists = [
{
value: getStringData($r('app.string.components_interaction_menuone')),
icon: $r('app.media.ic_other'),
action: () => {
}
},
{
value: getStringData($r('app.string.components_interaction_menutwo')),
icon: $r('app.media.ic_other'),
action: () => {
}
},
{
value: getStringData($r('app.string.components_interaction_menuthree')),
icon: $r('app.media.ic_other'),
action: () => {
}
},
{
value: getStringData($r('app.string.components_interaction_menufour')),
icon: $r('app.media.ic_other'),
action: () => {
}
}
@ -126,27 +136,46 @@ struct Interaction {
Row({ space: 20 }) {
Image($r("app.media.icon")).width(24).height(24)
Text('Content').fontSize(20).fontColor(Color.White)
}.width(200).height(80).padding(10)
}.width(140).height(40).padding(10)
}
@Builder menuBuilder() {
Menu() {
MenuItem({ startIcon: $r('app.media.ic_other'), content: $r('app.string.components_interaction_menuone') })
MenuItemGroup({ header: $r('app.string.components_interaction_menutwo') }) {
MenuItem({
startIcon: $r('app.media.ic_other'),
content: $r('app.string.components_interaction_menuthree')
})
MenuItem({
startIcon: $r('app.media.ic_other'),
content: $r('app.string.components_interaction_menufour')
})
}
}
}
private context: any = getContext(this)
private placementsNameArray = placementsNameData
private hitTestModeNameArray = hitTestModeNameData
private hoverEffectNameArray = hoverEffectNameData
private pointerStyleNameArray = pointerStyleNameData
@Builder tabbarTitle(name: string | Resource, index: number) {
Stack() {
Column() {
Text(name)
.fontSize(22)
.fontColor(this.mTabIndex === index ? $r('app.color.title_colorone') : $r('app.color.title_colortwo'))
.margin({ bottom: 5 })
if (this.mTabIndex === index) {
Row()
.width(measure.measureTextSize({textContent:name}).width)
.backgroundColor($r('app.color.title_colorone'))
.width('100%')
.height(2)
.position({ y: 48 })
}
}.width(48)
}
.margin(8)
.constraintSize({ minWidth: 32 })
.height(56)
}
@ -283,6 +312,13 @@ struct Interaction {
.onChange((value) => {
this.mPlacementOnTop = value
})
Text($r('app.string.interaction_mask'))
.fontSize(15)
Checkbox()
.select(this.isMask)
.onChange((value) => {
this.isMask = value
})
}.alignSelf(ItemAlign.Start)
Text($r('app.string.interaction_arrowoffset'))
@ -319,7 +355,8 @@ struct Interaction {
action: () => {
this.handlePopup = false
}
}
},
mask: this.isMask
}).id('test_popButton')
}.cardStyle()
@ -343,6 +380,7 @@ struct Interaction {
}.width('100%')
Button($r('app.string.interaction_showcustompopup'))
.margin({ bottom: 30 })
.onClick(() => {
this.handleCustomPopup = true;
})
@ -524,7 +562,13 @@ struct Interaction {
TabContent() {
Column() {
Blank()
Scroll() {
Column() {
Text($r('app.string.bind_menu_customBuilder'))
.leftTitleStyle()
Column() {
Text($r('app.string.click_on_any_action_below'))
.leftTitleStyle()
Row() {
Blank()
ForEach([1, 2, 3, 4, 5], (item) => {
@ -535,16 +579,76 @@ struct Interaction {
Text($r('app.string.option'))
.fontSize(15)
}
.id('menuBuilder' + item)
.bindMenu(this.menuBuilder)
Blank()
})
}.width('100%')
Blank()
}.cardStyle().height(250)
Text($r('app.string.bind_menu_content'))
.leftTitleStyle()
Column() {
Text($r('app.string.click_on_any_action_below'))
.leftTitleStyle()
Row() {
Blank()
ForEach([1, 2, 3, 4, 5], (item) => {
Column() {
Image($r('app.media.ic_other'))
.width(30)
.height(30)
Text($r('app.string.option'))
.fontSize(15)
}
.id('mMenuLists' + item)
.bindMenu(this.mMenuLists)
Blank()
})
}.width('100%')
Blank()
}.cardStyle().height(250)
Text($r('app.string.bind_content_menu'))
.leftTitleStyle()
Column() {
Text($r('app.string.long_press_any_action_below'))
.leftTitleStyle()
Row() {
Blank()
ForEach([1, 2, 3, 4, 5], (item) => {
Column() {
Image($r('app.media.ic_other'))
.width(30)
.height(30)
Text($r('app.string.option'))
.fontSize(15)
}
.id('contextMenu' + item)
.bindContextMenu(
this.menuBuilder,
ResponseType.LongPress,
{
offset: { x: 0, y: 0 }
}
)
Blank()
})
}.width('100%')
Blank()
}.cardStyle().height(250).margin({ bottom: 70 })
}
}
}.height('100%')
.width('100%')
.padding(20)
}.tabBar(this.tabbarTitle($r('app.string.menu'), 5))
.height('100%')
TabContent() {
Column() {
@ -584,10 +688,77 @@ struct Interaction {
}.width('100%')
.padding(12)
}.tabBar(this.tabbarTitle($r('app.string.multiState'), 6))
}.layoutWeight(1)
TabContent() {
Scroll() {
Column() {
Text($r('app.string.multi_short_key'))
.leftTitleStyle()
Column() {
Text($r('app.string.on_short_key'))
.leftTitleStyle()
Button($r('app.string.multi_short_key'))
.onClick(() => {
prompt.showToast({
message: getStringData($r('app.string.short_key_pressed')),
duration: 1000,
});
})
.keyboardShortcut('a', [ModifierKey.CTRL])
}.cardStyle()
Text($r('app.string.set_mouse_style'))
.leftTitleStyle()
Column() {
Flex({ wrap: FlexWrap.Wrap }) {
ForEach(this.pointerStyleNameArray, (item: string) => {
Row() {
Radio({ value: item, group: 'pointerStyle' })
.id(item)
.checked(this.mPointerStyle === pointer.PointerStyle[item])
.onChange((isChecked: boolean) => {
if (isChecked) {
this.mPointerStyle = pointer.PointerStyle[item];
try {
let promise = window.getLastWindow(this.context);
promise.then((win)=> {
let windowId = win.getWindowProperties().id;
Logger.info('Succeeded in obtaining the top window. Data: ' + JSON.stringify(win));
if (windowId < 0) {
Logger.info(`Invalid windowId`);
return;
}
try {
pointer.setPointerStyle(windowId, this.mPointerStyle, error => {
Logger.info(`Set pointer style success`);
});
} catch (error) {
Logger.info(`Set pointer style failed, error: ${JSON.stringify(error, [`code`, `message`])}`);
}
}).catch((err)=>{
Logger.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err));
});
} catch (exception) {
Logger.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception));
}
}
})
Text(item)
.fontSize(10)
}.width('50%')
})
}.width('100%')
}.cardStyle()
}.width('100%')
.padding(12)
}
}.tabBar(this.tabbarTitle($r('app.string.multimode_input'), 7))
}
.barOverlap(true)
.onChange((index) => {
this.mTabIndex = index
})
.barOverlap(true)
.barMode(BarMode.Scrollable)
}
.height('100%')

View File

@ -13,8 +13,10 @@
* limitations under the License.
*/
import { IntroductionTitle } from '../../../../common/IntroductionTitle';
import { TitleBar } from '../../../../common/TitleBar';
import { getStringData } from '../../../../data/ResourceDataHandle';
import Logger from '../../../../util/Logger';
@Extend(Button) function buttonStyle() {
.margin(8)
@ -23,9 +25,22 @@ import { getStringData } from '../../../../data/ResourceDataHandle';
.margin({ left: 24, right: 24, top: 12 })
}
@Extend(Column) function cardStyle() {
.backgroundColor(Color.White)
.borderRadius(24)
.width('100%')
.padding(15)
.margin({ left: 12, right: 12, bottom: 12 })
}
@Entry
@Component
struct RestoreIdExample {
@State outSetValueTwo: number = 40
@State fontColor: string = '#182431'
@State selectedFontColor: string = '#007DFF'
@State currentIndex: number = 0
private controller: TabsController = new TabsController()
private apple: string = getStringData($r('app.string.text_picker_text_apple'));
private orange: string = getStringData($r('app.string.text_picker_text_orange'));
private peach: string = getStringData($r('app.string.text_picker_text_peach'));
@ -33,9 +48,29 @@ struct RestoreIdExample {
private banana: string = getStringData($r('app.string.text_picker_text_banana'));
private fruits: string[] = [this.apple, this.orange, this.peach, this.grape, this.banana];
@Builder TabBuilder(index: number, name: string) {
Column() {
Text(name)
.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor)
.fontSize(16)
.fontWeight(this.currentIndex === index ? 500 : 400)
.lineHeight(22)
.margin({ top: 17, bottom: 7 })
Divider()
.strokeWidth(2)
.color('#007DFF')
.opacity(this.currentIndex === index ? 1 : 0)
}.width('100%')
}
build() {
Column() {
TitleBar({ title: $r('app.string.restore_id') })
Scroll() {
Column() {
IntroductionTitle({ introduction: $r('app.string.list') })
Column() {
List({ space: 8 }) {
ForEach(this.fruits, (item) => {
ListItem() {
@ -47,6 +82,126 @@ struct RestoreIdExample {
.alignListItem(ListItemAlign.Center)
.width('100%')
.restoreId(1)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.checkbox') })
Column() {
Checkbox()
.select(true)
.selectedColor(0xed6f21)
.restoreId(2)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.radio_title') })
Column() {
Radio({ value: 'Radio1', group: 'radioGroup' })
.checked(true)
.restoreId(3)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.toggle_title') })
Column() {
Toggle({ type: ToggleType.Switch, isOn: false })
.selectedColor('#007DFF')
.switchPointColor('#FFFFFF')
.restoreId(4)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.swiper_name') })
Column() {
Swiper() {
ForEach(['1', '2', '3'], (item: string) => {
Text(item)
.width('90%')
.height(160)
.backgroundColor(0xAFEEEE)
.textAlign(TextAlign.Center)
.fontSize(30)
}, item => item)
}
.cachedCount(2)
.index(1)
.autoPlay(true)
.interval(4000)
.indicator(true)
.loop(true)
.duration(1000)
.itemSpace(0)
.curve(Curve.Linear)
.restoreId(5)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.tabs_name') })
Column() {
Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
TabContent() {
Column().width('100%').height('100%').backgroundColor('#00CB87')
}.tabBar(this.TabBuilder(0, 'green'))
TabContent() {
Column().width('100%').height('100%').backgroundColor('#007DFF')
}.tabBar(this.TabBuilder(1, 'blue'))
TabContent() {
Column().width('100%').height('100%').backgroundColor('#FFBF00')
}.tabBar(this.TabBuilder(2, 'yellow'))
TabContent() {
Column().width('100%').height('100%').backgroundColor('#E67C92')
}.tabBar(this.TabBuilder(3, 'pink'))
}
.vertical(false)
.barMode(BarMode.Fixed)
.barWidth(360)
.barHeight(56)
.animationDuration(400)
.onChange((index: number) => {
this.currentIndex = index
})
.width(360)
.height(296)
.margin({ top: 52 })
.backgroundColor('#F1F3F5')
.restoreId(6)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.tabs_name') })
Column() {
Slider({
value: this.outSetValueTwo,
step: 10,
style: SliderStyle.OutSet
})
.showSteps(true)
.onChange((value: number, mode: SliderChangeMode) => {
this.outSetValueTwo = value
Logger.info('value:' + value + 'mode:' + mode.toString())
})
.restoreId(7)
Text(this.outSetValueTwo.toFixed(0)).fontSize(12)
}.cardStyle()
IntroductionTitle({ introduction: $r('app.string.select_name') })
Column() {
Select([{ value: 'aaa', icon: $r('app.media.ic_select_global') },
{ value: 'bbb', icon: $r('app.media.ic_select_global') },
{ value: 'ccc', icon: $r('app.media.ic_select_global') },
{ value: 'ddd', icon: $r('app.media.ic_select_global') }])
.selected(2)
.value('TTTTT')
.font({ size: 16, weight: 500 })
.fontColor('#182431')
.selectedOptionFont({ size: 16, weight: 400 })
.optionFont({ size: 16, weight: 400 })
.onSelect((index: number) => {
Logger.info('Select:' + index)
})
.restoreId(8)
}.cardStyle().margin({ bottom: 80 })
}
.padding(12)
.constraintSize({ minHeight: '100%' })
}
}
.height('100%')
.width('100%')

View File

@ -0,0 +1,166 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getStringData } from '../../../../data//ResourceDataHandle'
import Logger from '../../../../util/Logger'
@Component
export struct ChangePanel {
@Link mSafeAreaType: SafeAreaType[]
@Link mSafeAreaEdge: SafeAreaEdge[]
build() {
Row() {
Column() {
Row() {
CheckboxGroup({ group: getStringData($r('app.string.safe_area_type')) })
.selectedColor(0xed6f21)
.onChange((itemName: CheckboxGroupResult) => {
this.mSafeAreaType = []
for (let i = 0;i < itemName.name.length; i++) {
if (itemName.name[i] == getStringData($r('app.string.safe_area_type_system'))) {
this.mSafeAreaType.push(SafeAreaType.SYSTEM)
}
else if (itemName.name[i] == getStringData($r('app.string.safe_area_type_cutout'))) {
this.mSafeAreaType.push(SafeAreaType.CUTOUT)
}
else if (itemName.name[i] == getStringData($r('app.string.safe_area_type_keyboard'))) {
this.mSafeAreaType.push(SafeAreaType.KEYBOARD)
}
}
Logger.info(`checkbox group content ${JSON.stringify(this.mSafeAreaType)}`)
}).id('test_selectAll')
Text($r('app.string.checkbox_select_all')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_type_system')),
group: getStringData($r('app.string.safe_area_type'))
})
.id('SYSTEM')
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox1 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_type_system')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_type_cutout')),
group: getStringData($r('app.string.safe_area_type'))
})
.select(true)
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox2 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_type_cutout')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_type_keyboard')),
group: getStringData($r('app.string.safe_area_type'))
})
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox3 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_type_keyboard')).fontSize(20)
}.width('100%')
}
.layoutWeight(1)
Column() {
Row() {
CheckboxGroup({ group: getStringData($r('app.string.safe_area_edge')) })
.selectedColor(0xed6f21)
.onChange((itemName: CheckboxGroupResult) => {
this.mSafeAreaEdge = []
for (let i = 0;i < itemName.name.length; i++) {
if (itemName.name[i] == getStringData($r('app.string.safe_area_edge_bottom'))) {
this.mSafeAreaEdge.push(SafeAreaEdge.BOTTOM)
}
else if (itemName.name[i] == getStringData($r('app.string.safe_area_edge_top'))) {
this.mSafeAreaEdge.push(SafeAreaEdge.TOP)
}
else if (itemName.name[i] == getStringData($r('app.string.safe_area_edge_start'))) {
this.mSafeAreaEdge.push(SafeAreaEdge.START)
}
else if (itemName.name[i] == getStringData($r('app.string.safe_area_edge_end'))) {
this.mSafeAreaEdge.push(SafeAreaEdge.END)
}
}
Logger.info(`checkbox group content ${JSON.stringify(itemName)}`)
}).id('test_selectAll')
Text($r('app.string.checkbox_select_all')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_edge_top')),
group: getStringData($r('app.string.safe_area_edge'))
})
.select(true)
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox1 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_edge_top')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_edge_bottom')),
group: getStringData($r('app.string.safe_area_edge'))
})
.select(true)
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox2 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_edge_bottom')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_edge_start')),
group: getStringData($r('app.string.safe_area_edge'))
})
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox3 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_edge_start')).fontSize(20)
}.width('100%')
Row() {
Checkbox({
name: getStringData($r('app.string.safe_area_edge_end')),
group: getStringData($r('app.string.safe_area_edge'))
})
.selectedColor($r('app.color.select_option_font_color'))
.onChange((value: boolean) => {
Logger.info(`Checkbox3 change is ${value}`)
}).margin({ left: 30 })
Text($r('app.string.safe_area_edge_end')).fontSize(20)
}.width('100%')
}
.layoutWeight(1)
}
}
}

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ChangePanel } from './ChangePanel'
import { IntroductionTitle } from '../../../../common/IntroductionTitle'
import { TitleBar } from '../../../../common/TitleBar'
@Extend(Column) function columnStyle() {
.width('100%')
.padding(16)
.borderRadius(24)
.backgroundColor(Color.White)
}
@Entry
@Component
struct SafeAreaSample {
@State mSafeAreaType: SafeAreaType[] = [SafeAreaType.CUTOUT]
@State mSafeAreaEdge: SafeAreaEdge[] = [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]
build() {
Column() {
TitleBar({ title: $r('app.string.safe_area') })
.backgroundColor($r('app.color.background_shallow_grey'))
Stack() {
Row() {
TextInput({ placeholder: $r('app.string.save_area_input_text') })
.placeholderFont({ size: 14, weight: 400 })
.width(320)
.height(40)
.offset({ y: 120 })
.fontSize(14)
.fontColor(Color.Black)
.backgroundColor(Color.White)
.enableKeyboardOnFocus(false)
}.height('100%').alignItems(VerticalAlign.Top)
Column() {
Column() {
IntroductionTitle({ introduction: $r('app.string.safe_area_type_and_safe_area_edge') })
ChangePanel({
mSafeAreaType: $mSafeAreaType,
mSafeAreaEdge: $mSafeAreaEdge
})
}.columnStyle().alignItems(HorizontalAlign.Center)
}.padding(12).width('100%')
}
}
.width('100%')
.height('100%')
.backgroundImage($r('app.media.img_test_1'))
.backgroundImageSize(ImageSize.Cover)
.expandSafeArea(this.mSafeAreaType, this.mSafeAreaEdge)
}
}

View File

@ -17,10 +17,11 @@ import { IntroductionTitle } from '../../../../common/IntroductionTitle'
import { TitleBar } from '../../../../common/TitleBar'
@Extend(Row) function rowStyle() {
.width('100%')
.padding(12)
.borderRadius(24)
.backgroundColor(Color.White)
.margin({ left: 12, right: 12 })
.margin({ bottom: 12 })
.justifyContent(FlexAlign.SpaceBetween)
}
@ -45,6 +46,18 @@ struct Size {
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.background_green'))
Row() {
Text($r('app.string.size_width_fixed_60vw'))
.fontSize(18)
.fontColor(Color.White)
}
.width('60vw')
.height(100)
.margin({ left: 20 })
.borderRadius(5)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.background_green'))
Row() {
Text($r('app.string.size_width_percent'))
.fontSize(18)
@ -75,6 +88,17 @@ struct Size {
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.background_blue'))
Row() {
Text($r('app.string.size_height_fixed_60vh'))
.fontSize(18)
.fontColor(Color.White)
}
.height('60vh')
.borderRadius(5)
.margin({ left: 20 })
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.background_blue'))
Row() {
Text($r('app.string.size_height_percent'))
.fontSize(18)
@ -92,7 +116,21 @@ struct Size {
.backgroundColor($r('app.color.background_blue'))
}
.rowStyle()
Row() {
Row() {
Text($r('app.string.size_height_fixed_calc'))
.fontSize(18)
.fontColor(Color.White)
}
.height('calc(200vp - 100vp)')
.borderRadius(5)
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.background_blue'))
}
.rowStyle()
}
.margin({ left: 12, right: 12 })
.constraintSize({ minHeight: '100%' })
}
}

View File

@ -36,6 +36,7 @@
"name": "prop_background",
"value": "Background"
},
{
"name": "prop_foreground",
"value": "Foreground"
@ -981,6 +982,15 @@
"name": "qrcode_enter_content",
"value": "Enter to change QR code"
},
// Search
{
"name": "search_placeholder",
"value": "Type to search..."
},
{
"name": "search_name",
"value": "search"
},
// Radio
{
"name": "radio_title",
@ -1035,6 +1045,55 @@
"name": "rotate_image_angle",
"value": "Rotate 15°"
},
// SaveArea
{
"name": "safe_area_type_and_safe_area_edge",
"value": "SafeAreaType And SafeAreaEdge"
},
{
"name": "safe_area",
"value": "SafeArea"
},
{
"name": "save_area_input_text",
"value": "input your word ..."
},
{
"name": "safe_area_type",
"value": "SafeAreaType"
},
{
"name": "safe_area_edge",
"value": "SafeAreaEdge"
},
{
"name": "safe_area_edge_top",
"value": "TOP"
},
{
"name": "safe_area_edge_bottom",
"value": "BOTTOM"
},
{
"name": "safe_area_edge_start",
"value": "START"
},
{
"name": "safe_area_edge_end",
"value": "END"
},
{
"name": "safe_area_type_system",
"value": "SYSTEM"
},
{
"name": "safe_area_type_cutout",
"value": "CUTOUT"
},
{
"name": "safe_area_type_keyboard",
"value": "KEYBOARD"
},
// Select
{
"name": "select_title",
@ -1134,10 +1193,18 @@
"name": "size_width_percent",
"value": "width is 60%"
},
{
"name": "size_width_fixed_60vw",
"value": "Width is 60vw"
},
{
"name": "size_height",
"value": "Height"
},
{
"name": "size_height_fixed_60vh",
"value": "Width is 60vh"
},
{
"name": "size_height_fixed_100vp",
"value": "Height is 100vp"
@ -1146,6 +1213,10 @@
"name": "size_height_percent",
"value": "Height is 60%"
},
{
"name": "size_height_fixed_calc",
"value": "Height is calc(200vp-100vp)"
},
// Slider
{
"name": "slider_title",
@ -1248,6 +1319,10 @@
"name": "span_letter_spacing",
"value": "LetterSpacing"
},
{
"name": "span_line_height",
"value": "LineHeight"
},
{
"name": "span_decoration_type",
"value": "Decoration type"
@ -1260,6 +1335,14 @@
"name": "span_text_spacing",
"value": " LetterSpacing test text"
},
{
"name": "span_inherits_text_attribute",
"value": " Span inherits text attribute"
},
{
"name": "span_does_not_inherit_text_attribute",
"value": " Span does not inherits text attribute"
},
{
"name": "span_upper_lower",
"value": "Upper or lower case"
@ -1358,6 +1441,14 @@
"name": "text_content_en",
"value": "Steel is tempered in fire and sharp cooling, so it can be hard and not afraid of anything. It is also in this way that our generation has been tempered in struggles and terrible trials, learning not to succumb to life."
},
{
"name": "text_width",
"value": "Text width"
},
{
"name": "text_height",
"value": "Text height"
},
{
"name": "text_content_en_first",
"value": "Steel is tempered in fire and sharp cooling, so it can be hard and not afraid of anything. "
@ -1446,7 +1537,32 @@
"name": "text_text_case_lowercase",
"value": "Lowercase"
},
// TextArea
{
"name": "text_area_set_text_selection",
"value": "Set Text Selection"
},
{
"name": "text_area_set_text_selection_start_select_error",
"value": "Set Text Selection Start Select Error"
},
{
"name": "text_area_set_text_selection_end_select_error",
"value": "Set Text Selection End Select Error"
},
{
"name": "text_input_set_text_selection_start_select",
"value": "Start Select:"
},
{
"name": "text_input_set_text_selection_end_select",
"value": "End Select:"
},
// TextInput
{
"name": "avoiding_input_method_testing",
"value": "Avoiding Input Method Testing"
},
{
"name": "text_input_title",
"value": "TextInput"
@ -1515,6 +1631,10 @@
"name": "text_input_only_input_english",
"value": "Only english letters can be entered"
},
{
"name": "text_input_set_text_selection",
"value": "Set Text Selection"
},
{
"name": "text_input_caret_position",
"value": "Caret position"
@ -1927,6 +2047,26 @@
"name": "hovereffect",
"value": "Hover"
},
{
"name": "bind_menu_customBuilder",
"value": "Bind menu customBuilder"
},
{
"name": "bind_content_menu",
"value": "Bind content menu"
},
{
"name": "click_on_any_action_below",
"value": "Click on any action below"
},
{
"name": "long_press_any_action_below",
"value": "Long press any action below"
},
{
"name": "bind_menu_content",
"value": "Bind menu content"
},
{
"name": "menu",
"value": "Menu"
@ -1935,6 +2075,26 @@
"name": "multiState",
"value": "MultiState"
},
{
"name": "multi_short_key",
"value": "multi short key"
},
{
"name": "set_mouse_style",
"value": "Set mouse style"
},
{
"name": "multimode_input",
"value": "multimode input"
},
{
"name": "short_key_pressed",
"value": "Short key pressed"
},
{
"name": "on_short_key",
"value": "Simultaneously press the shortcut key ctrl+a to trigger the following button click event"
},
{
"name": "alert",
"value": "Alert"
@ -2034,6 +2194,10 @@
"name": "auxiliary_refresh",
"value": "Refresh"
},
{
"name": "auxiliary_refresh_refreshing",
"value": "Refreshing"
},
{
"name": "auxiliary_refresh_offset",
"value": "offset:"
@ -2178,6 +2342,10 @@
"name": "checkbox_checkboxgroup",
"value": "Checkbox && CheckboxGroup"
},
{
"name": "checkbox",
"value": "Checkbox"
},
{
"name": "checkbox_title",
"value": "Checkbox"
@ -2246,6 +2414,34 @@
"name": "swiper_name",
"value": "Swiper"
},
{
"name": "nav_router",
"value": "NavRouter"
},
{
"name": "tabs_name",
"value": "Tabs"
},
{
"name": "select_name",
"value": "Select"
},
{
"name": "slider_name",
"value": "Slider"
},
{
"name": "swiper_set_next_margin_and_previous_margin",
"value": "set next margin and previous margin"
},
{
"name": "swiper_next_margin",
"value": "next margin"
},
{
"name": "swiper_previous_margin",
"value": "previous margin"
},
{
"name": "alphabetindexer_an",
"value": "An"
@ -2406,6 +2602,10 @@
"name": "checkbox_select_all",
"value": "Select All"
},
{
"name": "delete_list_item",
"value": "Delete listItem"
},
{
"name": "normal_display",
"value": "Display"
@ -2478,6 +2678,10 @@
"name": "interaction_arrowoffset",
"value": "Change arrowOffset:"
},
{
"name": "interaction_mask",
"value": "isMask:"
},
// ComponentTransitionSample
{
"name": "component_transition",
@ -3066,6 +3270,10 @@
"name": "grid_settings_gridSpan",
"value": "GridSpan gridOffset"
},
{
"name": "grid_edgeEffect_spring",
"value": "Grid edgeEffect spring"
},
{
"name": "focus_control",
"value": "焦点控制"
@ -4404,6 +4612,10 @@
"value": "Previous page"
},
// Navigation
{
"name": "navRouter_title",
"value": "NavRouter"
},
{
"name": "navigation_title",
"value": "Navigation"

View File

@ -70,10 +70,12 @@
"pages/universal/properties/displaySample/DisplaySample",
"pages/universal/properties/interactionSample/InteractionSample",
"pages/universal/properties/effectsSample/EffectsSample",
"pages/universal/properties/safeAreaSample/SafeAreaSample",
"pages/components/auxiliary/scrollbarSample/ScrollBarSample",
"pages/components/auxiliary/refreshSample/RefreshSample",
"pages/components/auxiliary/panelSample/PanelSample",
"pages/components/auxiliary/alphabetIndexerSample/AlphabetIndexerSample",
"pages/components/informationPresentationAndDynamicEffects/listSample/ListSample",
"pages/components/informationPresentationAndDynamicEffects/loadingProgressSample/LoadingProgressSample",
"pages/components/informationPresentationAndDynamicEffects/marqueeSample/MarqueeSample",
"pages/components/informationPresentationAndDynamicEffects/textTimerSample/TextTimerSample",
@ -128,6 +130,7 @@
"pages/components/listAndGrid/gridSample/GridSample",
"pages/components/listAndGrid/gridItemSample/GridItemSample",
"pages/components/scrollAndSwipe/swiperSample/SwiperSample",
"pages/components/navigation/navRouterSample/NavRouterSample",
"pages/components/navigation/navigationSample/NavigationSample",
"pages/components/navigation/navigationSample/NavigationSecondPage",
"pages/components/navigation/navigationSample/NavigationThirdPage",

View File

@ -36,6 +36,10 @@
"name": "prop_background",
"value": "Background"
},
{
"name": "safe_area",
"value": "SafeArea"
},
{
"name": "prop_foreground",
"value": "Foreground"
@ -866,6 +870,15 @@
"name": "qrcode_enter_content",
"value": "Enter to change QR code"
},
// Search
{
"name": "search_placeholder",
"value": "Type to search..."
},
{
"name": "search_name",
"value": "search"
},
// Radio
{
"name": "radio_title",
@ -1015,10 +1028,18 @@
"name": "size_width_percent",
"value": "width is 60%"
},
{
"name": "size_width_fixed_60vw",
"value": "Width is 60vw"
},
{
"name": "size_height",
"value": "Height"
},
{
"name": "size_height_fixed_60vh",
"value": "Width is 60vh"
},
{
"name": "size_height_fixed_100vp",
"value": "Height is 100vp"
@ -1027,6 +1048,10 @@
"name": "size_height_percent",
"value": "Height is 60%"
},
{
"name": "size_height_fixed_calc",
"value": "Height is calc(200vp-100vp)"
},
// Slider
{
"name": "slider_title",
@ -1129,6 +1154,10 @@
"name": "span_letter_spacing",
"value": "LetterSpacing"
},
{
"name": "span_line_height",
"value": "LineHeight"
},
{
"name": "span_decoration_type",
"value": "Decoration type"
@ -1141,6 +1170,14 @@
"name": "span_text_spacing",
"value": " LetterSpacing test text"
},
{
"name": "span_inherits_text_attribute",
"value": " Span inherits text attribute"
},
{
"name": "span_does_not_inherit_text_attribute",
"value": " Span does not inherits text attribute"
},
{
"name": "span_upper_lower",
"value": "Upper or lower case"
@ -1231,6 +1268,14 @@
"name": "text_title",
"value": "Text"
},
{
"name": "text_width",
"value": "Text width"
},
{
"name": "text_height",
"value": "Text height"
},
{
"name": "text_content",
"value": "Steel is tempered in fire and sharp cooling, so it can be hard and not afraid of anything. It is also in this way that our generation has been tempered in struggles and terrible trials, learning not to succumb to life."
@ -1315,7 +1360,32 @@
"name": "text_text_case_lowercase",
"value": "Lowercase"
},
// TextArea
{
"name": "text_area_set_text_selection",
"value": "Set Text Selection"
},
{
"name": "text_area_set_text_selection_start_select_error",
"value": "Set Text Selection Start Select Error"
},
{
"name": "text_area_set_text_selection_end_select_error",
"value": "Set Text Selection End Select Error"
},
{
"name": "text_input_set_text_selection_start_select",
"value": "Start Select:"
},
{
"name": "text_input_set_text_selection_end_select",
"value": "End Select:"
},
// TextInput
{
"name": "avoiding_input_method_testing",
"value": "Avoiding Input Method Testing"
},
{
"name": "text_input_title",
"value": "TextInput"
@ -1388,6 +1458,10 @@
"name": "text_input_caret_position",
"value": "Caret position"
},
{
"name": "text_input_set_text_selection",
"value": "Set Text Selection"
},
{
"name": "text_input_max_length",
"value": "Limit the input character length"
@ -1470,6 +1544,10 @@
"name": "toggle_type_switch",
"value": "Switch"
},
{
"name": "checkbox",
"value": "Checkbox"
},
{
"name": "toggle_type_checkbox",
"value": "Check box"
@ -1799,6 +1877,26 @@
"name": "hovereffect",
"value": "Hover"
},
{
"name": "bind_menu_customBuilder",
"value": "Bind menu customBuilder"
},
{
"name": "bind_content_menu",
"value": "Bind content menu"
},
{
"name": "click_on_any_action_below",
"value": "Click on any action below"
},
{
"name": "long_press_any_action_below",
"value": "Long press any action below"
},
{
"name": "bind_menu_content",
"value": "Bind menu content"
},
{
"name": "menu",
"value": "Menu"
@ -1807,6 +1905,26 @@
"name": "multiState",
"value": "MultiState"
},
{
"name": "multi_short_key",
"value": "multi short key"
},
{
"name": "set_mouse_style",
"value": "Set mouse style"
},
{
"name": "multimode_input",
"value": "multimode input"
},
{
"name": "short_key_pressed",
"value": "Short key pressed"
},
{
"name": "on_short_key",
"value": "Simultaneously press the shortcut key ctrl+a to trigger the following button click event"
},
{
"name": "alert",
"value": "Alert"
@ -2532,6 +2650,10 @@
"name": "pinch_scale",
"value": "PinchGesture scale:\n"
},
{
"name": "interaction_mask",
"value": "isMask:"
},
{
"name": "rotation_description",
"value": "Rotate the black box with two fingers"

View File

@ -818,6 +818,15 @@
"name": "qrcode_enter_content",
"value": "改变二维码内容"
},
// Search
{
"name": "search_placeholder",
"value": "输入搜索..."
},
{
"name": "search_name",
"value": "search 搜索"
},
// Radio
{
"name": "radio_title",
@ -872,6 +881,23 @@
"name": "rotate_image_angle",
"value": "旋转15°"
},
// SaveArea
{
"name": "safe_area_type_and_safe_area_edge",
"value": "扩展安全区域的类型和方向"
},
{
"name": "safe_area",
"value": "SafeArea 安全区域"
},
{
"name": "safe_area_type",
"value": "扩展类型"
},
{
"name": "safe_area_edge",
"value": "扩展方向"
},
// Select
{
"name": "select_title",
@ -971,10 +997,18 @@
"name": "size_width_percent",
"value": "宽度为60%"
},
{
"name": "size_width_fixed_60vw",
"value": "宽度为60vw"
},
{
"name": "size_height",
"value": "高度"
},
{
"name": "size_height_fixed_60vh",
"value": "高度为60vh"
},
{
"name": "size_height_fixed_100vp",
"value": "高度为100vp"
@ -983,6 +1017,10 @@
"name": "size_height_percent",
"value": "高度为60%"
},
{
"name": "size_height_fixed_calc",
"value": "高度为calc(200vp-100vp)"
},
// Slider
{
"name": "slider_title",
@ -1085,6 +1123,10 @@
"name": "span_letter_spacing",
"value": "字符间距"
},
{
"name": "span_line_height",
"value": "跨度线高度"
},
{
"name": "span_decoration_type",
"value": "装饰线类型"
@ -1097,6 +1139,14 @@
"name": "span_text_spacing",
"value": " 字符间距示例文本"
},
{
"name": "span_inherits_text_attribute",
"value": " Span继承text样式"
},
{
"name": "span_does_not_inherit_text_attribute",
"value": " Span不继承text样式"
},
{
"name": "span_upper_lower",
"value": "配置不同文本属性"
@ -1175,6 +1225,14 @@
"name": "text_content",
"value": "钢是在烈火和急剧冷却里锻炼出来的,所以才能坚硬和什么也不怕。我们的一代也是这样的在斗争中和可怕的考验中锻炼出来的,学习了不在生活面前屈服。"
},
{
"name": "text_width",
"value": "Text 宽"
},
{
"name": "text_height",
"value": "Text 高"
},
{
"name": "text_text_align_center",
"value": "居中"
@ -1255,7 +1313,32 @@
"name": "text_text_case_lowercase",
"value": "小写"
},
// TextArea
{
"name": "text_area_set_text_selection",
"value": "文本选择"
},
{
"name": "text_area_set_text_selection_start_select_error",
"value": "起始位输入错误"
},
{
"name": "text_area_set_text_selection_end_select_error",
"value": "结束位输入错误"
},
{
"name": "text_input_set_text_selection_start_select",
"value": "起始位:"
},
{
"name": "text_input_set_text_selection_end_select",
"value": "结束位:"
},
// TextInput
{
"name": "avoiding_input_method_testing",
"value": "避让输入法测试"
},
{
"name": "text_input_title",
"value": "TextInput 文本输入"
@ -1328,6 +1411,10 @@
"name": "text_input_caret_position",
"value": "光标位置"
},
{
"name": "text_input_set_text_selection",
"value": "文本选择"
},
{
"name": "text_input_max_length",
"value": "限制输入字符长度"
@ -1648,6 +1735,26 @@
"name": "hovereffect",
"value": "悬停"
},
{
"name": "bind_menu_customBuilder",
"value": "绑定自定义菜单"
},
{
"name": "bind_content_menu",
"value": "绑定上下文菜单"
},
{
"name": "click_on_any_action_below",
"value": "点击下方任一操作"
},
{
"name": "long_press_any_action_below",
"value": "长按下方任一操作"
},
{
"name": "bind_menu_content",
"value": "绑定接口菜单"
},
{
"name": "menu",
"value": "菜单"
@ -1656,6 +1763,26 @@
"name": "multiState",
"value": "多态"
},
{
"name": "multi_short_key",
"value": "快捷键"
},
{
"name": "set_mouse_style",
"value": "设置鼠标样式"
},
{
"name": "multimode_input",
"value": "多模输入"
},
{
"name": "short_key_pressed",
"value": "快捷键已按下"
},
{
"name": "on_short_key",
"value": "同时按下快捷键ctrl+a触发以下按钮点击事件"
},
{
"name": "alert",
"value": "告警弹窗"
@ -1742,6 +1869,10 @@
"name": "auxiliary_refresh",
"value": "下拉刷新"
},
{
"name": "auxiliary_refresh_refreshing",
"value": "刷新中"
},
{
"name": "auxiliary_panel",
"value": "Panel 弹出面板"
@ -1777,6 +1908,10 @@
"name": "data_panel",
"value": "DataPanel 数据面板"
},
{
"name": "checkbox",
"value": "checkbox 勾选框"
},
{
"name": "checkbox_checkboxgroup",
"value": "勾选框"
@ -1813,6 +1948,34 @@
"name": "swiper_name",
"value": "Swiper 翻页"
},
{
"name": "nav_router",
"value": "点击跳转路由页面"
},
{
"name": "tabs_name",
"value": "Tabs 页签"
},
{
"name": "slider_name",
"value": "Slider 滚动条"
},
{
"name": "select_name",
"value": "Select 选择器"
},
{
"name": "swiper_set_next_margin_and_previous_margin",
"value": "设置前后页边距"
},
{
"name": "swiper_next_margin",
"value": "上一页边距"
},
{
"name": "swiper_previous_margin",
"value": "下一页边距"
},
{
"name": "alphabetindexer_an",
"value": "安"
@ -1933,6 +2096,10 @@
"name": "checkbox_select_all",
"value": "全选"
},
{
"name": "delete_list_item",
"value": "左划删除 listItem"
},
{
"name": "normal_display",
"value": "效果展示"
@ -2001,6 +2168,10 @@
"name": "interaction_placementontop",
"value": "显示位置:"
},
{
"name": "interaction_mask",
"value": "屏蔽周边事件:"
},
{
"name": "interaction_arrowoffset",
"value": "调整箭头:"
@ -2625,6 +2796,10 @@
"name": "grid_settings_gridSpan",
"value": "GridSpan gridOffset"
},
{
"name": "grid_edgeEffect_spring",
"value": "Grid edgeEffect spring"
},
{
"name": "focus_control",
"value": "焦点控制"
@ -3806,6 +3981,10 @@
"value": "上一页"
},
// Navigation
{
"name": "navRouter_title",
"value": "NavRouter"
},
{
"name": "navigation_title",
"value": "Navigation"

View File

@ -51,6 +51,14 @@ async function drawSliderWithId(text: string){
let rect = await slider_01.getBoundsCenter();
await driver.drag(rect.x - 100, rect.y, rect.x + 100, rect.y, 800)
}
// 通过 ID 滑动
async function drawPickerWithId(text: string){
let atom = text;
await driver.assertComponentExist(ON.id(atom));
let slider_01 = await driver.findComponent(ON.id(atom));
let rect = await slider_01.getBoundsCenter();
await driver.drag(rect.x, rect.y - 50, rect.x, rect.y + 50, 800)
}
// 通过text验证有没有这个组件 有的话点击一下
async function checkButtonAndClickWithText(text: string) {
let atom = text;
@ -228,7 +236,6 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
});
/**
* 按钮与选择
*/
@ -304,7 +311,6 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
/**
* DatePicker 时间选择器
*/
@ -652,6 +658,13 @@ export default function abilityTest() {
await driver.delayMs(DELAY_TIME);
// 点击加使能按钮
let inc = await driver.findComponent(ON.id('inc'));
await inc.click();
// 点击减使能按钮
let dec = await driver.findComponent(ON.id('dec'));
await dec.click();
let backBtn = await driver.findComponent(ON.id('backBtn'));
// 返回
await backBtn.click();
@ -725,11 +738,61 @@ export default function abilityTest() {
await driver.drag(110, 900, 110, 800, 800);
await driver.delayMs(DELAY_TIME);
// 输入法避让测试
let input = await driver.findComponent(ON.id('test_input'));
await input.click();
// 滑动slider调整 固定坐标只支持RK3568其他设备需要调整
await driver.drag(110, 4000, 110, 200, 800);
await driver.delayMs(500);
// 收起输入法
await input.inputText('test');
let backBtn = await driver.findComponent(ON.id('backBtn'));
// 返回
await backBtn.click();
await driver.delayMs(500);
Logger.info(BUNDLE + testName + ' end');
})
/**
* Swiper 翻页
*/
it(BUNDLE + 'SwiperFunction_001', 0, async function () {
let testName = 'SwiperFunction';
Logger.info(BUNDLE + testName + ' begin ------------------------------');
await driver.delayMs(DELAY_TIME);
let atom = await manager.getStringValue($r('app.string.swiper_name'));
let button = await driver.findComponent(ON.text(atom));
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.scroll_swiper')));
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
await checkButtonAndClickWithTextByResource($r('app.string.swiper_controller_next'));
await checkButtonAndClickWithTextByResource($r('app.string.swiper_controller_previous'));
await checkButtonAndClickWithID(`swiper_001`);
await checkButtonAndClickWithID(`swiper_002`);
await checkButtonAndClickWithTextByResource($r('app.string.swiper_controller_next'));
await checkButtonAndClickWithID(`swiper_003`);
await checkButtonAndClickWithID(`swiper_004`);
await drawSliderWithId(`swiper_005`);
await drawSliderWithId(`swiper_008`);
await drawSliderWithId(`swiper_009`);
await checkButtonAndClickWithID(`swiper_006`);
await checkButtonAndClickWithText(`1000`);
// 滑到底端
await driver.drag(110, 752, 110, 500, 800);
await checkButtonAndClickWithID(`swiper_007`);
await checkButtonAndClickWithText(`2000`);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
// 关闭展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.scroll_swiper')));
@ -1008,6 +1071,9 @@ export default function abilityTest() {
let driver: Driver = Driver.create();
await driver.delayMs(DELAY_TIME);
// 从下往上滑动列表
await driver.drag(200, 500, 200, 200, 800)
await driver.delayMs(DELAY_TIME);
// 进入DataPanel 数据面板
let atom = await manager.getStringValue($r('app.string.data_panel'));
@ -1241,11 +1307,10 @@ export default function abilityTest() {
}
await checkButtonAndClickWithText(atom);
// 字符间距
// 调节间距和高度
await drawSliderWithId('Slider1');
await driver.delayMs(DELAY_TIME);
// 滑动slider调整 固定坐标只支持RK3568其他设备需要调整
await driver.drag(212, 606, 400, 606, 800);
await driver.drag(800, 606, 100, 606, 800);
await drawSliderWithId('Slider2');
await driver.delayMs(DELAY_TIME);
// 展开装饰线类型
@ -1289,7 +1354,15 @@ export default function abilityTest() {
// 输入文本
let input = await driver.findComponent(ON.id('test_input'));
await input.inputText('test');
await input.inputText('testtesttesttest');
// 上下滑动选择器
await drawPickerWithId('end_select');
// 点击文本选择按钮
let select = await driver.findComponent(ON.id('button_to_select'));
await select.click();
await driver.delayMs(500);
// 收起输入法
await select.inputText('test');
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
@ -1361,6 +1434,10 @@ export default function abilityTest() {
let driver: Driver = Driver.create();
await driver.delayMs(DELAY_TIME);
// 从下往上滑动列表
await driver.drag(200, 500, 200, 200, 800)
await driver.delayMs(DELAY_TIME);
// 进入RichText 富文本
let atom = await manager.getStringValue($r('app.string.rich_text'));
let button = await driver.findComponent(ON.text(atom));
@ -1381,6 +1458,121 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
/**
*TextArea 多行文本输入框
*/
it(BUNDLE + 'TextareaFunction_001', 0, async function () {
let testName = 'TextareaFunction';
Logger.info(BUNDLE + testName + ' begin');
await driver.delayMs(DELAY_TIME);
let list = await driver.findComponent(ON.id('list_001'));
let on = ON.text(await manager.getStringValue($r('app.string.text_and_input')));
await list.scrollSearch(on);
let atom = await manager.getStringValue($r('app.string.textarea_title'));
let button = await driver.findComponent(ON.text(atom));
await driver.delayMs(DELAY_TIME);
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
if (!await driver.findComponent(ON.text(atom))) {
await driver.drag(200, 200, 200, 100, 800);
}
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
// 输入文本
let input = await driver.findComponent(ON.id('textarea_001'));
await input.inputText('testtesttesttest');
await checkButtonAndClickWithID('textarea_select_001');
await checkButtonAndClickWithText('End')
await checkButtonAndClickWithID('textarea_select_002');
await checkButtonAndClickWithText('In App')
await checkButtonAndClickWithID('textarea_color_001');
await checkButtonAndClickWithText('Pink')
await checkButtonAndClickWithID('textarea_color_002');
await checkButtonAndClickWithText('Blue')
await driver.delayMs(DELAY_TIME);
// 上下滑动选择器
await drawPickerWithId('end_select');
// 点击文本选择按钮
let select = await driver.findComponent(ON.id('button_to_select'));
await select.click();
await driver.delayMs(500);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
Logger.info(BUNDLE + testName + ' end');
})
/**
*PatternLock 图案密码锁
*/
it(BUNDLE + 'PatternLockFunction_001', 0, async function () {
let testName = 'PatternLockFunction';
Logger.info(BUNDLE + testName + ' begin');
await driver.delayMs(DELAY_TIME);
let atom = await manager.getStringValue($r('app.string.patternLock_title'));
let button = await driver.findComponent(ON.text(atom));
await driver.delayMs(DELAY_TIME);
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
await drawSliderWithId('patternLock_slider_001')
await drawSliderWithId('patternLock_slider_002')
await drawSliderWithId('patternLock_slider_003')
await checkButtonAndClickWithID('patternLock_color_001');
await checkButtonAndClickWithText('Pink')
await checkButtonAndClickWithID('patternLock_color_002');
await checkButtonAndClickWithText('Blue')
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
await driver.drag(200, 200, 200, 100, 800);
Logger.info(BUNDLE + testName + ' end');
})
/**
*Search 搜索框
*/
it(BUNDLE + 'SearchFunction_001', 0, async function () {
let testName = 'SearchFunction';
Logger.info(BUNDLE + testName + ' begin');
await driver.delayMs(DELAY_TIME);
let atom = await manager.getStringValue($r('app.string.search_title'));
let button = await driver.findComponent(ON.text(atom));
await driver.delayMs(DELAY_TIME);
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
}
// 从下往上滑动列表
await driver.drag(200, 500, 200, 200, 800);
await driver.delayMs(DELAY_TIME);
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
let input = await driver.findComponent(ON.id('search_001'));
await input.inputText('test');
await checkButtonAndClickWithID('search_select_001');
await checkButtonAndClickWithText('End')
await checkButtonAndClickWithID('search_select_002');
await checkButtonAndClickWithText('In App')
await checkButtonAndClickWithID('search_color_001');
await checkButtonAndClickWithText('Pink')
await driver.delayMs(DELAY_TIME);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
Logger.info(BUNDLE + testName + ' end');
})
/**
* Badge 标记
*/
@ -1561,44 +1753,6 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
/**
* Swiper 翻页
*/
it(BUNDLE + 'SwiperFunction_001', 0, async function () {
let testName = 'SwiperFunction';
Logger.info(BUNDLE + testName + ' begin ------------------------------');
await driver.delayMs(DELAY_TIME);
let atom = await manager.getStringValue($r('app.string.swiper_name'));
let button = await driver.findComponent(ON.text(atom));
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.scroll_swiper')));
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
await checkButtonAndClickWithTextByResource($r('app.string.swiper_controller_next'));
await checkButtonAndClickWithTextByResource($r('app.string.swiper_controller_previous'));
await checkButtonAndClickWithID(`swiper_001`);
await checkButtonAndClickWithID(`swiper_002`);
await checkButtonAndClickWithTextByResource($r('app.string.swiper_controller_next'));
await checkButtonAndClickWithID(`swiper_003`);
await checkButtonAndClickWithID(`swiper_004`);
await drawSliderWithId(`swiper_005`);
await checkButtonAndClickWithID(`swiper_006`);
await checkButtonAndClickWithText(`1000`)
await checkButtonAndClickWithID(`swiper_007`);
await checkButtonAndClickWithText(`2000`)
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.scroll_swiper')));
Logger.info(BUNDLE + testName + ' end');
})
/**
* Row
*/
@ -1972,6 +2126,34 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
/**
* NavRouter
*/
it(BUNDLE + 'NavRouterFunction_001', 0, async function () {
let testName = 'NavRouterFunction';
Logger.info(BUNDLE + testName + ' begin ------------------------------');
await driver.delayMs(DELAY_TIME);
// 滑到底端
await driver.drag(110, 752, 110, 500, 800);
let atom = await manager.getStringValue($r('app.string.navRouter_title'));
let button = await driver.findComponent(ON.text(atom));
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.navigation')));
}
await checkButtonAndClickWithText(atom);
let navigation = await driver.findComponent(ON.id('Navigation1'));
await navigation.click();
await driver.delayMs(DELAY_TIME);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
Logger.info(BUNDLE + testName + ' end');
})
/**
* Navigation
*/
@ -2091,109 +2273,6 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
/**
*TextArea 多行文本输入框
*/
it(BUNDLE + 'TextareaFunction_001', 0, async function () {
let testName = 'TextareaFunction';
Logger.info(BUNDLE + testName + ' begin');
await driver.delayMs(DELAY_TIME);
let list = await driver.findComponent(ON.id('list_001'));
let on = ON.text(await manager.getStringValue($r('app.string.text_and_input')));
await list.scrollSearch(on);
let atom = await manager.getStringValue($r('app.string.textarea_title'));
let button = await driver.findComponent(ON.text(atom));
await driver.delayMs(DELAY_TIME);
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
if (!await driver.findComponent(ON.text(atom))) {
await driver.drag(200, 200, 200, 100, 800);
}
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
// 输入文本
let input = await driver.findComponent(ON.id('textarea_001'));
await input.inputText('test');
await checkButtonAndClickWithID('textarea_select_001');
await checkButtonAndClickWithText('End')
await checkButtonAndClickWithID('textarea_select_002');
await checkButtonAndClickWithText('In App')
await checkButtonAndClickWithID('textarea_color_001');
await checkButtonAndClickWithText('Pink')
await checkButtonAndClickWithID('textarea_color_002');
await checkButtonAndClickWithText('Blue')
await driver.delayMs(DELAY_TIME);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
Logger.info(BUNDLE + testName + ' end');
})
/**
*PatternLock 图案密码锁
*/
it(BUNDLE + 'PatternLockFunction_001', 0, async function () {
let testName = 'PatternLockFunction';
Logger.info(BUNDLE + testName + ' begin');
await driver.delayMs(DELAY_TIME);
let atom = await manager.getStringValue($r('app.string.patternLock_title'));
let button = await driver.findComponent(ON.text(atom));
await driver.delayMs(DELAY_TIME);
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
await drawSliderWithId('patternLock_slider_001')
await drawSliderWithId('patternLock_slider_002')
await drawSliderWithId('patternLock_slider_003')
await checkButtonAndClickWithID('patternLock_color_001');
await checkButtonAndClickWithText('Pink')
await checkButtonAndClickWithID('patternLock_color_002');
await checkButtonAndClickWithText('Blue')
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
await driver.drag(200, 200, 200, 100, 800);
Logger.info(BUNDLE + testName + ' end');
})
/**
*Search 搜索框
*/
it(BUNDLE + 'SearchFunction_001', 0, async function () {
let testName = 'SearchFunction';
Logger.info(BUNDLE + testName + ' begin');
await driver.delayMs(DELAY_TIME);
let atom = await manager.getStringValue($r('app.string.search_title'));
let button = await driver.findComponent(ON.text(atom));
await driver.delayMs(DELAY_TIME);
if (!button) {
// 如果没展开 就展开
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
}
await checkButtonAndClickWithText(atom);
await driver.delayMs(DELAY_TIME);
let input = await driver.findComponent(ON.id('search_001'));
await input.inputText('test');
await checkButtonAndClickWithID('search_select_001');
await checkButtonAndClickWithText('End')
await checkButtonAndClickWithID('search_select_002');
await checkButtonAndClickWithText('In App')
await checkButtonAndClickWithID('search_color_001');
await checkButtonAndClickWithText('Pink')
await driver.delayMs(DELAY_TIME);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.text_and_input')));
Logger.info(BUNDLE + testName + ' end');
})
/**
*Image 图片
*/
@ -3042,12 +3121,36 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
});
/**
* safeArea 安全区域
*/
it(BUNDLE + 'SafeAreaFunction_001', 0, async function () {
let testName = 'SafeAreaFunction';
Logger.info(BUNDLE + testName + ' begin');
// 进入页面
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.safe_area')));
// 点击system
let select = await driver.findComponent(ON.id('SYSTEM'));
await select.click();
// 再次点击system
await select.click();
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
await driver.delayMs(500);
Logger.info(BUNDLE + testName + ' end');
});
/**
* foreground 前景
*/
it(BUNDLE + 'ForegroundFunction_001', 0, async function () {
let testName = 'ForegroundFunction';
Logger.info(BUNDLE + testName + ' begin');
// 从下往上滑动列表
await driver.drag(200, 700, 200, 200, 800)
await driver.delayMs(DELAY_TIME);
// 进入页面
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.prop_foreground')));
@ -3069,9 +3172,7 @@ export default function abilityTest() {
it(BUNDLE + 'BackgroundFunction_001', 0, async function () {
let testName = 'BackgroundFunction';
Logger.info(BUNDLE + testName + ' begin');
// 从下往上滑动列表
await driver.drag(200, 700, 200, 200, 800)
await driver.delayMs(DELAY_TIME);
// 进入页面
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.prop_background')));
// 正常显示
@ -3381,10 +3482,32 @@ export default function abilityTest() {
// 进入菜单
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.menu')));
// 点击自定义菜单
let menu = await checkButtonAndClickWithID('menuBuilder1');
// 点击接口菜单
menu = await checkButtonAndClickWithID('mMenuLists1');
// 从下往上滑动
await driver.drag(200, 750, 200, 150, 800);
// 长按上下文菜单
menu = await checkButtonAndLongClickWithID('contextMenu1');
// 取消菜单显示
await driver.click(400, 500);
// 进入多态
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.multiState')));
// 组件禁用
await checkButtonAndLongClickWithID('test_checkbox');
// 进入多模输入
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.multimode_input')));
// 模拟按键ctr+a
await driver.triggerCombineKeys(2072, 2017);
// 更换鼠标样式
let btn = await driver.findComponent(ON.id('WEST'));
await btn.click();
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
@ -3472,6 +3595,7 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
});
/**
* location 位置设置
*/
@ -3512,6 +3636,7 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
});
/**
* flex布局
*/
@ -3572,6 +3697,8 @@ export default function abilityTest() {
// 进入页面
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.grid_settings')));
// 正常显示
// 滑动grid查看效果
await driver.drag(212, 1000, 212, 800, 800);
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();
@ -3890,9 +4017,15 @@ export default function abilityTest() {
// 进入页面
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.Floating_window')));
// 拖动悬浮窗
await checkAndDragById('floatingWindowComponent', 'target');
// 输入法避让测试
let input = await driver.findComponent(ON.id('test_input'));
await input.click();
// 拖动悬浮窗
await checkAndDragById('floatingWindowComponent', 'target');
// 收起输入法
await input.inputText('test');
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
@ -4212,7 +4345,7 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
//
/**
* AlertDialog 警告弹窗
*/
@ -4269,6 +4402,19 @@ export default function abilityTest() {
// 点击4栅格弹窗并确认
await checkButtonAndClickWithID('test_4GridButton');
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.alert_dialog_confirm')));
// 往下滑动
await driver.drag(200, 600, 200, 400, 800);
// 输入法避让测试
let input = await driver.findComponent(ON.id('test_input'));
await input.click();
// 点击弹窗
await driver.click(300, 600);
await driver.delayMs(1000);
// 点击确认
await driver.click(300, 600);
await driver.delayMs(1000);
// 收起输入法
await input.inputText('test');
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
@ -4397,6 +4543,7 @@ export default function abilityTest() {
Logger.info(BUNDLE + testName + ' end');
})
/**
* ActionSheetDialogSample 列表选择弹窗
*/
@ -4435,6 +4582,19 @@ export default function abilityTest() {
// 点击内容并确认
await checkButtonAndClickWithID('sheet_click_contentButton');
await checkButtonAndClickWithText(await manager.getStringValue($r('app.string.alert_dialog_confirm')));
// 输入法避让测试
let input = await driver.findComponent(ON.id('test_input'));
await input.click();
// 点击弹窗
await driver.click(300, 600);
await driver.delayMs(1000);
// 点击确认
await driver.click(300, 600);
await driver.delayMs(1000);
// 收起输入法
await input.inputText('test');
// 返回
let backBtn = await driver.findComponent(ON.id('backBtn'));
await backBtn.click();

View File

@ -3156,6 +3156,14 @@
"name": "navigation",
"value": "导航"
},
{
"name": "navRouter_title",
"value": "NavRouter"
},
{
"name": "multimode_input",
"value": "multimode input"
},
{
"name": "navigation_title",
"value": "Navigation"
@ -3598,6 +3606,10 @@
{
"name": "particle_spawn_stop",
"value": "Stop"
},
{
"name": "safe_area",
"value": "SafeArea"
}
]
}

View File

@ -2470,6 +2470,10 @@
{
"name": "particle_spawn_stop",
"value": "Stop"
},
{
"name": "safe_area",
"value": "SafeArea"
}
]
}

View File

@ -1907,6 +1907,14 @@
"name": "navigation",
"value": "导航"
},
{
"name": "navRouter_title",
"value": "NavRouter"
},
{
"name": "multimode_input",
"value": "多模输入"
},
{
"name": "navigation_title",
"value": "Navigation"
@ -2155,6 +2163,10 @@
{
"name": "particle_spawn_stop",
"value": "停止"
},
{
"name": "safe_area",
"value": "SafeArea 安全区域"
}
]
}

View File

@ -14,9 +14,11 @@
| 验证Toggle 切换按钮 | 展开按钮与选择进入Toggle 切换按钮 | 依次点击Toggle 切换按钮 | 正确响应点击事件 | 是 | Pass |
| 验证勾选框 | 展开按钮与选择,进入勾选框 | 依次点击勾选框 | 正确选中勾选框 | 是 | Pass |
| 验证TimePicker 时间选择器 | 展开按钮与选择进入TimePicker 时间选择器 | 打开MilitaryTime | 时间选择器变化 | 是 | Pass |
| 验证Counter 计数器 | 展开按钮与选择进入Counter 计数器 | 点击enableInc和enableDec使能按钮查看计数器效果 | 计数器加减按钮被禁用 | 是 | Pass |
| 验证Rating 评分条 | 展开按钮与选择进入Rating 评分条 | 更改样式并打分 | 显示打分中间值,正确显示样式 | 是 | Pass |
| 验证Scroll 滚动 | 展开滚动与滑动进入Scroll 滚动 | 左右滑动,上下滑动 | 滚动条正确滑动 | 是 | Pass |
| 验证QRCode 二维码 | 展开信息展示与动效进入QRCode 二维码 | 改变二维码内容,改变颜色 | 正确改变二维码图片,改变颜色 | 是 | Pass |
| 验证List | 展开信息展示与动效进入List | 长按任一ListItem左划 | 呈现正确效果删除该ListItem | 是 | Pass |
| 验证LoadingProgress | 展开信息展示与动效进入LoadingProgress | 更改LoadingProgress的颜色 | 正确更改相应的颜色 | 是 | Pass |
| 验证Marquee 跑马灯 | 展开信息展示与动效进入Marquee 跑马灯 | 更改Marquee样式依次开始停止跑马灯 | 正确反馈状态,依次运行,停止跑马灯 | 是 | Pass |
| 验证TextTimer 文字计时器 | 展开信息展示与动效进入TextTimer 文字计时器 | 依次开始、暂停、重置、更换时间格式 | 正确运行状态 | 是 | Pass |
@ -28,8 +30,8 @@
| 验证Tab 模糊切换 | 展开信息展示与动效进入Tab 模糊切换 | 点击Tab 进行模糊切换 | Tab 模糊切换成功 | 是 | Pass |
| 验证ImageFit 切换 | 展开信息展示与动效进入ImageFit 切换 | 依次点击Radius按钮进行ImageFit模式切换 | ImageFit 模式切换成功 | 是 | Pass |
| 验证Particle粒子效果 | 展开信息展示与动效进入Particle粒子效果 | 点击Particle粒子效果生成按钮 | Particle粒子效果生成成功 | 是 | Pass |
| 验证Span 行内文本 | 展开文本与输入进入Span 行内文本 | 依次调整字符间距,装饰线类型,颜色 | 依次改变对于属性 | 是 | Pass |
| 验证TextInput 文本输入 | 展开文本与输入进入TextInput 文本输入 | 在输入框输入文本 | 正确显示输入文本 | 是 | Pass |
| 验证Span 行内文本 | 展开文本与输入进入Span 行内文本 | 依次调整字符间距,装饰线类型,跨度线高度,颜色 | 依次改变对于属性 | 是 | Pass |
| 验证TextInput 文本输入 | 展开文本与输入进入TextInput 文本输入 | 在输入框输入文本,可否选择对应文本段选中并高亮 | 正确显示输入文本 | 是 | Pass |
| 验证Text 文本 | 展开文本与输入进入Text 文本 | 依次更改字符间距,行高,对其类型,超长文本显示方式,装饰线,字体颜色,大小写 | 依次更改对应属性 | 是 | Pass |
| 验证RichText 富文本 | 展开文本与输入进入RichText 富文本 | | 正确显示富文本 | 是 | Pass |
| 验证ScrollBar 滚动条 | 展开辅助进入ScrollBar 滚动条 | 依次纵向滚动,横向滚动 | 正确滚动 | 是 | Pass |
@ -42,6 +44,7 @@
| 验证触摸事件 | | 拖动区域(100, 300, 300, 280) | 正确响应拖动 | 是 | Pass |
| 验证拖拽事件 | | 依次拖拽应用图标、GridItem、ListItem、Hyperlink、Text、Image、Video、FormComponent | 正确响应拖动 | 是 | Pass |
| 验证组件区域变化事件 | | 调整宽度,高度 | 正确约束小球运动范围 | 是 | Pass |
| 验证SafeArea 安全区域 | 进入SafeArea 安全区域 | 调整安全区域扩展的类型和方向 | 正确显示效果 | 是 | Pass |
| 验证foreground 前景 | | 进入foreground 前景 | 正确显示背景 | 是 | Pass |
| 验证background 背景 | | 进入background 背景 | 正确显示背景 | 是 | Pass |
| 验证border 边框 | | 进入border 边框页面 | 正确显示边框 | 是 | Pass |
@ -51,7 +54,7 @@
| 验证translate 平移 | 展开图形变化 | 调整图片平移和容器平移的X轴、y轴 | 正确响应调整 | 是 | Pass |
| 验证显示 | | 依次测试Z序浮层显隐透明测试响应属性 | 正确显示组件,并按调整改变 | 是 | Pass |
| 验证图像效果 | | 依次测试图像模糊,阴影,特效显示效果 | 正确显示效果 | 是 | Pass |
| 验证互动 | | 依次测试禁用、弹窗、点击、热区、悬停、菜单、多态 | 正确显示组件,并按调整改变 | 是 | Pass |
| 验证互动 | | 依次测试禁用、弹窗、点击、热区、悬停、菜单、多态 、多模输入 | 正确显示组件,并按调整改变 | 是 | Pass |
| 验证TarBar 进入动画 | 在通用页面 | 点击下方tab动画 | 跳转到动画页面 | 是 | Pass |
| 验证pageTransition 页面间转场 | 展开转场动画进入pageTransition 页面间转场 | 依次测试顶部进场/底部退场,左侧进场/右侧退场,缩放进场/退场等 | 正确展示动画 | 是 | Pass |
| 验证sharedTransition 共享元素转场 | 展开转场动画进入sharedTransition 页面间转场 | 点击一个元素转场3秒后点击返回 | 正确展示动画并返回 | 是 | Pass |
@ -77,7 +80,7 @@
| 验证flex 布局 | | 进入flex 布局 | 正确显示效果 | 是 | Pass |
| 验证图片边框设置 | | 进入图片边框设 | 正确显示效果 | 是 | Pass |
| 验证形状裁剪 | | 进入形状裁剪 | 正确显示效果 | 是 | Pass |
| 验证栅格设置 | | 进入栅格设置 | 正确显示效果 | 是 | Pass |
| 验证栅格设置 | 进入栅格设置 | 滑动Gird组件到底部查看回弹效果 | 正确显示效果 | 是 | Pass |
| 验证焦点控制 | | 按压外接键盘Tab键select选择水果后点击聚焦 | 正确显示效果 | 是 | Pass |
| 验证组件标识 | | 任意点击按钮 | 正确显示效果 | 是 | Pass |
| 验证组件背景模糊 | | 进入组件背景模糊 | 正确显示效果 | 是 | Pass |
@ -101,8 +104,8 @@
| 验证ActionSheetDialogSample 列表选择弹框 | 展开弹窗ActionSheetDialogSample 列表选择弹框 | 依次点击弹窗位置、是否关闭弹窗、偏移量、选项内容 | 正确展示响应弹窗 | 是 | Pass |
| 验证TextPickerDialogSample 文本滑动选择器弹框 | 展开弹窗TextPickerDialogSample 文本滑动选择器弹框 | 点击文字,滑动列表后点确定 | 正确展示响应弹窗 | 是 | Pass |
| 验证MenuSample 菜单 | 展开弹窗MenuSample 菜单 | 鼠标右键点击、手指触摸长按 | 正确展示响应弹窗 | 是 | Pass |
| 验证Swiper组件 | 展开滚动与滑动进入swiper翻页 | 依次点击下一页、上一页、是否被禁用左右滑动切换功能、是否能纵向滑动、是否首尾循环、是否开启自动循环播放、滑动页面间隙、滑动切换的动画时长、自动播放的时间间隔 | 正确显示效果 | 是 | Pass |
| 验证TextArea组件 | 展开文本与输入进入TextArea多行文本输入框 | 依次点击水平对齐、可否复制、placeholder文本颜色、输入框光标颜色 | 正确显示效果 | 是 | Pass |
| 验证Swiper组件 | 展开滚动与滑动进入swiper翻页 | 依次点击下一页、上一页、是否被禁用左右滑动切换功能、是否能纵向滑动、是否首尾循环、是否开启自动循环播放、滑动页面间隙、滑动切换的动画时长、自动播放的时间间隔、上下页边距 | 正确显示效果 | 是 | Pass |
| 验证TextArea组件 | 展开文本与输入进入TextArea多行文本输入框 | 依次点击水平对齐、可否复制、placeholder文本颜色、输入框光标颜色、可否选择对应文本段选中并高亮 | 正确显示效果 | 是 | Pass |
| 验证PatternLock组件 | 展开文本与输入进入PatternLock图案密码锁 | 依次滑动宫格宽高、圆点半径、连线宽度以及点击圆点未选中状态颜色、圆点激活状态颜色 | 正确显示效果 | 是 | Pass |
| 验证Search组件 | 展开文本与输入进入Search搜索框 | 依次点击水平对齐、可否复制、搜索框本文颜色 | 正确显示效果 | 是 | Pass |
| 验证Row组件 | 展开行列与分栏进入Row水平布局 | 依次滑动元素间距以及点击交叉轴对齐样式、主轴对齐样式 | 正确显示效果 | 是 | Pass |