提交 23d8a8d5 authored 作者: JarvanMo's avatar JarvanMo

reformat code

上级 7f65cd47
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest package="com.jarvan.fluwx">
package="com.jarvan.fluwx">
<application> <application>
</application> </application>
</manifest> </manifest>
...@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver; ...@@ -4,7 +4,6 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import com.jarvan.fluwx.constant.WechatPluginKeys;
import com.tencent.mm.opensdk.openapi.IWXAPI; import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory; import com.tencent.mm.opensdk.openapi.WXAPIFactory;
......
...@@ -35,7 +35,7 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler { ...@@ -35,7 +35,7 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
return return
} }
if(call.method == IS_WE_CHAT_INSTALLED){ if (call.method == IS_WE_CHAT_INSTALLED) {
WXAPiHandler.checkWeChatInstallation(result) WXAPiHandler.checkWeChatInstallation(result)
return return
} }
...@@ -45,8 +45,8 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler { ...@@ -45,8 +45,8 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
return return
} }
if(call.method == WeChatPluginMethods.PAY){ if (call.method == WeChatPluginMethods.PAY) {
FluwxPayHandler.pay(call,result) FluwxPayHandler.pay(call, result)
return return
} }
...@@ -57,6 +57,5 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler { ...@@ -57,6 +57,5 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
} }
} }
} }
...@@ -12,7 +12,7 @@ internal object FluwxAuthHandler { ...@@ -12,7 +12,7 @@ internal object FluwxAuthHandler {
req.scope = call.argument("scope") req.scope = call.argument("scope")
req.state = call.argument("state") req.state = call.argument("state")
val openId = call.argument<String?>("openId") val openId = call.argument<String?>("openId")
if(!openId.isNullOrBlank()){ if (!openId.isNullOrBlank()) {
req.openId = call.argument("openId") req.openId = call.argument("openId")
} }
......
...@@ -15,19 +15,19 @@ object FluwxPayHandler { ...@@ -15,19 +15,19 @@ object FluwxPayHandler {
if (WXAPiHandler.wxApi == null) { if (WXAPiHandler.wxApi == null) {
result.error(CallResult.RESULT_API_NULL, "please config wxapi first", null) result.error(CallResult.RESULT_API_NULL, "please config wxapi first", null)
return return
}else{ } else {
// 将该app注册到微信 // 将该app注册到微信
val request = PayReq() val request = PayReq()
request.appId = call.argument("appId") request.appId = call.argument("appId")
request.partnerId = call.argument("partnerId") request.partnerId = call.argument("partnerId")
request.prepayId= call.argument("prepayId") request.prepayId = call.argument("prepayId")
request.packageValue = call.argument("packageValue") request.packageValue = call.argument("packageValue")
request.nonceStr= call.argument("nonceStr") request.nonceStr = call.argument("nonceStr")
request.timeStamp= call.argument("timeStamp") request.timeStamp = call.argument("timeStamp")
request.sign= call.argument("sign") request.sign = call.argument("sign")
request.signType= call.argument("signType") request.signType = call.argument("signType")
request.extData=call.argument("extData") request.extData = call.argument("extData")
val done = WXAPiHandler.wxApi!!.sendReq(request) val done = WXAPiHandler.wxApi!!.sendReq(request)
result.success( result.success(
mapOf( mapOf(
......
...@@ -15,7 +15,7 @@ object FluwxResponseHandler { ...@@ -15,7 +15,7 @@ object FluwxResponseHandler {
private const val errStr = "errStr" private const val errStr = "errStr"
private const val errCode = "errCode" private const val errCode = "errCode"
private const val openId ="openId" private const val openId = "openId"
private const val type = "type" private const val type = "type"
fun setMethodChannel(channel: MethodChannel) { fun setMethodChannel(channel: MethodChannel) {
...@@ -23,13 +23,12 @@ object FluwxResponseHandler { ...@@ -23,13 +23,12 @@ object FluwxResponseHandler {
} }
fun handleResponse(response: BaseResp) { fun handleResponse(response: BaseResp) {
if (response is SendAuth.Resp) { if (response is SendAuth.Resp) {
handleAuthResponse(response) handleAuthResponse(response)
}else if (response is SendMessageToWX.Resp){ } else if (response is SendMessageToWX.Resp) {
handleSendMessageResp(response) handleSendMessageResp(response)
}else if(response is PayResp){ } else if (response is PayResp) {
handlePayResp(response) handlePayResp(response)
} }
} }
...@@ -64,7 +63,7 @@ object FluwxResponseHandler { ...@@ -64,7 +63,7 @@ object FluwxResponseHandler {
} }
private fun handleAuthResponse(response:SendAuth.Resp){ private fun handleAuthResponse(response: SendAuth.Resp) {
val result = mapOf( val result = mapOf(
WechatPluginKeys.PLATFORM to WechatPluginKeys.ANDROID, WechatPluginKeys.PLATFORM to WechatPluginKeys.ANDROID,
errCode to response.errCode, errCode to response.errCode,
......
...@@ -48,11 +48,11 @@ object WXAPiHandler { ...@@ -48,11 +48,11 @@ object WXAPiHandler {
)) ))
} }
fun checkWeChatInstallation(result: MethodChannel.Result){ fun checkWeChatInstallation(result: MethodChannel.Result) {
if (wxApi == null) { if (wxApi == null) {
result.error(CallResult.RESULT_API_NULL, "please config wxapi first", null) result.error(CallResult.RESULT_API_NULL, "please config wxapi first", null)
return return
}else{ } else {
result.success(wxApi!!.isWXAppInstalled) result.success(wxApi!!.isWXAppInstalled)
} }
......
...@@ -7,7 +7,6 @@ import android.graphics.BitmapFactory; ...@@ -7,7 +7,6 @@ import android.graphics.BitmapFactory;
import com.jarvan.fluwx.constant.WeChatPluginImageSchema; import com.jarvan.fluwx.constant.WeChatPluginImageSchema;
import com.jarvan.fluwx.constant.WechatPluginKeys; import com.jarvan.fluwx.constant.WechatPluginKeys;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
...@@ -23,7 +22,6 @@ import okhttp3.ResponseBody; ...@@ -23,7 +22,6 @@ import okhttp3.ResponseBody;
import okio.BufferedSink; import okio.BufferedSink;
import okio.Okio; import okio.Okio;
import okio.Source; import okio.Source;
import top.zibin.luban.Luban;
public class ShareImageUtil { public class ShareImageUtil {
......
...@@ -2,7 +2,6 @@ package com.jarvan.fluwx.utils; ...@@ -2,7 +2,6 @@ package com.jarvan.fluwx.utils;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Build;
import android.util.Log; import android.util.Log;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
......
package com.jarvan.fluwx.utils; package com.jarvan.fluwx.utils;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.Log;
import junit.framework.Assert;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
...@@ -9,16 +18,6 @@ import java.net.HttpURLConnection; ...@@ -9,16 +18,6 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.security.MessageDigest;
import junit.framework.Assert;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.Log;
class Util { class Util {
......
...@@ -3,8 +3,6 @@ package com.jarvan.fluwx.utils; ...@@ -3,8 +3,6 @@ package com.jarvan.fluwx.utils;
import android.content.res.AssetFileDescriptor; import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.util.Log;
import com.jarvan.fluwx.constant.WeChatPluginImageSchema; import com.jarvan.fluwx.constant.WeChatPluginImageSchema;
import com.jarvan.fluwx.constant.WechatPluginKeys; import com.jarvan.fluwx.constant.WechatPluginKeys;
......
...@@ -11,8 +11,7 @@ import com.tencent.mm.opensdk.modelbase.BaseResp ...@@ -11,8 +11,7 @@ import com.tencent.mm.opensdk.modelbase.BaseResp
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
open class FluwxWXEntryActivity:Activity(), IWXAPIEventHandler { open class FluwxWXEntryActivity : Activity(), IWXAPIEventHandler {
// IWXAPI 是第三方app和微信通信的openapi接口 // IWXAPI 是第三方app和微信通信的openapi接口
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="DisablePreviewTheme" parent="@android:style/Theme.Light.NoTitleBar"> <style name="DisablePreviewTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowIsTranslucent">false</item> <item name="android:windowIsTranslucent">false</item>
<item name="android:windowDisablePreview">true</item> <item name="android:windowDisablePreview">true</item>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
flutter needs it to communicate with the running application flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc. to allow setting breakpoints, to provide hot reload, etc.
--> -->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that <!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method. calls FlutterMain.startInitialization(this); in its onCreate method.
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame" android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" /> android:value="true" />
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
...@@ -42,9 +42,9 @@ ...@@ -42,9 +42,9 @@
android:launchMode="singleTop"> android:launchMode="singleTop">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sdksample"/> <data android:scheme="sdksample" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
...@@ -54,9 +54,9 @@ ...@@ -54,9 +54,9 @@
android:launchMode="singleTop"> android:launchMode="singleTop">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW"/> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sdksample"/> <data android:scheme="sdksample" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
......
...@@ -7,7 +7,7 @@ import net.sourceforge.simcpux.wxapi.WXPayEntryActivity ...@@ -7,7 +7,7 @@ import net.sourceforge.simcpux.wxapi.WXPayEntryActivity
import io.flutter.app.FlutterActivity import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant import io.flutter.plugins.GeneratedPluginRegistrant
class MainActivity(): FlutterActivity() { class MainActivity() : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
GeneratedPluginRegistrant.registerWith(this) GeneratedPluginRegistrant.registerWith(this)
......
...@@ -3,8 +3,7 @@ package net.sourceforge.simcpux.wxapi; ...@@ -3,8 +3,7 @@ package net.sourceforge.simcpux.wxapi;
import com.jarvan.fluwx.wxapi.FluwxWXEntryActivity; import com.jarvan.fluwx.wxapi.FluwxWXEntryActivity;
public class WXEntryActivity extends FluwxWXEntryActivity{ public class WXEntryActivity extends FluwxWXEntryActivity {
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!-- Modify this file to customize your launch splash screen -->
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" /> <item android:drawable="@android:color/white" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when <!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame --> Flutter draws its first frame -->
......
{ {
"images" : [ "images": [
{ {
"size" : "20x20", "size": "20x20",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-20x20@2x.png", "filename": "Icon-App-20x20@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "20x20", "size": "20x20",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-20x20@3x.png", "filename": "Icon-App-20x20@3x.png",
"scale" : "3x" "scale": "3x"
}, },
{ {
"size" : "29x29", "size": "29x29",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-29x29@1x.png", "filename": "Icon-App-29x29@1x.png",
"scale" : "1x" "scale": "1x"
}, },
{ {
"size" : "29x29", "size": "29x29",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-29x29@2x.png", "filename": "Icon-App-29x29@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "29x29", "size": "29x29",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-29x29@3x.png", "filename": "Icon-App-29x29@3x.png",
"scale" : "3x" "scale": "3x"
}, },
{ {
"size" : "40x40", "size": "40x40",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-40x40@2x.png", "filename": "Icon-App-40x40@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "40x40", "size": "40x40",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-40x40@3x.png", "filename": "Icon-App-40x40@3x.png",
"scale" : "3x" "scale": "3x"
}, },
{ {
"size" : "60x60", "size": "60x60",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-60x60@2x.png", "filename": "Icon-App-60x60@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "60x60", "size": "60x60",
"idiom" : "iphone", "idiom": "iphone",
"filename" : "Icon-App-60x60@3x.png", "filename": "Icon-App-60x60@3x.png",
"scale" : "3x" "scale": "3x"
}, },
{ {
"size" : "20x20", "size": "20x20",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-20x20@1x.png", "filename": "Icon-App-20x20@1x.png",
"scale" : "1x" "scale": "1x"
}, },
{ {
"size" : "20x20", "size": "20x20",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-20x20@2x.png", "filename": "Icon-App-20x20@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "29x29", "size": "29x29",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-29x29@1x.png", "filename": "Icon-App-29x29@1x.png",
"scale" : "1x" "scale": "1x"
}, },
{ {
"size" : "29x29", "size": "29x29",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-29x29@2x.png", "filename": "Icon-App-29x29@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "40x40", "size": "40x40",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-40x40@1x.png", "filename": "Icon-App-40x40@1x.png",
"scale" : "1x" "scale": "1x"
}, },
{ {
"size" : "40x40", "size": "40x40",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-40x40@2x.png", "filename": "Icon-App-40x40@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "76x76", "size": "76x76",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-76x76@1x.png", "filename": "Icon-App-76x76@1x.png",
"scale" : "1x" "scale": "1x"
}, },
{ {
"size" : "76x76", "size": "76x76",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-76x76@2x.png", "filename": "Icon-App-76x76@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "83.5x83.5", "size": "83.5x83.5",
"idiom" : "ipad", "idiom": "ipad",
"filename" : "Icon-App-83.5x83.5@2x.png", "filename": "Icon-App-83.5x83.5@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"size" : "1024x1024", "size": "1024x1024",
"idiom" : "ios-marketing", "idiom": "ios-marketing",
"filename" : "Icon-App-1024x1024@1x.png", "filename": "Icon-App-1024x1024@1x.png",
"scale" : "1x" "scale": "1x"
} }
], ],
"info" : { "info": {
"version" : 1, "version": 1,
"author" : "xcode" "author": "xcode"
} }
} }
{ {
"images" : [ "images": [
{ {
"idiom" : "universal", "idiom": "universal",
"filename" : "LaunchImage.png", "filename": "LaunchImage.png",
"scale" : "1x" "scale": "1x"
}, },
{ {
"idiom" : "universal", "idiom": "universal",
"filename" : "LaunchImage@2x.png", "filename": "LaunchImage@2x.png",
"scale" : "2x" "scale": "2x"
}, },
{ {
"idiom" : "universal", "idiom": "universal",
"filename" : "LaunchImage@3x.png", "filename": "LaunchImage@3x.png",
"scale" : "3x" "scale": "3x"
} }
], ],
"info" : { "info": {
"version" : 1, "version": 1,
"author" : "xcode" "author": "xcode"
} }
} }
import 'package:flutter/material.dart';
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart'; import 'package:fluwx/fluwx.dart';
import 'pay_page.dart';
import 'send_auth.dart'; import 'send_auth.dart';
import 'share_image_page.dart';
import 'share_mini_program.dart'; import 'share_mini_program.dart';
import 'share_video_page.dart';
import 'share_music.dart'; import 'share_music.dart';
import 'share_web_page.dart';
import 'share_image_page.dart';
import 'share_text_image.dart'; import 'share_text_image.dart';
import 'pay_page.dart'; import 'share_video_page.dart';
import 'share_web_page.dart';
void main() => runApp(new MyApp()); void main() => runApp(new MyApp());
class MyApp extends StatefulWidget { class MyApp extends StatefulWidget {
...@@ -37,9 +39,8 @@ class _MyAppState extends State<MyApp> { ...@@ -37,9 +39,8 @@ class _MyAppState extends State<MyApp> {
"shareMusic": (context) => ShareMusicPage(), "shareMusic": (context) => ShareMusicPage(),
"shareVideo": (context) => ShareVideoPage(), "shareVideo": (context) => ShareVideoPage(),
"sendAuth": (context) => SendAuthPage(), "sendAuth": (context) => SendAuthPage(),
"shareMiniProgram":(context) => ShareMiniProgramPage(), "shareMiniProgram": (context) => ShareMiniProgramPage(),
"pay":(context)=> PayPage(), "pay": (context) => PayPage(),
}, },
home: new Scaffold( home: new Scaffold(
appBar: new AppBar( appBar: new AppBar(
......
import 'dart:convert'; import 'dart:convert';
import 'dart:io' as H;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart'; import 'package:fluwx/fluwx.dart';
import 'dart:io' as H;
class PayPage extends StatefulWidget { class PayPage extends StatefulWidget {
@override @override
_PayPageState createState() => _PayPageState(); _PayPageState createState() => _PayPageState();
} }
class _PayPageState extends State<PayPage> { class _PayPageState extends State<PayPage> {
String _url = "https://wxpay.wxutil.com/pub_v2/app/app_pay.php"; String _url = "https://wxpay.wxutil.com/pub_v2/app/app_pay.php";
Fluwx _fluwx; Fluwx _fluwx;
String _result ="无"; String _result = "无";
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_fluwx = new Fluwx(); _fluwx = new Fluwx();
_fluwx.response.listen((data){ _fluwx.response.listen((data) {
setState(() { setState(() {
_result = data.toString(); _result = data.toString();
}); });
...@@ -36,15 +33,16 @@ class _PayPageState extends State<PayPage> { ...@@ -36,15 +33,16 @@ class _PayPageState extends State<PayPage> {
), ),
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
OutlineButton(onPressed: () async { OutlineButton(
onPressed: () async {
var h = H.HttpClient(); var h = H.HttpClient();
h.badCertificateCallback = (cert, String host, int port){ h.badCertificateCallback = (cert, String host, int port) {
return true; return true;
}; };
var request =await h.getUrl(Uri.parse(_url)); var request = await h.getUrl(Uri.parse(_url));
var response = await request.close(); var response = await request.close();
var data = await response.transform(Utf8Decoder()).join(); var data = await response.transform(Utf8Decoder()).join();
Map<String,dynamic> result = json.decode(data); Map<String, dynamic> result = json.decode(data);
print(result['appid']); print(result['appid']);
_fluwx.pay( _fluwx.pay(
WeChatPayModel( WeChatPayModel(
......
...@@ -7,14 +7,14 @@ class SendAuthPage extends StatefulWidget { ...@@ -7,14 +7,14 @@ class SendAuthPage extends StatefulWidget {
} }
class _SendAuthPageState extends State<SendAuthPage> { class _SendAuthPageState extends State<SendAuthPage> {
Fluwx _fluwx; Fluwx _fluwx;
String _result ="无"; String _result = "无";
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_fluwx = new Fluwx(); _fluwx = new Fluwx();
_fluwx.response.listen((data){ _fluwx.response.listen((data) {
setState(() { setState(() {
_result = data.toString(); _result = data.toString();
}); });
...@@ -29,8 +29,10 @@ class _SendAuthPageState extends State<SendAuthPage> { ...@@ -29,8 +29,10 @@ class _SendAuthPageState extends State<SendAuthPage> {
), ),
body: Column( body: Column(
children: <Widget>[ children: <Widget>[
OutlineButton(onPressed: (){ OutlineButton(
_fluwx.sendAuth(new WeChatSendAuthModel(scope: "snsapi_userinfo",state: "wechat_sdk_demo_test")); onPressed: () {
_fluwx.sendAuth(new WeChatSendAuthModel(
scope: "snsapi_userinfo", state: "wechat_sdk_demo_test"));
}, },
child: const Text("send auth"), child: const Text("send auth"),
), ),
......
...@@ -18,6 +18,7 @@ class _ShareImagePageState extends State<ShareImagePage> { ...@@ -18,6 +18,7 @@ class _ShareImagePageState extends State<ShareImagePage> {
super.initState(); super.initState();
fluwx = new Fluwx(); fluwx = new Fluwx();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
...@@ -45,7 +46,6 @@ class _ShareImagePageState extends State<ShareImagePage> { ...@@ -45,7 +46,6 @@ class _ShareImagePageState extends State<ShareImagePage> {
_imagePath = value; _imagePath = value;
}, },
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
), ),
TextField( TextField(
decoration: InputDecoration(labelText: "缩略地址"), decoration: InputDecoration(labelText: "缩略地址"),
......
...@@ -7,7 +7,6 @@ class ShareMiniProgramPage extends StatefulWidget { ...@@ -7,7 +7,6 @@ class ShareMiniProgramPage extends StatefulWidget {
} }
class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> { class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
Fluwx fluwx; Fluwx fluwx;
WeChatScene scene = WeChatScene.SESSION; WeChatScene scene = WeChatScene.SESSION;
String _webPageUrl = "http://www.qq.com"; String _webPageUrl = "http://www.qq.com";
...@@ -24,74 +23,66 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> { ...@@ -24,74 +23,66 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
fluwx = new Fluwx(); fluwx = new Fluwx();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text("ShareMiniProgram"), title: const Text("ShareMiniProgram"),
actions: <Widget>[ actions: <Widget>[
IconButton(icon: Icon(Icons.share,color: Colors.white,), onPressed: _share) IconButton(
icon: Icon(
Icons.share,
color: Colors.white,
),
onPressed: _share)
], ],
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: new ListView( child: new ListView(
children: <Widget>[ children: <Widget>[
new TextField( new TextField(
controller: TextEditingController(text: "http://www.qq.com"), controller: TextEditingController(text: "http://www.qq.com"),
onChanged: (str){ onChanged: (str) {
_webPageUrl = str; _webPageUrl = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "web page url"),
labelText: "web page url"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "gh_d43f693ca31f"), controller: TextEditingController(text: "gh_d43f693ca31f"),
onChanged: (str){ onChanged: (str) {
_userName = str; _userName = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "user name"),
labelText: "user name"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "/pages/media"), controller: TextEditingController(text: "/pages/media"),
onChanged: (str){ onChanged: (str) {
_path = str; _path = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "user name"),
labelText: "user name"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "Fluwx"), controller: TextEditingController(text: "Fluwx"),
onChanged: (str){ onChanged: (str) {
_title = str; _title = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "title"),
labelText: "title"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "Fluwx"), controller: TextEditingController(text: "Fluwx"),
onChanged: (str){ onChanged: (str) {
_description = str; _description = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "description"),
labelText: "description"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "assets://images/logo.png"), controller:
onChanged: (str){ TextEditingController(text: "assets://images/logo.png"),
onChanged: (str) {
_thumbnail = str; _thumbnail = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "thumbnail"),
labelText: "thumbnail"
),
), ),
], ],
), ),
...@@ -100,16 +91,13 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> { ...@@ -100,16 +91,13 @@ class _ShareMiniProgramPageState extends State<ShareMiniProgramPage> {
} }
void _share() { void _share() {
var model =new WeChatShareMiniProgramModel( var model = new WeChatShareMiniProgramModel(
webPageUrl: _webPageUrl, webPageUrl: _webPageUrl,
miniProgramType: WeChatShareMiniProgramModel.MINI_PROGRAM_TYPE_RELEASE, miniProgramType: WeChatShareMiniProgramModel.MINI_PROGRAM_TYPE_RELEASE,
userName: _userName, userName: _userName,
title: _title, title: _title,
description: _description, description: _description,
thumbnail: _thumbnail thumbnail: _thumbnail);
);
fluwx.share(model); fluwx.share(model);
} }
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart'; import 'package:fluwx/fluwx.dart';
...@@ -9,11 +8,12 @@ class ShareMusicPage extends StatefulWidget { ...@@ -9,11 +8,12 @@ class ShareMusicPage extends StatefulWidget {
class _ShareMusicPageState extends State<ShareMusicPage> { class _ShareMusicPageState extends State<ShareMusicPage> {
Fluwx fluwx; Fluwx fluwx;
String _musicUrl = "http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"; String _musicUrl =
"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3";
String _musicLowBandUrl = "http://www.qq.com"; String _musicLowBandUrl = "http://www.qq.com";
String _title = "Beyond"; String _title = "Beyond";
String _description = "A Popular Rock Band From China"; String _description = "A Popular Rock Band From China";
String _thumnail ="assets://images/logo.png"; String _thumnail = "assets://images/logo.png";
WeChatScene scene = WeChatScene.SESSION; WeChatScene scene = WeChatScene.SESSION;
@override @override
...@@ -28,58 +28,56 @@ class _ShareMusicPageState extends State<ShareMusicPage> { ...@@ -28,58 +28,56 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
appBar: AppBar( appBar: AppBar(
title: const Text("ShareMusicPage"), title: const Text("ShareMusicPage"),
actions: <Widget>[ actions: <Widget>[
IconButton(icon: Icon(Icons.share,color: Colors.white,), onPressed: _share) IconButton(
icon: Icon(
Icons.share,
color: Colors.white,
),
onPressed: _share)
], ],
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new TextField( new TextField(
controller: TextEditingController(text: "http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"), controller: TextEditingController(
onChanged: (str){ text:
"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"),
onChanged: (str) {
_musicUrl = str; _musicUrl = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "music url"),
labelText: "music url"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "http://www.qq.com"), controller: TextEditingController(text: "http://www.qq.com"),
onChanged: (str){ onChanged: (str) {
_musicLowBandUrl = str; _musicLowBandUrl = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "music low band url"),
labelText: "music low band url"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "Beyond"), controller: TextEditingController(text: "Beyond"),
onChanged: (str){ onChanged: (str) {
_title = str; _title = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "title"),
labelText: "title"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "A Popular Rock Band From China"), controller:
onChanged: (str){ TextEditingController(text: "A Popular Rock Band From China"),
onChanged: (str) {
_description = str; _description = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "description"),
labelText: "description"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "assets://images/logo.png"), controller:
onChanged: (str){ TextEditingController(text: "assets://images/logo.png"),
onChanged: (str) {
_thumnail = str; _thumnail = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "thumbnail"),
labelText: "thumbnail"
),
), ),
new Row( new Row(
children: <Widget>[ children: <Widget>[
...@@ -89,8 +87,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> { ...@@ -89,8 +87,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.SESSION, value: WeChatScene.SESSION,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("会话") const Text("会话")
], ],
), ),
...@@ -99,8 +96,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> { ...@@ -99,8 +96,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.TIMELINE, value: WeChatScene.TIMELINE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("朋友圈") const Text("朋友圈")
], ],
), ),
...@@ -109,8 +105,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> { ...@@ -109,8 +105,7 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.FAVORITE, value: WeChatScene.FAVORITE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("收藏") const Text("收藏")
], ],
) )
...@@ -129,13 +124,12 @@ class _ShareMusicPageState extends State<ShareMusicPage> { ...@@ -129,13 +124,12 @@ class _ShareMusicPageState extends State<ShareMusicPage> {
transaction: "music", transaction: "music",
musicUrl: _musicUrl, musicUrl: _musicUrl,
musicLowBandUrl: _musicLowBandUrl, musicLowBandUrl: _musicLowBandUrl,
thumbnail: _thumnail thumbnail: _thumnail);
);
fluwx.share(model); fluwx.share(model);
} }
void handleRadioValueChanged(WeChatScene scene){ void handleRadioValueChanged(WeChatScene scene) {
setState(() { setState(() {
this.scene = scene; this.scene = scene;
}); });
......
...@@ -10,34 +10,37 @@ class _ShareTextPageState extends State<ShareTextPage> { ...@@ -10,34 +10,37 @@ class _ShareTextPageState extends State<ShareTextPage> {
Fluwx fluwx; Fluwx fluwx;
String _text = "share text from fluwx"; String _text = "share text from fluwx";
WeChatScene scene = WeChatScene.SESSION; WeChatScene scene = WeChatScene.SESSION;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
fluwx = new Fluwx(); fluwx = new Fluwx();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text("ShareText"), title: const Text("ShareText"),
actions: <Widget>[ actions: <Widget>[
IconButton(icon: Icon(Icons.share,color: Colors.white,), onPressed: _shareText) IconButton(
icon: Icon(
Icons.share,
color: Colors.white,
),
onPressed: _shareText)
], ],
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new TextField( new TextField(
controller: TextEditingController(text: "share text from fluwx"), controller: TextEditingController(text: "share text from fluwx"),
onChanged: (str){ onChanged: (str) {
_text = str; _text = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "TextToShare"),
labelText: "TextToShare"
),
), ),
new Row( new Row(
children: <Widget>[ children: <Widget>[
...@@ -47,8 +50,7 @@ class _ShareTextPageState extends State<ShareTextPage> { ...@@ -47,8 +50,7 @@ class _ShareTextPageState extends State<ShareTextPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.SESSION, value: WeChatScene.SESSION,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("会话") const Text("会话")
], ],
), ),
...@@ -57,8 +59,7 @@ class _ShareTextPageState extends State<ShareTextPage> { ...@@ -57,8 +59,7 @@ class _ShareTextPageState extends State<ShareTextPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.TIMELINE, value: WeChatScene.TIMELINE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("朋友圈") const Text("朋友圈")
], ],
), ),
...@@ -67,8 +68,7 @@ class _ShareTextPageState extends State<ShareTextPage> { ...@@ -67,8 +68,7 @@ class _ShareTextPageState extends State<ShareTextPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.FAVORITE, value: WeChatScene.FAVORITE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("收藏") const Text("收藏")
], ],
) )
...@@ -79,17 +79,17 @@ class _ShareTextPageState extends State<ShareTextPage> { ...@@ -79,17 +79,17 @@ class _ShareTextPageState extends State<ShareTextPage> {
), ),
); );
} }
void _shareText(){
void _shareText() {
fluwx.share(WeChatShareTextModel( fluwx.share(WeChatShareTextModel(
text: _text, text: _text,
transaction: "text${DateTime.now().millisecondsSinceEpoch}", transaction: "text${DateTime.now().millisecondsSinceEpoch}",
scene: scene scene: scene));
));
// fluwx.sendAuth(WeChatSendAuthModel(scope: "snsapi_userinfo",state: "wechat_sdk_demo_test")); // fluwx.sendAuth(WeChatSendAuthModel(scope: "snsapi_userinfo",state: "wechat_sdk_demo_test"));
} }
void handleRadioValueChanged(WeChatScene scene){ void handleRadioValueChanged(WeChatScene scene) {
setState(() { setState(() {
this.scene = scene; this.scene = scene;
}); });
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart'; import 'package:fluwx/fluwx.dart';
...@@ -13,7 +12,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> { ...@@ -13,7 +12,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
String _videoLowBandUrl = "http://www.qq.com"; String _videoLowBandUrl = "http://www.qq.com";
String _title = "Beyond"; String _title = "Beyond";
String _description = "A Popular Rock Band From China"; String _description = "A Popular Rock Band From China";
String _thumnail ="assets://images/logo.png"; String _thumnail = "assets://images/logo.png";
WeChatScene scene = WeChatScene.SESSION; WeChatScene scene = WeChatScene.SESSION;
@override @override
...@@ -28,58 +27,56 @@ class _ShareMusicPageState extends State<ShareVideoPage> { ...@@ -28,58 +27,56 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
appBar: AppBar( appBar: AppBar(
title: const Text("ShareVideoPage"), title: const Text("ShareVideoPage"),
actions: <Widget>[ actions: <Widget>[
IconButton(icon: Icon(Icons.share,color: Colors.white,), onPressed: _share) IconButton(
icon: Icon(
Icons.share,
color: Colors.white,
),
onPressed: _share)
], ],
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new TextField( new TextField(
controller: TextEditingController(text: "http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"), controller: TextEditingController(
onChanged: (str){ text:
"http://staff2.ustc.edu.cn/~wdw/softdown/index.asp/0042515_05.ANDY.mp3"),
onChanged: (str) {
_videoUrl = str; _videoUrl = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "video url"),
labelText: "video url"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "http://www.qq.com"), controller: TextEditingController(text: "http://www.qq.com"),
onChanged: (str){ onChanged: (str) {
_videoLowBandUrl = str; _videoLowBandUrl = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "video low band url"),
labelText: "video low band url"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "Beyond"), controller: TextEditingController(text: "Beyond"),
onChanged: (str){ onChanged: (str) {
_title = str; _title = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "title"),
labelText: "title"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "A Popular Rock Band From China"), controller:
onChanged: (str){ TextEditingController(text: "A Popular Rock Band From China"),
onChanged: (str) {
_description = str; _description = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "description"),
labelText: "description"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "assets://images/logo.png"), controller:
onChanged: (str){ TextEditingController(text: "assets://images/logo.png"),
onChanged: (str) {
_thumnail = str; _thumnail = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "thumbnail"),
labelText: "thumbnail"
),
), ),
new Row( new Row(
children: <Widget>[ children: <Widget>[
...@@ -89,8 +86,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> { ...@@ -89,8 +86,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.SESSION, value: WeChatScene.SESSION,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("会话") const Text("会话")
], ],
), ),
...@@ -99,8 +95,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> { ...@@ -99,8 +95,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.TIMELINE, value: WeChatScene.TIMELINE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("朋友圈") const Text("朋友圈")
], ],
), ),
...@@ -109,8 +104,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> { ...@@ -109,8 +104,7 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.FAVORITE, value: WeChatScene.FAVORITE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("收藏") const Text("收藏")
], ],
) )
...@@ -129,12 +123,11 @@ class _ShareMusicPageState extends State<ShareVideoPage> { ...@@ -129,12 +123,11 @@ class _ShareMusicPageState extends State<ShareVideoPage> {
videoLowBandUrl: _videoLowBandUrl, videoLowBandUrl: _videoLowBandUrl,
thumbnail: _thumnail, thumbnail: _thumnail,
description: _description, description: _description,
title: _title title: _title);
);
fluwx.share(model); fluwx.share(model);
} }
void handleRadioValueChanged(WeChatScene scene){ void handleRadioValueChanged(WeChatScene scene) {
setState(() { setState(() {
this.scene = scene; this.scene = scene;
}); });
......
...@@ -12,7 +12,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -12,7 +12,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
Fluwx fluwx; Fluwx fluwx;
String _url = "share text from fluwx"; String _url = "share text from fluwx";
String _title = "Fluwx"; String _title = "Fluwx";
String _thumnail ="assets://images/logo.png"; String _thumnail = "assets://images/logo.png";
WeChatScene scene = WeChatScene.SESSION; WeChatScene scene = WeChatScene.SESSION;
@override @override
...@@ -27,40 +27,40 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -27,40 +27,40 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
appBar: AppBar( appBar: AppBar(
title: const Text("ShareWebPage"), title: const Text("ShareWebPage"),
actions: <Widget>[ actions: <Widget>[
IconButton(icon: Icon(Icons.share,color: Colors.white,), onPressed: _share) IconButton(
icon: Icon(
Icons.share,
color: Colors.white,
),
onPressed: _share)
], ],
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: new Column( child: new Column(
children: <Widget>[ children: <Widget>[
new TextField( new TextField(
controller: TextEditingController(text: "https://github.com/JarvanMo/fluwx"), controller: TextEditingController(
onChanged: (str){ text: "https://github.com/JarvanMo/fluwx"),
onChanged: (str) {
_url = str; _url = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "web page"),
labelText: "web page"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "Fluwx"), controller: TextEditingController(text: "Fluwx"),
onChanged: (str){ onChanged: (str) {
_title = str; _title = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "thumbnail"),
labelText: "thumbnail"
),
), ),
new TextField( new TextField(
controller: TextEditingController(text: "assets://images/logo.png"), controller:
onChanged: (str){ TextEditingController(text: "assets://images/logo.png"),
onChanged: (str) {
_thumnail = str; _thumnail = str;
}, },
decoration: InputDecoration( decoration: InputDecoration(labelText: "thumbnail"),
labelText: "thumbnail"
),
), ),
new Row( new Row(
children: <Widget>[ children: <Widget>[
...@@ -70,8 +70,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -70,8 +70,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.SESSION, value: WeChatScene.SESSION,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("会话") const Text("会话")
], ],
), ),
...@@ -80,8 +79,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -80,8 +79,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.TIMELINE, value: WeChatScene.TIMELINE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("朋友圈") const Text("朋友圈")
], ],
), ),
...@@ -90,8 +88,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -90,8 +88,7 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
new Radio<WeChatScene>( new Radio<WeChatScene>(
value: WeChatScene.FAVORITE, value: WeChatScene.FAVORITE,
groupValue: scene, groupValue: scene,
onChanged: handleRadioValueChanged onChanged: handleRadioValueChanged),
),
const Text("收藏") const Text("收藏")
], ],
) )
...@@ -108,13 +105,12 @@ class ShareWebPagePageState extends State<ShareWebPagePage> { ...@@ -108,13 +105,12 @@ class ShareWebPagePageState extends State<ShareWebPagePage> {
webPage: _url, webPage: _url,
title: _title, title: _title,
thumbnail: _thumnail, thumbnail: _thumnail,
scene :scene, scene: scene,
transaction: "hh" transaction: "hh");
);
fluwx.share(model); fluwx.share(model);
} }
void handleRadioValueChanged(WeChatScene scene){ void handleRadioValueChanged(WeChatScene scene) {
setState(() { setState(() {
this.scene = scene; this.scene = scene;
}); });
......
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
// find child widgets in the widget tree, read text, and verify that the values of widget properties // find child widgets in the widget tree, read text, and verify that the values of widget properties
// are correct. // are correct.
import 'package:flutter/material.dart';
void main() { void main() {
// testWidgets('Verify Platform version', (WidgetTester tester) async { // testWidgets('Verify Platform version', (WidgetTester tester) async {
// // Build our app and trigger a frame. // // Build our app and trigger a frame.
......
...@@ -6,9 +6,9 @@ library fluwx; ...@@ -6,9 +6,9 @@ library fluwx;
export 'src/fluwx_class.dart'; export 'src/fluwx_class.dart';
export 'src/models/flutter_register_model.dart'; export 'src/models/flutter_register_model.dart';
export 'src/models/wechat_pay_model.dart';
export 'src/models/wechat_response.dart';
export 'src/models/wechat_send_auth_model.dart';
export 'src/models/wechat_share_models.dart'; export 'src/models/wechat_share_models.dart';
export 'src/wechat_reponse.dart'; export 'src/wechat_reponse.dart';
export 'src/wechat_scene.dart'; export 'src/wechat_scene.dart';
export 'src/models/wechat_pay_model.dart';
export 'src/models/wechat_send_auth_model.dart';
export 'src/models/wechat_response.dart';
...@@ -3,10 +3,10 @@ import 'dart:async'; ...@@ -3,10 +3,10 @@ import 'dart:async';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'models/flutter_register_model.dart'; import 'models/flutter_register_model.dart';
import 'models/wechat_share_models.dart';
import 'models/wechat_send_auth_model.dart';
import 'models/wechat_pay_model.dart'; import 'models/wechat_pay_model.dart';
import 'models/wechat_response.dart'; import 'models/wechat_response.dart';
import 'models/wechat_send_auth_model.dart';
import 'models/wechat_share_models.dart';
StreamController<WeChatResponse> _responseController = StreamController<WeChatResponse> _responseController =
new StreamController.broadcast(); new StreamController.broadcast();
...@@ -16,11 +16,14 @@ final MethodChannel _channel = const MethodChannel('com.jarvanmo/fluwx') ...@@ -16,11 +16,14 @@ final MethodChannel _channel = const MethodChannel('com.jarvanmo/fluwx')
Future<dynamic> _handler(MethodCall methodCall) { Future<dynamic> _handler(MethodCall methodCall) {
if ("onShareResponse" == methodCall.method) { if ("onShareResponse" == methodCall.method) {
_responseController.add(WeChatResponse(methodCall.arguments, ResponseType.SHARE)); _responseController
.add(WeChatResponse(methodCall.arguments, ResponseType.SHARE));
} else if ("onAuthResponse" == methodCall.method) { } else if ("onAuthResponse" == methodCall.method) {
_responseController.add(WeChatResponse(methodCall.arguments, ResponseType.AUTH)); _responseController
.add(WeChatResponse(methodCall.arguments, ResponseType.AUTH));
} else if ("onPayResponse" == methodCall.method) { } else if ("onPayResponse" == methodCall.method) {
_responseController.add(WeChatResponse(methodCall.arguments, ResponseType.PAYMENT)); _responseController
.add(WeChatResponse(methodCall.arguments, ResponseType.PAYMENT));
} }
return Future.value(true); return Future.value(true);
...@@ -44,7 +47,7 @@ class Fluwx { ...@@ -44,7 +47,7 @@ class Fluwx {
} }
///we don't need the response any longer. ///we don't need the response any longer.
static void dispose(){ static void dispose() {
_responseController.close(); _responseController.close();
} }
...@@ -52,7 +55,6 @@ class Fluwx { ...@@ -52,7 +55,6 @@ class Fluwx {
// return await _channel.invokeMethod("unregisterApp", model.toMap()); // return await _channel.invokeMethod("unregisterApp", model.toMap());
// } // }
///the [model] can not be null ///the [model] can not be null
///see [WeChatShareWebPageModel] ///see [WeChatShareWebPageModel]
/// [WeChatShareTextModel] /// [WeChatShareTextModel]
......
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
class WeChatPayModel{ class WeChatPayModel {
final appId; final appId;
final partnerId; final partnerId;
final prepayId; final prepayId;
...@@ -11,24 +11,28 @@ class WeChatPayModel{ ...@@ -11,24 +11,28 @@ class WeChatPayModel{
final signType; final signType;
final extData; final extData;
WeChatPayModel(
WeChatPayModel({@required this.appId,@required this.partnerId,@required this.prepayId, {@required this.appId,
@required this.packageValue,@required this.nonceStr,@required this.timeStamp,@required this.sign, @required this.partnerId,
this.signType, this.extData}); @required this.prepayId,
@required this.packageValue,
@required this.nonceStr,
@required this.timeStamp,
@required this.sign,
this.signType,
this.extData});
Map toMap() { Map toMap() {
return { return {
"appId":appId, "appId": appId,
"partnerId":partnerId, "partnerId": partnerId,
"prepayId":prepayId, "prepayId": prepayId,
"packageValue":packageValue, "packageValue": packageValue,
"nonceStr":nonceStr, "nonceStr": nonceStr,
"timeStamp":timeStamp, "timeStamp": timeStamp,
"sign":sign, "sign": sign,
"signType":signType, "signType": signType,
"extData":extData, "extData": extData,
}; };
} }
} }
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
class WeChatSendAuthModel { class WeChatSendAuthModel {
final String scope; final String scope;
final String state; final String state;
final String openId; final String openId;
WeChatSendAuthModel({ WeChatSendAuthModel({@required this.scope, this.state, this.openId})
@required this.scope, : assert(scope != null && scope.trim().isNotEmpty);
this.state,
this.openId }) :
assert(scope != null && scope
.trim()
.isNotEmpty);
Map toMap() { Map toMap() {
return { return {"scope": scope, "state": state, "openId": openId};
"scope":scope,
"state":state,
"openId":openId
};
} }
} }
///[WeChatScene.SESSION]会话 ///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈 ///[WeChatScene.TIMELINE]朋友圈
///[WeChatScene.FAVORITE]收藏 ///[WeChatScene.FAVORITE]收藏
enum WeChatScene { enum WeChatScene { SESSION, TIMELINE, FAVORITE }
SESSION,
TIMELINE,
FAVORITE }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论