1
-
2
1
import { TViewBox, IViewPort, TChildrenBuilder } from './types'
3
2
import ListPanel from './ListPanel'
4
3
@@ -71,29 +70,8 @@ export struct ClipPathCode {
71
70
@Prop scOx: number = 0;
72
71
@Prop scOy: number = 0;
73
72
@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
80
73
@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> = [];
97
75
98
76
computedShapeWidth(): string {
99
77
const viewBox = this.computedViewBoxParam()
@@ -108,18 +86,14 @@ export struct ClipPathCode {
108
86
computedClipParams(): PathAttribute | boolean {
109
87
const openClip = this.openClip
110
88
const d = this.d
111
- // const viewBox = this.computedViewBoxParam()
112
89
return openClip ? new Path({ commands: d }) : false
113
90
}
91
+
114
92
computedViewBoxParam(): IViewPort {
115
93
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
+ }
123
97
return {
124
98
x: viewBox[0] + 'px',
125
99
y: viewBox[1] + 'px',
@@ -155,18 +129,30 @@ export struct ClipPathCode {
155
129
156
130
computedStrokeCap(): LineCapStyle {
157
131
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
+ }
161
141
return LineCapStyle.Butt
162
142
}
163
143
164
144
computedStrokeJoin(): LineJoinStyle {
165
145
let strokeJoin = this.strokeJoin || 'miter'
166
146
// 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
+ }
170
156
return LineJoinStyle.Miter
171
157
}
172
158
@@ -179,11 +165,6 @@ export struct ClipPathCode {
179
165
const transX = this.transX || 0
180
166
const transY = this.transY || 0
181
167
const transPercentageValue = this.transPercentageValue || false
182
- // let val: TranslateOptions = {
183
- // x: transX || 0,
184
- // y: transY || 0,
185
- // z: 0
186
- // }
187
168
let val: TranslateOptions = {
188
169
x: `${transX}px`,
189
170
y: `${transY}px`,
@@ -208,13 +189,6 @@ export struct ClipPathCode {
208
189
centerY: rotO
209
190
} as RotateOptions
210
191
211
- // if(rotOx || (rotOx === 0)){
212
- // val.centerX = rotOx || 0
213
- // }
214
- // if(rotOy || (rotOy === 0)){
215
- // val.centerY = rotOy || 0
216
- // }
217
-
218
192
if (rotOx) {
219
193
val.centerX = `${rotOx}px`
220
194
}
@@ -260,13 +234,6 @@ export struct ClipPathCode {
260
234
centerY: `${scO}px`
261
235
} as RotateOptions
262
236
263
- // if(scOx || (scOx === 0)){
264
- // val.centerX = scOx || 0
265
- // }
266
- // if(scOy || (scOy === 0)){
267
- // val.centerY = scOy || 0
268
- // }
269
-
270
237
if (scX !== 1) {
271
238
val.x = scX
272
239
}
@@ -298,45 +265,7 @@ export struct ClipPathCode {
298
265
defaultChildrenBuilder() {
299
266
};
300
267
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
-
338
268
build() {
339
- // RNViewBase({ ctx: this.ctx, tag: this.tag }) {
340
269
Column() {
341
270
if (this.showProperty) {
342
271
ListPanel({
@@ -349,20 +278,11 @@ export struct ClipPathCode {
349
278
})
350
279
Column() {
351
280
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())
357
281
}
358
282
.alignItems(HorizontalAlign.Start)
359
- // .width('100%')
360
- // .height('100%')
361
- // .clip(true)
362
283
}
363
284
.width(this.computedShapeWidth())
364
285
.height(this.computedShapeHeight())
365
- // .backgroundColor(Color.Pink)
366
286
.key(this.computedKey())
367
287
.viewPort(this.computedViewBoxParam())
368
288
.fill(this.computedFill())
0 commit comments