forked from bolav/fuse-contacts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContacts.uno
46 lines (36 loc) · 1005 Bytes
/
Contacts.uno
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Uno;
using Uno.UX;
using Uno.Threading;
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;
using Fuse.Contacts.Helpers;
[UXGlobalModule]
public class Contacts : NativeModule {
static readonly Contacts _instance;
public Contacts()
{
if (_instance != null) return;
_instance = this;
Uno.UX.Resource.SetGlobalKey(_instance = this, "FuseJS/Contacts");
AddMember(new NativePromise<string, string>("authorize", Authorize, null));
AddMember(new NativeFunction("getAll", (NativeCallback)GetAll));
AddMember(new NativeFunction("getPage", (NativeCallback)GetPage));
}
object GetAll (Context c, object[] args)
{
var a = new JSList(c);
ContactsImpl.GetAllImpl(a);
return a.GetScriptingArray();
}
object GetPage (Context c, object[] args)
{
var a = new JSList(c);
ContactsImpl.GetPageImpl(a, Marshal.ToInt(args[0]), Marshal.ToInt(args[1]));
return a.GetScriptingArray();
}
Future<string> Authorize (object[] args)
{
return ContactsImpl.AuthorizeImpl();
}
}