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

reformat code

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