107 lines
2.8 KiB
Go
107 lines
2.8 KiB
Go
package line
|
|
|
|
// Component -
|
|
type Component struct {
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
// BoxComponent -
|
|
type BoxComponent struct {
|
|
Component
|
|
Layout string `json:"layout"`
|
|
Contents []interface{} `json:"contents"`
|
|
Spacing NullString `json:"spacing,omitempty"`
|
|
Action interface{} `json:"action,omitempty"`
|
|
Flex NullInt `json:"flex,omitempty"`
|
|
Margin NullString `json:"margin,omitempty"`
|
|
}
|
|
|
|
// ButtonComponent -
|
|
type ButtonComponent struct {
|
|
Component
|
|
Action interface{} `json:"action"`
|
|
Height NullString `json:"height,omitempty"`
|
|
Style NullString `json:"style,omitempty"`
|
|
Color NullString `json:"color,omitempty"`
|
|
Gravity NullString `json:"gravity,omitempty"`
|
|
Flex NullInt `json:"flex,omitempty"`
|
|
Margin NullString `json:"margin,omitempty"`
|
|
}
|
|
|
|
// FillerComponent -
|
|
type FillerComponent struct {
|
|
Component
|
|
}
|
|
|
|
// IconComponent -
|
|
type IconComponent struct {
|
|
Component
|
|
URL string `json:"url"`
|
|
Margin NullString `json:"margin,omitempty"`
|
|
Size NullString `json:"size,omitempty"`
|
|
AspectRatio NullString `json:"aspectRatio,omitempty"`
|
|
}
|
|
|
|
// ImageComponent -
|
|
type ImageComponent struct {
|
|
Component
|
|
URL string `json:"url"`
|
|
Flex NullInt `json:"flex,omitempty"`
|
|
Margin NullString `json:"margin,omitempty"`
|
|
Align NullString `json:"align,omitempty"`
|
|
Gravity NullString `json:"gravity,omitempty"`
|
|
Size NullString `json:"size,omitempty"`
|
|
AspectRatio NullString `json:"aspectRatio,omitempty"`
|
|
AspectMode NullString `json:"aspectMode,omitempty"`
|
|
BackgroundColor NullString `json:"backgroundColor,omitempty"`
|
|
Action interface{} `json:"action,omitempty"`
|
|
}
|
|
|
|
// SeparatorComponent -
|
|
type SeparatorComponent struct {
|
|
Component
|
|
Margin NullString `json:"margin,omitempty"`
|
|
Color NullString `json:"color,omitempty"`
|
|
}
|
|
|
|
// SpacerComponent -
|
|
type SpacerComponent struct {
|
|
Component
|
|
Size NullString `json:"size,omitempty"`
|
|
}
|
|
|
|
// TextComponent -
|
|
type TextComponent struct {
|
|
Component
|
|
Text string `json:"text"`
|
|
Flex NullInt `json:"flex,omitempty"`
|
|
Margin NullString `json:"margin,omitempty"`
|
|
Size NullString `json:"size,omitempty"`
|
|
Align NullString `json:"align,omitempty"`
|
|
Gravity NullString `json:"gravity,omitempty"`
|
|
Wrap bool `json:"wrap"`
|
|
MaxLines NullInt `json:"maxLines,omitempty"`
|
|
Weight NullString `json:"weight,omitempty"`
|
|
Color NullString `json:"color,omitempty"`
|
|
Action interface{} `json:"action,omitempty"`
|
|
}
|
|
|
|
// NewBoxComponent -
|
|
func NewBoxComponent(layout string) (box *BoxComponent) {
|
|
box = &BoxComponent{}
|
|
box.Type = "box"
|
|
box.SetLayout(layout)
|
|
return
|
|
}
|
|
|
|
// SetLayout -
|
|
func (p *BoxComponent) SetLayout(layout string) {
|
|
switch layout {
|
|
case "horizontal":
|
|
case "vertical":
|
|
p.Layout = layout
|
|
default:
|
|
p.Layout = "horizontal"
|
|
}
|
|
}
|