feat(uikit): 引入明缘主题色板与通用组件
This commit is contained in:
35
uikit/src/main/ets/components/SegmentedControl.ets
Normal file
35
uikit/src/main/ets/components/SegmentedControl.ets
Normal file
@@ -0,0 +1,35 @@
|
||||
import { AppColor, AppFontSize, AppRadius } from '../theme/Theme';
|
||||
|
||||
/**
|
||||
* 分段切换控件:多个等宽选项,选中项白底金字。
|
||||
* 用于「周/月/年计划」类型切换、「小组/个人」tab 切换。
|
||||
*/
|
||||
@ComponentV2
|
||||
export struct SegmentedControl {
|
||||
@Param items: string[] = [];
|
||||
@Param selectedIndex: number = 0;
|
||||
@Event onSelect: (index: number) => void;
|
||||
|
||||
build() {
|
||||
Row() {
|
||||
ForEach(this.items, (item: string, index: number) => {
|
||||
Text(item)
|
||||
.fontSize(AppFontSize.body)
|
||||
.fontWeight(index === this.selectedIndex ? FontWeight.Bold : FontWeight.Normal)
|
||||
.fontColor(index === this.selectedIndex ? AppColor.gold : AppColor.textMuted)
|
||||
.backgroundColor(index === this.selectedIndex ? AppColor.white : Color.Transparent)
|
||||
.borderRadius(AppRadius.pill)
|
||||
.textAlign(TextAlign.Center)
|
||||
.height(36)
|
||||
.layoutWeight(1)
|
||||
.onClick(() => {
|
||||
this.onSelect(index);
|
||||
})
|
||||
}, (item: string) => item)
|
||||
}
|
||||
.width('100%')
|
||||
.padding(4)
|
||||
.backgroundColor(AppColor.segmentedTrack)
|
||||
.borderRadius(AppRadius.pill)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user