From 0e113b117eda8e69b1b1395c26e5023dd1bc5100 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Thu, 9 Mar 2023 11:00:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=A4=8D=E5=88=B6=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E5=BC=B9=E6=A1=86=EF=BC=9B=20=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85ui=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/image/2x/icon_copy_j.webp | Bin 0 -> 786 bytes assets/image/3x/多边形 1@3x.webp | Bin 0 -> 946 bytes assets/image/icon_copy_j.webp | Bin 0 -> 640 bytes lib/message/im/chat_details_page.dart | 200 +++++++- lib/message/im/im_view/emoji_text.dart | 53 -- lib/message/im/im_view/magic_pop.dart | 466 ------------------ .../im/im_view/text_item_container.dart | 55 --- lib/message/im/im_view/text_span_builder.dart | 33 -- lib/web/web_view/comment_list.dart | 184 ++++--- pubspec.lock | 28 -- pubspec.yaml | 4 - 11 files changed, 279 insertions(+), 744 deletions(-) create mode 100644 assets/image/2x/icon_copy_j.webp create mode 100644 assets/image/3x/多边形 1@3x.webp create mode 100644 assets/image/icon_copy_j.webp delete mode 100644 lib/message/im/im_view/emoji_text.dart delete mode 100644 lib/message/im/im_view/magic_pop.dart delete mode 100644 lib/message/im/im_view/text_item_container.dart delete mode 100644 lib/message/im/im_view/text_span_builder.dart diff --git a/assets/image/2x/icon_copy_j.webp b/assets/image/2x/icon_copy_j.webp new file mode 100644 index 0000000000000000000000000000000000000000..86805b42a107263ad7bbe924531ead713c6fc2fe GIT binary patch literal 786 zcmWIYbaUfkW?%?+bqWXzu!!JdU|=u+Vkrg&aRvrYXXk(uj6f~};|UPS0+hRrFR z%`5vW-`3sBQw~4PsB=n}L7*=5ciWGvtG`%$i0j&GBePn>>%kS@JFILoHCk6j-r!m6 zAaEciJ%+vUx5=BAPOA(w6gF+U9L8OA(vw9)ieGxcqk4~hwJ)+f%`61J$(bU=hK^z`$St#2O3?N(>C1&dvcR7=c^{#uFft1t^u9S5g$@ z?xYYA8KnRcgMq~4;sO{O3k@{o+cgHTS(kOO$P*IcOi3+H1}gdh#41HV%YkkZ0kTEX zA#9+78AOsGY#R`}yriH6s3ri!E(!^92C`FtY>jjzb`lahxu6K7z6YqrCO4-PWETj4 zT+EZ27a9ztIe=J(p_n0v!JWYg;s5+a3=9@u85o!+AjFbpGB9j!WnhrFg%DF&z`(%Y z!oaZYJVFc+CIyK_i9qv#fegem49N_7K$a0OQVki*fHCZ|n~{M*U!#FTfdA04i7M`;YSuO9Ub`5*W`E4*ViNm;!;cJICWubG$=W~qI) ziJo?}Q0Cm{JI5rx{@?%p_n!CBo;`-g{{R2?|NFlDs`m%?PboU^|G(#=t!$G#g0^1c zRya9} z|8C2@ZD#g=#l7nP^Se2eew{y%d)uw)?(Dm6@`92wo|9A%NREBt!`WLFegEJSb?IkH z@8u8KC+{cbWq0PDyT3p36JH zumvgx7gK~9q8>I+<4<&O&Yi1u-E518j%kG22jyO^S5~GR8fJy7QeNfEU6)kd`rXhW zdhPN*>sXmDb+0cm(7BX#b&gNw2F=k?*~ b?@|uNT-{v0V_ITkKxXmHDNV0FGB5xDe}gB{ literal 0 HcmV?d00001 diff --git a/assets/image/icon_copy_j.webp b/assets/image/icon_copy_j.webp new file mode 100644 index 0000000000000000000000000000000000000000..8263ada3a11773d1c4b1e2cb7f4e5f1990442e11 GIT binary patch literal 640 zcmWIYbaSgeKg93vmLmopigC3A&1dLQe1~Xs``*Z>o>hm685@=7Dkh|oq-_yT>|4n$7K(oe zL4rKD+={0Bj(dM-{=0W_Z5{u#b8c@7{Fe3qM@VSsf5UX0;;?lyZ4dA?ti9#;LPafV Xo7*+(H?50Snm@cSdFHoyb_@&vRTqx0 literal 0 HcmV?d00001 diff --git a/lib/message/im/chat_details_page.dart b/lib/message/im/chat_details_page.dart index a0ff3d0c..bc558cfc 100644 --- a/lib/message/im/chat_details_page.dart +++ b/lib/message/im/chat_details_page.dart @@ -16,7 +16,6 @@ import '../../generated/l10n.dart'; import '../../utils/font_weight.dart'; import 'im_view/on_chat_message.dart'; import 'im_view/on_chat_msg_instance.dart'; -import 'im_view/text_item_container.dart'; class ChatDetailsPage extends StatefulWidget { @override @@ -47,6 +46,7 @@ class _ChatDetailsPage extends State OnChatMsgInstance.instance.onChatMessage; final ScrollController scrollController = ScrollController(); String tex = ""; + int copyIndex = 0; @override void onMessage(txt) { @@ -132,6 +132,7 @@ class _ChatDetailsPage extends State }*/ } + ///输入框点击事件 _onTextFieldTap() { if (emojiShowing) { needHideSmiley = true; @@ -141,6 +142,7 @@ class _ChatDetailsPage extends State } } + ///表情包点击事件 _onSmileyTap() { if (!emojiShowing && commentFocus.hasFocus && isKeyBoardShow) { needShowSmiley = true; @@ -154,6 +156,7 @@ class _ChatDetailsPage extends State } } + ///更多点击事件 _onMoreTap() { if (!moreShow && commentFocus.hasFocus && isKeyBoardShow) { needShowMore = true; @@ -224,6 +227,7 @@ class _ChatDetailsPage extends State onTap: () { setState(() { Navigator.of(context).pushNamed('/router/chat_setting'); + copyIndex = 0; }); }, child: Container( @@ -280,10 +284,11 @@ class _ChatDetailsPage extends State physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return GestureDetector( + behavior: HitTestBehavior.opaque, onTap: () { - }, - onLongPress: (){ - showCustomDialog(context,position); + setState((){ + copyIndex = 0; + }); }, child: chatDetailsItem(), ); @@ -320,6 +325,83 @@ class _ChatDetailsPage extends State SizedBox( height: 16.h, ), + if(copyIndex == 1) + Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + padding: EdgeInsets.only(bottom:13.h), + child: Container( + width: 180.w, + decoration: BoxDecoration( + color: Color(0xFF2A2A2A), + borderRadius: BorderRadius.circular(6), + ), + padding: EdgeInsets.symmetric(horizontal: 32.w,vertical: 7.5.h), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: (){ + setState((){ + copyIndex = 0; + this.copy(tex); + }); + }, + child:Column( + children: [ + Image.asset( + "assets/image/icon_chat_copy.webp", + height:16, + width: 16, + ), + SizedBox(height: 2.h,), + Text( + "复制", + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ) , + ), + GestureDetector( + onTap: (){}, + child: Column( + children: [ + Image.asset( + "assets/image/icon_chat_delete.webp", + height:16, + width: 16, + ), + SizedBox(height: 2.h,), + Text( + S.of(context).shanchu, + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ), + ) + ], + ), + ), + ), + Image.asset( + "assets/image/icon_copy_j.webp", + height: 17, + width: 17, + ), + ], + ), Padding(padding:EdgeInsets.only(left: 17.w,right: 39.w), child: Row( children: [ @@ -348,9 +430,14 @@ class _ChatDetailsPage extends State ), padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 12.w), child:GestureDetector( - onTap:this.copy(tex), - child: SelectableText( - tex = "凭本事买的为啥要给你钱啊伙计", + onLongPress:(){ + setState((){ + copyIndex =1; + }); + }, + child: + Text( + tex = "上次你在我这里买的水果钱是不是忘记付了?一共18块钱做点生意也是真的不容易啊。", textAlign: TextAlign.left, style: TextStyle( height: 1.2.h, @@ -364,6 +451,83 @@ class _ChatDetailsPage extends State ], ),), SizedBox(height: 40.h,), + if(copyIndex == 1) + Stack( + alignment: Alignment.bottomCenter, + children: [ + Container( + padding: EdgeInsets.only(bottom:13.h), + child: Container( + width: 180.w, + decoration: BoxDecoration( + color: Color(0xFF2A2A2A), + borderRadius: BorderRadius.circular(6), + ), + padding: EdgeInsets.symmetric(horizontal: 32.w,vertical: 7.5.h), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: (){ + setState((){ + copyIndex = 0; + this.copy(tex); + }); + }, + child:Column( + children: [ + Image.asset( + "assets/image/icon_chat_copy.webp", + height:16, + width: 16, + ), + SizedBox(height: 2.h,), + Text( + "复制", + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ) , + ), + GestureDetector( + onTap: (){}, + child: Column( + children: [ + Image.asset( + "assets/image/icon_chat_delete.webp", + height:16, + width: 16, + ), + SizedBox(height: 2.h,), + Text( + S.of(context).shanchu, + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ), + ) + ], + ), + ), + ), + Image.asset( + "assets/image/icon_copy_j.webp", + height: 17, + width: 17, + ), + ], + ), Padding(padding:EdgeInsets.only(left:36.w,right: 16.w), child: Row( children: [ @@ -395,10 +559,24 @@ class _ChatDetailsPage extends State color: Color(0xFF32A060), ), padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 12.w), - child: TextItemContainer( - text: "上次你在我这里买的水果钱是不是忘记付了?一共18块钱做点生意也是真的不容易啊。", - action: '', - isMyself: true,), + child: GestureDetector( + onLongPress:(){ + setState((){ + copyIndex = 1; + }); + }, + child: + Text( + tex = "凭本事买的为啥要给你钱啊伙计", + textAlign: TextAlign.left, + style: TextStyle( + height: 1.2.h, + color: Colors.black, + fontSize: 17.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ), )), SizedBox( width: 12.w, diff --git a/lib/message/im/im_view/emoji_text.dart b/lib/message/im/im_view/emoji_text.dart deleted file mode 100644 index 9e0578ee..00000000 --- a/lib/message/im/im_view/emoji_text.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'package:extended_text/extended_text.dart'; -import 'package:flutter/material.dart'; - -///emoji/image text -class EmojiText extends SpecialText { - static const String flag = "["; - final int start; - EmojiText(TextStyle textStyle, {this.start}) - : super(EmojiText.flag, "]", textStyle); - - @override - InlineSpan finishText() { - var key = toString(); - if (EmojiUitl.instance.emojiMap.containsKey(key)) { - //fontsize id define image height - //size = 30.0/26.0 * fontSize - final double size = 20.0; - - ///fontSize 26 and text height =30.0 - //final double fontSize = 26.0; - - return ImageSpan(AssetImage(EmojiUitl.instance.emojiMap[key]), - actualText: key, - imageWidth: size, - imageHeight: size, - start: start, - fit: BoxFit.fill, - margin: EdgeInsets.only(left: 2.0, right: 2.0)); - } - - return TextSpan(text: toString(), style: textStyle); - } -} - -class EmojiUitl { - final Map _emojiMap = new Map(); - - Map get emojiMap => _emojiMap; - - final String _emojiFilePath = "assets/images/emoji"; - - static EmojiUitl _instance; - static EmojiUitl get instance { - if (_instance == null) _instance = new EmojiUitl._(); - return _instance; - } - - EmojiUitl._() { - for (int i = 1; i < 100; i++) { - _emojiMap["[$i]"] = "$_emojiFilePath/sg$i.png"; - } - } -} diff --git a/lib/message/im/im_view/magic_pop.dart b/lib/message/im/im_view/magic_pop.dart deleted file mode 100644 index 5cc03bb3..00000000 --- a/lib/message/im/im_view/magic_pop.dart +++ /dev/null @@ -1,466 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:huixiang/message/im/im_view/triangle_painter.dart'; - -const double _kMenuScreenPadding = 8.0; - -class MagicPop extends StatefulWidget { - MagicPop({ - @required this.onValueChanged, - @required this.actions, - @required this.child, - this.pressType = PressType.longPress, - this.pageMaxChildCount = 5, - this.backgroundColor = Colors.black, - this.menuWidth = 250, - this.menuHeight = 42, - }) : assert(onValueChanged != null), - assert(actions != null && actions.length > 0), - assert(child != null); - - final ValueChanged onValueChanged; - final List actions; - final Widget child; - final PressType pressType; // 点击方式 长按 还是单击 - final int pageMaxChildCount; - final Color backgroundColor; - final double menuWidth; - final double menuHeight; - - @override - _WPopupMenuState createState() => _WPopupMenuState(); -} - -class _WPopupMenuState extends State { - @override - Widget build(BuildContext context) { - return GestureDetector( - child: widget.child, - onTap: () { - if (widget.pressType == PressType.singleClick) { - onTap(); - } - }, - onLongPress: () { - if (widget.pressType == PressType.longPress) { - onTap(); - } - }, - ); - } - - void onTap() { - Navigator.push( - context, - _PopupMenuRoute(context, widget.actions, widget.pageMaxChildCount, - widget.backgroundColor, widget.menuWidth, widget.menuHeight)) - .then((index) { - widget.onValueChanged(index); - }); - } -} - -enum PressType { - // 长按 - longPress, - // 单击 - singleClick, -} - -class _PopupMenuRoute extends PopupRoute { - final BuildContext btnContext; - double _height; - double _width; - final List actions; - final int _pageMaxChildCount; - final Color backgroundColor; - final double menuWidth; - final double menuHeight; - - _PopupMenuRoute(this.btnContext, this.actions, this._pageMaxChildCount, - this.backgroundColor, this.menuWidth, this.menuHeight) { - _height = btnContext.size.height; - _width = btnContext.size.width; - } - - @override - Animation createAnimation() { - return CurvedAnimation( - parent: super.createAnimation(), - curve: Curves.linear, - reverseCurve: const Interval(0.0, 2.0 / 3.0), - ); - } - - @override - Color get barrierColor => null; - - @override - bool get barrierDismissible => true; - - @override - String get barrierLabel => null; - - @override - Widget buildPage(BuildContext context, Animation animation, - Animation secondaryAnimation) { - return _MenuPopWidget(this.btnContext, _height, _width, actions, - _pageMaxChildCount, backgroundColor, menuWidth, menuHeight); - } - - @override - Duration get transitionDuration => Duration(milliseconds: 300); -} - -class _MenuPopWidget extends StatefulWidget { - final BuildContext btnContext; - final double _height; - final double _width; - final List actions; - final int _pageMaxChildCount; - final Color backgroundColor; - final double menuWidth; - final double menuHeight; - - _MenuPopWidget( - this.btnContext, - this._height, - this._width, - this.actions, - this._pageMaxChildCount, - this.backgroundColor, - this.menuWidth, - this.menuHeight); - - @override - __MenuPopWidgetState createState() => __MenuPopWidgetState(); -} - -class __MenuPopWidgetState extends State<_MenuPopWidget> { - int _curPage = 0; - final double _arrowWidth = 40; - final double _separatorWidth = 1; - final double _triangleHeight = 10; - - RenderBox button; - RenderBox overlay; - RelativeRect position; - - @override - void initState() { - super.initState(); - button = widget.btnContext.findRenderObject(); - overlay = Overlay.of(widget.btnContext).context.findRenderObject(); - position = RelativeRect.fromRect( - Rect.fromPoints( - button.localToGlobal(Offset.zero, ancestor: overlay), - button.localToGlobal(Offset.zero, ancestor: overlay), - ), - Offset.zero & overlay.size, - ); - } - - @override - Widget build(BuildContext context) { - // 这里计算出来 当前页的 child 一共有多少个 - int _curPageChildCount = - (_curPage + 1) * widget._pageMaxChildCount > widget.actions.length - ? widget.actions.length % widget._pageMaxChildCount - : widget._pageMaxChildCount; - - double _curArrowWidth = 0; - int _curArrowCount = 0; // 一共几个箭头 - - if (widget.actions.length > widget._pageMaxChildCount) { - // 数据长度大于 widget._pageMaxChildCount - if (_curPage == 0) { - // 如果是第一页 - _curArrowWidth = _arrowWidth; - _curArrowCount = 1; - } else { - // 如果不是第一页 则需要也显示左箭头 - _curArrowWidth = _arrowWidth * 2; - _curArrowCount = 2; - } - } - - double _curPageWidth = widget.menuWidth + - (_curPageChildCount - 1 + _curArrowCount) * _separatorWidth + - _curArrowWidth; - - // ignore: unused_element - Widget view() { - var isInverted = (position.top + - (MediaQuery.of(context).size.height - - position.top - - position.bottom) / - 2.0 - - (widget.menuHeight + _triangleHeight)) < - (widget.menuHeight + _triangleHeight) * 2; - - var pain = CustomPaint( - size: Size(_curPageWidth, _triangleHeight), - painter: TrianglePainter( - color: widget.backgroundColor, - position: position, - isInverted: true, - size: button.size), - ); - - var row = Row( - mainAxisSize: MainAxisSize.min, - children: [ - // 左箭头:判断是否是第一页,如果是第一页则不显示 - _curPage == 0 - ? Container( - height: widget.menuHeight, - ) - : InkWell( - onTap: () { - setState(() { - _curPage--; - }); - }, - child: Container( - width: _arrowWidth, - height: widget.menuHeight, - child: Image.asset( - 'images/left_white.png', - fit: BoxFit.none, - ), - ), - ), - // 左箭头:判断是否是第一页,如果是第一页则不显示 - _curPage == 0 - ? Container( - height: widget.menuHeight, - ) - : Container( - width: 1, - height: widget.menuHeight, - color: Colors.grey, - ), - - // 中间是ListView - _buildList(_curPageChildCount, _curPageWidth, _curArrowWidth, - _curArrowCount), - - // 右箭头:判断是否有箭头,如果有就显示,没有就不显示 - _curArrowCount > 0 - ? Container( - width: 1, - color: Colors.grey, - height: widget.menuHeight, - ) - : Container( - height: widget.menuHeight, - ), - _curArrowCount > 0 - ? InkWell( - onTap: () { - if ((_curPage + 1) * widget._pageMaxChildCount < - widget.actions.length) - setState(() { - _curPage++; - }); - }, - child: Container( - width: _arrowWidth, - height: widget.menuHeight, - child: Image.asset( - (_curPage + 1) * widget._pageMaxChildCount >= - widget.actions.length - ? 'images/right_gray.png' - : 'images/right_white.png', - fit: BoxFit.none, - ), - ), - ) - : Container( - height: widget.menuHeight, - ), - ], - ); - - return Material( - color: Colors.transparent, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - isInverted ? pain : Container(), - Expanded( - child: Stack( - children: [ - ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Container( - color: widget.backgroundColor, - height: widget.menuHeight, - ), - ), - row, - ], - ), - ), - isInverted - ? Container() - : CustomPaint( - size: Size(_curPageWidth, _triangleHeight), - painter: TrianglePainter( - color: widget.backgroundColor, - position: position, - size: button.size), - ), - ], - ), - ); - } - - return MediaQuery.removePadding( - context: context, - removeTop: true, - removeBottom: true, - removeLeft: true, - removeRight: true, - child: Builder( - builder: (BuildContext context) { - return CustomSingleChildLayout( - // 这里计算偏移量 - delegate: _PopupMenuRouteLayout( - position, - widget.menuHeight + _triangleHeight, - Directionality.of(widget.btnContext), - widget._width, - widget.menuWidth), - child: SizedBox( - height: widget.menuHeight + _triangleHeight, - width: _curPageWidth, - child: view()), - ); - }, - ), - ); - } - - Widget _buildList(int _curPageChildCount, double _curPageWidth, - double _curArrowWidth, int _curArrowCount) { - return ListView.separated( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - scrollDirection: Axis.horizontal, - itemCount: _curPageChildCount, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - Navigator.pop( - context, _curPage * widget._pageMaxChildCount + index); - }, - child: SizedBox( - width: (_curPageWidth - - _curArrowWidth - - (_curPageChildCount - 1 + _curArrowCount) * - _separatorWidth) / - _curPageChildCount, - height: widget.menuHeight, - child: Center( - child: Text( - widget.actions[_curPage * widget._pageMaxChildCount + index], - style: TextStyle(color: Colors.white, fontSize: 16), - ), - ), - ), - ); - }, - separatorBuilder: (BuildContext context, int index) { - return Container( - width: 1, - height: widget.menuHeight, - color: Colors.grey, - ); - }, - ); - } -} - -// Positioning of the menu on the screen. -class _PopupMenuRouteLayout extends SingleChildLayoutDelegate { - _PopupMenuRouteLayout(this.position, this.selectedItemOffset, - this.textDirection, this.width, this.menuWidth); - - // Rectangle of underlying button, relative to the overlay's dimensions. - final RelativeRect position; - - // The distance from the top of the menu to the middle of selected item. - // - // This will be null if there's no item to position in this way. - final double selectedItemOffset; - - // Whether to prefer going to the left or to the right. - final TextDirection textDirection; - - final double width; - final double menuWidth; - - // We put the child wherever position specifies, so long as it will fit within - // the specified parent size padded (inset) by 8. If necessary, we adjust the - // child's position so that it fits. - - @override - BoxConstraints getConstraintsForChild(BoxConstraints constraints) { - // The menu can be at most the size of the overlay minus 8.0 pixels in each - // direction. - return BoxConstraints.loose(constraints.biggest - - const Offset(_kMenuScreenPadding * 2.0, _kMenuScreenPadding * 2.0)); - } - - @override - Offset getPositionForChild(Size size, Size childSize) { - // size: The size of the overlay. - // childSize: The size of the menu, when fully open, as determined by - // getConstraintsForChild. - - // Find the ideal vertical position. - double y; - if (selectedItemOffset == null) { - y = position.top; - } else { - y = position.top + - (size.height - position.top - position.bottom) / 2.0 - - selectedItemOffset; - } - - // Find the ideal horizontal position. - double x; - if (position.left > position.right) { - // Menu button is closer to the right edge, so grow to the left, aligned to the right edge. -// x = childSize.width - (size.width - position.right); - x = position.left + width - childSize.width; - } else if (position.left < position.right) { - // Menu button is closer to the left edge, so grow to the right, aligned to the left edge. - if (width > childSize.width) { - x = position.left + (childSize.width - menuWidth) / 2; - } else - x = position.left; - } else { - x = position.right - width / 2 - childSize.width / 2; - } - // Avoid going outside an area defined as the rectangle 8.0 pixels from the - // edge of the screen in every direction. - if (x < _kMenuScreenPadding) - x = _kMenuScreenPadding; - else if (x + childSize.width > size.width - _kMenuScreenPadding) - x = size.width - childSize.width - _kMenuScreenPadding; - if (y < _kMenuScreenPadding) - y = _kMenuScreenPadding; - else if (y + childSize.height > size.height - _kMenuScreenPadding) - y = size.height - childSize.height; - else if (y < childSize.height * 2) { - y = position.top + childSize.height; - } - return Offset(x, y); - } - - @override - bool shouldRelayout(_PopupMenuRouteLayout oldDelegate) { - return position != oldDelegate.position; - } -} diff --git a/lib/message/im/im_view/text_item_container.dart b/lib/message/im/im_view/text_item_container.dart deleted file mode 100644 index 226432b5..00000000 --- a/lib/message/im/im_view/text_item_container.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'package:extended_text/extended_text.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:flutter/services.dart';import 'package:huixiang/message/im/im_view/text_span_builder.dart'; - -import 'magic_pop.dart'; - -class TextItemContainer extends StatefulWidget { - final String text; - final String action; - final bool isMyself; - - TextItemContainer({this.text, this.action, this.isMyself = true}); - - @override - _TextItemContainerState createState() => _TextItemContainerState(); -} - -class _TextItemContainerState extends State { - TextSpanBuilder _spanBuilder = TextSpanBuilder(); - - @override - Widget build(BuildContext context) { - return MagicPop( - onValueChanged: (int value) { - switch (value) { - case 0: - Clipboard.setData(new ClipboardData(text: widget.text)); - break; - case 3: - break; - } - }, - pressType: PressType.longPress, - actions: ['复制', '转发', '收藏', '撤回', '删除'], - child: new Container( - // width: widget.text.length > 24 ? (MediaQuery.of(context).size.width - 66) - 100 : null, - // padding: EdgeInsets.all(5.0), - // decoration: BoxDecoration( - // color: widget.isMyself ? Color(0xff98E165) : Colors.white, - // borderRadius: BorderRadius.all(Radius.circular(5.0)), - // ), - // margin: EdgeInsets.only(right: 7.0), - child: ExtendedText( - widget.text ?? '文字为空', - maxLines: 99, - overflow: TextOverflow.ellipsis, - specialTextSpanBuilder: _spanBuilder, - style: TextStyle(fontSize: 17,color: Colors.white), - ), - ), - ); - } -} \ No newline at end of file diff --git a/lib/message/im/im_view/text_span_builder.dart b/lib/message/im/im_view/text_span_builder.dart deleted file mode 100644 index 6a46384a..00000000 --- a/lib/message/im/im_view/text_span_builder.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'package:extended_text_library/extended_text_library.dart'; -import 'package:flutter/material.dart'; - -import 'emoji_text.dart'; - -class TextSpanBuilder extends SpecialTextSpanBuilder { - final bool showAtBackground; - - TextSpanBuilder({ - this.showAtBackground: false, - }); - - @override - TextSpan build(String data, {TextStyle textStyle, onTap}) { - TextSpan result = super.build(data, textStyle: textStyle, onTap: onTap); - return result; - } - - @override - SpecialText createSpecialText(String flag, - {TextStyle textStyle, SpecialTextGestureTapCallback onTap, int index}) { - if (flag == null || flag == "") return null; - - if (isStart(flag, EmojiText.flag)) { - return EmojiText(textStyle, start: index - (EmojiText.flag.length - 1)); - } - return null; - } -} - -class SpecialTextStyle { - TextRange textRange; -} diff --git a/lib/web/web_view/comment_list.dart b/lib/web/web_view/comment_list.dart index f77fd774..20426281 100644 --- a/lib/web/web_view/comment_list.dart +++ b/lib/web/web_view/comment_list.dart @@ -73,105 +73,101 @@ class CommentListState extends State { @override Widget build(BuildContext context) { - return Column( - children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.all(16), - child: Row( - children: [ - Text( - S.of(context).pinglun_(commentTotal.toString()), - style: TextStyle( - fontSize: widget.fontSize + 4, - fontWeight: FontWeight.bold, - color: Color(0xff1A1A1A), - ), - ), - SizedBox( - width: 16.w, - ), - Text( - S.of(context).xihuan_("${widget.like ?? "0"}"), - style: TextStyle( - fontSize: widget.fontSize + 4, - fontWeight: FontWeight.bold, - color: Color(0xff1A1A1A), - ), - ), - ], + return Container( + decoration: BoxDecoration( + color: Colors.white, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(16), + child: Row( + children: [ + Text( + S.of(context).pinglun_(commentTotal.toString()), + style: TextStyle( + fontSize: widget.fontSize + 4, + fontWeight: FontWeight.bold, + color: Color(0xff1A1A1A), + ), ), - ), - if (memberList != null && memberList.length > 0) - ListView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: memberList != null ? memberList.length : 0, - scrollDirection: Axis.vertical, - itemBuilder: (context, position) { - return Material( - color: Colors.white, - child: InkWell( - onTap: () { - // showPressMenu(memberList[position].createUser, - // memberList[position]); - }, - child: commentItem(memberList[position]), - ), - ); - }, + SizedBox( + width: 16.w, ), - if (memberList != null && memberList.length > 0) - Container( - decoration: BoxDecoration( - color: Color(0xFFF2F2F2), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(12), - offset: Offset(0, 2), - blurRadius: 14, - spreadRadius: 0, - ), - ], - ), - alignment: Alignment.topCenter, - padding: EdgeInsets.only(top: 22.h, bottom: 22.h), - child: Text( - S.of(context).yixiansquanbupinglun, - style: TextStyle( - fontSize: widget.fontSize + 2, - color: Color(0xff353535), - ), + Text( + S.of(context).xihuan_("${widget.like ?? "0"}"), + style: TextStyle( + fontSize: widget.fontSize + 4, + fontWeight: FontWeight.bold, + color: Color(0xff1A1A1A), ), ), - // if (memberList == null || memberList.length == 0) - // Container( - // width: double.infinity, - // height: MediaQuery.of(context).size.height - kToolbarHeight - // - MediaQuery.of(context).padding.top - 160.h, - // alignment: Alignment.topCenter, - // color: Color(0xFFF2F2F2), - // padding: EdgeInsets.only(top: 22.h), - // child: Text( - // S.of(context).zanwupinglun, - // style: TextStyle( - // fontSize: widget.fontSize + 2, - // fontWeight: FontWeight.bold, - // color: Color(0xFFA0A0A0), - // ), - // ), - // ), - ], + ], + ), ), - ), - ], + if (memberList != null && memberList.length > 0) + ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: memberList != null ? memberList.length : 0, + scrollDirection: Axis.vertical, + itemBuilder: (context, position) { + return Material( + color: Colors.white, + child: InkWell( + onTap: () { + // showPressMenu(memberList[position].createUser, + // memberList[position]); + }, + child: commentItem(memberList[position]), + ), + ); + }, + ), + if (memberList != null && memberList.length > 0) + Container( + decoration: BoxDecoration( + color: Color(0xFFF2F2F2), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha(12), + offset: Offset(0, 2), + blurRadius: 14, + spreadRadius: 0, + ), + ], + ), + alignment: Alignment.topCenter, + padding: EdgeInsets.only(top: 22.h, bottom: 22.h), + child: Text( + S.of(context).yixiansquanbupinglun, + style: TextStyle( + fontSize: widget.fontSize + 2, + color: Color(0xff353535), + ), + ), + ), + // if (memberList == null || memberList.length == 0) + // Container( + // width: double.infinity, + // height: MediaQuery.of(context).size.height - kToolbarHeight + // - MediaQuery.of(context).padding.top - 160.h, + // alignment: Alignment.topCenter, + // color: Color(0xFFF2F2F2), + // padding: EdgeInsets.only(top: 22.h), + // child: Text( + // S.of(context).zanwupinglun, + // style: TextStyle( + // fontSize: widget.fontSize + 2, + // fontWeight: FontWeight.bold, + // color: Color(0xFFA0A0A0), + // ), + // ), + // ), + ], + ), ); } diff --git a/pubspec.lock b/pubspec.lock index ba048cc3..a7f3519c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -92,13 +92,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.16.0" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.0.2" csslib: dependency: transitive description: @@ -134,20 +127,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.0" - extended_text: - dependency: "direct main" - description: - name: extended_text - url: "https://pub.flutter-io.cn" - source: hosted - version: "9.1.2" - extended_text_library: - dependency: transitive - description: - name: extended_text_library - url: "https://pub.flutter-io.cn" - source: hosted - version: "9.1.1" fake_async: dependency: transitive description: @@ -434,13 +413,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.7.0" - mqtt_client: - dependency: "direct main" - description: - name: mqtt_client - url: "https://pub.flutter-io.cn" - source: hosted - version: "9.6.8" nested: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 68016815..62d0e705 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -103,10 +103,6 @@ dependencies: emoji_picker_flutter: ^1.4.1 - mqtt_client: ^9.6.8 - - extended_text: ^9.0.0 - dev_dependencies: flutter_test: sdk: flutter