feat: 新增Api的部分定义和实现

master
wangtao 2021-12-21 17:23:42 +08:00
parent f9a5f9d079
commit c89aaa91cd
19 changed files with 416 additions and 5 deletions

View File

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"android":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"mop","dependencies":[]}],"date_created":"2021-11-15 23:44:20.482386","version":"2.2.2"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mop","path":"/Users/wangtao/Documents/fantai/code/finclip-flutter-sdk/","dependencies":[]}],"android":[{"name":"mop","path":"/Users/wangtao/Documents/fantai/code/finclip-flutter-sdk/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"mop","dependencies":[]}],"date_created":"2021-12-20 16:48:35.113009","version":"2.2.1"}

View File

@ -87,7 +87,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.34.5"
version: "2.34.9"
path:
dependency: transitive
description:

View File

@ -0,0 +1,16 @@
//
// MOB_addWebExtentionApi.h
// mop
//
// Created by on 2021/12/21.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOB_addWebExtentionApi : MOPBaseApi
@property(nonatomic, copy) NSString* name;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,53 @@
//
// MOB_addWebExtentionApi.m
// mop
//
// Created by on 2021/12/21.
//
#import "MOB_addWebExtentionApi.h"
#import "MopPlugin.h"
#import <FinApplet/FinApplet.h>
@implementation MOB_addWebExtentionApi
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
NSLog(@"MOB_addWebExtentionApi");
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
[[FATClient sharedClient] fat_registerWebApi:self.name handle:^(id param, FATExtensionApiCallback callback) {
NSLog(@"invoke webExtentionApi:");
NSLog(@"%@",self.name);
NSLog(@"%@",param);
NSString* api = [@"webExtentionApi:" stringByAppendingString:self.name];
[channel invokeMethod:api arguments:param result:^(id _Nullable result) {
NSLog(@"webExtentionApi reslut:%@",result);
// flutter
BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented;
if (isFlutterError) {
NSLog(@"webExtentionApi reslut:fail");
callback(FATExtensionCodeFailure,nil);
return;
}
//
BOOL hasError = [[result allKeys] containsObject:@"errMsg"];
if (hasError) {
NSString *errMsg = result[@"errMsg"];
NSString *errPrefix = [NSString stringWithFormat:@"%@:fail", self.name];
BOOL isFail = [errMsg hasPrefix:errPrefix];
if (isFail) {
NSLog(@"webExtentionApi reslut:fail");
callback(FATExtensionCodeFailure,nil);
return;
}
}
//
NSLog(@"webExtentionApi callback:%@",result);
callback(FATExtensionCodeSuccess,result);
}];
}];
success(@{});
}
@end

View File

@ -0,0 +1,18 @@
//
// MOP_callJS.h
// mop
//
// Created by on 2021/12/21.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_callJS : MOPBaseApi
@property (nonatomic, copy) NSString *eventName;
@property (nonatomic, copy) NSString *nativeViewId;
@property (nonatomic, copy) NSDictionary *eventData;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// MOP_callJS.m
// mop
//
// Created by on 2021/12/21.
//
#import "MOP_callJS.h"
@implementation MOP_callJS
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
if (!self.eventData || !self.eventName || !self.nativeViewId) {
failure(@{@"errMsg": @"callJS:fail"});
return;
}
NSNumber *numberId = @(_nativeViewId.integerValue);
[[FATClient sharedClient].nativeViewManager sendEvent:_eventName nativeViewId:numberId detail:_eventData completion:^(id result, NSError *error) {
if (error) {
failure(@{@"errMsg": @"sendCustomEvent:fail"});
} else {
success(result);
}
}];
}
@end

View File

@ -0,0 +1,17 @@
//
// MOP_closeApplet.h
// mop
//
// Created by on 2021/12/21.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_closeApplet : MOPBaseApi
@property (nonatomic, copy) NSString *appletId;
@property (nonatomic, assign) BOOL animated;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
//
// MOP_closeApplet.m
// mop
//
// Created by on 2021/12/21.
//
#import "MOP_closeApplet.h"
#import <FinApplet/FinApplet.h>
@implementation MOP_closeApplet
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
if (!self.appletId || self.appletId.length < 1) {
failure(@{@"errMsg": @"closeApplet:fail"});
return;
}
[[FATClient sharedClient] closeApplet:self.appletId animated:_animated completion:^{
success(@{});
}];
}
@end

View File

@ -0,0 +1,17 @@
//
// MOP_finishRunningApplet.h
// mop
//
// Created by on 2021/12/21.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_finishRunningApplet : MOPBaseApi
@property (nonatomic, copy) NSString appletId;
@property (nonatomic, assign) BOOL animated;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,25 @@
//
// MOP_finishRunningApplet.m
// mop
//
// Created by on 2021/12/21.
//
#import "MOP_finishRunningApplet.h"
@implementation MOP_finishRunningApplet
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
if (!self.appletId || self.appletId.length < 1) {
failure(@{@"errMsg": @"finishRunningApplet:fail"});
return;
}
[[FATClient sharedClient] closeApplet:self.appletId animated:_animated completion:^{
[[FATClient sharedClient] clearMemeryApplet:self.appletId];
success(@{});
}];
}
@end

View File

@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface MOP_registerExtensionApi : MOPBaseApi
@property NSString* name;
@property(nonatomic, copy) NSString* name;
@end

View File

