diff --git a/go.mod b/go.mod index 44df2ed..aa2a4a2 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 github.com/stretchr/testify v1.2.2 // indirect github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect + golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6 // indirect diff --git a/go.sum b/go.sum index 0e1ac3c..1dcdf49 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,8 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 h1:EICbibRW4JNKMcY+LsWmuwob+CRS1BmdRdjphAm9mH4= github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 h1:Pn8fQdvx+z1avAi7fdM2kRYWQNxGlavNDSyzrQg2SsU= +golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= diff --git a/modules/apiact/line/component.go b/modules/apiact/line/component.go index d5ad793..12a4c98 100644 --- a/modules/apiact/line/component.go +++ b/modules/apiact/line/component.go @@ -85,3 +85,22 @@ type TextComponent struct { 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" + } +} diff --git a/modules/apiact/line/container.go b/modules/apiact/line/container.go index 5a2bcd7..6b724d7 100644 --- a/modules/apiact/line/container.go +++ b/modules/apiact/line/container.go @@ -44,9 +44,23 @@ func NewCarouselContainer() *CarouselContainer { } // AddContent - -func (p *CarouselContainer) AddContent(obj ...*BubbleContainer) (err error) { - if len(obj) == 0 { +func (p *CarouselContainer) AddContent(items ...*BubbleContainer) (err error) { + if len(items) == 0 { return errors.New("no item") } + if len(items) > 10 { + return errors.New("too many items") + } + if len(items)+len(p.Contents) > 10 { + return errors.New("too many items") + } + + for _, v := range items { + if v == nil { + continue + } + p.Contents = append(p.Contents, v) + } + return }