Skip to content

Commit 85b43ac

Browse files
authored
Merge pull request #205 from line/flex_1_update
Flex Message Update 1
2 parents c716bd2 + 7803413 commit 85b43ac

File tree

6 files changed

+410
-37
lines changed

6 files changed

+410
-37
lines changed

examples/flask-kitchensink/app.py

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import datetime
1818
import errno
19+
import json
1920
import os
2021
import sys
2122
import tempfile
@@ -332,6 +333,137 @@ def handle_text_message(event):
332333
event.reply_token,
333334
message
334335
)
336+
elif text == 'flex_update_1':
337+
bubble_string = """
338+
{
339+
"type": "bubble",
340+
"body": {
341+
"type": "box",
342+
"layout": "vertical",
343+
"contents": [
344+
{
345+
"type": "image",
346+
"url": "https://line-objects-dev.com/flex/bg/eiji-k-1360395-unsplash.jpg",
347+
"position": "relative",
348+
"size": "full",
349+
"aspectMode": "cover",
350+
"aspectRatio": "1:1",
351+
"gravity": "center"
352+
},
353+
{
354+
"type": "box",
355+
"layout": "horizontal",
356+
"contents": [
357+
{
358+
"type": "box",
359+
"layout": "vertical",
360+
"contents": [
361+
{
362+
"type": "text",
363+
"text": "Brown Hotel",
364+
"weight": "bold",
365+
"size": "xl",
366+
"color": "#ffffff"
367+
},
368+
{
369+
"type": "box",
370+
"layout": "baseline",
371+
"margin": "md",
372+
"contents": [
373+
{
374+
"type": "icon",
375+
"size": "sm",
376+
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
377+
},
378+
{
379+
"type": "icon",
380+
"size": "sm",
381+
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
382+
},
383+
{
384+
"type": "icon",
385+
"size": "sm",
386+
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
387+
},
388+
{
389+
"type": "icon",
390+
"size": "sm",
391+
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gold_star_28.png"
392+
},
393+
{
394+
"type": "icon",
395+
"size": "sm",
396+
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/review_gray_star_28.png"
397+
},
398+
{
399+
"type": "text",
400+
"text": "4.0",
401+
"size": "sm",
402+
"color": "#d6d6d6",
403+
"margin": "md",
404+
"flex": 0
405+
}
406+
]
407+
}
408+
]
409+
},
410+
{
411+
"type": "box",
412+
"layout": "vertical",
413+
"contents": [
414+
{
415+
"type": "text",
416+
"text": "¥62,000",
417+
"color": "#a9a9a9",
418+
"decoration": "line-through",
419+
"align": "end"
420+
},
421+
{
422+
"type": "text",
423+
"text": "¥42,000",
424+
"color": "#ebebeb",
425+
"size": "xl",
426+
"align": "end"
427+
}
428+
]
429+
}
430+
],
431+
"position": "absolute",
432+
"offsetBottom": "0px",
433+
"offsetStart": "0px",
434+
"offsetEnd": "0px",
435+
"backgroundColor": "#00000099",
436+
"paddingAll": "20px"
437+
},
438+
{
439+
"type": "box",
440+
"layout": "vertical",
441+
"contents": [
442+
{
443+
"type": "text",
444+
"text": "SALE",
445+
"color": "#ffffff"
446+
}
447+
],
448+
"position": "absolute",
449+
"backgroundColor": "#ff2600",
450+
"cornerRadius": "20px",
451+
"paddingAll": "5px",
452+
"offsetTop": "10px",
453+
"offsetEnd": "10px",
454+
"paddingStart": "10px",
455+
"paddingEnd": "10px"
456+
}
457+
],
458+
"paddingAll": "0px"
459+
}
460+
}
461+
"""
462+
message = FlexSendMessage(alt_text="hello", contents=json.loads(bubble_string))
463+
line_bot_api.reply_message(
464+
event.reply_token,
465+
message
466+
)
335467
elif text == 'quick_reply':
336468
line_bot_api.reply_message(
337469
event.reply_token,

linebot/models/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
ImageComponent,
7070
SeparatorComponent,
7171
SpacerComponent,
72-
TextComponent
72+
TextComponent,
73+
SpanComponent
7374
)
7475
from .imagemap import ( # noqa
7576
ImagemapSendMessage,

0 commit comments

Comments
 (0)