Skip to content

Commit ed911a9

Browse files
authored
Flex message Update2 (#581)
1 parent 2744171 commit ed911a9

File tree

17 files changed

+734
-52
lines changed

17 files changed

+734
-52
lines changed

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Box.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@
2828
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
2929

3030
import com.linecorp.bot.model.action.Action;
31+
import com.linecorp.bot.model.message.flex.component.box.BoxBackground;
32+
import com.linecorp.bot.model.message.flex.unit.FlexAlignItems;
3133
import com.linecorp.bot.model.message.flex.unit.FlexBorderWidthSize;
3234
import com.linecorp.bot.model.message.flex.unit.FlexCornerRadiusSize;
35+
import com.linecorp.bot.model.message.flex.unit.FlexJustifyContent;
3336
import com.linecorp.bot.model.message.flex.unit.FlexLayout;
3437
import com.linecorp.bot.model.message.flex.unit.FlexMarginSize;
3538
import com.linecorp.bot.model.message.flex.unit.FlexOffsetSize;
@@ -51,9 +54,9 @@ public class Box implements FlexComponent {
5154

5255
List<FlexComponent> contents;
5356

54-
FlexMarginSize spacing;
57+
String spacing;
5558

56-
FlexMarginSize margin;
59+
String margin;
5760

5861
FlexPosition position;
5962

@@ -89,8 +92,34 @@ public class Box implements FlexComponent {
8992

9093
Action action;
9194

95+
FlexJustifyContent justifyContent;
96+
97+
FlexAlignItems alignItems;
98+
99+
BoxBackground background;
100+
92101
@JsonPOJOBuilder(withPrefix = "")
93102
public static class BoxBuilder {
103+
public BoxBuilder spacing(FlexMarginSize spacing) {
104+
this.spacing = spacing.getPropertyValue();
105+
return this;
106+
}
107+
108+
public BoxBuilder spacing(String spacing) {
109+
this.spacing = spacing;
110+
return this;
111+
}
112+
113+
public BoxBuilder margin(FlexMarginSize margin) {
114+
this.margin = margin.getPropertyValue();
115+
return this;
116+
}
117+
118+
public BoxBuilder margin(String margin) {
119+
this.margin = margin;
120+
return this;
121+
}
122+
94123
@JsonSetter // Avoid conflict with same name method.
95124
public BoxBuilder contents(List<FlexComponent> contents) {
96125
this.contents = new ArrayList<>(contents);

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Button.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
2525

2626
import com.linecorp.bot.model.action.Action;
27+
import com.linecorp.bot.model.message.flex.unit.FlexAdjustMode;
2728
import com.linecorp.bot.model.message.flex.unit.FlexGravity;
2829
import com.linecorp.bot.model.message.flex.unit.FlexMarginSize;
2930
import com.linecorp.bot.model.message.flex.unit.FlexOffsetSize;
@@ -64,7 +65,7 @@ public enum ButtonHeight {
6465

6566
FlexGravity gravity;
6667

67-
FlexMarginSize margin;
68+
String margin;
6869

6970
FlexPosition position;
7071

@@ -78,10 +79,22 @@ public enum ButtonHeight {
7879

7980
ButtonHeight height;
8081

82+
FlexAdjustMode adjustMode;
83+
8184
@JsonPOJOBuilder(withPrefix = "")
8285
public static class ButtonBuilder {
8386
// Providing builder instead of public constructor. Class body is filled by lombok.
8487

88+
public ButtonBuilder margin(FlexMarginSize margin) {
89+
this.margin = margin.getPropertyValue();
90+
return this;
91+
}
92+
93+
public ButtonBuilder margin(String margin) {
94+
this.margin = margin;
95+
return this;
96+
}
97+
8598
public ButtonBuilder offsetTop(FlexOffsetSize offset) {
8699
offsetTop = offset.getPropertyValue();
87100
return this;

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Icon.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public enum IconAspectRatio {
5454

5555
URI url;
5656

57-
FlexFontSize size;
57+
String size;
5858

5959
String aspectRatio;
6060

61-
FlexMarginSize margin;
61+
String margin;
6262

6363
FlexPosition position;
6464

@@ -74,6 +74,26 @@ public enum IconAspectRatio {
7474
public static class IconBuilder {
7575
private static final Supplier<DecimalFormat> RATIO_FORMAT = () -> new DecimalFormat("0.#####");
7676

77+
public IconBuilder size(FlexFontSize size) {
78+
this.size = size.getPropertyValue();
79+
return this;
80+
}
81+
82+
public IconBuilder size(String size) {
83+
this.size = size;
84+
return this;
85+
}
86+
87+
public IconBuilder margin(FlexMarginSize margin) {
88+
this.margin = margin.getPropertyValue();
89+
return this;
90+
}
91+
92+
public IconBuilder margin(String margin) {
93+
this.margin = margin;
94+
return this;
95+
}
96+
7797
public IconBuilder offsetTop(FlexOffsetSize offset) {
7898
offsetTop = offset.getPropertyValue();
7999
return this;

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Image.java

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,34 @@
4545
@Builder(toBuilder = true)
4646
@JsonDeserialize(builder = Image.ImageBuilder.class)
4747
public class Image implements FlexComponent {
48+
49+
@AllArgsConstructor
50+
@Getter
4851
public enum ImageSize {
4952
@JsonProperty("xxs")
50-
XXS,
53+
XXS("xxs"),
5154
@JsonProperty("xs")
52-
XS,
55+
XS("xs"),
5356
@JsonProperty("sm")
54-
SM,
57+
SM("sm"),
5558
@JsonProperty("md")
56-
MD,
59+
MD("md"),
5760
@JsonProperty("lg")
58-
LG,
61+
LG("lg"),
5962
@JsonProperty("xl")
60-
XL,
63+
XL("xl"),
6164
@JsonProperty("xxl")
62-
XXL,
65+
XXL("xxl"),
6366
@JsonProperty("3xl")
64-
XXXL,
67+
XXXL("3xl"),
6568
@JsonProperty("4xl")
66-
XXXXL,
69+
XXXXL("4xl"),
6770
@JsonProperty("5xl")
68-
XXXXXL,
71+
XXXXXL("5xl"),
6972
@JsonProperty("full")
70-
FULL_WIDTH,
73+
FULL_WIDTH("full");
74+
75+
private final String propertyValue;
7176
}
7277

7378
@AllArgsConstructor
@@ -100,7 +105,7 @@ public enum ImageAspectMode {
100105

101106
URI url;
102107

103-
ImageSize size;
108+
String size;
104109

105110
String aspectRatio;
106111

@@ -114,7 +119,7 @@ public enum ImageAspectMode {
114119

115120
FlexGravity gravity;
116121

117-
FlexMarginSize margin;
122+
String margin;
118123

119124
FlexPosition position;
120125

@@ -126,10 +131,22 @@ public enum ImageAspectMode {
126131

127132
String offsetEnd;
128133

134+
Boolean animated;
135+
129136
@JsonPOJOBuilder(withPrefix = "")
130137
public static class ImageBuilder {
131138
private static final Supplier<DecimalFormat> RATIO_FORMAT = () -> new DecimalFormat("0.#####");
132139

140+
public ImageBuilder size(ImageSize size) {
141+
this.size = size.getPropertyValue();
142+
return this;
143+
}
144+
145+
public ImageBuilder size(String size) {
146+
this.size = size;
147+
return this;
148+
}
149+
133150
/**
134151
* Specify aspect ratio by keyword.
135152
*/
@@ -155,6 +172,16 @@ public ImageBuilder aspectRatio(double width, double height) {
155172
return this;
156173
}
157174

175+
public ImageBuilder margin(FlexMarginSize margin) {
176+
this.margin = margin.getPropertyValue();
177+
return this;
178+
}
179+
180+
public ImageBuilder margin(String margin) {
181+
this.margin = margin;
182+
return this;
183+
}
184+
158185
public ImageBuilder offsetTop(FlexOffsetSize offset) {
159186
offsetTop = offset.getPropertyValue();
160187
return this;

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Separator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,22 @@
3333
@Builder(toBuilder = true)
3434
@JsonDeserialize(builder = Separator.SeparatorBuilder.class)
3535
public class Separator implements FlexComponent {
36-
FlexMarginSize margin;
36+
String margin;
3737

3838
String color;
3939

4040
@JsonPOJOBuilder(withPrefix = "")
4141
public static class SeparatorBuilder {
4242
// Providing builder instead of public constructor. Class body is filled by lombok.
43+
44+
public SeparatorBuilder margin(FlexMarginSize margin) {
45+
this.margin = margin.getPropertyValue();
46+
return this;
47+
}
48+
49+
public SeparatorBuilder margin(String margin) {
50+
this.margin = margin;
51+
return this;
52+
}
4353
}
4454
}

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Span.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class Span implements FlexComponent {
3939
String text;
4040

41-
FlexFontSize size;
41+
String size;
4242

4343
String color;
4444

@@ -51,5 +51,15 @@ public class Span implements FlexComponent {
5151
@JsonPOJOBuilder(withPrefix = "")
5252
public static class SpanBuilder {
5353
// Providing builder instead of public constructor. Class body is filled by lombok.
54+
55+
public SpanBuilder size(FlexFontSize size) {
56+
this.size = size.getPropertyValue();
57+
return this;
58+
}
59+
60+
public SpanBuilder size(String size) {
61+
this.size = size;
62+
return this;
63+
}
5464
}
5565
}

line-bot-model/src/main/java/com/linecorp/bot/model/message/flex/component/Text.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
2727

2828
import com.linecorp.bot.model.action.Action;
29+
import com.linecorp.bot.model.message.flex.unit.FlexAdjustMode;
2930
import com.linecorp.bot.model.message.flex.unit.FlexAlign;
3031
import com.linecorp.bot.model.message.flex.unit.FlexFontSize;
3132
import com.linecorp.bot.model.message.flex.unit.FlexGravity;
@@ -69,7 +70,7 @@ public enum TextDecoration {
6970

7071
String text;
7172

72-
FlexFontSize size;
73+
String size;
7374

7475
FlexAlign align;
7576

@@ -85,7 +86,7 @@ public enum TextDecoration {
8586

8687
Boolean wrap;
8788

88-
FlexMarginSize margin;
89+
String margin;
8990

9091
FlexPosition position;
9192

@@ -103,10 +104,32 @@ public enum TextDecoration {
103104

104105
List<Span> contents;
105106

107+
FlexAdjustMode adjustMode;
108+
106109
@JsonPOJOBuilder(withPrefix = "")
107110
public static class TextBuilder {
108111
// Providing builder instead of public constructor. Class body is filled by lombok.
109112

113+
public TextBuilder size(FlexFontSize size) {
114+
this.size = size.getPropertyValue();
115+
return this;
116+
}
117+
118+
public TextBuilder size(String size) {
119+
this.size = size;
120+
return this;
121+
}
122+
123+
public TextBuilder margin(FlexMarginSize margin) {
124+
this.margin = margin.getPropertyValue();
125+
return this;
126+
}
127+
128+
public TextBuilder margin(String margin) {
129+
this.margin = margin;
130+
return this;
131+
}
132+
110133
public TextBuilder offsetTop(FlexOffsetSize offset) {
111134
offsetTop = offset.getPropertyValue();
112135
return this;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2020 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
package com.linecorp.bot.model.message.flex.component.box;
18+
19+
import com.fasterxml.jackson.annotation.JsonSubTypes;
20+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
21+
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
22+
23+
@JsonSubTypes({
24+
@JsonSubTypes.Type(BoxLinearGradient.class),
25+
})
26+
@JsonTypeInfo(
27+
use = JsonTypeInfo.Id.NAME,
28+
include = As.PROPERTY,
29+
property = "type"
30+
)
31+
public interface BoxBackground {
32+
}

0 commit comments

Comments
 (0)