mirror of
https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
synced 2026-06-04 00:00:20 +08:00
#4 Upgrading the JS API to prepare for custom options (no additional options yet, this is a change to make that possible in the future)
This commit is contained in:
+32
-4
@@ -1,3 +1,4 @@
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -26,13 +27,40 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
}
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class ToastOptions
|
||||
{
|
||||
[DataMember(IsRequired = true, Name = "message")]
|
||||
public string message { get; set; }
|
||||
|
||||
[DataMember(IsRequired = true, Name = "duration")]
|
||||
public string duration { get; set; }
|
||||
|
||||
[DataMember(IsRequired = true, Name = "position")]
|
||||
public string position { get; set; }
|
||||
}
|
||||
|
||||
public void show(string options)
|
||||
{
|
||||
ToastOptions toastOptions;
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
var message = args[0];
|
||||
var duration = args[1];
|
||||
var position = args[2];
|
||||
string aliasCurrentCommandCallbackId = args[3];
|
||||
String jsonOptions = args[0];
|
||||
|
||||
try
|
||||
{
|
||||
toastOptions = JsonHelper.Deserialize<ToastOptions>(jsonOptions);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
|
||||
return;
|
||||
}
|
||||
|
||||
var message = toastOptions.message;
|
||||
var duration = toastOptions.duration;
|
||||
var position = toastOptions.position;
|
||||
|
||||
string aliasCurrentCommandCallbackId = args[1];
|
||||
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user