2016-06-14 11:19:56 +00:00
|
|
|
status.command({
|
|
|
|
name: "location",
|
|
|
|
description: "Send location",
|
2016-06-29 11:28:43 +00:00
|
|
|
color: "#9a5dcf",
|
|
|
|
preview: function (params) {
|
2016-07-07 16:09:16 +00:00
|
|
|
var text = status.components.text(
|
2016-06-29 11:28:43 +00:00
|
|
|
{
|
|
|
|
style: {
|
|
|
|
marginTop: 5,
|
|
|
|
marginHorizontal: 0,
|
|
|
|
fontSize: 14,
|
|
|
|
fontFamily: "font",
|
|
|
|
color: "black"
|
|
|
|
}
|
|
|
|
}, params.value);
|
|
|
|
var uri = "https://maps.googleapis.com/maps/api/staticmap?center="
|
|
|
|
+ params.value
|
|
|
|
+ "&size=100x100&maptype=roadmap&key=AIzaSyBNsj1qoQEYPb3IllmWMAscuXW0eeuYqAA&language=en"
|
|
|
|
+ "&markers=size:mid%7Ccolor:0xff0000%7Clabel:%7C"
|
|
|
|
+ params.value;
|
|
|
|
|
|
|
|
var image = status.components.image(
|
|
|
|
{
|
|
|
|
source: {uri: uri},
|
|
|
|
style: {
|
|
|
|
width: 100,
|
|
|
|
height: 100
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return status.components.view({}, [text, image]);
|
|
|
|
}
|
2016-06-14 11:19:56 +00:00
|
|
|
}).param({
|
|
|
|
name: "address",
|
2016-06-27 15:38:44 +00:00
|
|
|
type: status.types.TEXT,
|
|
|
|
placeholder: "Address"
|
2016-06-14 11:19:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var phones = [
|
|
|
|
{
|
|
|
|
number: "89171111111",
|
|
|
|
description: "Number format 1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
number: "89371111111",
|
|
|
|
description: "Number format 1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
number: "+79171111111",
|
|
|
|
description: "Number format 2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
number: "9171111111",
|
|
|
|
description: "Number format 3"
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function suggestionsContainerStyle(suggestionsCount) {
|
|
|
|
return {
|
|
|
|
marginVertical: 1,
|
|
|
|
marginHorizontal: 0,
|
|
|
|
height: Math.min(150, (56 * suggestionsCount)),
|
|
|
|
backgroundColor: "white",
|
|
|
|
borderRadius: 5
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var suggestionContainerStyle = {
|
|
|
|
paddingLeft: 16,
|
|
|
|
backgroundColor: "white"
|
|
|
|
};
|
|
|
|
|
|
|
|
var suggestionSubContainerStyle = {
|
|
|
|
height: 56,
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
borderBottomColor: "#0000001f"
|
|
|
|
};
|
|
|
|
|
|
|
|
var valueStyle = {
|
|
|
|
marginTop: 9,
|
|
|
|
fontSize: 14,
|
|
|
|
fontFamily: "font",
|
|
|
|
color: "#000000de"
|
|
|
|
};
|
|
|
|
|
|
|
|
var descriptionStyle = {
|
|
|
|
marginTop: 1.5,
|
|
|
|
fontSize: 14,
|
|
|
|
fontFamily: "font",
|
|
|
|
color: "#838c93de"
|
|
|
|
};
|
|
|
|
|
|
|
|
function startsWith(str1, str2) {
|
2016-06-15 07:47:38 +00:00
|
|
|
// String.startsWith(...) doesn't work in otto
|
2016-06-14 11:19:56 +00:00
|
|
|
return str1.lastIndexOf(str2, 0) == 0 && str1 != str2;
|
|
|
|
}
|
|
|
|
|
|
|
|
function phoneSuggestions(params) {
|
|
|
|
var ph, suggestions;
|
|
|
|
if (!params.value || params.value == "") {
|
|
|
|
ph = phones;
|
|
|
|
} else {
|
|
|
|
ph = phones.filter(function (phone) {
|
|
|
|
return startsWith(phone.number, params.value);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ph.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
suggestions = ph.map(function (phone) {
|
2016-06-14 12:56:03 +00:00
|
|
|
return status.components.touchable(
|
2016-06-14 11:19:56 +00:00
|
|
|
{onPress: [status.events.SET_VALUE, phone.number]},
|
2016-06-14 12:56:03 +00:00
|
|
|
status.components.view(suggestionContainerStyle,
|
|
|
|
[status.components.view(suggestionSubContainerStyle,
|
2016-06-14 11:19:56 +00:00
|
|
|
[
|
2016-06-14 12:56:03 +00:00
|
|
|
status.components.text(
|
|
|
|
{style: valueStyle},
|
|
|
|
phone.number
|
|
|
|
),
|
|
|
|
status.components.text(
|
|
|
|
{style: descriptionStyle},
|
|
|
|
phone.description
|
|
|
|
)
|
2016-06-14 11:19:56 +00:00
|
|
|
])])
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-07-18 07:38:24 +00:00
|
|
|
var view = status.components.scrollView(
|
2016-06-14 12:56:03 +00:00
|
|
|
suggestionsContainerStyle(ph.length),
|
|
|
|
suggestions
|
|
|
|
);
|
2016-07-18 07:38:24 +00:00
|
|
|
|
|
|
|
return {markup: view};
|
2016-06-14 11:19:56 +00:00
|
|
|
}
|
|
|
|
|
2016-07-18 13:22:32 +00:00
|
|
|
var phoneConfig = {
|
2016-06-14 11:19:56 +00:00
|
|
|
name: "phone",
|
|
|
|
description: "Send phone number",
|
|
|
|
color: "#5fc48d",
|
2016-07-07 16:09:16 +00:00
|
|
|
validator: function (params) {
|
|
|
|
return {
|
|
|
|
validationHandler: "phone",
|
|
|
|
parameters: [params.value]
|
|
|
|
};
|
|
|
|
},
|
2016-06-14 11:19:56 +00:00
|
|
|
params: [{
|
|
|
|
name: "phone",
|
2016-06-27 15:38:44 +00:00
|
|
|
type: status.types.PHONE,
|
|
|
|
suggestions: phoneSuggestions,
|
|
|
|
placeholder: "Phone number"
|
2016-06-14 11:19:56 +00:00
|
|
|
}],
|
|
|
|
handler: function (params) {
|
|
|
|
return {
|
|
|
|
event: "sign-up",
|
|
|
|
params: [params.value]
|
|
|
|
};
|
|
|
|
}
|
2016-07-18 13:22:32 +00:00
|
|
|
};
|
|
|
|
status.response(phoneConfig);
|
|
|
|
status.command(phoneConfig);
|
2016-06-14 11:19:56 +00:00
|
|
|
|
|
|
|
status.command({
|
|
|
|
name: "help",
|
|
|
|
description: "Help",
|
2016-06-25 13:28:45 +00:00
|
|
|
color: "#7099e6",
|
2016-07-07 16:09:16 +00:00
|
|
|
/* Validator example
|
2016-07-18 07:38:24 +00:00
|
|
|
validator: function (params) {
|
|
|
|
if (params.value != "3") {
|
|
|
|
var error = status.components.view(
|
|
|
|
{backgroundColor: "red"},
|
|
|
|
[status.components.text({}, "ooops :(")]
|
|
|
|
);
|
|
|
|
return {errors: [error]}
|
|
|
|
}
|
|
|
|
},*/
|
2016-06-14 11:19:56 +00:00
|
|
|
params: [{
|
|
|
|
name: "query",
|
2016-06-27 15:38:44 +00:00
|
|
|
type: status.types.TEXT
|
2016-06-14 11:19:56 +00:00
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
status.response({
|
|
|
|
name: "confirmation-code",
|
|
|
|
color: "#7099e6",
|
|
|
|
description: "Confirmation code",
|
2016-06-15 07:47:38 +00:00
|
|
|
params: [{
|
2016-06-14 11:19:56 +00:00
|
|
|
name: "code",
|
|
|
|
type: status.types.NUMBER
|
|
|
|
}],
|
|
|
|
handler: function (params) {
|
|
|
|
return {
|
|
|
|
event: "confirm-sign-up",
|
|
|
|
params: [params.value]
|
|
|
|
};
|
2016-07-18 13:22:32 +00:00
|
|
|
},
|
|
|
|
validator: function(params){
|
|
|
|
if(!/^[\d]{4}$/.test(params.value)){
|
|
|
|
var error = status.components.validationMessage(
|
|
|
|
"Confirmation code",
|
|
|
|
"Wrong format"
|
|
|
|
);
|
|
|
|
|
|
|
|
return {errors: [error]}
|
|
|
|
}
|
2016-06-14 11:19:56 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
status.response({
|
|
|
|
name: "keypair",
|
|
|
|
color: "#7099e6",
|
|
|
|
description: "Keypair password",
|
|
|
|
icon: "icon_lock_white",
|
2016-06-15 07:47:38 +00:00
|
|
|
params: [{
|
2016-06-14 11:19:56 +00:00
|
|
|
name: "password",
|
|
|
|
type: status.types.PASSWORD
|
|
|
|
}],
|
|
|
|
handler: function (params) {
|
|
|
|
return {
|
|
|
|
event: "save-password",
|
|
|
|
params: [params.value]
|
|
|
|
};
|
2016-06-14 14:36:39 +00:00
|
|
|
},
|
|
|
|
preview: function (params) {
|
|
|
|
return status.components.text(
|
|
|
|
{
|
|
|
|
style: {
|
|
|
|
marginTop: 5,
|
|
|
|
marginHorizontal: 0,
|
|
|
|
fontSize: 14,
|
|
|
|
fontFamily: "font",
|
|
|
|
color: "black"
|
|
|
|
}
|
|
|
|
}, "*****");
|
2016-06-14 11:19:56 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-07-18 07:38:24 +00:00
|
|
|
function walletView(params) {
|
|
|
|
if (params.value != "") {
|
|
|
|
var url = params.value;
|
|
|
|
if (!/^[a-zA-Z-_]+:/.test(url)) {
|
|
|
|
url = 'http://' + url;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {webViewUrl: url};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
status.command({
|
|
|
|
name: "browse",
|
|
|
|
description: "browser",
|
|
|
|
color: "#ffa500",
|
|
|
|
fullscreen: true,
|
|
|
|
suggestionsTrigger: 'on-send',
|
|
|
|
params: [{
|
|
|
|
name: "webpage",
|
|
|
|
suggestions: walletView,
|
|
|
|
type: status.types.TEXT
|
|
|
|
}]
|
|
|
|
});
|