status-react/bots/mailman/bot.js

98 lines
3.5 KiB
JavaScript
Raw Normal View History

2017-07-10 10:29:58 +00:00
function locationsSuggestions (params) {
var result = {title: "Send location"};
var seqArg = params["seq-arg"] ? params["seq-arg"] : "";
if (seqArg === "Dropped pin")
{
result.showBack = true;
result.height = "max";
result.markup = ['view', {},
['dropped-pin']];
}
else if (seqArg != "")
{
result.showBack = true;
result.markup = ['scroll-view', {keyboardShouldPersistTaps: "always"},
['view', {},
['places-search']]];
}
else
{
result.markup = ['scroll-view', {keyboardShouldPersistTaps: "always"},
['view', {},
['current-location-map'],
['current-location'],
['separator'],
['places-nearby']]];
}
return result;
}
status.command({
name: "location",
title: I18n.t('location_title'),
description: I18n.t('location_description'),
sequentialParams: true,
2017-07-10 10:29:58 +00:00
hideSendButton: true,
params: [{
name: "address",
type: status.types.TEXT,
2017-07-10 10:29:58 +00:00
placeholder: I18n.t('location_address'),
suggestions: locationsSuggestions
}],
preview: function (params) {
2017-07-10 10:29:58 +00:00
var address = params.address.split("&");
var text = status.components.text(
{
style: {
2017-07-10 10:29:58 +00:00
marginTop: 0,
marginHorizontal: 0,
2017-07-10 10:29:58 +00:00
fontSize: 15,
lineHeight: 23,
fontFamily: "font",
color: "black"
}
2017-07-10 10:29:58 +00:00
}, address[0]);
var uri = "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/" +
address[1] + "," + address[2] + ",10,20" +
"/175x58?access_token=pk.eyJ1Ijoic3RhdHVzaW0iLCJhIjoiY2oydmtnZjRrMDA3czMzcW9kemR4N2lxayJ9.Rz8L6xdHBjfO8cR3CDf3Cw";
var image = status.components.image(
{
source: {uri: uri},
style: {
2017-07-10 10:29:58 +00:00
borderRadius: 5
marginTop: 12
height: 58
}
}
);
2017-07-10 10:29:58 +00:00
return {markup: ['view', {},
text,
['view', {},
image,
['view', {style: {position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
justifyContent: "center",
alignItems: "center"}},
['view', {style: {borderColor: "#628fe3",
backgroundColor: "#FFFFFF",
borderWidth: 4,
borderRadius: 8,
height: 15,
width: 15}}]]]]};
},
shortPreview: function (params) {
return {
markup: status.components.text(
{},
I18n.t('location_title') + ": " + params.address
)
};
}
2017-07-10 10:29:58 +00:00
});