feat: 私信图片查看
This commit is contained in:
@ -217,6 +217,7 @@ class SessionItem extends StatelessWidget {
|
||||
final String heroTag = Utils.makeHeroTag(sessionItem.accountInfo?.mid ?? 0);
|
||||
final content = sessionItem.lastMsg.content;
|
||||
final msgStatus = sessionItem.lastMsg.msgStatus;
|
||||
final int msgType = sessionItem.lastMsg.msgType;
|
||||
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
@ -251,6 +252,8 @@ class SessionItem extends StatelessWidget {
|
||||
subtitle: Text(
|
||||
msgStatus == 1
|
||||
? '你撤回了一条消息'
|
||||
: msgType == 2
|
||||
? '[图片]'
|
||||
: content != null && content != ''
|
||||
? (content['text'] ??
|
||||
content['content'] ??
|
||||
|
@ -22,6 +22,7 @@ class WhisperDetailController extends GetxController {
|
||||
final TextEditingController replyContentController = TextEditingController();
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
List emoteList = [];
|
||||
List<String> picList = [];
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -41,6 +42,18 @@ class WhisperDetailController extends GetxController {
|
||||
var res = await MsgHttp.sessionMsg(talkerId: talkerId);
|
||||
if (res['status']) {
|
||||
messageList.value = res['data'].messages;
|
||||
// 找出图片
|
||||
try {
|
||||
for (var item in messageList) {
|
||||
if (item.msgType == 2) {
|
||||
picList.add(item.content['url']);
|
||||
}
|
||||
}
|
||||
picList = picList.reversed.toList();
|
||||
} catch (e) {
|
||||
print('e: $e');
|
||||
}
|
||||
|
||||
if (messageList.isNotEmpty) {
|
||||
ackSessionMsg();
|
||||
if (res['data'].eInfos != null) {
|
||||
|
@ -193,27 +193,21 @@ class _WhisperDetailPageState extends State<WhisperDetailPage>
|
||||
? const SizedBox()
|
||||
: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: ListView.builder(
|
||||
child: ListView.separated(
|
||||
itemCount: messageList.length,
|
||||
shrinkWrap: true,
|
||||
reverse: true,
|
||||
itemBuilder: (_, int i) {
|
||||
if (i == 0) {
|
||||
return Column(
|
||||
children: [
|
||||
ChatItem(
|
||||
item: messageList[i],
|
||||
e_infos: _whisperDetailController
|
||||
.eInfos),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return ChatItem(
|
||||
item: messageList[i],
|
||||
e_infos:
|
||||
_whisperDetailController.eInfos);
|
||||
}
|
||||
e_infos: _whisperDetailController.eInfos,
|
||||
ctr: _whisperDetailController,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, int i) {
|
||||
return i == 0
|
||||
? const SizedBox(height: 20)
|
||||
: const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -2,14 +2,18 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/hero_dialog_route.dart';
|
||||
import 'package:pilipala/plugin/pl_gallery/interactiveviewer_gallery.dart';
|
||||
import 'package:pilipala/utils/route_push.dart';
|
||||
import 'package:pilipala/utils/utils.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
import '../../../http/search.dart';
|
||||
import '../controller.dart';
|
||||
|
||||
enum MsgType {
|
||||
invalid(value: 0, label: "空空的~"),
|
||||
@ -42,10 +46,12 @@ enum MsgType {
|
||||
class ChatItem extends StatelessWidget {
|
||||
dynamic item;
|
||||
List? e_infos;
|
||||
WhisperDetailController ctr;
|
||||
|
||||
ChatItem({
|
||||
super.key,
|
||||
this.item,
|
||||
required this.item,
|
||||
required this.ctr,
|
||||
this.e_infos,
|
||||
});
|
||||
|
||||
@ -157,10 +163,48 @@ class ChatItem extends StatelessWidget {
|
||||
case MsgType.text:
|
||||
return richTextMessage(context);
|
||||
case MsgType.pic:
|
||||
return NetworkImgLayer(
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
HeroDialogRoute<void>(
|
||||
builder: (BuildContext context) => InteractiveviewerGallery(
|
||||
sources: ctr.picList,
|
||||
initIndex: ctr.picList.indexOf(content['url']),
|
||||
itemBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
bool isFocus,
|
||||
bool enablePageView,
|
||||
) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
if (enablePageView) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Center(
|
||||
child: Hero(
|
||||
tag: ctr.picList[index],
|
||||
child: CachedNetworkImage(
|
||||
fadeInDuration: const Duration(milliseconds: 0),
|
||||
imageUrl: ctr.picList[index],
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
onPageChanged: (int pageIndex) {},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: NetworkImgLayer(
|
||||
width: 220,
|
||||
height: 220 * content['height'] / content['width'],
|
||||
src: content['url'],
|
||||
),
|
||||
);
|
||||
case MsgType.share_v2:
|
||||
return Column(
|
||||
|
Reference in New Issue
Block a user