Skip to content

Commit 47fda32

Browse files
committed
refactor: delete redundant commented code
1 parent 42fb9ce commit 47fda32

File tree

1 file changed

+23
-103
lines changed

1 file changed

+23
-103
lines changed

harmony/clip_path/src/main/ets/ClipPathCode.ets

Lines changed: 23 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { TViewBox, IViewPort, TChildrenBuilder } from './types'
32
import ListPanel from './ListPanel'
43

@@ -71,29 +70,8 @@ export struct ClipPathCode {
7170
@Prop scOx: number = 0;
7271
@Prop scOy: number = 0;
7372
@Prop scPercentageValue: boolean = false;
74-
75-
76-
// ctx!: RNOHContext
77-
// tag: number = 0
78-
// @State descriptor: ClipPathDescriptor = {} as ClipPathDescriptor
79-
// @BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
8073
@BuilderParam childrenBuilder: TChildrenBuilder = this.defaultChildrenBuilder
81-
// private unregisterDescriptorChangesListener?: () => void = undefined
82-
@State propertyArr: Array<string> = [];
83-
84-
// aboutToAppear() {
85-
// this.descriptor = this.ctx.descriptorRegistry.getDescriptor<ClipPathDescriptor>(this.tag)
86-
// this.unregisterDescriptorChangesListener = this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag,
87-
// (newDescriptor) => {
88-
// this.descriptor = (newDescriptor as ClipPathDescriptor)
89-
// }
90-
// )
91-
// this.propertyArr = Object.entries(this).map((item: Array<string>) => `${item[0]}: ${item[1]}`)
92-
// }
93-
94-
// aboutToDisappear() {
95-
// this.unregisterDescriptorChangesListener?.()
96-
// }
74+
@State propertyArr: Array<string> = [];
9775

9876
computedShapeWidth(): string {
9977
const viewBox = this.computedViewBoxParam()
@@ -108,18 +86,14 @@ export struct ClipPathCode {
10886
computedClipParams(): PathAttribute | boolean {
10987
const openClip = this.openClip
11088
const d = this.d
111-
// const viewBox = this.computedViewBoxParam()
11289
return openClip ? new Path({ commands: d }) : false
11390
}
91+
11492
computedViewBoxParam(): IViewPort {
11593
const viewBox = this.viewBox
116-
if (viewBox?.length !== 4) return {}
117-
// return {
118-
// x: viewBox[0],
119-
// y: viewBox[1],
120-
// width: viewBox[2],
121-
// height: viewBox[3]
122-
// }
94+
if (viewBox?.length !== 4) {
95+
return {}
96+
}
12397
return {
12498
x: viewBox[0] + 'px',
12599
y: viewBox[1] + 'px',
@@ -155,18 +129,30 @@ export struct ClipPathCode {
155129

156130
computedStrokeCap(): LineCapStyle {
157131
let strokeCap = this.strokeCap || 'butt'
158-
if(String(strokeCap).toLowerCase() === "butt") return LineCapStyle.Butt
159-
if(String(strokeCap).toLowerCase() === "round") return LineCapStyle.Round
160-
if(String(strokeCap).toLowerCase() === "square") return LineCapStyle.Square
132+
if (String(strokeCap).toLowerCase() === "butt") {
133+
return LineCapStyle.Butt
134+
}
135+
if (String(strokeCap).toLowerCase() === "round") {
136+
return LineCapStyle.Round
137+
}
138+
if (String(strokeCap).toLowerCase() === "square") {
139+
return LineCapStyle.Square
140+
}
161141
return LineCapStyle.Butt
162142
}
163143

164144
computedStrokeJoin(): LineJoinStyle {
165145
let strokeJoin = this.strokeJoin || 'miter'
166146
// bevel/miter/round
167-
if(String(strokeJoin).toLowerCase() === "miter") return LineJoinStyle.Miter
168-
if(String(strokeJoin).toLowerCase() === "round") return LineJoinStyle.Round
169-
if(String(strokeJoin).toLowerCase() === "bevel") return LineJoinStyle.Bevel
147+
if (String(strokeJoin).toLowerCase() === "miter") {
148+
return LineJoinStyle.Miter
149+
}
150+
if (String(strokeJoin).toLowerCase() === "round") {
151+
return LineJoinStyle.Round
152+
}
153+
if (String(strokeJoin).toLowerCase() === "bevel") {
154+
return LineJoinStyle.Bevel
155+
}
170156
return LineJoinStyle.Miter
171157
}
172158

@@ -179,11 +165,6 @@ export struct ClipPathCode {
179165
const transX = this.transX || 0
180166
const transY = this.transY || 0
181167
const transPercentageValue = this.transPercentageValue || false
182-
// let val: TranslateOptions = {
183-
// x: transX || 0,
184-
// y: transY || 0,
185-
// z: 0
186-
// }
187168
let val: TranslateOptions = {
188169
x: `${transX}px`,
189170
y: `${transY}px`,
@@ -208,13 +189,6 @@ export struct ClipPathCode {
208189
centerY: rotO
209190
} as RotateOptions
210191

211-
// if(rotOx || (rotOx === 0)){
212-
// val.centerX = rotOx || 0
213-
// }
214-
// if(rotOy || (rotOy === 0)){
215-
// val.centerY = rotOy || 0
216-
// }
217-
218192
if (rotOx) {
219193
val.centerX = `${rotOx}px`
220194
}
@@ -260,13 +234,6 @@ export struct ClipPathCode {
260234
centerY: `${scO}px`
261235
} as RotateOptions
262236

263-
// if(scOx || (scOx === 0)){
264-
// val.centerX = scOx || 0
265-
// }
266-
// if(scOy || (scOy === 0)){
267-
// val.centerY = scOy || 0
268-
// }
269-
270237
if (scX !== 1) {
271238
val.x = scX
272239
}
@@ -298,45 +265,7 @@ export struct ClipPathCode {
298265
defaultChildrenBuilder() {
299266
};
300267

301-
// build() {
302-
// Column() {
303-
// if (this.showProperty) {
304-
// ListPanel({
305-
// arr: this.propertyArr
306-
// })
307-
// }
308-
// Shape() {
309-
// Path({
310-
// commands: this.d
311-
// })
312-
// Column() {
313-
// this.childrenBuilder()
314-
// ForEach(this.descriptor.childrenTags, (tag: Tag) => {
315-
// Column() {
316-
// RNComponentFactory({ ctx: this.ctx, tag: tag, buildCustomComponent: this.buildCustomComponent })
317-
// }
318-
// }, (tag: Tag) => tag.toString())
319-
// }
320-
// .alignItems(HorizontalAlign.Start)
321-
// }
322-
// .key(this.computedKey())
323-
// .viewPort(this.computedViewBoxParam())
324-
// .fill(this.computedFill())
325-
// .stroke(this.computedStroke())
326-
// .strokeWidth(this.computedStrokeWidth())
327-
// .strokeMiterLimit(this.computedStrokeMiter())
328-
// .strokeLineCap(this.computedStrokeCap())
329-
// .strokeLineJoin(this.computedStrokeJoin())
330-
// .zIndex(this.computedTranslateZ())
331-
// .translate(this.computedTranslateValue())
332-
// .scale(this.computedScaleValue())
333-
// .rotate(this.computedRotateValue())
334-
// .clip(this.computedClipParams())
335-
// }
336-
// }
337-
338268
build() {
339-
// RNViewBase({ ctx: this.ctx, tag: this.tag }) {
340269
Column() {
341270
if (this.showProperty) {
342271
ListPanel({
@@ -349,20 +278,11 @@ export struct ClipPathCode {
349278
})
350279
Column() {
351280
this.childrenBuilder()
352-
// ForEach(this.descriptor.childrenTags, (tag: Tag) => {
353-
// Column() {
354-
// RNComponentFactory({ ctx: this.ctx, tag: tag, buildCustomComponent: this.buildCustomComponent })
355-
// }
356-
// }, (tag: Tag) => tag.toString())
357281
}
358282
.alignItems(HorizontalAlign.Start)
359-
// .width('100%')
360-
// .height('100%')
361-
// .clip(true)
362283
}
363284
.width(this.computedShapeWidth())
364285
.height(this.computedShapeHeight())
365-
// .backgroundColor(Color.Pink)
366286
.key(this.computedKey())
367287
.viewPort(this.computedViewBoxParam())
368288
.fill(this.computedFill())

0 commit comments

Comments
 (0)