diff --git a/android/build.gradle b/android/build.gradle index 8870e78..7b5b834 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.13.13' - implementation 'com.finogeeks.mop:plugins:0.0.23' + implementation 'com.finogeeks.lib:finapplet:2.13.29' + implementation 'com.finogeeks.mop:plugins:0.0.26' } \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 2bd6f4f..1441b1d 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,2 +1,3 @@ org.gradle.jvmargs=-Xmx1536M +android.enableR8=true diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java index 9934861..c70010c 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; +import java.io.ByteArrayOutputStream; import io.flutter.plugin.common.MethodChannel; @@ -54,10 +55,14 @@ public class AppletHandlerModule extends BaseApi { @Override public void shareAppMessage(@NotNull String s, @Nullable Bitmap bitmap, @NotNull IAppletCallback iAppletCallback) { - Log.d("MopPlugin", "shareAppMessage:" + s); + Log.d("MopPlugin", "shareAppMessage:" + s+" bitmap:"+bitmap); Map params = new HashMap<>(); params.put("appletInfo", GsonUtil.gson.fromJson(s, new TypeToken>() { }.getType())); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); + byte[] data = baos.toByteArray(); + params.put("bitmap",data); handler.post(() -> { channel.invokeMethod("extensionApi:forwardApplet", params, new MethodChannel.Result() { @Override diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java index 6dff660..b35821e 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletModule.java @@ -4,8 +4,6 @@ import android.content.Context; import android.util.Log; import com.finogeeks.lib.applet.client.FinAppClient; -import com.finogeeks.lib.applet.client.FinAppConfig; -import com.finogeeks.lib.applet.client.FinAppInfo; import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.interfaces.ICallback; diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java index afb73b9..9d6384c 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java @@ -1,20 +1,24 @@ package com.finogeeks.mop.api.mop; +import android.app.Activity; import android.app.Application; import android.content.Context; -import android.util.Log; -import android.widget.Toast; import com.finogeeks.lib.applet.BuildConfig; import com.finogeeks.lib.applet.client.FinAppClient; import com.finogeeks.lib.applet.client.FinAppConfig; +import com.finogeeks.lib.applet.client.FinAppProcessClient; import com.finogeeks.lib.applet.interfaces.FinCallback; +import com.finogeeks.lib.applet.interfaces.IApi; import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.plugins.client.FinPluginClient; import com.finogeeks.mop.service.MopPluginService; -import java.util.HashMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; import java.util.Map; public class BaseModule extends BaseApi { @@ -39,7 +43,20 @@ public class BaseModule extends BaseApi { public void invoke(String event, Map param, final ICallback callback) { if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) { - // 小程序进程不执行任何初始化操作 + // 扩展SDK的API都注册到小程序进程 + FinAppProcessClient.INSTANCE.setCallback(new FinAppProcessClient.Callback() { + @Nullable + @Override + public List getRegisterExtensionApis(@NotNull Activity activity) { + return FinPluginClient.INSTANCE.getPluginManager().getPlugins(activity); + } + + @Nullable + @Override + public List getRegisterExtensionWebApis(@NotNull Activity activity) { + return null; + } + }); return; } String appkey = String.valueOf(param.get("appkey")); @@ -79,7 +96,6 @@ public class BaseModule extends BaseApi { @Override public void onSuccess(Object result) { // SDK初始化成功 - FinPluginClient.INSTANCE.getPluginManager().registerPlugins(application); callback.onSuccess(null); } diff --git a/example/ios/Flutter/.last_build_id b/example/ios/Flutter/.last_build_id new file mode 100644 index 0000000..f8ccbe5 --- /dev/null +++ b/example/ios/Flutter/.last_build_id @@ -0,0 +1 @@ +9b8dc99cc1898757c03a06b2261ab8de \ No newline at end of file diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index 85b3469..b0ab388 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -22,7 +22,7 @@ - (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion { - NSLog(@"forwardAppletWithInfo:%@",contentInfo); + NSLog(@"forwardAppletWithInfo1:%@",contentInfo); FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; [channel invokeMethod:@"extensionApi:forwardApplet" arguments:@{@"appletInfo":contentInfo} result:^(id _Nullable result) { if([result isKindOfClass:[FlutterError class]]|| [result isKindOfClass:[FlutterMethodNotImplemented class] ]) diff --git a/ios/Classes/Api/MOP_showBotomSheetModel.h b/ios/Classes/Api/MOP_showBotomSheetModel.h new file mode 100644 index 0000000..4d444f7 --- /dev/null +++ b/ios/Classes/Api/MOP_showBotomSheetModel.h @@ -0,0 +1,37 @@ +// +// MOP_showBotomSheetModel.h +// mop +// +// Created by 胡健辉 on 2020/12/11. +// + +#import +#import "MOPBaseApi.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MOP_showBotomSheetModel : MOPBaseApi +@property(nonatomic, strong) NSString *appId; + +@end + + +typedef void (^MOP_shareBottomViewTypeBlock)(NSInteger type); + +@interface MOP_shareBottomView : UIView +@property(nonatomic, copy) MOP_shareBottomViewTypeBlock didSelcetTypeBlock; + ++ (instancetype)view; +- (void)show; +- (void)dismiss; + +@end + +@interface MOP_shareBottomViewCell : UICollectionViewCell +@property(nonatomic, assign) NSInteger type; +@property(nonatomic, strong) UIImageView *imageView; +@property(nonatomic, strong) UILabel *label; + + +@end +NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Api/MOP_showBotomSheetModel.m b/ios/Classes/Api/MOP_showBotomSheetModel.m new file mode 100644 index 0000000..f86728a --- /dev/null +++ b/ios/Classes/Api/MOP_showBotomSheetModel.m @@ -0,0 +1,199 @@ +// +// MOP_showBotomSheetModel.m +// mop +// +// Created by 胡健辉 on 2020/12/11. +// + +#import "MOP_showBotomSheetModel.h" +#import "MopPlugin.h" + + +@implementation MOP_showBotomSheetModel + +- (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel { + NSLog(@"showBotomSheetModel"); + MOP_shareBottomView *view = [MOP_shareBottomView view]; + [view show]; + [view setDidSelcetTypeBlock:^(NSInteger type) { + FlutterMethodChannel *channel = [[MopPlugin instance] shareMethodChannel]; + [channel invokeMethod:@"shareApi:doShare" arguments:@{@"type":@(type)} result:^(id _Nullable result) { + + }]; + }]; + success(@{}); +} + +@end + + +//获取安全区域距离 +#define kFinoSafeAreaTop kFinoWindowSafeAreaInset.top +#define kFinoSafeAreaBottom kFinoWindowSafeAreaInset.bottom + +#define kFinoWindowSafeAreaInset \ +({\ +UIEdgeInsets returnInsets = UIEdgeInsetsMake([UIApplication sharedApplication].statusBarFrame.size.height, 0, 0, 0);\ +UIWindow * keyWindow = [UIApplication sharedApplication].keyWindow;\ +if ([keyWindow respondsToSelector:NSSelectorFromString(@"safeAreaInsets")]) {\ +UIEdgeInsets inset = [[keyWindow valueForKeyPath:@"safeAreaInsets"] UIEdgeInsetsValue];\ +if (inset.top < [UIApplication sharedApplication].statusBarFrame.size.height) {\ +inset.top = [UIApplication sharedApplication].statusBarFrame.size.height;\ +}\ +returnInsets = inset;\ +}\ +(returnInsets);\ +})\ + +@interface MOP_shareBottomView () +/** + 整个内容的View + */ +@property (nonatomic, strong) UIView *contentView; + +/** + 取消按钮 + */ +@property (nonatomic, strong) UIButton *cancelButton; + +@property(nonatomic, strong) UICollectionView *collectionView; + +@property(nonatomic, strong) NSArray *dataArray; + +@end + +@implementation MOP_shareBottomView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + self.dataArray = @[@(0)]; + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f]; + self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 150 - kFinoSafeAreaBottom, self.frame.size.width, 150 + kFinoSafeAreaBottom)]; + self.contentView.backgroundColor = [UIColor whiteColor]; + [self addSubview:self.contentView]; + + self.cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [self.cancelButton setTitle:@"取消" forState:UIControlStateNormal]; + [self.cancelButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [self.contentView addSubview:self.cancelButton]; + self.cancelButton.frame = CGRectMake(0, self.contentView.frame.size.height - kFinoSafeAreaBottom - 50, self.contentView.frame.size.width, 50); + + UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.cancelButton.frame.size.width, 0.5)]; + line.backgroundColor = [UIColor lightGrayColor]; + [self.cancelButton addSubview:line]; + + [self.contentView addSubview:self.collectionView]; + self.collectionView.frame = CGRectMake(0, 0, frame.size.width, 100); + + } + return self; +} + ++ (instancetype)view { + return [[self alloc] initWithFrame:[UIScreen mainScreen].bounds]; +} + +- (void)show { + if (self.superview) { + return; + } + [UIView animateWithDuration:0.3 animations:^{ + UIWindow * window=[UIApplication sharedApplication].keyWindow; + [window addSubview:self]; + } completion:^(BOOL finished) { + }]; +} + +- (void)dismiss +{ + [UIView animateWithDuration:0.25 animations:^{ + self.contentView.transform = CGAffineTransformMakeTranslation(0, self.contentView.frame.size.height); + self.alpha = 0.5f; + } completion:^(BOOL finished) { + [self removeFromSuperview]; + }]; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + [self dismiss]; +} + +#pragma mark colletionview ------------------------------ +static NSString *cellID = @"cellid"; +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + MOP_shareBottomViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; + cell.type = [self.dataArray[indexPath.row] intValue]; + return cell; +} + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + if (self.didSelcetTypeBlock) { + MOP_shareBottomViewCell *cell = (MOP_shareBottomViewCell *)[collectionView cellForItemAtIndexPath:indexPath]; + self.didSelcetTypeBlock(cell.type); + } + [self dismiss]; +} + +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { + return 1; +} + +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.dataArray.count; +} + +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { + return CGSizeMake(self.collectionView.frame.size.width / self.dataArray.count, self.collectionView.frame.size.height); +} + +- (UICollectionViewFlowLayout *)layout { + UICollectionViewFlowLayout *collectionViewLayout = [[UICollectionViewFlowLayout alloc] init]; + collectionViewLayout.minimumLineSpacing = 0; + collectionViewLayout.minimumInteritemSpacing = 0; + collectionViewLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; + return collectionViewLayout; +} + +- (UICollectionView *)collectionView { + if (!_collectionView) { + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:[self layout]]; + _collectionView.delegate = self; + _collectionView.dataSource = self; + [_collectionView registerClass:[MOP_shareBottomViewCell class] forCellWithReuseIdentifier:cellID]; + _collectionView.pagingEnabled = YES; + _collectionView.showsVerticalScrollIndicator = NO; + _collectionView.showsHorizontalScrollIndicator = NO; + } + return _collectionView;; +} +@end + +@implementation MOP_shareBottomViewCell +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + self.backgroundColor = [UIColor whiteColor]; + self.imageView = [UIImageView new]; + self.imageView.frame = CGRectMake((frame.size.width-50)/2, 10, 50, 50); + [self.contentView addSubview:self.imageView]; + + self.label = [[UILabel alloc] initWithFrame:CGRectMake((frame.size.width-50)/2, 65, frame.size.width, 30)]; + self.label.font = [UIFont systemFontOfSize:14]; + self.label.textColor = [UIColor grayColor]; + [self.contentView addSubview:self.label]; + + } + return self; +} + +- (void)setType:(NSInteger)type { + _type = type; + if (_type == 0) { + self.label.text = @"微信好友"; + self.imageView.image = [UIImage imageNamed:@"turkey_share_wechat"]; + } +} +@end diff --git a/ios/Classes/MopPlugin.h b/ios/Classes/MopPlugin.h index 6c2a24e..70db2b6 100644 --- a/ios/Classes/MopPlugin.h +++ b/ios/Classes/MopPlugin.h @@ -7,6 +7,7 @@ @interface MopPlugin : NSObject @property MopEventStream *mopEventStreamHandler; @property FlutterMethodChannel *methodChannel; +@property FlutterMethodChannel *shareMethodChannel; + (instancetype) instance; @end diff --git a/ios/Classes/MopPlugin.m b/ios/Classes/MopPlugin.m index 0ee5cb8..d927950 100644 --- a/ios/Classes/MopPlugin.m +++ b/ios/Classes/MopPlugin.m @@ -41,6 +41,12 @@ static MopPlugin *_instance; FlutterEventChannel *mopEventChannel = [FlutterEventChannel eventChannelWithName:@"plugins.mop.finogeeks.com/mop_event" binaryMessenger:[registrar messenger]]; _instance.mopEventStreamHandler = [[MopEventStream alloc] init]; [mopEventChannel setStreamHandler:_instance.mopEventStreamHandler]; + + FlutterMethodChannel* shareChannel = [FlutterMethodChannel + methodChannelWithName:@"plugins.finosprite.finogeeks.com/share" + binaryMessenger:[registrar messenger]]; + [registrar addMethodCallDelegate:_instance channel:shareChannel]; + _instance.shareMethodChannel = shareChannel; } + (instancetype)instance{ diff --git a/lib/api.dart b/lib/api.dart index c1af4cd..b48683d 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,3 +1,5 @@ +import 'dart:typed_data'; + class CustomMenu { int menuId; String image; diff --git a/lib/mop.dart b/lib/mop.dart index e34cbe8..83d675b 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -161,7 +161,7 @@ class Mop { /// void registerAppletHandler(AppletHandler handler) { _extensionApis["forwardApplet"] = (params) async { - handler.forwardApplet(Map.from(params["appletInfo"])); + handler.forwardApplet(Map.from(params)); }; _extensionApis["getUserInfo"] = (params) { return handler.getUserInfo();