Open Nicero opened 7 years ago
Hello there ! glad I was a help.
This code was based on Fuse the earlier versions which are the beta, however you can try replacing Uno.UX.Resource with Uno.UX;
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive.Resource;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
[ForeignInclude(Language.Java, "android.content.Intent")]
[ForeignInclude(Language.Java, "com.fuse.Activity")]
[UXGlobalModule]
public class Share : NativeModule
{
static readonly Share _instance;
public Share()
{
// Make sure we're only initializing the module once
if(_instance != null) return;
_instance = this;
Resource.SetGlobalKey(_instance, "Share");
AddMember(new NativeFunction("sendIntent", (NativeCallback)SendIntent));
}
static object SendIntent(Context c, object[] args)
{
if defined(Android) SendIntent((string)args[0]);
if defined(iOS) SendIntent((string)args[0]);
return null;
}
[Foreign(Language.Java)]
static extern(Android) void SendIntent(string data)
@{
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, data);
sendIntent.setType("text/plain");
Activity.getRootActivity().startActivity(Intent.createChooser(sendIntent, "Share via..."));
@}
[Foreign(Language.ObjC)]
static extern(iOS) void SendIntent(string data)
@{
NSString *textToShare = data;
NSArray *itemsToShare = @[textToShare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities: nil];
activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //or whichever you don't need
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:activityVC animated:YES completion:nil];
@}
}
Hallo! I was happy to find your very practical ShareSheet but as I added to my app (Android) following your instructions, Fuse won't compile and returned:
My
.unoproj
file:My MainView.ux file:
var Share = require("Share");
I'm using Fuse 1.21 on Windows 10 pro 64bit