mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-21 16:48:43 +00:00
feat: pm: send pic
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
## feat
|
## feat
|
||||||
|
|
||||||
|
- [x] 私信发图
|
||||||
- [x] 投币动画
|
- [x] 投币动画
|
||||||
- [x] 取消/追番,更新追番状态
|
- [x] 取消/追番,更新追番状态
|
||||||
- [x] 取消/订阅合集
|
- [x] 取消/订阅合集
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
|
|
||||||
## opt
|
## opt
|
||||||
|
|
||||||
|
- [x] 私信界面
|
||||||
- [x] 收藏面板
|
- [x] 收藏面板
|
||||||
- [x] PIP
|
- [x] PIP
|
||||||
- [x] 视频封面
|
- [x] 视频封面
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -11,7 +13,7 @@ class WhisperDetailController extends GetxController {
|
|||||||
late int talkerId;
|
late int talkerId;
|
||||||
late String name;
|
late String name;
|
||||||
late String face;
|
late String face;
|
||||||
late String mid;
|
String? mid;
|
||||||
RxList<MessageItem> messageList = <MessageItem>[].obs;
|
RxList<MessageItem> messageList = <MessageItem>[].obs;
|
||||||
//表情转换图片规则
|
//表情转换图片规则
|
||||||
List<dynamic>? eInfos;
|
List<dynamic>? eInfos;
|
||||||
@@ -25,6 +27,8 @@ class WhisperDetailController extends GetxController {
|
|||||||
name = Get.parameters['name']!;
|
name = Get.parameters['name']!;
|
||||||
face = Get.parameters['face']!;
|
face = Get.parameters['face']!;
|
||||||
mid = Get.parameters['mid']!;
|
mid = Get.parameters['mid']!;
|
||||||
|
|
||||||
|
querySessionMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future querySessionMsg() async {
|
Future querySessionMsg() async {
|
||||||
@@ -64,34 +68,41 @@ class WhisperDetailController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future sendMsg() async {
|
Future sendMsg({
|
||||||
|
dynamic picMsg,
|
||||||
|
}) async {
|
||||||
feedBack();
|
feedBack();
|
||||||
String message = replyContentController.text;
|
String message = replyContentController.text;
|
||||||
final userInfo = userInfoCache.get('userInfoCache');
|
final userInfo = userInfoCache.get('userInfoCache');
|
||||||
if (userInfo == null) {
|
if (userInfo == null) {
|
||||||
|
SmartDialog.dismiss();
|
||||||
SmartDialog.showToast('请先登录');
|
SmartDialog.showToast('请先登录');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (message == '') {
|
if (picMsg == null && message == '') {
|
||||||
|
SmartDialog.dismiss();
|
||||||
SmartDialog.showToast('请输入内容');
|
SmartDialog.showToast('请输入内容');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mid == null) {
|
if (mid == null) {
|
||||||
|
SmartDialog.dismiss();
|
||||||
SmartDialog.showToast('这里不能发');
|
SmartDialog.showToast('这里不能发');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = await MsgHttp.sendMsg(
|
var result = await MsgHttp.sendMsg(
|
||||||
senderUid: userInfo.mid,
|
senderUid: userInfo.mid,
|
||||||
receiverId: int.parse(mid),
|
receiverId: int.parse(mid!),
|
||||||
content: '{"content":"$message"}',
|
content: picMsg != null ? jsonEncode(picMsg) : '{"content":"$message"}',
|
||||||
msgType: 1,
|
msgType: picMsg != null ? 2 : 1,
|
||||||
);
|
);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
// print(result['data']);
|
// print(result['data']);
|
||||||
querySessionMsg();
|
querySessionMsg();
|
||||||
replyContentController.text = "";
|
replyContentController.text = "";
|
||||||
|
SmartDialog.dismiss();
|
||||||
SmartDialog.showToast('发送成功');
|
SmartDialog.showToast('发送成功');
|
||||||
} else {
|
} else {
|
||||||
|
SmartDialog.dismiss();
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:PiliPalaX/http/msg.dart';
|
||||||
import 'package:PiliPalaX/pages/emote/view.dart';
|
import 'package:PiliPalaX/pages/emote/view.dart';
|
||||||
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
|
||||||
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:chat_bottom_container/panel_container.dart';
|
import 'package:chat_bottom_container/panel_container.dart';
|
||||||
import 'package:chat_bottom_container/typedef.dart';
|
import 'package:chat_bottom_container/typedef.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:mime/mime.dart';
|
||||||
|
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
@@ -35,12 +40,6 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
|
|||||||
late bool _visibleSend = false;
|
late bool _visibleSend = false;
|
||||||
late final _imagePicker = ImagePicker();
|
late final _imagePicker = ImagePicker();
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_whisperDetailController.querySessionMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_readOnlyStream.close();
|
_readOnlyStream.close();
|
||||||
@@ -51,6 +50,10 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onChooseEmote(Packages package, Emote emote) {
|
void onChooseEmote(Packages package, Emote emote) {
|
||||||
|
if (!_visibleSend) {
|
||||||
|
_visibleSend = true;
|
||||||
|
_enableSend.add(true);
|
||||||
|
}
|
||||||
int cursorPosition =
|
int cursorPosition =
|
||||||
_whisperDetailController.replyContentController.selection.baseOffset;
|
_whisperDetailController.replyContentController.selection.baseOffset;
|
||||||
if (cursorPosition == -1) cursorPosition = 0;
|
if (cursorPosition == -1) cursorPosition = 0;
|
||||||
@@ -227,9 +230,11 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
|
|||||||
|
|
||||||
if (isUpdated) {
|
if (isUpdated) {
|
||||||
// Waiting for the input view to update.
|
// Waiting for the input view to update.
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback(
|
||||||
updatePanelTypeFunc();
|
(timeStamp) {
|
||||||
});
|
updatePanelTypeFunc();
|
||||||
|
},
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
updatePanelTypeFunc();
|
updatePanelTypeFunc();
|
||||||
}
|
}
|
||||||
@@ -297,26 +302,51 @@ class _WhisperDetailPageState extends State<WhisperDetailPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
StreamBuilder(
|
StreamBuilder(
|
||||||
stream: _enableSend.stream,
|
stream: _enableSend.stream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
return IconButton(
|
return IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (snapshot.data == true) {
|
if (snapshot.data == true) {
|
||||||
_whisperDetailController.sendMsg();
|
_whisperDetailController.sendMsg();
|
||||||
} else {
|
} else {
|
||||||
XFile? pickedFile = await _imagePicker.pickImage(
|
XFile? pickedFile = await _imagePicker.pickImage(
|
||||||
source: ImageSource.gallery,
|
source: ImageSource.gallery,
|
||||||
imageQuality: 100,
|
imageQuality: 100,
|
||||||
);
|
);
|
||||||
if (pickedFile != null) {}
|
if (pickedFile != null) {
|
||||||
|
SmartDialog.showLoading(msg: '正在上传图片');
|
||||||
|
dynamic result = await MsgHttp.uploadBfs(pickedFile.path);
|
||||||
|
if (result['status']) {
|
||||||
|
int imageSize = await File(pickedFile.path).length();
|
||||||
|
String mimeType = lookupMimeType(pickedFile.path)
|
||||||
|
?.split('/')
|
||||||
|
.getOrNull(1) ??
|
||||||
|
'png';
|
||||||
|
dynamic picMsg = {
|
||||||
|
'url': result['data']['image_url'],
|
||||||
|
'height': result['data']['image_height'],
|
||||||
|
'width': result['data']['image_width'],
|
||||||
|
'imageType': mimeType,
|
||||||
|
'original': 1,
|
||||||
|
'size': imageSize / 1024,
|
||||||
|
};
|
||||||
|
SmartDialog.showLoading(msg: '正在发送');
|
||||||
|
await _whisperDetailController.sendMsg(picMsg: picMsg);
|
||||||
|
} else {
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
SmartDialog.showToast(result['msg']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
icon: Icon(snapshot.data == true
|
},
|
||||||
? Icons.send
|
icon: Icon(snapshot.data == true
|
||||||
: Icons.add_photo_alternate_outlined),
|
? Icons.send
|
||||||
tooltip: snapshot.data == true ? '发送' : '图片',
|
: Icons.add_photo_alternate_outlined),
|
||||||
);
|
tooltip: snapshot.data == true ? '发送' : '图片',
|
||||||
}),
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
11
pubspec.lock
11
pubspec.lock
@@ -1221,12 +1221,11 @@ packages:
|
|||||||
mime:
|
mime:
|
||||||
dependency: "direct overridden"
|
dependency: "direct overridden"
|
||||||
description:
|
description:
|
||||||
path: "."
|
name: mime
|
||||||
ref: HEAD
|
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
|
||||||
resolved-ref: "922e1f3d0b68291c42a2ec3a83542a886ea9b041"
|
url: "https://pub.dev"
|
||||||
url: "https://github.com/orz12/mime.git"
|
source: hosted
|
||||||
source: git
|
version: "2.0.0"
|
||||||
version: "1.0.5"
|
|
||||||
nil:
|
nil:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -161,9 +161,11 @@ dependencies:
|
|||||||
chat_bottom_container: ^0.2.0
|
chat_bottom_container: ^0.2.0
|
||||||
image_picker: ^1.1.2
|
image_picker: ^1.1.2
|
||||||
|
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
mime:
|
# mime:
|
||||||
git: https://github.com/orz12/mime.git
|
# git: https://github.com/orz12/mime.git
|
||||||
|
mime: ^2.0.0
|
||||||
fading_edge_scrollview: ^4.1.1
|
fading_edge_scrollview: ^4.1.1
|
||||||
rxdart: ^0.28.0
|
rxdart: ^0.28.0
|
||||||
webview_flutter_android: 3.16.1
|
webview_flutter_android: 3.16.1
|
||||||
|
|||||||
Reference in New Issue
Block a user