From aba707e627612ceaf6b199f20dcc9a1c1ff53baa Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 27 May 2023 16:14:42 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=9B=9E=E5=A4=8D=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/main/view.dart | 26 +++++++++---------- lib/pages/video/detail/reply/view.dart | 13 +++++----- .../detail/reply/widgets/reply_item.dart | 25 ++++++++++++++---- lib/pages/video/detail/replyNew/view.dart | 6 ++++- lib/pages/video/detail/replyReply/view.dart | 22 +++++++++++----- 5 files changed, 59 insertions(+), 33 deletions(-) diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index ded53199..9a8bab87 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -102,7 +102,7 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { ), child: PageView( controller: _pageController, - physics: const NeverScrollableScrollPhysics(), + // physics: const NeverScrollableScrollPhysics(), onPageChanged: (index) { selectedIndex = index; setState(() {}); @@ -111,19 +111,17 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { ), ), ), - bottomNavigationBar: Obx( - () => NavigationBar( - elevation: 1, - destinations: _mainController.navigationBars.map((e) { - return NavigationDestination( - icon: e['icon'], - selectedIcon: e['selectedIcon'], - label: e['label'], - ); - }).toList(), - selectedIndex: selectedIndex, - onDestinationSelected: (value) => setIndex(value), - ), + bottomNavigationBar: NavigationBar( + elevation: 1, + destinations: _mainController.navigationBars.map((e) { + return NavigationDestination( + icon: e['icon'], + selectedIcon: e['selectedIcon'], + label: e['label'], + ); + }).toList(), + selectedIndex: selectedIndex, + onDestinationSelected: (value) => setIndex(value), ), ); } diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 1e5ffd22..ba3a11a8 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -163,12 +163,7 @@ class _VideoReplyPanelState extends State return ReplyItem( replyItem: _videoReplyController .replyList[index], - weakUpReply: (replyItem, replyLevel) => - _showReply( - 'floor', - replyItem: replyItem, - replyLevel: replyLevel, - ), + showReplyRow: true, replyLevel: replyLevel); } }, @@ -223,7 +218,11 @@ class _VideoReplyPanelState extends State parent: 0, ); }, - ).then((value) => {print('close ModalBottomSheet')}); + ).then((value) => { + // 完成评论,数据添加 + _videoReplyController + .replyList.add(value['data']) + }); }, tooltip: '发表评论', child: const Icon(Icons.reply), diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 847bdfb2..1615ad49 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -11,10 +13,16 @@ import 'package:pilipala/pages/video/detail/replyReply/index.dart'; import 'package:pilipala/utils/utils.dart'; class ReplyItem extends StatelessWidget { - ReplyItem({super.key, this.replyItem, this.weakUpReply, this.replyLevel}); + ReplyItem( + {super.key, + this.replyItem, + this.addReply, + this.replyLevel, + this.showReplyRow}); ReplyItemModel? replyItem; - Function? weakUpReply; + Function? addReply; String? replyLevel; + bool? showReplyRow = true; @override Widget build(BuildContext context) { @@ -179,7 +187,7 @@ class ReplyItem extends StatelessWidget { // 操作区域 bottonAction(context, replyItem!.replyControl), const SizedBox(height: 3), - if (replyItem!.replies!.isNotEmpty && replyLevel != '2') ...[ + if (replyItem!.replies!.isNotEmpty && showReplyRow!) ...[ Padding( padding: const EdgeInsets.only(top: 2, bottom: 12), child: ReplyItemRow( @@ -241,7 +249,6 @@ class ReplyItem extends StatelessWidget { context: context, isScrollControlled: true, builder: (builder) { - print('🌹: ${replyItem!.rpid}'); return VideoReplyNewDialog( replyLevel: replyLevel, oid: replyItem!.oid, @@ -249,7 +256,15 @@ class ReplyItem extends StatelessWidget { parent: replyItem!.rpid, ); }, - ).then((value) => {print('showModalBottomSheet')}); + ).then((value) => { + // 完成评论,数据添加 + if (value['data'] != null) + { + print('🌹: ${value['data'].content.message}'), + addReply!(value['data']) + // replyControl.replies.add(value['data']), + } + }); }, ), ), diff --git a/lib/pages/video/detail/replyNew/view.dart b/lib/pages/video/detail/replyNew/view.dart index 3f530d7e..f69a1d1f 100644 --- a/lib/pages/video/detail/replyNew/view.dart +++ b/lib/pages/video/detail/replyNew/view.dart @@ -1,9 +1,11 @@ import 'dart:async'; +import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:pilipala/http/video.dart'; import 'package:pilipala/models/common/reply_type.dart'; +import 'package:pilipala/models/video/reply/item.dart'; class VideoReplyNewDialog extends StatefulWidget { int? oid; @@ -59,7 +61,6 @@ class _VideoReplyNewDialogState extends State Future submitReplyAdd() async { String message = _replyContentController.text; - print(widget.oid); var result = await VideoHttp.replyAdd( type: ReplyType.video, oid: widget.oid!, @@ -69,6 +70,9 @@ class _VideoReplyNewDialogState extends State ); if (result['status']) { SmartDialog.showToast(result['data']['success_toast']); + Get.back(result: { + 'data': ReplyItemModel.fromJson(result['data']['reply'], ''), + }); } else {} } diff --git a/lib/pages/video/detail/replyReply/view.dart b/lib/pages/video/detail/replyReply/view.dart index ac3c45fd..2157927b 100644 --- a/lib/pages/video/detail/replyReply/view.dart +++ b/lib/pages/video/detail/replyReply/view.dart @@ -104,9 +104,13 @@ class _VideoReplyReplyPanelState extends State { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: ReplyItem( - replyItem: widget.firstFloor, - replyLevel: '2', - ), + replyItem: widget.firstFloor, + replyLevel: '1', + showReplyRow: false, + addReply: (replyItem) { + _videoReplyReplyController.replyList + .add(replyItem); + }), ), SliverToBoxAdapter( child: Divider( @@ -151,9 +155,15 @@ class _VideoReplyReplyPanelState extends State { } else { return Material( child: ReplyItem( - replyItem: _videoReplyReplyController - .replyList[index], - ), + replyItem: _videoReplyReplyController + .replyList[index], + replyLevel: '2', + showReplyRow: false, + addReply: (replyItem) { + _videoReplyReplyController + .replyList + .add(replyItem); + }), ); } },