forked from line/line-bot-sdk-go
/
flex.go
678 lines (595 loc) · 21.7 KB
/
flex.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
// Copyright 2018 LINE Corporation
//
// LINE Corporation licenses this file to you 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.
package linebot
import "encoding/json"
// FlexContainerType type
type FlexContainerType string
// IntPtr is a helper function for using *int values
func IntPtr(v int) *int {
return &v
}
// FlexContainerType constants
const (
FlexContainerTypeBubble FlexContainerType = "bubble"
FlexContainerTypeCarousel FlexContainerType = "carousel"
)
// FlexComponentType type
type FlexComponentType string
// FlexComponentType constants
const (
FlexComponentTypeBox FlexComponentType = "box"
FlexComponentTypeButton FlexComponentType = "button"
FlexComponentTypeFiller FlexComponentType = "filler"
FlexComponentTypeIcon FlexComponentType = "icon"
FlexComponentTypeImage FlexComponentType = "image"
FlexComponentTypeSeparator FlexComponentType = "separator"
FlexComponentTypeSpacer FlexComponentType = "spacer"
FlexComponentTypeText FlexComponentType = "text"
)
// FlexBubbleSizeType type
type FlexBubbleSizeType string
// FlexBubbleSizeType constants
const (
FlexBubbleSizeTypeNano FlexBubbleSizeType = "nano"
FlexBubbleSizeTypeMicro FlexBubbleSizeType = "micro"
FlexBubbleSizeTypeKilo FlexBubbleSizeType = "kilo"
FlexBubbleSizeTypeMega FlexBubbleSizeType = "mega"
FlexBubbleSizeTypeGiga FlexBubbleSizeType = "giga"
)
// FlexBubbleDirectionType type
type FlexBubbleDirectionType string
// FlexBubbleDirectionType constants
const (
FlexBubbleDirectionTypeLTR FlexBubbleDirectionType = "ltr"
FlexBubbleDirectionTypeRTL FlexBubbleDirectionType = "rtl"
)
// FlexButtonStyleType type
type FlexButtonStyleType string
// FlexButtonStyleType constants
const (
FlexButtonStyleTypeLink FlexButtonStyleType = "link"
FlexButtonStyleTypePrimary FlexButtonStyleType = "primary"
FlexButtonStyleTypeSecondary FlexButtonStyleType = "secondary"
)
// FlexButtonHeightType type
type FlexButtonHeightType string
// FlexButtonHeightType constants
const (
FlexButtonHeightTypeMd FlexButtonHeightType = "md"
FlexButtonHeightTypeSm FlexButtonHeightType = "sm"
)
// FlexIconAspectRatioType type
type FlexIconAspectRatioType string
// FlexIconAspectRatioType constants
const (
FlexIconAspectRatioType1to1 FlexIconAspectRatioType = "1:1"
FlexIconAspectRatioType2to1 FlexIconAspectRatioType = "2:1"
FlexIconAspectRatioType3to1 FlexIconAspectRatioType = "3:1"
)
// FlexImageSizeType type
type FlexImageSizeType string
// FlexImageSizeType constants
const (
FlexImageSizeTypeXxs FlexImageSizeType = "xxs"
FlexImageSizeTypeXs FlexImageSizeType = "xs"
FlexImageSizeTypeSm FlexImageSizeType = "sm"
FlexImageSizeTypeMd FlexImageSizeType = "md"
FlexImageSizeTypeLg FlexImageSizeType = "lg"
FlexImageSizeTypeXl FlexImageSizeType = "xl"
FlexImageSizeTypeXxl FlexImageSizeType = "xxl"
FlexImageSizeType3xl FlexImageSizeType = "3xl"
FlexImageSizeType4xl FlexImageSizeType = "4xl"
FlexImageSizeType5xl FlexImageSizeType = "5xl"
FlexImageSizeTypeFull FlexImageSizeType = "full"
)
// FlexImageAspectRatioType type
type FlexImageAspectRatioType string
// FlexImageAspectRatioType constants
const (
FlexImageAspectRatioType1to1 FlexImageAspectRatioType = "1:1"
FlexImageAspectRatioType1_51to1 FlexImageAspectRatioType = "1.51:1"
FlexImageAspectRatioType1_91to1 FlexImageAspectRatioType = "1.91:1"
FlexImageAspectRatioType4to3 FlexImageAspectRatioType = "4:3"
FlexImageAspectRatioType16to9 FlexImageAspectRatioType = "16:9"
FlexImageAspectRatioType20to13 FlexImageAspectRatioType = "20:13"
FlexImageAspectRatioType2to1 FlexImageAspectRatioType = "2:1"
FlexImageAspectRatioType3to1 FlexImageAspectRatioType = "3:1"
FlexImageAspectRatioType3to4 FlexImageAspectRatioType = "3:4"
FlexImageAspectRatioType9to16 FlexImageAspectRatioType = "9:16"
FlexImageAspectRatioType1to2 FlexImageAspectRatioType = "1:2"
FlexImageAspectRatioType1to3 FlexImageAspectRatioType = "1:3"
)
// FlexImageAspectModeType type
type FlexImageAspectModeType string
// FlexImageAspectModeType constants
const (
FlexImageAspectModeTypeCover FlexImageAspectModeType = "cover"
FlexImageAspectModeTypeFit FlexImageAspectModeType = "fit"
)
// FlexBoxLayoutType type
type FlexBoxLayoutType string
// FlexBoxLayoutType constants
const (
FlexBoxLayoutTypeHorizontal FlexBoxLayoutType = "horizontal"
FlexBoxLayoutTypeVertical FlexBoxLayoutType = "vertical"
FlexBoxLayoutTypeBaseline FlexBoxLayoutType = "baseline"
)
// FlexComponentSpacingType type
type FlexComponentSpacingType string
// FlexComponentSpacingType constants
const (
FlexComponentSpacingTypeNone FlexComponentSpacingType = "none"
FlexComponentSpacingTypeXs FlexComponentSpacingType = "xs"
FlexComponentSpacingTypeSm FlexComponentSpacingType = "sm"
FlexComponentSpacingTypeMd FlexComponentSpacingType = "md"
FlexComponentSpacingTypeLg FlexComponentSpacingType = "lg"
FlexComponentSpacingTypeXl FlexComponentSpacingType = "xl"
FlexComponentSpacingTypeXxl FlexComponentSpacingType = "xxl"
)
// FlexComponentMarginType type
type FlexComponentMarginType string
// FlexComponentMarginType constants
const (
FlexComponentMarginTypeNone FlexComponentMarginType = "none"
FlexComponentMarginTypeXs FlexComponentMarginType = "xs"
FlexComponentMarginTypeSm FlexComponentMarginType = "sm"
FlexComponentMarginTypeMd FlexComponentMarginType = "md"
FlexComponentMarginTypeLg FlexComponentMarginType = "lg"
FlexComponentMarginTypeXl FlexComponentMarginType = "xl"
FlexComponentMarginTypeXxl FlexComponentMarginType = "xxl"
)
// FlexComponentGravityType type
type FlexComponentGravityType string
// FlexComponentGravityType constants
const (
FlexComponentGravityTypeTop FlexComponentGravityType = "top"
FlexComponentGravityTypeBottom FlexComponentGravityType = "bottom"
FlexComponentGravityTypeCenter FlexComponentGravityType = "center"
)
// FlexComponentAlignType type
type FlexComponentAlignType string
// FlexComponentAlignType constants
const (
FlexComponentAlignTypeStart FlexComponentAlignType = "start"
FlexComponentAlignTypeEnd FlexComponentAlignType = "end"
FlexComponentAlignTypeCenter FlexComponentAlignType = "center"
)
// FlexComponentCornerRadiusType type
type FlexComponentCornerRadiusType string
// FlexComponentCornerRadius constants
const (
FlexComponentCornerRadiusTypeNone FlexComponentCornerRadiusType = "none"
FlexComponentCornerRadiusTypeXs FlexComponentCornerRadiusType = "xs"
FlexComponentCornerRadiusTypeSm FlexComponentCornerRadiusType = "sm"
FlexComponentCornerRadiusTypeMd FlexComponentCornerRadiusType = "md"
FlexComponentCornerRadiusTypeLg FlexComponentCornerRadiusType = "lg"
FlexComponentCornerRadiusTypeXl FlexComponentCornerRadiusType = "xl"
FlexComponentCornerRadiusTypeXxl FlexComponentCornerRadiusType = "xxl"
)
// FlexComponentOffsetType type
type FlexComponentOffsetType string
// FlexComponentOffsetType constants
const (
FlexComponentOffsetTypeNone FlexComponentOffsetType = "none"
FlexComponentOffsetTypeXs FlexComponentOffsetType = "xs"
FlexComponentOffsetTypeSm FlexComponentOffsetType = "sm"
FlexComponentOffsetTypeMd FlexComponentOffsetType = "md"
FlexComponentOffsetTypeLg FlexComponentOffsetType = "lg"
FlexComponentOffsetTypeXl FlexComponentOffsetType = "xl"
FlexComponentOffsetTypeXxl FlexComponentOffsetType = "xxl"
)
// FlexIconSizeType type
type FlexIconSizeType string
// FlexIconSizeType constants
const (
FlexIconSizeTypeXxs FlexIconSizeType = "xxs"
FlexIconSizeTypeXs FlexIconSizeType = "xs"
FlexIconSizeTypeSm FlexIconSizeType = "sm"
FlexIconSizeTypeMd FlexIconSizeType = "md"
FlexIconSizeTypeLg FlexIconSizeType = "lg"
FlexIconSizeTypeXl FlexIconSizeType = "xl"
FlexIconSizeTypeXxl FlexIconSizeType = "xxl"
FlexIconSizeType3xl FlexIconSizeType = "3xl"
FlexIconSizeType4xl FlexIconSizeType = "4xl"
FlexIconSizeType5xl FlexIconSizeType = "5xl"
)
// FlexSpacerSizeType type
type FlexSpacerSizeType string
// FlexSpacerSizeType constants
const (
FlexSpacerSizeTypeXs FlexSpacerSizeType = "xs"
FlexSpacerSizeTypeSm FlexSpacerSizeType = "sm"
FlexSpacerSizeTypeMd FlexSpacerSizeType = "md"
FlexSpacerSizeTypeLg FlexSpacerSizeType = "lg"
FlexSpacerSizeTypeXl FlexSpacerSizeType = "xl"
FlexSpacerSizeTypeXxl FlexSpacerSizeType = "xxl"
)
// FlexTextWeightType type
type FlexTextWeightType string
// FlexTextWeightType constants
const (
FlexTextWeightTypeRegular FlexTextWeightType = "regular"
FlexTextWeightTypeBold FlexTextWeightType = "bold"
)
// FlexTextSizeType type
type FlexTextSizeType string
// FlexTextSizeType constants
const (
FlexTextSizeTypeXxs FlexTextSizeType = "xxs"
FlexTextSizeTypeXs FlexTextSizeType = "xs"
FlexTextSizeTypeSm FlexTextSizeType = "sm"
FlexTextSizeTypeMd FlexTextSizeType = "md"
FlexTextSizeTypeLg FlexTextSizeType = "lg"
FlexTextSizeTypeXl FlexTextSizeType = "xl"
FlexTextSizeTypeXxl FlexTextSizeType = "xxl"
FlexTextSizeType3xl FlexTextSizeType = "3xl"
FlexTextSizeType4xl FlexTextSizeType = "4xl"
FlexTextSizeType5xl FlexTextSizeType = "5xl"
)
// FlexTextStyleType type
type FlexTextStyleType string
// FlexTextStyleType constants
const (
FlexTextStyleTypeNormal FlexTextStyleType = "normal"
FlexTextStyleTypeItalic FlexTextStyleType = "italic"
)
// FlexTextDecorationType type
type FlexTextDecorationType string
// FlexTextDecorationType constants
const (
FlexTextDecorationTypeNone FlexTextDecorationType = "none"
FlexTextDecorationTypeUnderline FlexTextDecorationType = "underline"
FlexTextDecorationTypeLineThrough FlexTextDecorationType = "line-through"
)
// FlexContainer interface
type FlexContainer interface {
FlexContainer()
}
// BubbleContainer type
type BubbleContainer struct {
Type FlexContainerType
Size FlexBubbleSizeType
Direction FlexBubbleDirectionType
Header *BoxComponent
Hero *ImageComponent
Body *BoxComponent
Footer *BoxComponent
Styles *BubbleStyle
}
// MarshalJSON method of BubbleContainer
func (c *BubbleContainer) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexContainerType `json:"type"`
Size FlexBubbleSizeType `json:"size,omitempty"`
Direction FlexBubbleDirectionType `json:"direction,omitempty"`
Header *BoxComponent `json:"header,omitempty"`
Hero *ImageComponent `json:"hero,omitempty"`
Body *BoxComponent `json:"body,omitempty"`
Footer *BoxComponent `json:"footer,omitempty"`
Styles *BubbleStyle `json:"styles,omitempty"`
}{
Type: FlexContainerTypeBubble,
Size: c.Size,
Direction: c.Direction,
Header: c.Header,
Hero: c.Hero,
Body: c.Body,
Footer: c.Footer,
Styles: c.Styles,
})
}
// CarouselContainer type
type CarouselContainer struct {
Type FlexContainerType
Contents []*BubbleContainer
}
// MarshalJSON method of CarouselContainer
func (c *CarouselContainer) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexContainerType `json:"type"`
Contents []*BubbleContainer `json:"contents"`
}{
Type: FlexContainerTypeCarousel,
Contents: c.Contents,
})
}
// FlexContainer implements FlexContainer interface
func (*BubbleContainer) FlexContainer() {}
// FlexContainer implements FlexContainer interface
func (*CarouselContainer) FlexContainer() {}
// BubbleStyle type
type BubbleStyle struct {
Header *BlockStyle `json:"header,omitempty"`
Hero *BlockStyle `json:"hero,omitempty"`
Body *BlockStyle `json:"body,omitempty"`
Footer *BlockStyle `json:"footer,omitempty"`
}
// BlockStyle type
type BlockStyle struct {
BackgroundColor string `json:"backgroundColor,omitempty"`
Separator bool `json:"separator,omitempty"`
SeparatorColor string `json:"separatorColor,omitempty"`
}
// FlexComponent interface
type FlexComponent interface {
FlexComponent()
}
// BoxComponent type
type BoxComponent struct {
Type FlexComponentType
Layout FlexBoxLayoutType
Contents []FlexComponent
Flex *int
Spacing FlexComponentSpacingType
Margin FlexComponentMarginType
Width string
Height string
CornerRadius FlexComponentCornerRadiusType
BackgroundColor string `json:"backgroundColor,omitempty"`
BorderWidth string `json:"borderWidth,omitempty"`
BorderColor string `json:"borderColor,omitempty"`
}
// MarshalJSON method of BoxComponent
func (c *BoxComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
Layout FlexBoxLayoutType `json:"layout"`
Contents []FlexComponent `json:"contents"`
Flex *int `json:"flex,omitempty"`
Spacing FlexComponentSpacingType `json:"spacing,omitempty"`
Margin FlexComponentMarginType `json:"margin,omitempty"`
Width string `json:"width,omitempty"`
Height string `json:"height,omitempty"`
CornerRadius FlexComponentCornerRadiusType `json:"cornerRadius,omitempty"`
BackgroundColor string `json:"backgroundColor,omitempty"`
BorderWidth string `json:"borderWidth,omitempty"`
BorderColor string `json:"borderColor,omitempty"`
}{
Type: FlexComponentTypeBox,
Layout: c.Layout,
Contents: c.Contents,
Flex: c.Flex,
Spacing: c.Spacing,
Margin: c.Margin,
Width: c.Width,
Height: c.Height,
CornerRadius: c.CornerRadius,
BackgroundColor: c.BackgroundColor,
BorderWidth: c.BorderWidth,
BorderColor: c.BorderColor,
})
}
// ButtonComponent type
type ButtonComponent struct {
Type FlexComponentType
Action TemplateAction
Flex *int
Margin FlexComponentMarginType
Height FlexButtonHeightType
Style FlexButtonStyleType
Color string
Gravity FlexComponentGravityType
}
// MarshalJSON method of ButtonComponent
func (c *ButtonComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
Action TemplateAction `json:"action"`
Flex *int `json:"flex,omitempty"`
Margin FlexComponentMarginType `json:"margin,omitempty"`
Height FlexButtonHeightType `json:"height,omitempty"`
Style FlexButtonStyleType `json:"style,omitempty"`
Color string `json:"color,omitempty"`
Gravity FlexComponentGravityType `json:"gravity,omitempty"`
}{
Type: FlexComponentTypeButton,
Action: c.Action,
Flex: c.Flex,
Margin: c.Margin,
Height: c.Height,
Style: c.Style,
Color: c.Color,
Gravity: c.Gravity,
})
}
// FillerComponent type
type FillerComponent struct {
Type FlexComponentType
Flex *int
}
// MarshalJSON method of FillerComponent
func (c *FillerComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
Flex *int `json:"flex,omitempty"`
}{
Type: FlexComponentTypeFiller,
Flex: c.Flex,
})
}
// IconComponent type
type IconComponent struct {
Type FlexComponentType
URL string
Margin FlexComponentMarginType
Size FlexIconSizeType
AspectRatio FlexIconAspectRatioType
}
// MarshalJSON method of IconComponent
func (c *IconComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
URL string `json:"url"`
Margin FlexComponentMarginType `json:"margin,omitempty"`
Size FlexIconSizeType `json:"size,omitempty"`
AspectRatio FlexIconAspectRatioType `json:"aspectRatio,omitempty"`
}{
Type: FlexComponentTypeIcon,
URL: c.URL,
Margin: c.Margin,
Size: c.Size,
AspectRatio: c.AspectRatio,
})
}
// ImageComponent type
type ImageComponent struct {
Type FlexComponentType
URL string
Flex *int
Margin FlexComponentMarginType
Align FlexComponentAlignType
Gravity FlexComponentGravityType
Size FlexImageSizeType
AspectRatio FlexImageAspectRatioType
AspectMode FlexImageAspectModeType
BackgroundColor string
Action TemplateAction
}
// MarshalJSON method of ImageComponent
func (c *ImageComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
URL string `json:"url"`
Flex *int `json:"flex,omitempty"`
Margin FlexComponentMarginType `json:"margin,omitempty"`
Align FlexComponentAlignType `json:"align,omitempty"`
Gravity FlexComponentGravityType `json:"gravity,omitempty"`
Size FlexImageSizeType `json:"size,omitempty"`
AspectRatio FlexImageAspectRatioType `json:"aspectRatio,omitempty"`
AspectMode FlexImageAspectModeType `json:"aspectMode,omitempty"`
BackgroundColor string `json:"backgroundColor,omitempty"`
Action TemplateAction `json:"action,omitempty"`
}{
Type: FlexComponentTypeImage,
URL: c.URL,
Flex: c.Flex,
Margin: c.Margin,
Align: c.Align,
Gravity: c.Gravity,
Size: c.Size,
AspectRatio: c.AspectRatio,
AspectMode: c.AspectMode,
BackgroundColor: c.BackgroundColor,
Action: c.Action,
})
}
// SeparatorComponent type
type SeparatorComponent struct {
Type FlexComponentType
Margin FlexComponentMarginType
Color string
}
// MarshalJSON method of SeparatorComponent
func (c *SeparatorComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
Margin FlexComponentMarginType `json:"margin,omitempty"`
Color string `json:"color,omitempty"`
}{
Type: FlexComponentTypeSeparator,
Margin: c.Margin,
Color: c.Color,
})
}
// SpacerComponent type
type SpacerComponent struct {
Type FlexComponentType
Size FlexSpacerSizeType
}
// MarshalJSON method of SpacerComponent
func (c *SpacerComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
Size FlexSpacerSizeType `json:"size,omitempty"`
}{
Type: FlexComponentTypeSpacer,
Size: c.Size,
})
}
// TextComponent type
type TextComponent struct {
Type FlexComponentType
Text string
Flex *int
Margin FlexComponentMarginType
Size FlexTextSizeType
Align FlexComponentAlignType
Gravity FlexComponentGravityType
Wrap bool
Weight FlexTextWeightType
Color string
Action TemplateAction
Style FlexTextStyleType
Decoration FlexTextDecorationType
OffsetTop FlexComponentOffsetType
OffsetBottom FlexComponentOffsetType
OffsetStart FlexComponentOffsetType
OffsetEnd FlexComponentOffsetType
}
// MarshalJSON method of TextComponent
func (c *TextComponent) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type FlexComponentType `json:"type"`
Text string `json:"text"`
Flex *int `json:"flex,omitempty"`
Margin FlexComponentMarginType `json:"margin,omitempty"`
Size FlexTextSizeType `json:"size,omitempty"`
Align FlexComponentAlignType `json:"align,omitempty"`
Gravity FlexComponentGravityType `json:"gravity,omitempty"`
Wrap bool `json:"wrap,omitempty"`
Weight FlexTextWeightType `json:"weight,omitempty"`
Color string `json:"color,omitempty"`
Action TemplateAction `json:"action,omitempty"`
Style FlexTextStyleType `json:"style,omitempty"`
Decoration FlexTextDecorationType `json:"decoration,omitempty"`
OffsetTop FlexComponentOffsetType `json:"offsetTop,omitempty"`
OffsetBottom FlexComponentOffsetType `json:"offsetBottom,omitempty"`
OffsetStart FlexComponentOffsetType `json:"offsetStart,omitempty"`
OffsetEnd FlexComponentOffsetType `json:"offsetEnd,omitempty"`
}{
Type: FlexComponentTypeText,
Text: c.Text,
Flex: c.Flex,
Margin: c.Margin,
Size: c.Size,
Align: c.Align,
Gravity: c.Gravity,
Wrap: c.Wrap,
Weight: c.Weight,
Color: c.Color,
Action: c.Action,
Style: c.Style,
Decoration: c.Decoration,
OffsetTop: c.OffsetTop,
OffsetBottom: c.OffsetBottom,
OffsetStart: c.OffsetStart,
OffsetEnd: c.OffsetEnd,
})
}
// FlexComponent implements FlexComponent interface
func (*BoxComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*ButtonComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*FillerComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*IconComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*ImageComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*SeparatorComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*SpacerComponent) FlexComponent() {}
// FlexComponent implements FlexComponent interface
func (*TextComponent) FlexComponent() {}