Commit 1d049ed6 authored by netyouli's avatar netyouli

添加分享功能

parent b99145b8
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{
"name": "Flutter: Attach to Device",
"type": "dart",
"request": "attach"
},
{ {
"name": "chart", "name": "chart",
"request": "launch", "request": "launch",
......
...@@ -2,12 +2,35 @@ import UIKit ...@@ -2,12 +2,35 @@ import UIKit
import Flutter import Flutter
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate, WXApiDelegate {
override func application( override func application(
_ application: UIApplication, _ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool { ) -> Bool {
let ksj = WXApi.registerApp("wxac6457d4b052cc48", universalLink: "https://order.1clickpass.com/app/")
GeneratedPluginRegistrant.register(with: self) GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions) return super.application(application, didFinishLaunchingWithOptions: launchOptions)
} }
override func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
override func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
WXApi.handleOpenUniversalLink(userActivity, delegate: self)
}
func onReq(_ req: BaseReq) {
}
func onResp(_ resp: BaseResp) {
}
} }
...@@ -32,9 +32,11 @@ ...@@ -32,9 +32,11 @@
<key>CFBundleTypeRole</key> <key>CFBundleTypeRole</key>
<string>Editor</string> <string>Editor</string>
<key>CFBundleURLName</key> <key>CFBundleURLName</key>
<string>wxac6457d4b052cc48</string> <string>weixin</string>
<key>CFBundleURLSchemes</key> <key>CFBundleURLSchemes</key>
<array/> <array>
<string>wxac6457d4b052cc48</string>
</array>
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
...@@ -49,9 +51,9 @@ ...@@ -49,9 +51,9 @@
<true/> <true/>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>
<dict> <dict>
<key>NSAllowsArbitraryLoads</key> <key>NSAllowsArbitraryLoads</key>
<true/> <true/>
</dict> </dict>
<key>NSMicrophoneUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>只有您‘允许使用麦克风’AI写作大师才能听您说话</string> <string>只有您‘允许使用麦克风’AI写作大师才能听您说话</string>
<key>NSPhotoLibraryUsageDescription</key> <key>NSPhotoLibraryUsageDescription</key>
......
#import "GeneratedPluginRegistrant.h" #import "GeneratedPluginRegistrant.h"
#import <WXApi.h>
import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:share_plus/share_plus.dart';
class WXShare {
static const _dataMap = {
"微信好友": "assets/images/wx_session.png",
"微信朋友圈": "assets/images/wx_timeline.png",
"微信收藏": "assets/images/wx_favorite.png",
"其他分享": "assets/images/wx_other.png"
};
static shareText(String content) {
final items = <Widget>[];
_dataMap.forEach((title, image) {
items.add(
InkWell(
onTap: () {
if (title.contains("微信")) {
final WeChatShareBaseModel model;
if (title == "微信好友") {
model = WeChatShareTextModel(content, scene: WeChatScene.SESSION);
} else if (title == "微信朋友圈") {
model = WeChatShareTextModel(content, scene: WeChatScene.TIMELINE);
} else {
model = WeChatShareTextModel(content, scene: WeChatScene.FAVORITE);
}
shareToWeChat(model);
} else {
Share.shareWithResult(content);
}
Get.back();
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(image, width: 60, height: 60,),
const SizedBox(height: 8),
Text(title, style: const TextStyle(fontSize: 14, color: Colors.black)),
],
),
)
);
});
Get.bottomSheet(Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(20))
),
padding: const EdgeInsets.fromLTRB(20, 20, 20, 100),
child: Wrap(
spacing: 30,
children: items,
),
));
}
}
\ No newline at end of file
...@@ -17,6 +17,7 @@ import 'package:get/get.dart'; ...@@ -17,6 +17,7 @@ import 'package:get/get.dart';
import 'package:glassy/glassy.dart'; import 'package:glassy/glassy.dart';
import 'package:glassy/glassy_config.dart'; import 'package:glassy/glassy_config.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:fluwx/fluwx.dart';
void main() async { void main() async {
// WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); // WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
...@@ -35,6 +36,11 @@ void main() async { ...@@ -35,6 +36,11 @@ void main() async {
const SystemUiOverlayStyle(systemNavigationBarColor: Colors.black); const SystemUiOverlayStyle(systemNavigationBarColor: Colors.black);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
} }
registerWxApi(appId: "wxac6457d4b052cc48",
doOnAndroid: true,
doOnIOS: true,
universalLink: "https://order.1clickpass.com/app/");
} }
class ChatApp extends StatelessWidget { class ChatApp extends StatelessWidget {
......
...@@ -23,11 +23,13 @@ import 'package:highlight/languages/awk.dart'; ...@@ -23,11 +23,13 @@ import 'package:highlight/languages/awk.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types; import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import '../../common/widgets/wx_share.dart';
import 'index.dart'; import 'index.dart';
import 'package:eventsource/eventsource.dart'; import 'package:eventsource/eventsource.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_client_sse/flutter_client_sse.dart'; import 'package:flutter_client_sse/flutter_client_sse.dart';
import 'package:fluwx/fluwx.dart';
// EventSource eventSource = EventSource(Uri.parse('http://example.com/events')); // EventSource eventSource = EventSource(Uri.parse('http://example.com/events'));
// //
...@@ -502,9 +504,7 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin { ...@@ -502,9 +504,7 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin {
Icons.share, Icons.share,
(ChatMessage message, CustomPopupMenuController controller) async { (ChatMessage message, CustomPopupMenuController controller) async {
if (message.text.isNotEmpty) { if (message.text.isNotEmpty) {
await Share.share( WXShare.shareText("${message.text}\n\n");
"${message.text}\n\n",
);
controller.hideMenu(); controller.hideMenu();
} else { } else {
EasyLoading.showToast("分享内容不能为空", EasyLoading.showToast("分享内容不能为空",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment