Skip to content

Commit c5e19b0

Browse files
committed
-
1 parent 5280d61 commit c5e19b0

6 files changed

Lines changed: 37 additions & 78 deletions

File tree

Plugins/CS/NativeShare.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace iOSNativePlugin
77
public static class NativeShare
88
{
99
[DllImport("__Internal")]
10-
private static extern void NativeShare_Share(string message, string url, string imagePath, ShareCloseCallback callback);
10+
private static extern void NativeShare_Share(string message, string url, string imagePath, double posX, double posY, ShareCloseCallback callback);
1111
[DllImport("__Internal")]
12-
private static extern void NativeShare_ShareObjects(string[] objects, int count, ShareCloseCallback callback);
12+
private static extern void NativeShare_ShareObjects(string[] objects, int count, double posX, double posY, ShareCloseCallback callback);
1313
[DllImport("__Internal")]
1414
private static extern void NativeShare_SaveFileDialog(string content, string fileName, FileSavedCallback callback);
1515
[DllImport("__Internal")]

Plugins/CS/NativeUI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static class NativeUI
2020
[DllImport("__Internal")] static extern void NativeUI_ShowTempMessage(string alertString, int duration = 5);
2121
[DllImport("__Internal")] static extern void NativeUI_SetStatusBarHidden(bool hidden, int withAnimation);
2222
[DllImport("__Internal")] static extern void NativeUI_SetStatusBarStyle(int style, bool animated);
23-
[DllImport("__Internal")] static extern void NativeUI_ShowDialog(string title, string message, string[] actions, int count, int style, DialogSelectionCallback callback);
23+
[DllImport("__Internal")] static extern void NativeUI_ShowDialog(string title, string message, string[] actions, int count, int style, double posX, double posY, DialogSelectionCallback callback);
2424

2525
public static bool HideHomeIndicator
2626
{

Plugins/Native/Headers/NativeShare.h

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
+(void)SaveImageToAlbum:(NSString *)imagePath
66
callback:(SaveImageToAlbumCallback)callback;
7-
+(void)ShareMessage:(NSString *)message
8-
addUrl:(NSString *)url
9-
imgPath:(NSString *)imgPath
10-
callback:(ShareCloseCallback)callback;
117
+(void)ShareObject:(NSMutableArray<NSString*>*)objects
8+
posX:(CGFloat)posX posY:(CGFloat)posY
129
callback:(ShareCloseCallback)callback;
1310
+(void)SaveFileDialog:(NSString *)content
1411
fileName:(NSString *)fileName
@@ -23,14 +20,23 @@ extern "C"
2320
void NativeShare_SaveImageToAlbum(const char* imagePath, SaveImageToAlbumCallback callback){
2421
[NativeShare SaveImageToAlbum:[NSString stringWithUTF8String:imagePath ?: ""] callback:callback];
2522
}
26-
void NativeShare_Share(const char* message, const char* url, const char* imagePath, ShareCloseCallback callback)
23+
void NativeShare_Share(const char* message, const char* url, const char* imagePath, double posX, double posY, ShareCloseCallback callback)
2724
{
28-
[NativeShare ShareMessage:[NSString stringWithUTF8String:message ?: ""]
29-
addUrl:[NSString stringWithUTF8String:url ?: ""]
30-
imgPath:[NSString stringWithUTF8String:imagePath ?: ""]
31-
callback:callback];
25+
NSMutableArray<NSString*>* array = [NSMutableArray new];
26+
27+
if(message != nil)
28+
[array addObject:[NSString stringWithFormat:@"0%@", message]];
29+
30+
if(url != nil)
31+
[array addObject:[NSString stringWithFormat:@"1%@", url]];
32+
33+
if(imgPath != nil)
34+
[array addObject:[NSString stringWithFormat:@"2%@", imgPath]];
35+
36+
37+
[NativeShare ShareObject:array posX:posY posY:posY callback:callback];
3238
}
33-
void NativeShare_ShareObjects(const char** objects, int count, ShareCloseCallback callback)
39+
void NativeShare_ShareObjects(const char** objects, int count, double posX, double posY,ShareCloseCallback callback)
3440
{
3541
if(count <= 0)
3642
return;
@@ -42,7 +48,7 @@ extern "C"
4248
[objectsArray addObject:str];
4349
}
4450

45-
[NativeShare ShareObject:objectsArray callback:callback];
51+
[NativeShare ShareObject:objectsArray posX:posY posY:posY callback:callback];
4652
}
4753
void NativeShare_SaveFileDialog(const char* content, const char* fileName, FileSavedCallback callback)
4854
{

Plugins/Native/Headers/NativeUI.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
+(void)SetStatusBarStyle:(NSInteger)style animated:(BOOL)animated;
1616
+(void)ShowTempMessage:(NSString *)alertString duration:(NSInteger)duration;
1717
+(void)ShowTempMessage:(NSString *)alertString;
18-
+(void)ShowDialog:(NSString *) title message:(NSString *)message actions:(NSMutableArray*)actions
19-
style:(NSInteger)style
18+
+(void)ShowDialog:(NSString *) title
19+
message:(NSString *)message
20+
actions:(NSMutableArray*)actions
21+
style:(UIAlertControllerStyle)style
22+
posX:(CGFloat)posX posY:(CGFloat)posY
2023
callback:(DialogSelectionCallback)callback;
2124
@end
2225

@@ -72,7 +75,8 @@ extern "C"
7275
void NativeUI_ShowTempMessage(const char* alertString, int duration = 5){
7376
[NativeUI ShowTempMessage:[NSString stringWithUTF8String:alertString ?: ""] duration:duration];
7477
}
75-
void NativeUI_ShowDialog(const char* title, const char* message, const char** actions, int count, int style, DialogSelectionCallback callback)
78+
79+
void NativeUI_ShowDialog(const char* title, const char* message, const char** actions, int count, int style, double posX, double posY, DialogSelectionCallback callback)
7680
{
7781
if(count <= 0)
7882
return;
@@ -87,7 +91,8 @@ extern "C"
8791
[NativeUI ShowDialog:[NSString stringWithUTF8String:title ?: ""]
8892
message:[NSString stringWithUTF8String:message ?: ""]
8993
actions:actionsArray
90-
style:style
94+
style:(UIAlertControllerStyle)style
95+
posX:posX posY:posY
9196
callback:callback];
9297
}
9398
}

Plugins/Native/Implementations/NativeShare.mm

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,9 @@ +(void)SaveImageToAlbum:(NSString *)imagePath callback:(SaveImageToAlbumCallback
5151
}];
5252
}
5353

54-
55-
+(void)ShareMessage:(NSString *)message addUrl:(NSString *)url imgPath:(NSString *)imgPath callback:(ShareCloseCallback)callback
56-
{
57-
NSMutableArray<NSString*>* array = [NSMutableArray new];
58-
59-
if(message != nil)
60-
[array addObject:[NSString stringWithFormat:@"0%@", message]];
61-
62-
if(url != nil)
63-
[array addObject:[NSString stringWithFormat:@"1%@", url]];
64-
65-
if(imgPath != nil)
66-
[array addObject:[NSString stringWithFormat:@"2%@", imgPath]];
67-
68-
69-
[NativeShare ShareObject:array callback:callback];
70-
71-
}
72-
+(void)ShareObject:(NSMutableArray<NSString*>*)objects callback:(ShareCloseCallback)callback
54+
+(void)ShareObject:(NSMutableArray<NSString*>*)objects
55+
posX:(CGFloat)posX posY:(CGFloat)posY
56+
callback:(ShareCloseCallback)callback
7357
{
7458
if(objects == nil || objects == nil){
7559
if(callback != nil){
@@ -116,7 +100,7 @@ +(void)ShareObject:(NSMutableArray<NSString*>*)objects callback:(ShareCloseCallb
116100
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
117101

118102
//为iPad初始化分享界面
119-
InitUIPopoverViewController(activity);
103+
InitUIPopoverViewController(activity, posX, posY);
120104

121105
//显示分享界面
122106
[UnityGetGLViewController() presentViewController:activity animated:YES completion:nil];

Plugins/Native/Implementations/NativeUI.mm

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,18 @@ +(void)ShowTempMessage:(NSString *)alertString
242242
+(void)ShowDialog:(NSString *) title
243243
message:(NSString *)message
244244
actions:(NSMutableArray*)actions
245-
style:(NSInteger)style
245+
style:(UIAlertControllerStyle)style
246+
posX:(CGFloat)posX posY:(CGFloat)posY
246247
callback:(DialogSelectionCallback)callback
247248
{
248249

249250

250251

251252
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:(UIAlertControllerStyle)style];
252253

253-
if ((UIAlertControllerStyle)style == UIAlertControllerStyleActionSheet)
254+
if (style == UIAlertControllerStyleActionSheet)
254255
{
255-
InitUIPopoverViewController(alertController);
256+
InitUIPopoverViewController(alertController, posX, posY);
256257
}
257258

258259
UIAlertAction *action;
@@ -278,41 +279,4 @@ +(void)ShowDialog:(NSString *) title
278279

279280
[UnityGetGLViewController() presentViewController:alertController animated:YES completion:nil];
280281
}
281-
282-
+(void)ShowAlert:(NSString *) title
283-
message:(NSString *)message
284-
actions:(NSMutableArray*)actions
285-
callback:(DialogSelectionCallback)callback
286-
{
287-
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
288-
289-
UIAlertAction *action;
290-
291-
for(int i = 0; i < actions.count; i++){
292-
NSString *actionStr = actions[i];
293-
294-
NSString *firstChar = [actionStr substringToIndex:1];
295-
NSInteger style = [firstChar intValue];
296-
297-
action = [UIAlertAction actionWithTitle:[actionStr substringFromIndex:1]
298-
style:(UIAlertActionStyle)style
299-
handler:^(UIAlertAction * _Nonnull action) {
300-
301-
if(callback != nil)
302-
callback(i);
303-
}];
304-
305-
[alertController addAction:action];
306-
307-
}
308-
309-
310-
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alertController animated:YES completion:nil];
311-
}
312-
313-
+(void)ShowUIAlert:(UIAlertController*)alertController
314-
action:(UIAlertAction*)action
315-
{
316-
317-
}
318282
@end

0 commit comments

Comments
 (0)