Merge branch 'master' of https://git.finogeeks.club/mop-mobile/mop-flutter-sdk
commit
4ed9b57647
|
@ -91,6 +91,6 @@ kapt {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.finogeeks.lib:finapplet:2.13.13'
|
implementation 'com.finogeeks.lib:finapplet:2.13.29'
|
||||||
implementation 'com.finogeeks.mop:plugins:0.0.23'
|
implementation 'com.finogeeks.mop:plugins:0.0.26'
|
||||||
}
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
|
||||||
|
android.enableR8=true
|
||||||
|
|
Binary file not shown.
|
@ -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 "$@"
|
|
@ -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
|
|
@ -24,6 +24,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
import io.flutter.plugin.common.MethodChannel;
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
|
|
||||||
|
@ -54,10 +55,14 @@ public class AppletHandlerModule extends BaseApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shareAppMessage(@NotNull String s, @Nullable Bitmap bitmap, @NotNull IAppletCallback iAppletCallback) {
|
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<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("appletInfo", GsonUtil.gson.fromJson(s, new TypeToken<Map<String, Object>>() {
|
params.put("appletInfo", GsonUtil.gson.fromJson(s, new TypeToken<Map<String, Object>>() {
|
||||||
}.getType()));
|
}.getType()));
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
||||||
|
byte[] data = baos.toByteArray();
|
||||||
|
params.put("bitmap",data);
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
channel.invokeMethod("extensionApi:forwardApplet", params, new MethodChannel.Result() {
|
channel.invokeMethod("extensionApi:forwardApplet", params, new MethodChannel.Result() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,8 +4,6 @@ import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
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.api.BaseApi;
|
||||||
import com.finogeeks.mop.interfaces.ICallback;
|
import com.finogeeks.mop.interfaces.ICallback;
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
package com.finogeeks.mop.api.mop;
|
package com.finogeeks.mop.api.mop;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.finogeeks.lib.applet.BuildConfig;
|
import com.finogeeks.lib.applet.BuildConfig;
|
||||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
import com.finogeeks.lib.applet.client.FinAppClient;
|
||||||
import com.finogeeks.lib.applet.client.FinAppConfig;
|
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.FinCallback;
|
||||||
|
import com.finogeeks.lib.applet.interfaces.IApi;
|
||||||
import com.finogeeks.mop.api.BaseApi;
|
import com.finogeeks.mop.api.BaseApi;
|
||||||
import com.finogeeks.mop.interfaces.ICallback;
|
import com.finogeeks.mop.interfaces.ICallback;
|
||||||
import com.finogeeks.mop.plugins.client.FinPluginClient;
|
import com.finogeeks.mop.plugins.client.FinPluginClient;
|
||||||
import com.finogeeks.mop.service.MopPluginService;
|
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;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BaseModule extends BaseApi {
|
public class BaseModule extends BaseApi {
|
||||||
|
@ -39,7 +43,20 @@ public class BaseModule extends BaseApi {
|
||||||
public void invoke(String event, Map param, final ICallback callback) {
|
public void invoke(String event, Map param, final ICallback callback) {
|
||||||
|
|
||||||
if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) {
|
if (FinAppClient.INSTANCE.isFinAppProcess(super.getContext())) {
|
||||||
// 小程序进程不执行任何初始化操作
|
// 扩展SDK的API都注册到小程序进程
|
||||||
|
FinAppProcessClient.INSTANCE.setCallback(new FinAppProcessClient.Callback() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public List<IApi> getRegisterExtensionApis(@NotNull Activity activity) {
|
||||||
|
return FinPluginClient.INSTANCE.getPluginManager().getPlugins(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public List<IApi> getRegisterExtensionWebApis(@NotNull Activity activity) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String appkey = String.valueOf(param.get("appkey"));
|
String appkey = String.valueOf(param.get("appkey"));
|
||||||
|
@ -79,7 +96,6 @@ public class BaseModule extends BaseApi {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object result) {
|
public void onSuccess(Object result) {
|
||||||
// SDK初始化成功
|
// SDK初始化成功
|
||||||
FinPluginClient.INSTANCE.getPluginManager().registerPlugins(application);
|
|
||||||
callback.onSuccess(null);
|
callback.onSuccess(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
9b8dc99cc1898757c03a06b2261ab8de
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
- (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion
|
- (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion
|
||||||
{
|
{
|
||||||
NSLog(@"forwardAppletWithInfo:%@",contentInfo);
|
NSLog(@"forwardAppletWithInfo1:%@",contentInfo);
|
||||||
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
|
FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel];
|
||||||
[channel invokeMethod:@"extensionApi:forwardApplet" arguments:@{@"appletInfo":contentInfo} result:^(id _Nullable result) {
|
[channel invokeMethod:@"extensionApi:forwardApplet" arguments:@{@"appletInfo":contentInfo} result:^(id _Nullable result) {
|
||||||
if([result isKindOfClass:[FlutterError class]]|| [result isKindOfClass:[FlutterMethodNotImplemented class] ])
|
if([result isKindOfClass:[FlutterError class]]|| [result isKindOfClass:[FlutterMethodNotImplemented class] ])
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
//
|
||||||
|
// MOP_showBotomSheetModel.h
|
||||||
|
// mop
|
||||||
|
//
|
||||||
|
// Created by 胡健辉 on 2020/12/11.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#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
|
|
@ -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<NSString *,id> * _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 ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||||
|
/**
|
||||||
|
整个内容的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<UITouch *> *)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
|
|
@ -7,6 +7,7 @@
|
||||||
@interface MopPlugin : NSObject <FlutterPlugin>
|
@interface MopPlugin : NSObject <FlutterPlugin>
|
||||||
@property MopEventStream *mopEventStreamHandler;
|
@property MopEventStream *mopEventStreamHandler;
|
||||||
@property FlutterMethodChannel *methodChannel;
|
@property FlutterMethodChannel *methodChannel;
|
||||||
|
@property FlutterMethodChannel *shareMethodChannel;
|
||||||
|
|
||||||
+ (instancetype) instance;
|
+ (instancetype) instance;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -41,6 +41,12 @@ static MopPlugin *_instance;
|
||||||
FlutterEventChannel *mopEventChannel = [FlutterEventChannel eventChannelWithName:@"plugins.mop.finogeeks.com/mop_event" binaryMessenger:[registrar messenger]];
|
FlutterEventChannel *mopEventChannel = [FlutterEventChannel eventChannelWithName:@"plugins.mop.finogeeks.com/mop_event" binaryMessenger:[registrar messenger]];
|
||||||
_instance.mopEventStreamHandler = [[MopEventStream alloc] init];
|
_instance.mopEventStreamHandler = [[MopEventStream alloc] init];
|
||||||
[mopEventChannel setStreamHandler:_instance.mopEventStreamHandler];
|
[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{
|
+ (instancetype)instance{
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
class CustomMenu {
|
class CustomMenu {
|
||||||
int menuId;
|
int menuId;
|
||||||
String image;
|
String image;
|
||||||
|
|
|
@ -161,7 +161,7 @@ class Mop {
|
||||||
///
|
///
|
||||||
void registerAppletHandler(AppletHandler handler) {
|
void registerAppletHandler(AppletHandler handler) {
|
||||||
_extensionApis["forwardApplet"] = (params) async {
|
_extensionApis["forwardApplet"] = (params) async {
|
||||||
handler.forwardApplet(Map<String, dynamic>.from(params["appletInfo"]));
|
handler.forwardApplet(Map<String, dynamic>.from(params));
|
||||||
};
|
};
|
||||||
_extensionApis["getUserInfo"] = (params) {
|
_extensionApis["getUserInfo"] = (params) {
|
||||||
return handler.getUserInfo();
|
return handler.getUserInfo();
|
||||||
|
|
Loading…
Reference in New Issue