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