|
@@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
import 'package:flutter/scheduler.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
+import 'package:flutter/widgets.dart';
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
import 'package:sport/bean/image.dart' as photo;
|
|
|
import 'package:sport/bean/message.dart';
|
|
@@ -137,6 +138,8 @@ class _ChatPageState extends State<ChatPage>
|
|
|
MessageInstance _instance = (await api.shareForwardSubject(
|
|
|
int.parse(widget.post.id), widget.user.id))
|
|
|
.data;
|
|
|
+ print(
|
|
|
+ "[_instance]${_instance.toJson()}---------------------------------------");
|
|
|
|
|
|
await MessageDB().insert(new MessageItem(
|
|
|
message: _instance, status: 0, curId: 0, userId: widget.user.id));
|
|
@@ -217,7 +220,10 @@ class _ChatPageState extends State<ChatPage>
|
|
|
return Padding(
|
|
|
padding: EdgeInsets.symmetric(vertical: 5.0),
|
|
|
child: Center(
|
|
|
- child: Text("${item.dateTime}"),
|
|
|
+ child: Text(
|
|
|
+ "${item.dateTime}",
|
|
|
+ style: TextStyle(fontSize: 12.0),
|
|
|
+ ),
|
|
|
),
|
|
|
);
|
|
|
}
|
|
@@ -247,7 +253,6 @@ class _ChatPageState extends State<ChatPage>
|
|
|
.textTheme
|
|
|
.subtitle1
|
|
|
.copyWith(fontSize: 16, color: Colors.black),
|
|
|
- key: anchorKey,
|
|
|
),
|
|
|
if (data.data.url != null)
|
|
|
InkWell(
|
|
@@ -256,7 +261,11 @@ class _ChatPageState extends State<ChatPage>
|
|
|
maxHeight: MediaQuery.of(context).size.height,
|
|
|
maxWidth: MediaQuery.of(context).size.width,
|
|
|
),
|
|
|
- child: CachedNetworkImage(imageUrl: data.data.url),
|
|
|
+ child: CachedNetworkImage(
|
|
|
+ imageUrl:
|
|
|
+ data.data.url + "?x-oss-process=image/resize,p_10",
|
|
|
+ height: 100,
|
|
|
+ ),
|
|
|
),
|
|
|
onTap: () {
|
|
|
Navigator.push(
|
|
@@ -281,75 +290,43 @@ class _ChatPageState extends State<ChatPage>
|
|
|
}
|
|
|
// 论坛消息 ...
|
|
|
if (type == "forum-forward") {
|
|
|
+ print("[forum-forward]${item.toJson()}----------------------");
|
|
|
return InkWell(
|
|
|
- child: Column(
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
children: <Widget>[
|
|
|
- RichText(
|
|
|
- text: TextSpan(children: [
|
|
|
- TextSpan(
|
|
|
- text: data.data.user.name,
|
|
|
- style: Theme.of(context)
|
|
|
- .textTheme
|
|
|
- .headline6
|
|
|
- .copyWith(color: Color(0xFFFFC400))),
|
|
|
- TextSpan(
|
|
|
- text: data.data.subject.content,
|
|
|
- style: Theme.of(context).textTheme.subtitle1),
|
|
|
- ]),
|
|
|
+ ClipRRect(
|
|
|
+ child: Image.asset(
|
|
|
+ "lib/assets/img/chat.png",
|
|
|
+ width: 40,
|
|
|
+ height: 40,
|
|
|
+ fit: BoxFit.cover,
|
|
|
+ ),
|
|
|
+ borderRadius: BorderRadius.circular(10),
|
|
|
),
|
|
|
Space(
|
|
|
- height: 5.0,
|
|
|
+ width: 10.0,
|
|
|
),
|
|
|
- if (data.data.subject.images.length > 0)
|
|
|
- GridView.count(
|
|
|
- physics: new NeverScrollableScrollPhysics(),
|
|
|
- shrinkWrap: true,
|
|
|
- padding: EdgeInsets.zero,
|
|
|
- crossAxisSpacing: 10.0,
|
|
|
- crossAxisCount: data.data.subject.images.length > 3
|
|
|
- ? 3
|
|
|
- : data.data.subject.images.length,
|
|
|
- mainAxisSpacing: 10.0,
|
|
|
- childAspectRatio: 9 / 6,
|
|
|
- children: data.data.subject.images
|
|
|
- .asMap()
|
|
|
- .keys
|
|
|
- .map(
|
|
|
- (i) => CachedNetworkImage(
|
|
|
- alignment: Alignment.centerLeft,
|
|
|
- imageUrl: data.data.subject.images[i],
|
|
|
- fit: BoxFit.cover,
|
|
|
-// width: data.data.subject.images[i]
|
|
|
- ),
|
|
|
- )
|
|
|
- .toList()),
|
|
|
- Divider(),
|
|
|
- Row(
|
|
|
- children: <Widget>[
|
|
|
- Container(
|
|
|
- width: 20.0,
|
|
|
- height: 20.0,
|
|
|
- child: ClipRRect(
|
|
|
- borderRadius: BorderRadius.circular(6),
|
|
|
- child: CachedNetworkImage(
|
|
|
- imageUrl: data.data.forum.cover,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- Space(
|
|
|
- width: 5,
|
|
|
- ),
|
|
|
- Text(
|
|
|
- data.data.forum.name,
|
|
|
- )
|
|
|
- ],
|
|
|
+ Expanded(
|
|
|
+ child: RichText(
|
|
|
+ text: TextSpan(children: [
|
|
|
+ TextSpan(
|
|
|
+ text: "@" + data.data.user.name + ":",
|
|
|
+ style: Theme.of(context)
|
|
|
+ .textTheme
|
|
|
+ .headline6
|
|
|
+ .copyWith(color: Color(0xFFFFC400))),
|
|
|
+ TextSpan(
|
|
|
+ text: "分享了一篇帖子",
|
|
|
+ style: Theme.of(context).textTheme.subtitle1),
|
|
|
+ ]),
|
|
|
+ ),
|
|
|
)
|
|
|
],
|
|
|
),
|
|
|
onTap: () async {
|
|
|
Post post =
|
|
|
(await api.getPostDetail("${data.data.subject.id}")).data;
|
|
|
- print(post);
|
|
|
NavigatorUtil.goPage(
|
|
|
context, (context) => PostDetailPage(post, false, null));
|
|
|
},
|
|
@@ -357,13 +334,12 @@ class _ChatPageState extends State<ChatPage>
|
|
|
}
|
|
|
// 链接..
|
|
|
if (type == "share") {
|
|
|
- print("${data.toJson()}--------------------------------------");
|
|
|
return InkWell(
|
|
|
child: Row(
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
children: <Widget>[
|
|
|
CachedNetworkImage(
|
|
|
- imageUrl: avatarList[9],
|
|
|
+ imageUrl: avatarList[8],
|
|
|
width: 60.0,
|
|
|
height: 60.0,
|
|
|
),
|
|
@@ -398,104 +374,115 @@ class _ChatPageState extends State<ChatPage>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Widget customPoint = CustomPaint(
|
|
|
- painter: who == 1 ? _BubblePainterRight() : _BubblePainter(),
|
|
|
- child: ConstrainedBox(
|
|
|
- constraints:
|
|
|
- BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.6),
|
|
|
- child: Container(
|
|
|
- padding: who == 1
|
|
|
- ? EdgeInsets.fromLTRB(12, 6, 20, 8)
|
|
|
- : EdgeInsets.fromLTRB(20, 6, 12, 8),
|
|
|
- child: GestureDetector(
|
|
|
- behavior: HitTestBehavior.opaque,
|
|
|
- onLongPressStart: (e) {
|
|
|
- RenderBox renderBox =
|
|
|
- anchorKey.currentContext.findRenderObject();
|
|
|
- var offset = renderBox
|
|
|
- .localToGlobal(Offset(0.0, renderBox.size.height));
|
|
|
- final RelativeRect position = RelativeRect.fromLTRB(
|
|
|
- e.globalPosition.dx, //取点击位置坐弹出x坐标
|
|
|
- offset.dy, //取text高度做弹出y坐标(这样弹出就不会遮挡文本)
|
|
|
- e.globalPosition.dx,
|
|
|
- offset.dy);
|
|
|
-
|
|
|
- PopupMenuEntry menuItem(
|
|
|
- {String imgUrl, String text, Function callBack}) =>
|
|
|
- menu.PopupMenuItem(
|
|
|
- child: InkWell(
|
|
|
- onTap: () {
|
|
|
- callBack();
|
|
|
- Navigator.pop(context);
|
|
|
- },
|
|
|
- child: Row(
|
|
|
- mainAxisSize: MainAxisSize.min,
|
|
|
+ Widget chatContent(){
|
|
|
+ return ConstrainedBox(
|
|
|
+ constraints:
|
|
|
+ BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.6),
|
|
|
+ child: Container(
|
|
|
+ padding: who == 1
|
|
|
+ ? EdgeInsets.fromLTRB(12, 6, 20, 8)
|
|
|
+ : EdgeInsets.fromLTRB(20, 6, 12, 8),
|
|
|
+ key: anchorKey,
|
|
|
+ child: GestureDetector(
|
|
|
+ behavior: HitTestBehavior.opaque,
|
|
|
+ onLongPressStart: (e) {
|
|
|
+ RenderBox renderBox =
|
|
|
+ anchorKey.currentContext.findRenderObject();
|
|
|
+ var offset = renderBox
|
|
|
+ .localToGlobal(Offset(0.0, renderBox.size.height));
|
|
|
+ final RelativeRect position = RelativeRect.fromLTRB(
|
|
|
+ e.globalPosition.dx, //取点击位置坐弹出x坐标
|
|
|
+ offset.dy, //取text高度做弹出y坐标(这样弹出就不会遮挡文本)
|
|
|
+ e.globalPosition.dx,
|
|
|
+ offset.dy);
|
|
|
+
|
|
|
+ PopupMenuEntry menuItem(
|
|
|
+ {String imgUrl, String text, Function callBack}) =>
|
|
|
+ menu.PopupMenuItem(
|
|
|
+ child: InkWell(
|
|
|
+ onTap: () {
|
|
|
+ callBack();
|
|
|
+ Navigator.pop(context);
|
|
|
+ },
|
|
|
+ child: Row(
|
|
|
+ mainAxisSize: MainAxisSize.min,
|
|
|
+ children: <Widget>[
|
|
|
+ Image.asset(
|
|
|
+ "lib/assets/img/$imgUrl",
|
|
|
+ width: 24,
|
|
|
+ ),
|
|
|
+ SizedBox(
|
|
|
+ width: 4,
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ text,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ showMenu(
|
|
|
+ context: context,
|
|
|
+ position: position,
|
|
|
+ items: <PopupMenuEntry>[
|
|
|
+ PopupMenuItem(
|
|
|
+ child: Container(
|
|
|
+ child: Column(
|
|
|
children: <Widget>[
|
|
|
- Image.asset(
|
|
|
- "lib/assets/img/$imgUrl",
|
|
|
- width: 24,
|
|
|
- ),
|
|
|
- SizedBox(
|
|
|
- width: 4,
|
|
|
- ),
|
|
|
- Text(
|
|
|
- text,
|
|
|
+ menuItem(
|
|
|
+ imgUrl: "linkpop_icon_copy.png",
|
|
|
+ text: "复制",
|
|
|
+ callBack: () {
|
|
|
+ Clipboard.setData(ClipboardData(
|
|
|
+ text: '${data.data.text}'));
|
|
|
+ ToastUtil.show("复制成功");
|
|
|
+ }),
|
|
|
+ who == 1
|
|
|
+ ? menuItem(
|
|
|
+ imgUrl: "linkpop_icon_del.png",
|
|
|
+ text: "删除",
|
|
|
+ callBack: () async {
|
|
|
+ await MessageDB()
|
|
|
+ .deleteMessageIdMessage(
|
|
|
+ item.messageId);
|
|
|
+ messageList.remove(item);
|
|
|
+ setState(() {
|
|
|
+ messageList = messageList;
|
|
|
+ });
|
|
|
+ },
|
|
|
)
|
|
|
+ : menuItem(
|
|
|
+ imgUrl: "linkpop_icon_modify_1.png",
|
|
|
+ text: "举报",
|
|
|
+ callBack: () async {
|
|
|
+ await api.postForumReport(
|
|
|
+ userId: item.userId,
|
|
|
+ content:
|
|
|
+ "该用户涉嫌发送不良消息内容为:${item.message.data.text}");
|
|
|
+ ToastUtil.show("举报已受理...");
|
|
|
+ }),
|
|
|
+ menuItem(
|
|
|
+ imgUrl: "linkpop_icon_cancel.png", text: "取消")
|
|
|
],
|
|
|
),
|
|
|
- ),
|
|
|
- );
|
|
|
-
|
|
|
- showMenu(
|
|
|
- context: context,
|
|
|
- position: position,
|
|
|
- items: <PopupMenuEntry>[
|
|
|
- PopupMenuItem(
|
|
|
- child: Container(
|
|
|
- child: Column(
|
|
|
- children: <Widget>[
|
|
|
- menuItem(
|
|
|
- imgUrl: "linkpop_icon_copy.png",
|
|
|
- text: "复制",
|
|
|
- callBack: () {
|
|
|
- Clipboard.setData(ClipboardData(
|
|
|
- text: '${data.data.text}'));
|
|
|
- ToastUtil.show("复制成功");
|
|
|
- }),
|
|
|
- who == 1
|
|
|
- ? menuItem(
|
|
|
- imgUrl: "linkpop_icon_del.png",
|
|
|
- text: "删除",
|
|
|
- callBack: () async {
|
|
|
- await MessageDB()
|
|
|
- .deleteMessageIdMessage(
|
|
|
- item.messageId);
|
|
|
- messageList.remove(item);
|
|
|
- setState(() {
|
|
|
- messageList = messageList;
|
|
|
- });
|
|
|
- },
|
|
|
- )
|
|
|
- : menuItem(
|
|
|
- imgUrl: "linkpop_icon_modify_1.png",
|
|
|
- text: "举报",
|
|
|
- callBack: () async {
|
|
|
- await api.postForumReport(
|
|
|
- userId: item.userId,
|
|
|
- content:
|
|
|
- "该用户涉嫌发送不良消息内容为:${item.message.data.text}");
|
|
|
- ToastUtil.show("举报已受理...");
|
|
|
- }),
|
|
|
- menuItem(
|
|
|
- imgUrl: "linkpop_icon_cancel.png", text: "取消")
|
|
|
- ],
|
|
|
- ),
|
|
|
- ))
|
|
|
- ],
|
|
|
- );
|
|
|
- },
|
|
|
- child: chatItemOfType(data.type))),
|
|
|
- ));
|
|
|
+ ))
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ },
|
|
|
+ child: chatItemOfType(data.type))),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget customPoint(){
|
|
|
+ print("[data.type]:${data.type}--------------------");
|
|
|
+ if(data.type != "image"){
|
|
|
+ return CustomPaint(
|
|
|
+ painter: who == 1 ? _BubblePainterRight() : _BubblePainter(),
|
|
|
+ child: chatContent());
|
|
|
+ }
|
|
|
+ return chatContent();
|
|
|
+ };
|
|
|
|
|
|
Widget spaceItem = Space(
|
|
|
width: 12,
|
|
@@ -524,9 +511,9 @@ class _ChatPageState extends State<ChatPage>
|
|
|
),
|
|
|
);
|
|
|
|
|
|
- List<Widget> chatContentUsr = [customPoint, spaceItem, avatar];
|
|
|
+ List<Widget> chatContentUsr = [customPoint(), spaceItem, avatar];
|
|
|
|
|
|
- List<Widget> chatContentOther = [avatar, spaceItem, customPoint];
|
|
|
+ List<Widget> chatContentOther = [avatar, spaceItem, customPoint()];
|
|
|
|
|
|
return Padding(
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
|
|
@@ -552,9 +539,10 @@ class _ChatPageState extends State<ChatPage>
|
|
|
body: WillPopScope(
|
|
|
onWillPop: () async {
|
|
|
// 这是分享.... 只能一步一步pop 出去
|
|
|
- if(widget.post != null || widget.hash != null || widget.image != null){
|
|
|
- print("${widget.post}=============");
|
|
|
- Navigator.pop(context,true);
|
|
|
+ if (widget.post != null ||
|
|
|
+ widget.hash != null ||
|
|
|
+ widget.image != null) {
|
|
|
+ Navigator.pop(context, true);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
@@ -620,7 +608,7 @@ class _BubblePainter extends CustomPainter {
|
|
|
|
|
|
class _BubblePainterRight extends CustomPainter {
|
|
|
final circular = Radius.circular(10);
|
|
|
- final Paint _paint = Paint()..color = Colors.white;
|
|
|
+ final Paint _paint = Paint()..color = Color(0xffffe400).withOpacity(0.7);
|
|
|
final double _bubbleWidth = 10;
|
|
|
|
|
|
@override
|