@ -0,0 +1,16 @@
//
// MOP_removeApplet.h
// mop
//
// Created by on 2021/12/21.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_removeApplet : MOPBaseApi
@property (nonatomic, copy) NSString *appletId;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,32 @@
//
// MOP_removeApplet.m
// mop
//
// Created by on 2021/12/21.
//
#import "MOP_removeApplet.h"
@implementation MOP_removeApplet
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
if (!self.appletId || self.appletId.length < 1) {
failure(@{@"errMsg": @"removeApplet:fail"});
return;
}
FATAppletInfo *appletInfo = [[FATClient sharedClient] currentApplet];
if (appletInfo && [appletInfo.appId isEqual:self.appletId]) {
[[FATClient sharedClient] closeApplet:self.appletId animated:NO completion:^{
[[FATClient sharedClient] removeAppletFromLocalCache:self.appletId];
success(@{});
}];
} else {
[[FATClient sharedClient] removeAppletFromLocalCache:self.appletId];
success(@{});
}
}
@end

View File

@ -0,0 +1,16 @@
//
// MOP_sendCustomEvent.h
// mop
//
// Created by on 2021/12/21.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_sendCustomEvent : MOPBaseApi
@property (nonatomic, strong) NSDictonary *eventData;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// MOP_sendCustomEvent.m
// mop
//
// Created by on 2021/12/21.
//
#import "MOP_sendCustomEvent.h"
@implementation MOP_sendCustomEvent
- (void)setupApiWithSuccess:(void (^)(NSDictionary<NSString *,id> * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel
{
if (!self.eventData ) {
failure(@{@"errMsg": @"sendCustomEvent:fail"});
return;
}
[[FATClient sharedClient].nativeViewManager sendCustomEventWithDetail:self.eventData completion:^(id result, NSError *error) {
if (error) {
failure(@{@"errMsg": @"sendCustomEvent:fail"});
} else {
success(result);
}
}];
}
@end

View File

@ -0,0 +1,16 @@
//
// MOP_setFinStoreConfigs.h
// mop
//
// Created by on 2021/12/20.
//
#import "MOPBaseApi.h"
NS_ASSUME_NONNULL_BEGIN
@interface MOP_setFinStoreConfigs : MOPBaseApi
@property(nonatomic, strong) NSArray *storeConfigs;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,12 @@
//
// MOP_setFinStoreConfigs.m
// mop
//
// Created by on 2021/12/20.
//
#import "MOP_setFinStoreConfigs.h"
@implementation MOP_setFinStoreConfigs
@end

View File

@ -91,7 +91,9 @@ static MopPlugin *_instance;
return [[FATClient sharedClient] handleOpenURL:url];
}
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler
- (BOOL)application:(UIApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
restorationHandler:(void (^)(NSArray*))restorationHandler
{
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *url = userActivity.webpageURL;

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:ffi';
import 'package:flutter/services.dart';
import 'package:mop/api.dart';
@ -8,6 +9,24 @@ typedef MopEventErrorCallback = void Function(dynamic event);
typedef ExtensionApiHandler = Future Function(dynamic params);
class FinStoreConfig {
String sdkKey; //SDK Key
String sdkSecret; //SDK secret
String apiServer; //
String apmServer; //apm,apiServer
int cryptType; //MD5 0:MD5 1:MD5
String fingerprint; //SDK (https://open.fdep.cn/)
String
encryptServerData; //使YES
}
class FinAppletUIConfig {
Map<String, dynamic> navigationTitleTextAttributes; //font
}
class Mop {
static final Mop _instance = new Mop._internal();
MethodChannel _channel;
@ -17,6 +36,8 @@ class Mop {
Map<String, ExtensionApiHandler> _extensionApis = {};
Map<String, ExtensionApiHandler> _webExtensionApis = {};
factory Mop() {
return _instance;
}
@ -54,7 +75,13 @@ class Mop {
if (handler != null) {
return await handler(call.arguments);
}
} else if (call.method.startsWith("extensionApi:")) {}
} else if (call.method.startsWith("webExtentionApi:")) {
final name = call.method.substring("webExtentionApi:".length);
final handler = _webExtensionApis[name];
if (handler != null) {
return await handler(call.arguments);
}
}
}
///
@ -246,4 +273,67 @@ class Mop {
await _channel.invokeMapMethod("webViewBounces", {'bounces': bounces});
return;
}
//20211220Api
//
Future<void> setFinStoreConfigs(List<FinStoreConfig> configs) async {}
//ui
Future<void> setUiConfig() async {}
//ua setUiConfigua
Future<void> setCustomWebViewUserAgent(String ua) async {}
//
Future<void> startApplet() async {}
//
Future<void> setAppletIntervalUpdateLimit(int count) async {}
//
Future<void> closeApplet(String appletId, bool animated) async {
await _channel.invokeMethod(
"closeApplet", {"appletId": appletId, "animated": animated});
return;
}
//
Future<void> finishRunningApplet(String appletId, bool animated) async {
await _channel.invokeMethod(
"finishRunningApplet", {"appletId": appletId, "animated": animated});
return;
}
// removeUsedApplet?
Future<void> removeApplet(String appletId) async {
await _channel.invokeMethod("removeApplet", {"appletId": appletId});
return;
}
//
Future<void> setActivityTransitionAnim() async {}
//
Future<void> sendCustomEvent(Map<String, dynamic> eventData) async {
await _channel.invokeMethod("sendCustomEvent", {"eventData": eventData});
return;
}
//js
Future<void> callJS(String eventName, String nativeViewId,
Map<String, dynamic> eventData) async {
await _channel.invokeMethod("callJS", {
"eventName": eventName,
"nativeViewId": nativeViewId,
"eventData": eventData
});
return;
}
//h5
void addWebExtentionApi(String name, ExtensionApiHandler handler) {
_webExtensionApis[name] = handler;
_channel.invokeMethod("addWebExtentionApi", {"name": name});
}
}