forked from go-lark/lark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg_card_builder.go
139 lines (111 loc) · 3.42 KB
/
msg_card_builder.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
package lark
import (
"github.com/illacloud/larksdk/card"
"github.com/illacloud/larksdk/card/i18n"
)
type i18nCardBuilder struct{}
// CardBuilder .
type CardBuilder struct {
I18N *i18nCardBuilder
}
// Card wraps i18n card
func (i18nCardBuilder) Card(blocks ...*i18n.LocalizedBlock) *i18n.Block {
return i18n.Card(blocks...)
}
func (i18nCardBuilder) WithLocale(locale string, elements ...card.Element) *i18n.LocalizedBlock {
return i18n.WithLocale(locale, elements...)
}
// Title wraps i18n title block
func (i18nCardBuilder) LocalizedText(locale, s string) *i18n.LocalizedTextBlock {
return i18n.LocalizedText(locale, s)
}
// NewCardBuilder 新建卡片构造器
func NewCardBuilder() *CardBuilder {
return &CardBuilder{
I18N: &i18nCardBuilder{},
}
}
// Card 包裹了最外层的卡片结构
func (CardBuilder) Card(elements ...card.Element) *card.Block {
return card.Card(elements...)
}
// Action 交互元素,可添加 Button, SelectMenu, Overflow, DatePicker, TimePicker, DatetimePicker
func (CardBuilder) Action(actions ...card.Element) *card.ActionBlock {
return card.Action(actions...)
}
// Button 按钮交互元素
func (CardBuilder) Button(text *card.TextBlock) *card.ButtonBlock {
return card.Button(text)
}
// Confirm 用于交互元素的二次确认
func (CardBuilder) Confirm(title, text string) *card.ConfirmBlock {
return card.Confirm(title, text)
}
// DatePicker 日期选择器
func (CardBuilder) DatePicker() *card.DatePickerBlock {
return card.DatePicker()
}
// TimePicker 时间选择器
func (CardBuilder) TimePicker() *card.TimePickerBlock {
return card.TimePicker()
}
// DatetimePicker 日期时间选择器
func (CardBuilder) DatetimePicker() *card.DatetimePickerBlock {
return card.DatetimePicker()
}
// Div 内容模块
func (CardBuilder) Div(fields ...*card.FieldBlock) *card.DivBlock {
return card.Div(fields...)
}
// Field 内容模块的排版元素
func (CardBuilder) Field(text *card.TextBlock) *card.FieldBlock {
return card.Field(text)
}
// Hr 分割线模块
func (CardBuilder) Hr() *card.HrBlock {
return card.Hr()
}
// Img 图片展示模块
func (CardBuilder) Img(key string) *card.ImgBlock {
return card.Img(key)
}
// Note 备注模块
func (CardBuilder) Note() *card.NoteBlock {
return card.Note()
}
// Option 选项模块,可用于 SelectMenu 和 Overflow
func (CardBuilder) Option(value string) *card.OptionBlock {
return card.Option(value)
}
// Overflow 折叠按钮菜单组件
func (CardBuilder) Overflow(options ...*card.OptionBlock) *card.OverflowBlock {
return card.Overflow(options...)
}
// SelectMenu 菜单组件
func (CardBuilder) SelectMenu(options ...*card.OptionBlock) *card.SelectMenuBlock {
return card.SelectMenu(options...)
}
// Text 文本模块
func (CardBuilder) Text(s string) *card.TextBlock {
return card.Text(s)
}
// Markdown 单独使用的 Markdown 文本模块
func (CardBuilder) Markdown(s string) *card.MarkdownBlock {
return card.Markdown(s)
}
// URL 链接模块
func (CardBuilder) URL() *card.URLBlock {
return card.URL()
}
// ColumnSet column set module
func (CardBuilder) ColumnSet(columns ...*card.ColumnBlock) *card.ColumnSetBlock {
return card.ColumnSet(columns...)
}
// Column column module
func (CardBuilder) Column(elements ...card.Element) *card.ColumnBlock {
return card.Column(elements...)
}
// ColumnSetAction column action module
func (CardBuilder) ColumnSetAction(url *card.URLBlock) *card.ColumnSetActionBlock {
return card.ColumnSetAction(url)
}