mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-02-18 19:59:56 +00:00
新增rating组件至统一hap
Signed-off-by: Zhang Jinyu <zhangjinyu101@huawei.com>
This commit is contained in:
parent
416fb0d1dc
commit
9fc7b1b380
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { Drawer } from '../../components/Drawer';
|
||||
import { RadioBlock, SliderBlock, useEnabled } from 'common';
|
||||
|
||||
@Component
|
||||
export struct RatingBootcamp {
|
||||
@Require @Prop title: ResourceStr;
|
||||
@State showParameters: boolean = false;
|
||||
@State enableRating: boolean = false;
|
||||
@State rating: number = 0;
|
||||
@State enableIndicator: boolean = false;
|
||||
@State indicator: boolean = false;
|
||||
@State enableStars: boolean = false;
|
||||
@State stars: number = 5;
|
||||
@State enableStepSize: boolean = false;
|
||||
@State stepSize: number = 0.5;
|
||||
@State enableStarStyle: boolean = false;
|
||||
|
||||
build() {
|
||||
NavDestination() {
|
||||
Drawer({
|
||||
title: this.title,
|
||||
showParameters: $showParameters,
|
||||
content: () => {
|
||||
this.Content()
|
||||
},
|
||||
parameters: () => {
|
||||
this.Parameters()
|
||||
}
|
||||
})
|
||||
}
|
||||
.hideTitleBar(true)
|
||||
}
|
||||
|
||||
@Builder
|
||||
Content() {
|
||||
Column() {
|
||||
Rating({
|
||||
rating: (useEnabled(this.enableRating, this.rating)),
|
||||
indicator: (useEnabled(this.enableIndicator, this.indicator)),
|
||||
})
|
||||
.stars(useEnabled(this.enableStars, this.stars))
|
||||
.stepSize(useEnabled(this.enableStepSize, this.stepSize))
|
||||
.onChange((value: number) => {
|
||||
this.rating = value;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Builder
|
||||
Parameters() {
|
||||
Scroll() {
|
||||
Column({ space: 8 }) {
|
||||
SliderBlock({
|
||||
title: '当前评分为',
|
||||
isEnabled: this.enableRating,
|
||||
value: this.rating,
|
||||
min: 0,
|
||||
max: this.stars
|
||||
})
|
||||
|
||||
RadioBlock({
|
||||
title: '是否作为指示器使用',
|
||||
isEnabled: this.enableIndicator,
|
||||
value: this.indicator,
|
||||
dataSource: [
|
||||
{ label: '是:不可进行评分', value: true },
|
||||
{ label: '否:可进行评分', value: false },
|
||||
]
|
||||
})
|
||||
|
||||
SliderBlock({
|
||||
title: '评分总数',
|
||||
isEnabled: this.enableStars,
|
||||
value: this.stars,
|
||||
min: 0,
|
||||
max: 20
|
||||
})
|
||||
|
||||
SliderBlock({
|
||||
title: '评分步长',
|
||||
isEnabled: this.enableStepSize,
|
||||
value: this.stepSize,
|
||||
min: 0.1,
|
||||
max: this.stars
|
||||
})
|
||||
|
||||
}.width('100%')
|
||||
}.height('50%')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview
|
||||
@Component
|
||||
struct RatingBootcampPreviewer {
|
||||
build() {
|
||||
RatingBootcamp({
|
||||
title: '评分条/Rating'
|
||||
})
|
||||
}
|
||||
}
|
@ -1,33 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 { Route, RouteGroup } from '../../common/route';
|
||||
import { CalendarPickerBootcamp } from './CalendarPickerBootcamp';
|
||||
|
||||
export const pickersRoute: RouteGroup = {
|
||||
name: 'pickers',
|
||||
label: '选择类',
|
||||
children: [
|
||||
{ name: 'calendar', label: '日历选择器/calendar' },
|
||||
]
|
||||
};
|
||||
|
||||
@Builder
|
||||
export function PickersDestination(name: string, route: Route) {
|
||||
if (name === 'pickers/calendar') {
|
||||
CalendarPickerBootcamp({ title: route.label })
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 2024 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 { Route, RouteGroup } from '../../common/route';
|
||||
import { CalendarPickerBootcamp } from './CalendarPickerBootcamp';
|
||||
import { RatingBootcamp } from '../pickers/RatingBootcamp';
|
||||
|
||||
export const pickersRoute: RouteGroup = {
|
||||
name: 'pickers',
|
||||
label: '选择类',
|
||||
children: [
|
||||
{ name: 'calendar', label: '日历选择器/calendar' },
|
||||
{ name: 'rating', label: '评分条/Rating' },
|
||||
]
|
||||
};
|
||||
|
||||
@Builder
|
||||
export function PickersDestination(name: string, route: Route) {
|
||||
if (name === 'pickers/calendar') {
|
||||
CalendarPickerBootcamp({ title: route.label })
|
||||
} else if (name === 'pickers/rating') {
|
||||
RatingBootcamp({ title: route.label })
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user