提交 b1e3a51d authored 作者: JarvanMo's avatar JarvanMo

format code

上级 a335eb8e
...@@ -23,7 +23,6 @@ import 'wechat_type.dart'; ...@@ -23,7 +23,6 @@ import 'wechat_type.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'utils/utils.dart'; import 'utils/utils.dart';
StreamController<WeChatShareResponse> _responseShareController = StreamController<WeChatShareResponse> _responseShareController =
new StreamController.broadcast(); new StreamController.broadcast();
...@@ -42,10 +41,11 @@ StreamController<WeChatPaymentResponse> _responsePaymentController = ...@@ -42,10 +41,11 @@ StreamController<WeChatPaymentResponse> _responsePaymentController =
Stream<WeChatPaymentResponse> get responseFromPayment => Stream<WeChatPaymentResponse> get responseFromPayment =>
_responsePaymentController.stream; _responsePaymentController.stream;
Stream<WeChatLaunchMiniProgramResponse> get responseFromLaunchMiniProgram => _responseLaunchMiniProgramController.stream; Stream<WeChatLaunchMiniProgramResponse> get responseFromLaunchMiniProgram =>
_responseLaunchMiniProgramController.stream;
StreamController<WeChatLaunchMiniProgramResponse> _responseLaunchMiniProgramController = StreamController<WeChatLaunchMiniProgramResponse>
new StreamController.broadcast(); _responseLaunchMiniProgramController = new StreamController.broadcast();
final MethodChannel _channel = const MethodChannel('com.jarvanmo/fluwx') final MethodChannel _channel = const MethodChannel('com.jarvanmo/fluwx')
..setMethodCallHandler(_handler); ..setMethodCallHandler(_handler);
...@@ -94,7 +94,11 @@ Future register( ...@@ -94,7 +94,11 @@ Future register(
} }
///we don't need the response any longer if params are true. ///we don't need the response any longer if params are true.
void dispose({shareResponse: true, authResponse: true, paymentResponse: true,launchMiniProgramResponse:true}) { void dispose(
{shareResponse: true,
authResponse: true,
paymentResponse: true,
launchMiniProgramResponse: true}) {
if (shareResponse) { if (shareResponse) {
_responseShareController.close(); _responseShareController.close();
} }
...@@ -130,19 +134,26 @@ Future share(WeChatShareModel model) async { ...@@ -130,19 +134,26 @@ Future share(WeChatShareModel model) async {
} }
} }
Future sendAuth({ String openId,@required String scope,String state}) async { Future sendAuth({String openId, @required String scope, String state}) async {
// "scope": scope, "state": state, "openId": openId // "scope": scope, "state": state, "openId": openId
assert(scope != null && scope.trim().isNotEmpty); assert(scope != null && scope.trim().isNotEmpty);
return await _channel.invokeMethod("sendAuth", {"scope": scope, "state": state, "openId": openId}); return await _channel.invokeMethod(
"sendAuth", {"scope": scope, "state": state, "openId": openId});
} }
Future launchMiniProgram({@required String username, String path, WXMiniProgramType miniProgramType = WXMiniProgramType.RELEASE}) async { Future launchMiniProgram(
{@required String username,
String path,
WXMiniProgramType miniProgramType = WXMiniProgramType.RELEASE}) async {
assert(username != null && username.trim().isNotEmpty); assert(username != null && username.trim().isNotEmpty);
return await _channel.invokeMethod("launchMiniProgram", {"userName": username, "path": path, "miniProgramType": miniProgramTypeToInt(miniProgramType)}); return await _channel.invokeMethod("launchMiniProgram", {
"userName": username,
"path": path,
"miniProgramType": miniProgramTypeToInt(miniProgramType)
});
} }
Future isWeChatInstalled() async { Future isWeChatInstalled() async {
return await _channel.invokeMethod("isWeChatInstalled"); return await _channel.invokeMethod("isWeChatInstalled");
} }
...@@ -169,5 +180,3 @@ Future pay( ...@@ -169,5 +180,3 @@ Future pay(
"extData": extData, "extData": extData,
}); });
} }
...@@ -76,7 +76,6 @@ class WeChatAuthResponse { ...@@ -76,7 +76,6 @@ class WeChatAuthResponse {
androidTransaction = map["transaction"]; androidTransaction = map["transaction"];
} }
class WeChatLaunchMiniProgramResponse { class WeChatLaunchMiniProgramResponse {
final String errStr; final String errStr;
final int type; final int type;
...@@ -96,7 +95,6 @@ class WeChatLaunchMiniProgramResponse { ...@@ -96,7 +95,6 @@ class WeChatLaunchMiniProgramResponse {
extMsg = map["extMsg"]; extMsg = map["extMsg"];
} }
class WeChatPaymentResponse { class WeChatPaymentResponse {
final String errStr; final String errStr;
final int type; final int type;
......
...@@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart'; ...@@ -17,6 +17,7 @@ import 'package:flutter/foundation.dart';
import '../wechat_type.dart'; import '../wechat_type.dart';
import '../utils/utils.dart'; import '../utils/utils.dart';
const String _scene = "scene"; const String _scene = "scene";
const String _transaction = "transaction"; const String _transaction = "transaction";
const String _thumbnail = "thumbnail"; const String _thumbnail = "thumbnail";
...@@ -80,8 +81,6 @@ class WeChatShareTextModel extends WeChatShareModel { ...@@ -80,8 +81,6 @@ class WeChatShareTextModel extends WeChatShareModel {
/// [hdImagePath] only works with iOS /// [hdImagePath] only works with iOS
/// ///
class WeChatShareMiniProgramModel extends WeChatShareModel { class WeChatShareMiniProgramModel extends WeChatShareModel {
final String webPageUrl; final String webPageUrl;
final WXMiniProgramType miniProgramType; final WXMiniProgramType miniProgramType;
final String userName; final String userName;
......
import '../wechat_type.dart'; import '../wechat_type.dart';
int miniProgramTypeToInt(WXMiniProgramType type){ int miniProgramTypeToInt(WXMiniProgramType type) {
switch(type){ switch (type) {
case WXMiniProgramType.PREVIEW: case WXMiniProgramType.PREVIEW:
return 2; return 2;
case WXMiniProgramType.TEST: case WXMiniProgramType.TEST:
return 1; return 1;
case WXMiniProgramType.RELEASE: case WXMiniProgramType.RELEASE:
return 0; return 0;
} }
return 0; return 0;
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
///[WXMiniProgramType.RELEASE]正式版 ///[WXMiniProgramType.RELEASE]正式版
///[WXMiniProgramType.TEST]测试版 ///[WXMiniProgramType.TEST]测试版
///[WXMiniProgramType.PREVIEW]预览版 ///[WXMiniProgramType.PREVIEW]预览版
...@@ -21,4 +22,4 @@ enum WXMiniProgramType { RELEASE, TEST, PREVIEW } ...@@ -21,4 +22,4 @@ enum WXMiniProgramType { RELEASE, TEST, PREVIEW }
///[WeChatScene.SESSION]会话 ///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈 ///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.FAVORITE]收藏 ///[WeChatScene.FAVORITE]收藏
enum WeChatScene { SESSION, TIMELINE, FAVORITE } enum WeChatScene { SESSION, TIMELINE, FAVORITE }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论