!33547 Feat:通用规范修改

Merge pull request !33547 from yangziyong/tongyong_change
This commit is contained in:
openharmony_ci 2024-05-27 15:18:14 +00:00 committed by Gitee
commit 7399618520
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
21 changed files with 366 additions and 305 deletions

View File

@ -486,14 +486,16 @@ export struct ChipComponent {
}
private getChipNodePadding(): Padding {
return (this.isChipSizeEnum() && this.chipSize === ChipSize.SMALL) ? this.theme.chipNode.smallPadding : this.theme.chipNode.normalPadding
return (this.isChipSizeEnum() &&
this.chipSize === ChipSize.SMALL) ? this.theme.chipNode.smallPadding : this.theme.chipNode.normalPadding
}
private getChipNodeRadius(): Dimension {
if (this.chipNodeRadius !== void (0) && this.toVp(this.chipNodeRadius) >= 0) {
return this.chipNodeRadius as Dimension
} else {
return ((this.isChipSizeEnum() && this.chipSize === ChipSize.SMALL) ? this.theme.chipNode.smallBorderRadius : this.theme.chipNode.normalBorderRadius)
return ((this.isChipSizeEnum() && this.chipSize === ChipSize.SMALL) ?
this.theme.chipNode.smallBorderRadius : this.theme.chipNode.normalBorderRadius)
}
}
@ -502,8 +504,7 @@ export struct ChipComponent {
if (this.getChipActive()) {
currentColor = this.chipNodeActivatedBackgroundColor ?? this.theme.chipNode.activatedBackgroundColor
}
else {
} else {
currentColor = this.chipNodeBackgroundColor ?? this.theme.chipNode.backgroundColor
}
@ -533,7 +534,8 @@ export struct ChipComponent {
return this.chipSize === ChipSize.SMALL ? this.theme.chipNode.smallHeight : this.theme.chipNode.normalHeight
} else {
this.chipNodeSize = this.chipSize as SizeOptions
return (this.chipNodeSize?.height !== void (0) && this.toVp(this.chipNodeSize?.height) >= 0) ? this.toVp(this.chipNodeSize?.height) : this.theme.chipNode.normalHeight
return (this.chipNodeSize?.height !== void (0) && this.toVp(this.chipNodeSize?.height) >= 0) ?
this.toVp(this.chipNodeSize?.height) : this.theme.chipNode.normalHeight
}
}
@ -660,7 +662,8 @@ export struct ChipComponent {
}
}
let constraintWidth: ConstraintSizeOptions = this.getChipConstraintWidth()
return Math.min(Math.max(this.getCalculateChipNodeWidth(), constraintWidth.minWidth as number), constraintWidth.maxWidth as number);
return Math.min(Math.max(this.getCalculateChipNodeWidth(),
constraintWidth.minWidth as number), constraintWidth.maxWidth as number);
}
private getFocusOverlaySize(): SizeOptions {
@ -906,8 +909,7 @@ export struct ChipComponent {
.onHover((isHover: boolean) => {
if (this.isShowPressedBackGroundColor == false) {
this.isShowPressedBackGroundColor = true
}
else {
} else {
this.isShowPressedBackGroundColor = false
}

View File

@ -23,7 +23,7 @@ interface ChipGroupTheme {
const noop = (selectedIndexes: Array<number>) => {
}
const colorStops: Array<[string, number]> = [['rgba(0, 0, 0, 1)', 0], ['rgba(0, 0, 0, 0)', 1]]
const colorStops: ( string | number )[] = [['rgba(0, 0, 0, 1)', 0], ['rgba(0, 0, 0, 0)', 1]]
const defaultTheme: ChipGroupTheme = {
itemStyle: {
size: ChipSize.NORMAL,

View File

@ -28,32 +28,32 @@ enum FocusText {
}
export class CommonOptions {
focusable?: boolean;
step?: number;
onHoverIncrease?: (isHover: boolean) => void;
onHoverDecrease?: (isHover: boolean) => void;
public focusable?: boolean;
public step?: number;
public onHoverIncrease?: (isHover: boolean) => void;
public onHoverDecrease?: (isHover: boolean) => void;
}
export class InlineStyleOptions extends CommonOptions {
value?: number;
min?: number;
max?: number;
textWidth?: number;
onChange?: (value: number) => void;
public value?: number;
public min?: number;
public max?: number;
public textWidth?: number;
public onChange?: (value: number) => void;
}
export class NumberStyleOptions extends InlineStyleOptions {
label?: ResourceStr;
onFocusIncrease?: () => void;
onFocusDecrease?: () => void;
onBlurIncrease?: () => void;
onBlurDecrease?: () => void;
public label?: ResourceStr;
public onFocusIncrease?: () => void;
public onFocusDecrease?: () => void;
public onBlurIncrease?: () => void;
public onBlurDecrease?: () => void;
}
export class DateData{
year: number;
month: number;
day: number;
export class DateData {
public year: number;
public month: number;
public day: number;
constructor(year: number, month: number, day: number) {
this.year = year;
@ -72,121 +72,121 @@ export class DateData{
}
export class DateStyleOptions extends CommonOptions {
year?: number;
month?: number;
day?: number;
onDateChange?: (date: DateData) => void;
public year?: number;
public month?: number;
public day?: number;
public onDateChange?: (date: DateData) => void;
}
export class CounterOptions {
type: CounterType;
numberOptions?: NumberStyleOptions;
inlineOptions?: InlineStyleOptions;
dateOptions?: DateStyleOptions;
public type: CounterType;
public numberOptions?: NumberStyleOptions;
public inlineOptions?: InlineStyleOptions;
public dateOptions?: DateStyleOptions;
}
class CounterResource {
// counter color
static readonly BUTTON_BACKGROUD_COLOR = $r('sys.color.ohos_id_color_button_normal');
static readonly BUTTON_ICON_COLOR = $r('sys.color.ohos_id_color_primary');
static readonly BUTTON_BORDER_FOCUSED_COLOR = $r('sys.color.ohos_id_color_focused_outline');
static readonly COUNTER_TEXT_COLOR = $r('sys.color.ohos_id_color_text_primary');
static readonly COUNTER_BORDER_COLOR = $r('sys.color.ohos_id_color_component_normal');
public static readonly BUTTON_BACKGROUD_COLOR = $r('sys.color.ohos_id_color_button_normal');
public static readonly BUTTON_ICON_COLOR = $r('sys.color.ohos_id_color_primary');
public static readonly BUTTON_BORDER_FOCUSED_COLOR = $r('sys.color.ohos_id_color_focused_outline');
public static readonly COUNTER_TEXT_COLOR = $r('sys.color.ohos_id_color_text_primary');
public static readonly COUNTER_BORDER_COLOR = $r('sys.color.ohos_id_color_component_normal');
// button icon
static readonly BUTTON_ADD_ICON = $r("sys.media.ohos_ic_public_add");
static readonly BUTTON_SUB_ICON = $r("sys.media.ohos_ic_public_minus");
static readonly BUTTON_ARROW_UP = $r('sys.media.ohos_ic_public_arrow_up');
static readonly BUTTON_ARROW_DOWN = $r('sys.media.ohos_ic_public_arrow_down');
public static readonly BUTTON_ADD_ICON = $r("sys.media.ohos_ic_public_add");
public static readonly BUTTON_SUB_ICON = $r("sys.media.ohos_ic_public_minus");
public static readonly BUTTON_ARROW_UP = $r('sys.media.ohos_ic_public_arrow_up');
public static readonly BUTTON_ARROW_DOWN = $r('sys.media.ohos_ic_public_arrow_down');
// counter size
static readonly BUTTON_BORDER_FOCUSED_WIDTH = '2vp';
static readonly BUTTON_BORDER_BLUR_WIDTH = '0vp';
static readonly COUNTER_BORDER_WIDTH = '1vp';
static readonly COUNTER_LIST_LABEL_SIZE = $r('sys.float.ohos_id_text_size_body1');
static readonly COUNTER_LIST_NUMBER_SIZE = $r('sys.float.ohos_id_text_size_body1');
static readonly COUNTER_COMPACT_LABEL_SIZE = $r('sys.float.ohos_id_text_size_body2');
static readonly COUNTER_NUMBER_SIZE = $r('sys.float.ohos_id_text_size_body1');
static readonly COUNTER_LIST_LEFT_PADDING = $r('sys.float.ohos_id_default_padding_start');
static readonly COUNTER_LIST_RIGHT_PADDING = $r('sys.float.ohos_id_default_padding_end');
static readonly COUNTER_LIST_HEIGHT = '48vp';
static readonly COUNTER_LIST_BUTTON_ICON_SIZE = '20vp';
static readonly COUNTER_LIST_BUTTON_SIZE = '32vp';
static readonly COUNTER_LIST_BUTTON_RADIUS = '16vp';
static readonly COUNTER_LIST_BUTTON_TEXT_DISTANCE = '8vp';
static readonly COUNTER_LIST_FOCUS_BORDER_SIZE = '30vp';
static readonly COUNTER_LIST_FOCUS_BORDER_RADIUS = '15vp';
static readonly COUNTER_LIST_BUTTON_HOT_SPOT_X = '-8vp';
static readonly COUNTER_LIST_BUTTON_HOT_SPOT_Y = '-8vp';
public static readonly BUTTON_BORDER_FOCUSED_WIDTH = '2vp';
public static readonly BUTTON_BORDER_BLUR_WIDTH = '0vp';
public static readonly COUNTER_BORDER_WIDTH = '1vp';
public static readonly COUNTER_LIST_LABEL_SIZE = $r('sys.float.ohos_id_text_size_body1');
public static readonly COUNTER_LIST_NUMBER_SIZE = $r('sys.float.ohos_id_text_size_body1');
public static readonly COUNTER_COMPACT_LABEL_SIZE = $r('sys.float.ohos_id_text_size_body2');
public static readonly COUNTER_NUMBER_SIZE = $r('sys.float.ohos_id_text_size_body1');
public static readonly COUNTER_LIST_LEFT_PADDING = $r('sys.float.ohos_id_default_padding_start');
public static readonly COUNTER_LIST_RIGHT_PADDING = $r('sys.float.ohos_id_default_padding_end');
public static readonly COUNTER_LIST_HEIGHT = '48vp';
public static readonly COUNTER_LIST_BUTTON_ICON_SIZE = '20vp';
public static readonly COUNTER_LIST_BUTTON_SIZE = '32vp';
public static readonly COUNTER_LIST_BUTTON_RADIUS = '16vp';
public static readonly COUNTER_LIST_BUTTON_TEXT_DISTANCE = '8vp';
public static readonly COUNTER_LIST_FOCUS_BORDER_SIZE = '30vp';
public static readonly COUNTER_LIST_FOCUS_BORDER_RADIUS = '15vp';
public static readonly COUNTER_LIST_BUTTON_HOT_SPOT_X = '-8vp';
public static readonly COUNTER_LIST_BUTTON_HOT_SPOT_Y = '-8vp';
static readonly COUNTER_COMPACT_BUTTON_ICON_SIZE = '16vp';
static readonly COUNTER_COMPACT_BUTTON_SIZE = '24vp';
static readonly COUNTER_COMPACT_BUTTON_RADIUS = '12vp';
static readonly COUNTER_COMPACT_BUTTON_TEXT_DISTANCE = '10vp';
static readonly COUNTER_COMPACT_CONTAINER_HEIGHT = '28vp';
static readonly COUNTER_COMPACT_CONTAINER_RADIUS = '14vp';
static readonly COUNTER_COMPACT_CONTAINER_LABEL_DISTANCE = '8vp';
static readonly COUNTER_COMPACT_FOCUS_BORDER_SIZE = '22vp';
static readonly COUNTER_COMPACT_FOCUS_BORDER_RADIUS = '11vp';
public static readonly COUNTER_COMPACT_BUTTON_ICON_SIZE = '16vp';
public static readonly COUNTER_COMPACT_BUTTON_SIZE = '24vp';
public static readonly COUNTER_COMPACT_BUTTON_RADIUS = '12vp';
public static readonly COUNTER_COMPACT_BUTTON_TEXT_DISTANCE = '10vp';
public static readonly COUNTER_COMPACT_CONTAINER_HEIGHT = '28vp';
public static readonly COUNTER_COMPACT_CONTAINER_RADIUS = '14vp';
public static readonly COUNTER_COMPACT_CONTAINER_LABEL_DISTANCE = '8vp';
public static readonly COUNTER_COMPACT_FOCUS_BORDER_SIZE = '22vp';
public static readonly COUNTER_COMPACT_FOCUS_BORDER_RADIUS = '11vp';
static readonly COUNTER_INLINE_BUTTON_ICON_WIDTH = '24vp';
static readonly COUNTER_INLINE_BUTTON_ICON_HEIGHT = '12vp';
static readonly COUNTER_INLINE_BUTTON_TEXT_DISTANCE = '12vp';
static readonly COUNTER_INLINE_CONTAINER_HEIGHT = '32vp';
static readonly COUNTER_INLINE_BUTTON_WIDTH = '32vp';
static readonly COUNTER_INLINE_BUTTON_HEIGHT = '16vp';
static readonly COUNTER_INLINE_RADIUS = '8vp';
static readonly COUNTER_INLINE_FOCUS_BORDER_WIDTH = '28vp';
static readonly COUNTER_INLINE_FOCUS_BORDER_HEIGHT = '13.5vp';
static readonly COUNTER_INLINE_DATE_TEXT_MARGIN = '12vp';
static readonly COUNTER_BUTTON_INITIAL_OPACITY = 1;
static readonly COUNTER_BUTTON_DISABLE_OPACITY = 0.4;
public static readonly COUNTER_INLINE_BUTTON_ICON_WIDTH = '24vp';
public static readonly COUNTER_INLINE_BUTTON_ICON_HEIGHT = '12vp';
public static readonly COUNTER_INLINE_BUTTON_TEXT_DISTANCE = '12vp';
public static readonly COUNTER_INLINE_CONTAINER_HEIGHT = '32vp';
public static readonly COUNTER_INLINE_BUTTON_WIDTH = '32vp';
public static readonly COUNTER_INLINE_BUTTON_HEIGHT = '16vp';
public static readonly COUNTER_INLINE_RADIUS = '8vp';
public static readonly COUNTER_INLINE_FOCUS_BORDER_WIDTH = '28vp';
public static readonly COUNTER_INLINE_FOCUS_BORDER_HEIGHT = '13.5vp';
public static readonly COUNTER_INLINE_DATE_TEXT_MARGIN = '12vp';
public static readonly COUNTER_BUTTON_INITIAL_OPACITY = 1;
public static readonly COUNTER_BUTTON_DISABLE_OPACITY = 0.4;
}
class CounterConstant {
static readonly COUNTER_MAX_YEAR = 5000;
static readonly COUNTER_MIN_YEAR = 1;
static readonly COUNTER_INITIAL_MONTH = 1;
static readonly COUNTER_INITIAL_DAY = 1;
static readonly COUNTER_INITIAL_STEP = 1;
public static readonly COUNTER_MAX_YEAR = 5000;
public static readonly COUNTER_MIN_YEAR = 1;
public static readonly COUNTER_INITIAL_MONTH = 1;
public static readonly COUNTER_INITIAL_DAY = 1;
public static readonly COUNTER_INITIAL_STEP = 1;
static readonly COUNTER_TEN_NUMBER = 10;
static readonly COUNTER_MIN_MONTH = 1;
static readonly COUNTER_MAX_MONTH = 12;
static readonly COUNTER_MIN_DAY = 1;
static readonly KEYCODE_DPAD_UP = 2012;
static readonly KEYCODE_DPAD_DOWN = 2013;
static readonly KEYCODE_DPAD_LEFT = 2014;
static readonly KEYCODE_DPAD_RIGHT = 2015;
static readonly KEYCODE_MOVE_HOME = 2081;
static readonly KEYCODE_MOVE_END = 2082;
static readonly KEYCODE_TAB = 2049;
static readonly KEYCODE_ESC = 2070;
static readonly COUNTER_MIN_VALUE = 0;
static readonly COUNTER_MAX_VALUE = 999;
static readonly JANUARY = 1;
static readonly FEBRUARY = 2;
static readonly MARCH = 3;
static readonly APRIL = 4;
static readonly MAY = 5;
static readonly JUNE = 6;
static readonly JULY = 7;
static readonly AUGUST = 8;
static readonly SEPTEMBER = 9;
static readonly OCTOBER = 10;
static readonly NOVEMBER = 11;
static readonly DECEMBER = 12;
static readonly BIG_MONTH_DAYS = 31;
static readonly SMALL_MONTH_DAYS = 30;
static readonly FEBRUARY_DAYS = 28;
static readonly AUSPICIOUS_FEBRUARY_DAYS = 29;
static readonly AUSPICIOUS_FOUR = 4;
static readonly AUSPICIOUS_HUNDRED = 100;
static readonly AUSPICIOUS_FOUR_HUNDRED = 400;
public static readonly COUNTER_TEN_NUMBER = 10;
public static readonly COUNTER_MIN_MONTH = 1;
public static readonly COUNTER_MAX_MONTH = 12;
public static readonly COUNTER_MIN_DAY = 1;
public static readonly KEYCODE_DPAD_UP = 2012;
public static readonly KEYCODE_DPAD_DOWN = 2013;
public static readonly KEYCODE_DPAD_LEFT = 2014;
public static readonly KEYCODE_DPAD_RIGHT = 2015;
public static readonly KEYCODE_MOVE_HOME = 2081;
public static readonly KEYCODE_MOVE_END = 2082;
public static readonly KEYCODE_TAB = 2049;
public static readonly KEYCODE_ESC = 2070;
public static readonly COUNTER_MIN_VALUE = 0;
public static readonly COUNTER_MAX_VALUE = 999;
public static readonly JANUARY = 1;
public static readonly FEBRUARY = 2;
public static readonly MARCH = 3;
public static readonly APRIL = 4;
public static readonly MAY = 5;
public static readonly JUNE = 6;
public static readonly JULY = 7;
public static readonly AUGUST = 8;
public static readonly SEPTEMBER = 9;
public static readonly OCTOBER = 10;
public static readonly NOVEMBER = 11;
public static readonly DECEMBER = 12;
public static readonly BIG_MONTH_DAYS = 31;
public static readonly SMALL_MONTH_DAYS = 30;
public static readonly FEBRUARY_DAYS = 28;
public static readonly AUSPICIOUS_FEBRUARY_DAYS = 29;
public static readonly AUSPICIOUS_FOUR = 4;
public static readonly AUSPICIOUS_HUNDRED = 100;
public static readonly AUSPICIOUS_FOUR_HUNDRED = 400;
}
@Component
export struct CounterComponent {
@Prop @Watch('onOptionsChange') options: CounterOptions;
@Prop @Watch('onOptionsChange') options: CounterOptions;
@State type: number = -1;
@State choverEffect: HoverEffect = HoverEffect.Auto;
@State focusEnable: boolean = true;
@ -226,7 +226,7 @@ export struct CounterComponent {
private maxYear: number = CounterConstant.COUNTER_MAX_YEAR;
private minYear: number = CounterConstant.COUNTER_MIN_YEAR;
private numberStrList: Array<string> = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09'];
private numberStrList: Array<string> = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09'];
private onHoverIncrease?: (isHover: boolean) => void;
private onHoverDecrease?: (isHover: boolean) => void;
private onFocusIncrease?: () => void;
@ -283,7 +283,7 @@ export struct CounterComponent {
}
if (this.numberStyleOptions.textWidth !== undefined) {
this.textWidth = this.numberStyleOptions.textWidth;
if (this.textWidth < 0) {
if (this.textWidth < 0) {
this.textWidth = 0;
}
this.hasTextWidth = true;
@ -547,7 +547,7 @@ export struct CounterComponent {
}
private getDayNumber(): number {
switch(this.month) {
switch (this.month) {
case CounterConstant.JANUARY:
case CounterConstant.MARCH:
case CounterConstant.MAY:
@ -828,7 +828,7 @@ export struct CounterComponent {
if (this.inputValue == undefined) {
this.inputValue = ''
}
return this.hasInputText1? this.inputValue : this.value.toString();
return this.hasInputText1 ? this.inputValue : this.value.toString();
}
private getValueLength() {
@ -1368,7 +1368,7 @@ export struct CounterComponent {
})
.onChange((value: string) => {
this.inputValue = value;
for(let i= 0; i < value.length; i++) {
for (let i = 0; i < value.length; i++) {
let c = value[i];
if (c === '+' || c === '*' || c === '#') {
this.value -= 1;
@ -1383,7 +1383,7 @@ export struct CounterComponent {
}
this.hasInputText1 = true;
let c = value[value.length -1];
let c = value[value.length - 1];
if (value.length === this.getMaxLength()) {
this.inputValue = c;
}
@ -1506,7 +1506,7 @@ export struct CounterComponent {
})
.onChange((value: string) => {
this.inputValue = value;
for(let i= 0; i < value.length; i++) {
for (let i= 0; i < value.length; i++) {
let c = value[i];
if (c === '+' || c === '*' || c === '#') {
this.value -= 1;
@ -1646,7 +1646,7 @@ export struct CounterComponent {
.focusable(false)
.onFocus(()=>{
this.addBtnFocusWidh = CounterResource.BUTTON_BORDER_FOCUSED_WIDTH;
this.onFocusIncrease&& this.onFocusIncrease();
this.onFocusIncrease && this.onFocusIncrease();
})
.onBlur(()=>{
this.addBtnFocusWidh = CounterResource.BUTTON_BORDER_BLUR_WIDTH;
@ -1743,10 +1743,10 @@ export struct CounterComponent {
.copyOption(CopyOptions.None)
.fontSize(CounterResource.COUNTER_NUMBER_SIZE)
.fontWeight(FontWeight.Medium)
.fontColor(this.hasFocusText1? Color.White : CounterResource.COUNTER_TEXT_COLOR)
.fontColor(this.hasFocusText1 ? Color.White : CounterResource.COUNTER_TEXT_COLOR)
.maxLength(5)
.padding(0)
.backgroundColor(this.hasFocusText1? CounterResource.BUTTON_BORDER_FOCUSED_COLOR : Color.Transparent)
.backgroundColor(this.hasFocusText1 ? CounterResource.BUTTON_BORDER_FOCUSED_COLOR : Color.Transparent)
.width('38vp')
.height('20vp')
.borderRadius(0)
@ -1793,7 +1793,7 @@ export struct CounterComponent {
this.hasInputText1 = true;
}
this.inputYear = Number(value)
if(value.length === 5) {
if (value.length === 5) {
this.inputYear = this.inputYear % 10;
}
@ -1861,7 +1861,7 @@ export struct CounterComponent {
.fontColor(CounterResource.COUNTER_TEXT_COLOR)
.width('8vp')
TextInput({
text: this.hasInputText2? this.inputMoon.toString() : this.convertNumberToString(this.month),
text: this.hasInputText2 ? this.inputMoon.toString() : this.convertNumberToString(this.month),
controller: this.controller2
})
.type(InputType.Number)
@ -1869,10 +1869,10 @@ export struct CounterComponent {
.copyOption(CopyOptions.None)
.fontSize(CounterResource.COUNTER_NUMBER_SIZE)
.fontWeight(FontWeight.Medium)
.fontColor(this.hasFocusText2? Color.White : CounterResource.COUNTER_TEXT_COLOR)
.fontColor(this.hasFocusText2 ? Color.White : CounterResource.COUNTER_TEXT_COLOR)
.maxLength(3)
.padding(0)
.backgroundColor(this.hasFocusText2? CounterResource.BUTTON_BORDER_FOCUSED_COLOR : Color.Transparent)
.backgroundColor(this.hasFocusText2 ? CounterResource.BUTTON_BORDER_FOCUSED_COLOR : Color.Transparent)
.width('19vp')
.height('20vp')
.borderRadius(0)
@ -2000,7 +2000,7 @@ export struct CounterComponent {
.fontColor(CounterResource.COUNTER_TEXT_COLOR)
.width('8vp')
TextInput({
text: this.hasInputText3? this.inputDay.toString(): this.convertNumberToString(this.day),
text: this.hasInputText3 ? this.inputDay.toString(): this.convertNumberToString(this.day),
controller: this.controller3
})
.type(InputType.Number)
@ -2008,10 +2008,10 @@ export struct CounterComponent {
.copyOption(CopyOptions.None)
.fontSize(CounterResource.COUNTER_NUMBER_SIZE)
.fontWeight(FontWeight.Medium)
.fontColor(this.hasFocusText3? Color.White : CounterResource.COUNTER_TEXT_COLOR)
.fontColor(this.hasFocusText3 ? Color.White : CounterResource.COUNTER_TEXT_COLOR)
.maxLength(3)
.padding(0)
.backgroundColor(this.hasFocusText3? CounterResource.BUTTON_BORDER_FOCUSED_COLOR : Color.Transparent)
.backgroundColor(this.hasFocusText3 ? CounterResource.BUTTON_BORDER_FOCUSED_COLOR : Color.Transparent)
.width('19vp')
.height('20vp')
.borderRadius(0)

View File

@ -67,9 +67,9 @@ interface PositionXY {
}
class MenuItem {
value: Resource;
isEnabled: boolean;
action: () => void;
pubilc value: Resource;
pubilc isEnabled: boolean;
pubilc action: () => void;
constructor(value: Resource, enabled: boolean, action: () => void) {
this.value = value;
@ -203,7 +203,9 @@ export struct GridObjectSortComponent {
// cancel edit function
cancelEdit() {
if (this.isStartDrag || this.clickAddBtn || this.clickRemoveBtn) return
if (this.isStartDrag || this.clickAddBtn || this.clickRemoveBtn) {
return
}
animateTo({
duration: ENTER_EXIT_ICON_DURATION,
curve: LONG_TOUCH_SCALE
@ -276,7 +278,9 @@ export struct GridObjectSortComponent {
// delete Editing an Area Item
handleDeleteClick(content: GridObjectSortComponentItem) {
if (this.clickAddBtn || this.clickRemoveBtn) return
if (this.clickAddBtn || this.clickRemoveBtn) {
return
}
this.clickRemoveBtn = true;
this.scaleIcon = 0;
this.arraySelectIsChange = 1;
@ -345,19 +349,19 @@ export struct GridObjectSortComponent {
return height
}
// Display area icon in image_text mode
imageTextRemoveIcon (select: GridObjectSortComponentItem): Resource {
imageTextRemoveIcon(select: GridObjectSortComponentItem): Resource {
const clickRemoveIcon = this.clickRemoveBtn && this.content.id === select.id
const icon = clickRemoveIcon ? $r("sys.media.ohos_ic_public_add_norm_filled") : $r("sys.media.ohos_ic_public_remove_filled")
return icon
}
// Adding a Region Icon in image_text Mode
imageTextAddIcon (select: GridObjectSortComponentItem): Resource {
imageTextAddIcon(select: GridObjectSortComponentItem): Resource {
const clickAddIcon = this.clickAddBtn && this.content.id === select.id && this.gridComState
const icon = clickAddIcon ? $r("sys.media.ohos_ic_public_remove_filled") : $r("sys.media.ohos_ic_public_add_norm_filled")
return icon
}
// Displaying and hiding area icons in image_text mode
imageTextAddIconVisible (select: GridObjectSortComponentItem): Visibility {
imageTextAddIconVisible(select: GridObjectSortComponentItem): Visibility {
const iconHideShow = this.clickAddBtn && this.content.id === select.id && !this.gridComState
const visible = iconHideShow ? Visibility.Hidden : Visibility.Visible
return visible
@ -527,7 +531,7 @@ export struct GridObjectSortComponent {
}
// Move the position when adding an item.
if(!this.clickRemoveBtn && index === this.unSelectedIndex) {
if (!this.clickRemoveBtn && index === this.unSelectedIndex) {
return {
x: this.addItemMoveX,
y: -this.addItemMoveY
@ -665,7 +669,9 @@ export struct GridObjectSortComponent {
y: -MARGIN_EIGHT
})
.onClick(() => {
if (this.clickAddBtn || this.clickRemoveBtn) return
if (this.clickAddBtn || this.clickRemoveBtn) {
return
}
this.scaleIcon = 0
this.content = select
const index = this.unSelected.findIndex(i => i.id === select.id)
@ -713,7 +719,8 @@ export struct GridObjectSortComponent {
.width('100%')
.height(this.imageItemWidth)
.padding({ left: MARGIN_EIGHT, right: MARGIN_EIGHT })
.borderRadius((this.isTouchDown && select.id === this.content.id) || select.id === this.hoverId ? this.touchBorderRadius : 0)
.borderRadius((this.isTouchDown && select.id === this.content.id) ||
select.id === this.hoverId ? this.touchBorderRadius : 0)
.backgroundColor(
this.isTouchDown && select.id === this.content.id
? this.touchDown : select.id === this.hoverId ? this.hoverBackgroundColor : ''
@ -734,9 +741,8 @@ export struct GridObjectSortComponent {
}
.borderRadius(50)
.width(this.clickRemoveBtn && select.id === this.content.id ? this.textItemEditWidth + 8 : this.textItemEditWidth)
.translate(this.gridComState ? this.clickRemoveBtn && select.id === this.content.id ? { x: 0 } : { x: -4 } : {
x: 0
})
.translate(this.gridComState ? this.clickRemoveBtn &&
select.id === this.content.id ? { x: 0 } : { x: -4 } : { x: 0})
.height('100%')
.animation(!this.firstIn ? {
duration: ENTER_EXIT_ICON_DURATION,
@ -909,14 +915,18 @@ export struct GridObjectSortComponent {
})
.clickEffect({ level: ClickEffectLevel.LIGHT })
.onTouch((event: TouchEvent) => {
if (this.clickAddBtn || this.clickRemoveBtn) return
if(event.type === TouchType.Down) {
if (this.clickAddBtn || this.clickRemoveBtn) {
return
}
if (event.type === TouchType.Down) {
this.content = item
this.isTouchDown = true
}
if (event.type === TouchType.Up) {
this.isTouchDown = false
if (this.addAreaLongPressGesture || this.longScaleOnePointTwo === 1.05 || this.imageText) return
if (this.addAreaLongPressGesture || this.longScaleOnePointTwo === 1.05 || this.imageText) {
return
}
animateTo({
duration: ENTER_EXIT_ICON_DURATION,
curve: COMMON_BEZIER
@ -994,7 +1004,7 @@ export struct GridObjectSortComponent {
.clip(false)
.translate(this.getAddAreaItemTranslate(index))
.animation({
curve: this.clickRemoveBtn ? DRAG_SPRING : index === this.unSelectedIndex ? REMOVE_ADD_SPRING : DRAG_SPRING
curve: this.clickRemoveBtn ? DRAG_SPRING : index === this.unSelectedIndex ? REMOVE_ADD_SPRING : DRAG_SPRING
})
}, (item: GridObjectSortComponentItem) => item.id.toString())
}
@ -1038,7 +1048,9 @@ export struct GridObjectSortComponent {
bottom: this.imageText ? ROW_GAP : this.gridComState ? ROW_GAP : MARGIN_EIGHT
})
.onTouch((event: TouchEvent) => {
if (this.clickAddBtn || this.clickRemoveBtn) return
if (this.clickAddBtn || this.clickRemoveBtn) {
return
}
if (event.type === TouchType.Down) {
this.content = select
this.isTouchDown = true
@ -1058,7 +1070,7 @@ export struct GridObjectSortComponent {
.clip(false)
.translate(this.getShowAreaItemTranslate(index))
.animation({
curve: this.isStartDrag ? DRAG_SPRING : index === this.selectedIndex ? REMOVE_ADD_SPRING : DRAG_SPRING,
curve: this.isStartDrag ? DRAG_SPRING : index === this.selectedIndex ? REMOVE_ADD_SPRING : DRAG_SPRING,
})
}, (item: GridObjectSortComponentItem) => item.id.toString())
}
@ -1135,7 +1147,8 @@ export struct GridObjectSortComponent {
this.isStartDrag = false
this.selected.splice(insertIndex === -1 ? itemIndex : insertIndex, 0, this.content)
})
.onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) => this.onDragMoveEvent(event, itemIndex, insertIndex))
.onItemDragMove((event: ItemDragInfo, itemIndex: number, insertIndex: number) =>
this.onDragMoveEvent(event, itemIndex, insertIndex))
}
}

View File

@ -29,12 +29,12 @@ interface SegmentButtonThemeInterface {
TAB_SELECTED_BACKGROUND_COLOR: ResourceColor,
CAPSULE_SELECTED_BACKGROUND_COLOR: ResourceColor,
FOCUS_BORDER_COLOR: ResourceColor,
HOVER_COlOR: ResourceColor,
HOVER_COLOR: ResourceColor,
PRESS_COLOR: ResourceColor,
BACKGROUND_BLUR_STYLE: BlurStyle,
}
const SegmentButtonTheme: SegmentButtonThemeInterface = {
const segmentButtonTheme: SegmentButtonThemeInterface = {
FONT_COLOR: $r('sys.color.ohos_id_color_text_secondary'),
TAB_SELECTED_FONT_COLOR: $r('sys.color.ohos_id_color_text_primary'),
CAPSULE_SELECTED_FONT_COLOR: $r('sys.color.ohos_id_color_foreground_contrary'),
@ -44,7 +44,7 @@ const SegmentButtonTheme: SegmentButtonThemeInterface = {
TAB_SELECTED_BACKGROUND_COLOR: $r('sys.color.ohos_id_color_foreground_contrary'),
CAPSULE_SELECTED_BACKGROUND_COLOR: $r('sys.color.ohos_id_color_emphasize'),
FOCUS_BORDER_COLOR: $r("sys.color.ohos_id_color_focused_outline"),
HOVER_COlOR: $r("sys.color.ohos_id_color_hover"),
HOVER_COLOR: $r("sys.color.ohos_id_color_hover"),
PRESS_COLOR: $r("sys.color.ohos_id_color_click_effect"),
BACKGROUND_BLUR_STYLE: BlurStyle.NONE
}
@ -91,8 +91,10 @@ interface CommonSegmentButtonOptions {
}
type ItemRestriction<T> = [T, T, T?, T?, T?]
type SegmentButtonItemTuple = ItemRestriction<SegmentButtonTextItem> | ItemRestriction<SegmentButtonIconItem> | ItemRestriction<SegmentButtonIconTextItem>
type SegmentButtonItemArray = Array<SegmentButtonTextItem> | Array<SegmentButtonIconItem> | Array<SegmentButtonIconTextItem>
type SegmentButtonItemTuple = ItemRestriction<SegmentButtonTextItem> |
ItemRestriction<SegmentButtonIconItem> | ItemRestriction<SegmentButtonIconTextItem>
type SegmentButtonItemArray = Array<SegmentButtonTextItem> |
Array<SegmentButtonIconItem> | Array<SegmentButtonIconTextItem>
export interface TabSegmentButtonConstructionOptions extends CommonSegmentButtonOptions {
buttons: ItemRestriction<SegmentButtonTextItem>
@ -119,9 +121,9 @@ interface SegmentButtonItemOptionsConstructorOptions {
@Observed
class SegmentButtonItemOptions {
icon?: ResourceStr
selectedIcon?: ResourceStr
text?: ResourceStr
public icon?: ResourceStr
public selectedIcon?: ResourceStr
public text?: ResourceStr
constructor(options: SegmentButtonItemOptionsConstructorOptions) {
this.icon = options.icon
@ -132,9 +134,9 @@ class SegmentButtonItemOptions {
@Observed
export class SegmentButtonItemOptionsArray extends Array<SegmentButtonItemOptions> {
changeStartIndex: number | undefined = void 0
deleteCount: number | undefined = void 0
addLength: number | undefined = void 0
public changeStartIndex: number | undefined = void 0
public deleteCount: number | undefined = void 0
public addLength: number | undefined = void 0
constructor(length: number)
@ -145,7 +147,9 @@ export class SegmentButtonItemOptionsArray extends Array<SegmentButtonItemOption
super(typeof elementsOrLength === "number" ? elementsOrLength : 0);
if (typeof elementsOrLength !== "number" && elementsOrLength !== void 0) {
super.push(...elementsOrLength.map((element?: SegmentButtonTextItem | SegmentButtonIconItem | SegmentButtonIconTextItem) => new SegmentButtonItemOptions(element as SegmentButtonItemOptionsConstructorOptions)))
super.push(...elementsOrLength.map((element?: SegmentButtonTextItem | SegmentButtonIconItem |
SegmentButtonIconTextItem) => new SegmentButtonItemOptions(element as
SegmentButtonItemOptionsConstructorOptions)))
}
}
@ -157,7 +161,8 @@ export class SegmentButtonItemOptionsArray extends Array<SegmentButtonItemOption
this.changeStartIndex = this.length
this.deleteCount = 0
this.addLength = items.length
return super.push(...items.map((element: SegmentButtonItemOptionsConstructorOptions) => new SegmentButtonItemOptions(element)))
return super.push(...items.map((element: SegmentButtonItemOptionsConstructorOptions) =>
new SegmentButtonItemOptions(element)))
}
pop() {
@ -192,7 +197,8 @@ export class SegmentButtonItemOptionsArray extends Array<SegmentButtonItemOption
this.deleteCount = 0
this.addLength = items.length
}
return super.unshift(...items.map((element: SegmentButtonItemOptionsConstructorOptions) => new SegmentButtonItemOptions(element)))
return super.unshift(...items.map((element: SegmentButtonItemOptionsConstructorOptions) =>
new SegmentButtonItemOptions(element)))
}
splice(start: number, deleteCount: number, ...items: SegmentButtonItemOptions[]): SegmentButtonItemOptions[] {
@ -219,25 +225,25 @@ export class SegmentButtonItemOptionsArray extends Array<SegmentButtonItemOption
@Observed
export class SegmentButtonOptions {
type: "tab" | "capsule"
multiply: boolean = false
fontColor: ResourceColor
selectedFontColor: ResourceColor
fontSize: DimensionNoPercentage
selectedFontSize: DimensionNoPercentage
fontWeight: FontWeight
selectedFontWeight: FontWeight
backgroundColor: ResourceColor
selectedBackgroundColor: ResourceColor
imageSize: SizeOptions
buttonPadding: Padding | Dimension
textPadding: Padding | Dimension
componentPadding: Padding | Dimension
showText: boolean = false
showIcon: boolean = false
iconTextRadius?: number
iconTextBackgroundRadius?: number
backgroundBlurStyle: BlurStyle
public type: "tab" | "capsule"
public multiply: boolean = false
public fontColor: ResourceColor
public selectedFontColor: ResourceColor
public fontSize: DimensionNoPercentage
public selectedFontSize: DimensionNoPercentage
public fontWeight: FontWeight
public selectedFontWeight: FontWeight
public backgroundColor: ResourceColor
public selectedBackgroundColor: ResourceColor
public imageSize: SizeOptions
public buttonPadding: Padding | Dimension
public textPadding: Padding | Dimension
public componentPadding: Padding | Dimension
public showText: boolean = false
public showIcon: boolean = false
public iconTextRadius?: number
public iconTextBackgroundRadius?: number
public backgroundBlurStyle: BlurStyle
private _buttons: SegmentButtonItemOptionsArray | undefined = void 0
get buttons() {
@ -251,22 +257,22 @@ export class SegmentButtonOptions {
this._buttons = val
}
onButtonsChange?: () => void
public onButtonsChange?: () => void
constructor(options: TabSegmentButtonOptions | CapsuleSegmentButtonOptions) {
this.fontColor = options.fontColor ?? SegmentButtonTheme.FONT_COLOR
this.selectedFontColor = options.selectedFontColor ?? SegmentButtonTheme.TAB_SELECTED_FONT_COLOR
this.fontSize = options.fontSize ?? SegmentButtonTheme.FONT_SIZE
this.selectedFontSize = options.selectedFontSize ?? SegmentButtonTheme.SELECTED_FONT_SIZE
this.fontColor = options.fontColor ?? segmentButtonTheme.FONT_COLOR
this.selectedFontColor = options.selectedFontColor ?? segmentButtonTheme.TAB_SELECTED_FONT_COLOR
this.fontSize = options.fontSize ?? segmentButtonTheme.FONT_SIZE
this.selectedFontSize = options.selectedFontSize ?? segmentButtonTheme.SELECTED_FONT_SIZE
this.fontWeight = options.fontWeight ?? FontWeight.Regular
this.selectedFontWeight = options.selectedFontWeight ?? FontWeight.Medium
this.backgroundColor = options.backgroundColor ?? SegmentButtonTheme.BACKGROUND_COLOR
this.selectedBackgroundColor = options.selectedBackgroundColor ?? SegmentButtonTheme.TAB_SELECTED_BACKGROUND_COLOR
this.backgroundColor = options.backgroundColor ?? segmentButtonTheme.BACKGROUND_COLOR
this.selectedBackgroundColor = options.selectedBackgroundColor ?? segmentButtonTheme.TAB_SELECTED_BACKGROUND_COLOR
this.imageSize = options.imageSize ?? { width: 24, height: 24 }
this.buttonPadding = options.buttonPadding ?? { top: 4, right: 8, bottom: 4, left: 8 }
this.textPadding = options.textPadding ?? 0
this.type = options.type
this.backgroundBlurStyle = options.backgroundBlurStyle ?? SegmentButtonTheme.BACKGROUND_BLUR_STYLE
this.backgroundBlurStyle = options.backgroundBlurStyle ?? segmentButtonTheme.BACKGROUND_BLUR_STYLE
this.buttons = new SegmentButtonItemOptionsArray(options.buttons)
if (this.type === "capsule") {
this.multiply = (options as CapsuleSegmentButtonOptions).multiply ?? false
@ -279,8 +285,9 @@ export class SegmentButtonOptions {
this.buttonPadding = options.buttonPadding ?? { top: 6, right: 8, bottom: 6, left: 8 }
this.iconTextBackgroundRadius = 14
}
this.selectedFontColor = options.selectedFontColor ?? SegmentButtonTheme.CAPSULE_SELECTED_FONT_COLOR
this.selectedBackgroundColor = options.selectedBackgroundColor ?? SegmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
this.selectedFontColor = options.selectedFontColor ?? segmentButtonTheme.CAPSULE_SELECTED_FONT_COLOR
this.selectedBackgroundColor = options.selectedBackgroundColor ??
segmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
} else {
this.showText = true
}
@ -341,7 +348,7 @@ struct MultiSelectBackground {
Stack()
.layoutWeight(1)
.height(this.buttonItemsSize[index].height)
.backgroundColor(this.options.backgroundColor ?? SegmentButtonTheme.BACKGROUND_COLOR)
.backgroundColor(this.options.backgroundColor ?? segmentButtonTheme.BACKGROUND_COLOR)
.borderRadius(this.buttonBorderRadius[index])
.backgroundBlurStyle(this.options.backgroundBlurStyle)
}
@ -367,8 +374,8 @@ struct SelectItem {
.borderRadius(this.buttonBorderRadius[this.selectedIndexes[0]])
.size(this.buttonItemsSize[this.selectedIndexes[0]])
.backgroundColor(this.options.selectedBackgroundColor ??
(this.options.type === 'tab' ? SegmentButtonTheme.TAB_SELECTED_BACKGROUND_COLOR :
SegmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR))
(this.options.type === 'tab' ? segmentButtonTheme.TAB_SELECTED_BACKGROUND_COLOR :
segmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR))
.position(this.selectedItemPosition)
.scale({ x: this.zoomScaleArray[this.selectedIndexes[0]], y: this.zoomScaleArray[this.selectedIndexes[0]] })
.shadow(ShadowStyle.OUTER_DEFAULT_XS)
@ -391,7 +398,8 @@ struct MultiSelectItemArray {
onOptionsChange() {
for (let i = 0; i < this.selectedIndexes.length; i++) {
this.multiColor[this.selectedIndexes[i]] = this.options.selectedBackgroundColor ?? SegmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
this.multiColor[this.selectedIndexes[i]] = this.options.selectedBackgroundColor ??
segmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
}
}
@ -400,13 +408,15 @@ struct MultiSelectItemArray {
this.multiColor[i] = Color.Transparent
}
for (let i = 0; i < this.selectedIndexes.length; i++) {
this.multiColor[this.selectedIndexes[i]] = this.options.selectedBackgroundColor ?? SegmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
this.multiColor[this.selectedIndexes[i]] = this.options.selectedBackgroundColor ??
segmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
}
}
aboutToAppear() {
for (let i = 0; i < this.selectedIndexes.length; i++) {
this.multiColor[this.selectedIndexes[i]] = this.options.selectedBackgroundColor ?? SegmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
this.multiColor[this.selectedIndexes[i]] = this.options.selectedBackgroundColor ??
segmentButtonTheme.CAPSULE_SELECTED_BACKGROUND_COLOR
}
}
@ -443,8 +453,9 @@ struct SegmentButtonItem {
.size(this.options.imageSize ?? { width: 24, height: 24 })
.focusable(!this.options.showText)
.draggable(false)
.fillColor(this.property.isSelected ? (this.options.selectedFontColor ?? SegmentButtonTheme.CAPSULE_SELECTED_FONT_COLOR) :
(this.options.fontColor ?? SegmentButtonTheme.FONT_COLOR))
.fillColor(this.property.isSelected ? (this.options.selectedFontColor ??
segmentButtonTheme.CAPSULE_SELECTED_FONT_COLOR) : (this.options.fontColor ??
segmentButtonTheme.FONT_COLOR))
}
if (this.options.showText) {
Text(this.itemOptions.text)
@ -482,7 +493,7 @@ struct SegmentButtonItem {
@Observed
class HoverColorProperty {
hoverColor: ResourceColor = Color.Transparent
public hoverColor: ResourceColor = Color.Transparent
}
@Component
@ -492,7 +503,7 @@ struct PressAndHoverEffect {
@ObjectLink colorProperty: HoverColorProperty
@Consume buttonBorderRadius: BorderRadiuses[]
pressIndex: number = 0
pressColor: ResourceColor = SegmentButtonTheme.PRESS_COLOR
pressColor: ResourceColor = segmentButtonTheme.PRESS_COLOR
build() {
Stack()
@ -532,7 +543,8 @@ struct SegmentButtonItemArrayComponent {
}
changeSelectedIndexes(buttonsLength: number) {
if (this.optionsArray.changeStartIndex === void 0 || this.optionsArray.deleteCount === void 0 || this.optionsArray.addLength === void 0) {
if (this.optionsArray.changeStartIndex === void 0 || this.optionsArray.deleteCount === void 0 ||
this.optionsArray.addLength === void 0) {
return
}
if (!(this.options.multiply ?? false)) {
@ -557,14 +569,16 @@ struct SegmentButtonItemArrayComponent {
let saveIndexes = this.selectedIndexes
for (let i = 0; i < this.optionsArray.deleteCount; i++) {
let deleteIndex = saveIndexes.indexOf(this.optionsArray.changeStartIndex)
let indexes = saveIndexes.map(value => this.optionsArray.changeStartIndex && (value > this.optionsArray.changeStartIndex) ? value - 1 : value)
let indexes = saveIndexes.map(value => this.optionsArray.changeStartIndex &&
(value > this.optionsArray.changeStartIndex) ? value - 1 : value)
if (deleteIndex !== -1) {
indexes.splice(deleteIndex, 1)
}
saveIndexes = indexes
}
for (let i = 0; i < this.optionsArray.addLength; i++) {
let indexes = saveIndexes.map(value => this.optionsArray.changeStartIndex && (value >= this.optionsArray.changeStartIndex) ? value + 1 : value)
let indexes = saveIndexes.map(value => this.optionsArray.changeStartIndex &&
(value >= this.optionsArray.changeStartIndex) ? value + 1 : value)
saveIndexes = indexes
}
this.selectedIndexes = saveIndexes
@ -573,7 +587,8 @@ struct SegmentButtonItemArrayComponent {
}
changeFocusIndex(buttonsLength: number) {
if (this.optionsArray.changeStartIndex === void 0 || this.optionsArray.deleteCount === void 0 || this.optionsArray.addLength === void 0) {
if (this.optionsArray.changeStartIndex === void 0 || this.optionsArray.deleteCount === void 0 ||
this.optionsArray.addLength === void 0) {
return
}
if (this.focusIndex === -1) {
@ -595,7 +610,8 @@ struct SegmentButtonItemArrayComponent {
return
}
let buttonsLength = Math.min(this.options.buttons.length, this.buttonItemsSize.length)
if (this.optionsArray.changeStartIndex !== void 0 && this.optionsArray.deleteCount !== void 0 && this.optionsArray.addLength !== void 0) {
if (this.optionsArray.changeStartIndex !== void 0 && this.optionsArray.deleteCount !== void 0 &&
this.optionsArray.addLength !== void 0) {
this.changeSelectedIndexes(buttonsLength)
this.changeFocusIndex(buttonsLength)
this.optionsArray.changeStartIndex = void 0
@ -631,7 +647,7 @@ struct SegmentButtonItemArrayComponent {
width: this.options.type === 'capsule' && this.buttonItemsSelected[this.focusIndex] ? this.buttonWidth[index] + 8 : this.buttonWidth[index],
height: this.options.type === 'capsule' && this.buttonItemsSelected[this.focusIndex] ? this.buttonHeight[index] + 8 : this.buttonHeight[index]
})
.borderColor(SegmentButtonTheme.FOCUS_BORDER_COLOR)
.borderColor(segmentButtonTheme.FOCUS_BORDER_COLOR)
.borderWidth(2)
}
.size({ width: 1, height: 1 })
@ -657,7 +673,8 @@ struct SegmentButtonItemArrayComponent {
borderRadiusArray[index].topRight = 0
borderRadiusArray[index].bottomLeft = this.options.iconTextRadius ?? halfButtonItemsSizeHeight
borderRadiusArray[index].bottomRight = 0
} else if (this.options.buttons && index === Math.min(this.options.buttons.length, this.buttonItemsSize.length) - 1) {
} else if (this.options.buttons && index === Math.min(this.options.buttons.length,
this.buttonItemsSize.length) - 1) {
borderRadiusArray[index].topLeft = 0
borderRadiusArray[index].topRight = this.options.iconTextRadius ?? halfButtonItemsSizeHeight
borderRadiusArray[index].bottomLeft = 0
@ -696,7 +713,8 @@ struct SegmentButtonItemArrayComponent {
.onSizeChange((_, newValue) => {
// Calculate height of items
this.buttonItemsRealHeight[index] = newValue.height as number
let maxHeight = Math.max(...this.buttonItemsRealHeight.slice(0, this.options.buttons ? this.options.buttons.length : 0))
let maxHeight = Math.max(...this.buttonItemsRealHeight.slice(0, this.options.buttons ?
this.options.buttons.length : 0))
for (let index = 0; index < this.buttonItemsSize.length; index++) {
this.buttonItemsSize[index] = { width: this.buttonItemsSize[index].width, height: maxHeight }
}
@ -714,7 +732,8 @@ struct SegmentButtonItemArrayComponent {
//measure position
if (newValue.width) {
this.buttonItemsPosition[index] = {
x: Number.parseFloat(this.options.componentPadding.toString()) + (Number.parseFloat(newValue.width.toString()) + 1) * index,
x: Number.parseFloat(this.options.componentPadding.toString()) +
(Number.parseFloat(newValue.width.toString()) + 1) * index,
y: Number.parseFloat(this.options.componentPadding.toString())
}
}
@ -749,7 +768,7 @@ struct SegmentButtonItemArrayComponent {
.onHover((isHover: boolean) => {
if (isHover) {
animateTo({ duration: 250, curve: Curve.Friction }, () => {
this.hoverColorArray[index].hoverColor = (SegmentButtonTheme.HOVER_COlOR)
this.hoverColorArray[index].hoverColor = (segmentButtonTheme.HOVER_COLOR)
})
} else {
animateTo({ duration: 250, curve: Curve.Friction }, () => {
@ -791,10 +810,10 @@ struct SegmentButtonItemArrayComponent {
@Observed
class ItemProperty {
fontColor: ResourceColor = SegmentButtonTheme.FONT_COLOR
fontSize: DimensionNoPercentage = SegmentButtonTheme.FONT_SIZE
fontWeight: FontWeight = FontWeight.Regular
isSelected: boolean = false
public fontColor: ResourceColor = segmentButtonTheme.FONT_COLOR
public fontSize: DimensionNoPercentage = segmentButtonTheme.FONT_SIZE
public fontWeight: FontWeight = FontWeight.Regular
public isSelected: boolean = false
}
@Component
@ -919,7 +938,7 @@ export struct SegmentButton {
}
private isMovedFromPanGestureStartPoint(x: number, y: number) {
return!nearEqual(x, this.panGestureStartPoint.x) || !nearEqual(y, this.panGestureStartPoint.y)
return !nearEqual(x, this.panGestureStartPoint.x) || !nearEqual(y, this.panGestureStartPoint.y)
}
build() {
@ -933,7 +952,7 @@ export struct SegmentButton {
} else {
Stack()
.size(this.componentSize)
.backgroundColor(this.options.backgroundColor ?? SegmentButtonTheme.BACKGROUND_COLOR)
.backgroundColor(this.options.backgroundColor ?? segmentButtonTheme.BACKGROUND_COLOR)
.borderRadius(this.options.iconTextBackgroundRadius ?? this.componentSize.height as number / 2)
.backgroundBlurStyle(this.options.backgroundBlurStyle)
}
@ -973,7 +992,8 @@ export struct SegmentButton {
return
}
if (event.type === KeyType.Down) {
if (event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER || event.keyCode === KeyCode.KEYCODE_NUMPAD_ENTER) {
if (event.keyCode === KeyCode.KEYCODE_SPACE || event.keyCode === KeyCode.KEYCODE_ENTER ||
event.keyCode === KeyCode.KEYCODE_NUMPAD_ENTER) {
if (this.options.type === 'capsule' && (this.options.multiply ?? false)) {
if (this.selectedIndexes.indexOf(this.focusIndex) === -1) {
// Select
@ -1008,7 +1028,8 @@ export struct SegmentButton {
continue
}
this.doSelectedChangeAnimate =
this.selectedIndexes[0] > Math.min(this.options.buttons.length, this.buttonItemsSize.length) ? false : true
this.selectedIndexes[0] > Math.min(this.options.buttons.length,
this.buttonItemsSize.length) ? false : true
if (this.options.type === 'capsule' && (this.options.multiply ?? false)) {
if (this.selectedIndexes.indexOf(i) === -1) {
this.selectedIndexes.push(i)
@ -1034,7 +1055,8 @@ export struct SegmentButton {
if (this.isCurrentPositionSelected) {
return
}
if (event.angle > 0 && this.selectedIndexes[0] !== Math.min(this.options.buttons.length, this.buttonItemsSize.length) - 1) {
if (event.angle > 0 && this.selectedIndexes[0] !== Math.min(this.options.buttons.length,
this.buttonItemsSize.length) - 1) {
// Move to next
this.doSelectedChangeAnimate = true
this.selectedIndexes[0] = this.selectedIndexes[0] + 1
@ -1086,7 +1108,8 @@ export struct SegmentButton {
return
}
let selectedInfo = fingerInfo.localX
if (!this.isPanGestureMoved && this.isMovedFromPanGestureStartPoint(fingerInfo.globalX, fingerInfo.globalY)) {
if (!this.isPanGestureMoved && this.isMovedFromPanGestureStartPoint(fingerInfo.globalX,
fingerInfo.globalY)) {
this.isPanGestureMoved = true
}
for (let i = 0; i < Math.min(this.options.buttons.length, this.buttonItemsSize.length); i++) {
@ -1122,7 +1145,8 @@ export struct SegmentButton {
if (fingerInfo === void 0) {
return
}
if (!this.isPanGestureMoved && this.isMovedFromPanGestureStartPoint(fingerInfo.globalX, fingerInfo.globalY)) {
if (!this.isPanGestureMoved && this.isMovedFromPanGestureStartPoint(fingerInfo.globalX,
fingerInfo.globalY)) {
this.isPanGestureMoved = true
}
if (this.isMouseWheelScroll(event)) {
@ -1130,7 +1154,8 @@ export struct SegmentButton {
this.doSelectedChangeAnimate = true
if (offset > 0 && this.selectedIndexes[0] > 0) {
this.selectedIndexes[0] -= 1
} else if (offset < 0 && this.selectedIndexes[0] < Math.min(this.options.buttons.length, this.buttonItemsSize.length) - 1) {
} else if (offset < 0 && this.selectedIndexes[0] < Math.min(this.options.buttons.length,
this.buttonItemsSize.length) - 1) {
this.selectedIndexes[0] += 1
}
this.doSelectedChangeAnimate = false
@ -1158,8 +1183,8 @@ export struct SegmentButton {
this.buttonItemsSelected.forEach((selected, index) => {
this.buttonItemProperty[index].fontColor = selected ?
this.options.selectedFontColor ?? (this.options.type === 'tab' ?
SegmentButtonTheme.TAB_SELECTED_FONT_COLOR : SegmentButtonTheme.CAPSULE_SELECTED_FONT_COLOR) :
this.options.fontColor ?? SegmentButtonTheme.FONT_COLOR
segmentButtonTheme.TAB_SELECTED_FONT_COLOR : segmentButtonTheme.CAPSULE_SELECTED_FONT_COLOR) :
this.options.fontColor ?? segmentButtonTheme.FONT_COLOR
})
}
if (curve) {
@ -1168,8 +1193,8 @@ export struct SegmentButton {
setAnimatedPropertyFunc()
}
this.buttonItemsSelected.forEach((selected, index) => {
this.buttonItemProperty[index].fontSize = selected ? this.options.selectedFontSize ?? SegmentButtonTheme.SELECTED_FONT_SIZE
: this.options.fontSize ?? SegmentButtonTheme.FONT_SIZE
this.buttonItemProperty[index].fontSize = selected ? this.options.selectedFontSize ??
segmentButtonTheme.SELECTED_FONT_SIZE : this.options.fontSize ?? segmentButtonTheme.FONT_SIZE
this.buttonItemProperty[index].fontWeight = selected ? this.options.selectedFontWeight ?? FontWeight.Medium :
this.options.fontWeight ?? FontWeight.Regular
this.buttonItemProperty[index].isSelected = selected

View File

@ -136,10 +136,10 @@ const MediaQueryerRule CSS_LEVEL4_MULTI(
auto mediaFeatureValue = mediaFeature->GetDouble(matchResults[MEDIA_FEATURE], NOT_FOUND);
return CalculateExpression(TransferValue(mediaFeatureValue, matchResults[LEFT_UNIT]),
matchResults[LEFT_RELATIONSHIP], StringToDouble(matchResults[LEFT_CONDITION_VALUE]), failReason) &&
CalculateExpression(StringToDouble(matchResults[RIGHT_CONDITION_VALUE]),
matchResults[RIGHT_RELATIONSHIP], TransferValue(mediaFeatureValue, matchResults[RIGHT_UNIT]),
failReason);
matchResults[LEFT_RELATIONSHIP], StringToDouble(matchResults[LEFT_CONDITION_VALUE]), failReason) &&
CalculateExpression(StringToDouble(matchResults[RIGHT_CONDITION_VALUE]),
matchResults[RIGHT_RELATIONSHIP], TransferValue(mediaFeatureValue, matchResults[RIGHT_UNIT]),
failReason);
},
8);

View File

@ -29,6 +29,6 @@
}; \
\
template<typename ToCheck> \
static inline constexpr const bool has_##method = internal_has_##method<ToCheck>::value;
static inline constexpr const bool has_##method = internal_has_##method<ToCheck>::value
#endif // FOUNDATION_ACE_FRAMEWORKS_BRIDGE_COMMON_UTILS_CLASS_UTILS_H

View File

@ -60,7 +60,7 @@ public:
}
template<class... Args>
static JsiType<T> New(Args&&... args);
static JsiType<T> New(Args &&... args);
void SetWeakCallback(void *ref, panda::WeakRefClearCallBack callback);
const panda::CopyableGlobal<T>& GetHandle() const;

View File

@ -17,7 +17,7 @@
#define FOUNDATION_ARKUI_FRAMEWORKS_CORE_COMMON_ANR_THREAD_H
#include <functional>
#include <stdint.h>
#include <cstdint>
#include <string>
namespace OHOS::Ace {

View File

@ -48,7 +48,7 @@
#endif
#include "core/common/udmf/udmf_client.h"
const int64_t MAX_NUMBER_OF_JS = 0x20000000000000;
static const int64_t MAX_NUMBER_OF_JS = 0x20000000000000;
namespace OHOS::Ace::NG {
namespace {
@ -306,7 +306,7 @@ void FormPattern::OnSnapshot(std::shared_ptr<Media::PixelMap> pixelMap)
auto formPattern = weak.Upgrade();
CHECK_NULL_VOID(formPattern);
formPattern->HandleOnSnapshot(pixelMap);
}, "ArkUIFormHandleOnSnapshot");
}, "ArkUIFormHandleOnSnapshot");
}
void FormPattern::HandleOnSnapshot(std::shared_ptr<Media::PixelMap> pixelMap)
@ -924,7 +924,7 @@ void FormPattern::InitFormManagerDelegate()
CHECK_NULL_VOID(container);
container->SetWindowConfig({ formJsInfo.formWindow.designWidth, formJsInfo.formWindow.autoDesignWidth });
container->RunCard(id, path, module, data, imageDataMap, formJsInfo.formSrc, frontendType, uiSyntax);
}, "ArkUIFormRunCard");
}, "ArkUIFormRunCard");
});
formManagerBridge_->AddFormUpdateCallback(
@ -944,7 +944,7 @@ void FormPattern::InitFormManagerDelegate()
if (form->ISAllowUpdate()) {
form->GetSubContainer()->UpdateCard(data, imageDataMap);
}
}, "ArkUIFormUpdateCard");
}, "ArkUIFormUpdateCard");
});
formManagerBridge_->AddFormErrorCallback(
@ -961,7 +961,7 @@ void FormPattern::InitFormManagerDelegate()
auto form = weak.Upgrade();
CHECK_NULL_VOID(form);
form->FireOnErrorEvent(code, msg);
}, "ArkUIFormFireErrorEvent");
}, "ArkUIFormFireErrorEvent");
});
formManagerBridge_->AddFormUninstallCallback([weak = WeakClaim(this), instanceID](int64_t formId) {
@ -977,7 +977,7 @@ void FormPattern::InitFormManagerDelegate()
auto form = weak.Upgrade();
CHECK_NULL_VOID(form);
form->FireOnUninstallEvent(formId);
}, "ArkUIFormFireUninstallEvent");
}, "ArkUIFormFireUninstallEvent");
});
formManagerBridge_->AddFormSurfaceNodeCallback(
@ -995,7 +995,7 @@ void FormPattern::InitFormManagerDelegate()
auto form = weak.Upgrade();
CHECK_NULL_VOID(form);
form->FireFormSurfaceNodeCallback(node, isDynamic, isRecover);
}, "ArkUIFormFireSurfaceNodeCallback");
}, "ArkUIFormFireSurfaceNodeCallback");
});
formManagerBridge_->AddFormSurfaceChangeCallback([weak = WeakClaim(this), instanceID](float width, float height,
@ -1012,7 +1012,7 @@ void FormPattern::InitFormManagerDelegate()
auto form = weak.Upgrade();
CHECK_NULL_VOID(form);
form->FireFormSurfaceChangeCallback(width, height, borderWidth);
}, "ArkUIFormFireSurfaceChange");
}, "ArkUIFormFireSurfaceChange");
});
formManagerBridge_->AddFormSurfaceDetachCallback([weak = WeakClaim(this), instanceID]() {
@ -1043,7 +1043,7 @@ void FormPattern::InitFormManagerDelegate()
auto formPattern = weak.Upgrade();
CHECK_NULL_VOID(formPattern);
formPattern->HandleUnTrustForm();
}, "ArkUIFormHandleUnTrust");
}, "ArkUIFormHandleUnTrust");
});
formManagerBridge_->AddSnapshotCallback([weak = WeakClaim(this), instanceID](const uint32_t& delayTime) {
@ -1233,7 +1233,7 @@ void FormPattern::CreateCardContainer()
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->FireOnAcquiredEvent(id);
}, "ArkUIFormFireAcquiredEvent");
}, "ArkUIFormFireAcquiredEvent");
});
subContainer_->SetFormLoadCallback([weak = WeakClaim(this)]() {
@ -1368,7 +1368,7 @@ void FormPattern::OnLoadEvent()
auto pattern = weak.Upgrade();
CHECK_NULL_VOID(pattern);
pattern->FireOnLoadEvent();
}, "ArkUIFormFireLoadEvent");
}, "ArkUIFormFireLoadEvent");
}
void FormPattern::OnActionEvent(const std::string& action)
@ -1403,7 +1403,7 @@ void FormPattern::OnActionEvent(const std::string& action)
auto eventAction = JsonUtil::ParseJsonString(action);
TAG_LOGI(AceLogTag::ACE_FORM, "UI task execute begin.");
pattern->FireOnRouterEvent(eventAction);
}, "ArkUIFormFireRouterEvent");
}, "ArkUIFormFireRouterEvent");
}
}

View File

@ -152,7 +152,7 @@ struct SafeAreaExpandOpts {
return "SafeAreaExpandOpts: type:" + TypeToString() + ", edges: " + EdgeToString();
}
std::string TypeToString()
const std::string TypeToString()
{
switch (type) {
case SAFE_AREA_TYPE_NONE:
@ -170,7 +170,7 @@ struct SafeAreaExpandOpts {
}
}
std::string EdgeToString()
const std::string EdgeToString()
{
switch (edges) {
case SAFE_AREA_EDGE_NONE:

View File

@ -542,9 +542,9 @@ const char MODEL_COMPONENT_TAG[] = "Component3DComponent";
const char MODEL_ETS_TAG[] = "Component3D";
// window scene
ACE_EXPORT extern const char ROOT_SCENE_ETS_TAG[] = "RootScene";
ACE_EXPORT extern const char SCREEN_ETS_TAG[] = "Screen";
ACE_EXPORT extern const char WINDOW_SCENE_ETS_TAG[] = "WindowScene";
ACE_EXPORT const char ROOT_SCENE_ETS_TAG[] = "RootScene";
ACE_EXPORT const char SCREEN_ETS_TAG[] = "Screen";
ACE_EXPORT const char WINDOW_SCENE_ETS_TAG[] = "WindowScene";
// ui_extension_component
const char UI_EXTENSION_COMPONENT_TAG[] = "UIExtensionComponent";

View File

@ -23,10 +23,10 @@
extern "C" {
#endif
const struct ArkUINodeModifiers* GetArkUINodeModifiers();
const struct ArkUINodeModifiers* GetArkUINodeModifiers(void);
// use internal, not for export.
const struct ArkUIFullNodeAPI* GetArkUIFullNodeAPI();
const struct ArkUIFullNodeAPI* GetArkUIFullNodeAPI(void);
void SendArkUIAsyncEvent(struct ArkUINodeEvent* event);
void SendArkUIAsyncCustomEvent(struct ArkUICustomNodeEvent* event);
#ifdef __cplusplus

View File

@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_CONTENT_MODIFIER_H
#define FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_CONTENT_MODIFIER_H
#pragma once
@ -20,3 +22,4 @@
namespace OHOS::Ace::NG::NodeModifier {
const ArkUINodeContentModifier* GetNodeContentModifier();
} // namespace OHOS::Ace::NG::NodeModifier
#endif

View File

@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_TEXT_AREA_MODIFIER_H
#define FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_NODE_TEXT_AREA_MODIFIER_H
#pragma once
@ -28,3 +30,4 @@ namespace OHOS::Ace::NG::NodeModifier {
void SetTextAreaOnTextContentScroll(ArkUINodeHandle node, void* extraParam);
void SetTextAreaOnSubmit(ArkUINodeHandle node, void* extraParam);
} // namespace OHOS::Ace::NG::NodeModifier
#endif

View File

@ -12,6 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_VIEW_MODEL_H
#define FRAMEWORKS_CORE_INTERFACES_NATIVE_NODE_VIEW_MODEL_H
#pragma once
@ -59,3 +61,4 @@ void SetAttachNodePtr(ArkUINodeHandle nodePtr, void* attachNode);
void* GetAttachNodePtr(ArkUINodeHandle nodePtr);
} // namespace OHOS::Ace::NG::ViewModel
#endif

View File

@ -6766,8 +6766,8 @@ typedef void (*ArkUI_NodeContentCallback)(ArkUI_NodeContentEvent* event);
* @brief Register a callback for this <b>ArkUI_NodeContentHandle</b> instance.
*
* @param handle Indicates the <b>ArkUI_NodeContentHandle</b> instance.
* @param callback Indicates the callback of <b>ArkUI_NodeContentHandle</b>
* @return Returns the status code
* @param callback Indicates the callback of <b>ArkUI_NodeContentHandle</b>
* @return Returns the status code
* @since 12
*/
int32_t OH_ArkUI_NodeContent_RegisterCallback(ArkUI_NodeContentHandle handle, ArkUI_NodeContentCallback callback);

View File

@ -45,6 +45,33 @@ constexpr int32_t ORIGIN_MOUSE_BUTTON_MIDDLE = 4;
constexpr int32_t ORIGIN_MOUSE_BUTTON_BACK = 8;
constexpr int32_t ORIGIN_MOUSE_BUTTON_FORWARD = 16;
void ConvertToOriginEvent(const ArkUITouchEvent& origin, ArkUI_NodeTouchEvent& event)
{
if (origin.sourceType == UI_INPUT_EVENTT_SOURCE_TYPE_TOUCH_SCREEN) {
event.sourceType = NODE_SOURCE_TYPE_TOUCH_SCREEN;
} else {
event.sourceType = NODE_SOURCE_TYPE_UNKNOWN;
}
switch (origin.action) {
case static_cast<int32_t>(TouchType::DOWN):
event.action = NODE_ACTION_DOWN;
break;
// TouchType::UP
case static_cast<int32_t>(TouchType::UP):
event.action = NODE_ACTION_UP;
break;
// TouchType::MOVE
case static_cast<int32_t>(TouchType::MOVE):
event.action = NODE_ACTION_MOVE;
break;
case static_cast<int32_t>(TouchType::CANCEL):
event.action = NODE_ACTION_CANCEL;
break;
default:
event.action = static_cast<ArkUI_NodeTouchEventAction>(-1);
}
}
void ConvertToTouchEvent(const ArkUITouchEvent& origin, ArkUI_NodeTouchEvent& event)
{
memset_s(&event, sizeof(ArkUI_NodeTouchEvent), 0, sizeof(ArkUI_NodeTouchEvent));
@ -67,30 +94,7 @@ void ConvertToTouchEvent(const ArkUITouchEvent& origin, ArkUI_NodeTouchEvent& ev
event.actionTouch.rawY = origin.actionTouchPoint.rawY;
event.timeStamp = origin.timeStamp;
if (origin.sourceType == UI_INPUT_EVENTT_SOURCE_TYPE_TOUCH_SCREEN) {
event.sourceType = NODE_SOURCE_TYPE_TOUCH_SCREEN;
} else {
event.sourceType = NODE_SOURCE_TYPE_UNKNOWN;
}
switch (origin.action) {
case static_cast<int32_t>(TouchType::DOWN):
event.action = NODE_ACTION_DOWN;
break;
// TouchType::UP
case static_cast<int32_t>(TouchType::UP):
event.action = NODE_ACTION_UP;
break;
// TouchType::MOVE
case static_cast<int32_t>(TouchType::MOVE):
event.action = NODE_ACTION_MOVE;
break;
case static_cast<int32_t>(TouchType::CANCEL):
event.action = NODE_ACTION_CANCEL;
break;
default:
event.action = static_cast<ArkUI_NodeTouchEventAction>(-1);
}
ConvertToOriginEvent(origin, event);
static ArkUI_Uint32 touchPointSize = origin.touchPointSize;
static ArkUITouchPoint* touchPoints = origin.touchPointes;
auto getTouchPoints = [](ArkUI_NodeTouchPoint** points) -> ArkUI_Int32 {

View File

@ -37,8 +37,7 @@
#ifndef ARKUI_NATIVE_COMPATIBLE
#define ARKUI_NATIVE_COMPATIBLE
#include <stdbool.h>
#include <stdint.h>
#include <cstdint>
#include "native_node.h"
#include "native_type.h"

View File

@ -369,6 +369,24 @@ void UnregisterOnEvent()
g_eventReceiver = nullptr;
}
void SetNodeEvent(ArkUINodeEvent* innerEvent)
{
auto nativeNodeEventType = GetNativeNodeEventType(innerEvent);
auto eventType = static_cast<ArkUI_NodeEventType>(nativeNodeEventType);
auto* nodePtr = reinterpret_cast<ArkUI_NodeHandle>(innerEvent->extraParam);
auto extraData = reinterpret_cast<ExtraData*>(nodePtr->extraData);
auto innerEventExtraParam = extraData->eventMap.find(eventType);
if (g_compatibleEventReceiver) {
ArkUI_CompatibleNodeEvent nodeEvent;
nodeEvent.node = nodePtr;
nodeEvent.eventId = innerEventExtraParam->second->targetId;
if (ConvertEvent(innerEvent, &nodeEvent)) {
g_compatibleEventReceiver(&nodeEvent);
ConvertEventResult(&nodeEvent, innerEvent);
}
}
}
void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent)
{
if (!innerEvent) {
@ -415,15 +433,7 @@ void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent)
}
HandleNodeEvent(&event);
}
if (g_compatibleEventReceiver) {
ArkUI_CompatibleNodeEvent event;
event.node = nodePtr;
event.eventId = innerEventExtraParam->second->targetId;
if (ConvertEvent(innerEvent, &event)) {
g_compatibleEventReceiver(&event);
ConvertEventResult(&event, innerEvent);
}
}
SetNodeEvent(innerEvent);
}
int32_t GetNativeNodeEventType(ArkUINodeEvent* innerEvent)
@ -483,7 +493,6 @@ void HandleNodeEvent(ArkUI_NodeEvent* event)
int32_t CheckEvent(ArkUI_NodeEvent* event)
{
// TODO.
return 0;
}
@ -510,7 +519,7 @@ int32_t SetLengthMetricUnit(ArkUI_NodeHandle nodePtr, ArkUI_LengthMetricUnit uni
return ERROR_CODE_PARAM_INVALID;
}
if (!InRegion(static_cast<int32_t>(ARKUI_LENGTH_METRIC_UNIT_DEFAULT),
static_cast<int32_t>(ARKUI_LENGTH_METRIC_UNIT_FP), static_cast<int32_t>(unit))) {
static_cast<int32_t>(ARKUI_LENGTH_METRIC_UNIT_FP), static_cast<int32_t>(unit))) {
return ERROR_CODE_PARAM_INVALID;
}
nodePtr->lengthMetricUnit = unit;

View File

@ -35,7 +35,7 @@
#ifndef _ARKUI_UI_INPUT_EVENT_H_
#define _ARKUI_UI_INPUT_EVENT_H_
#include <stdint.h>
#include <cstdint>
#ifdef __cplusplus
extern "C" {