mod: 回复内容回填

This commit is contained in:
guozhigq
2023-05-27 16:14:42 +08:00
parent 0d49f9824c
commit aba707e627
5 changed files with 59 additions and 33 deletions

View File

@ -102,7 +102,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
), ),
child: PageView( child: PageView(
controller: _pageController, controller: _pageController,
physics: const NeverScrollableScrollPhysics(), // physics: const NeverScrollableScrollPhysics(),
onPageChanged: (index) { onPageChanged: (index) {
selectedIndex = index; selectedIndex = index;
setState(() {}); setState(() {});
@ -111,8 +111,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
), ),
), ),
), ),
bottomNavigationBar: Obx( bottomNavigationBar: NavigationBar(
() => NavigationBar(
elevation: 1, elevation: 1,
destinations: _mainController.navigationBars.map((e) { destinations: _mainController.navigationBars.map((e) {
return NavigationDestination( return NavigationDestination(
@ -124,7 +123,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
selectedIndex: selectedIndex, selectedIndex: selectedIndex,
onDestinationSelected: (value) => setIndex(value), onDestinationSelected: (value) => setIndex(value),
), ),
),
); );
} }
} }

View File

@ -163,12 +163,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
return ReplyItem( return ReplyItem(
replyItem: _videoReplyController replyItem: _videoReplyController
.replyList[index], .replyList[index],
weakUpReply: (replyItem, replyLevel) => showReplyRow: true,
_showReply(
'floor',
replyItem: replyItem,
replyLevel: replyLevel,
),
replyLevel: replyLevel); replyLevel: replyLevel);
} }
}, },
@ -223,7 +218,11 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
parent: 0, parent: 0,
); );
}, },
).then((value) => {print('close ModalBottomSheet')}); ).then((value) => {
// 完成评论,数据添加
_videoReplyController
.replyList.add(value['data'])
});
}, },
tooltip: '发表评论', tooltip: '发表评论',
child: const Icon(Icons.reply), child: const Icon(Icons.reply),

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.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'; import 'package:pilipala/utils/utils.dart';
class ReplyItem extends StatelessWidget { 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; ReplyItemModel? replyItem;
Function? weakUpReply; Function? addReply;
String? replyLevel; String? replyLevel;
bool? showReplyRow = true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -179,7 +187,7 @@ class ReplyItem extends StatelessWidget {
// 操作区域 // 操作区域
bottonAction(context, replyItem!.replyControl), bottonAction(context, replyItem!.replyControl),
const SizedBox(height: 3), const SizedBox(height: 3),
if (replyItem!.replies!.isNotEmpty && replyLevel != '2') ...[ if (replyItem!.replies!.isNotEmpty && showReplyRow!) ...[
Padding( Padding(
padding: const EdgeInsets.only(top: 2, bottom: 12), padding: const EdgeInsets.only(top: 2, bottom: 12),
child: ReplyItemRow( child: ReplyItemRow(
@ -241,7 +249,6 @@ class ReplyItem extends StatelessWidget {
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
builder: (builder) { builder: (builder) {
print('🌹: ${replyItem!.rpid}');
return VideoReplyNewDialog( return VideoReplyNewDialog(
replyLevel: replyLevel, replyLevel: replyLevel,
oid: replyItem!.oid, oid: replyItem!.oid,
@ -249,7 +256,15 @@ class ReplyItem extends StatelessWidget {
parent: replyItem!.rpid, 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']),
}
});
}, },
), ),
), ),

View File

@ -1,9 +1,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:developer';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pilipala/http/video.dart'; import 'package:pilipala/http/video.dart';
import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/item.dart';
class VideoReplyNewDialog extends StatefulWidget { class VideoReplyNewDialog extends StatefulWidget {
int? oid; int? oid;
@ -59,7 +61,6 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
Future submitReplyAdd() async { Future submitReplyAdd() async {
String message = _replyContentController.text; String message = _replyContentController.text;
print(widget.oid);
var result = await VideoHttp.replyAdd( var result = await VideoHttp.replyAdd(
type: ReplyType.video, type: ReplyType.video,
oid: widget.oid!, oid: widget.oid!,
@ -69,6 +70,9 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
); );
if (result['status']) { if (result['status']) {
SmartDialog.showToast(result['data']['success_toast']); SmartDialog.showToast(result['data']['success_toast']);
Get.back(result: {
'data': ReplyItemModel.fromJson(result['data']['reply'], ''),
});
} else {} } else {}
} }

View File

@ -105,8 +105,12 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
SliverToBoxAdapter( SliverToBoxAdapter(
child: ReplyItem( child: ReplyItem(
replyItem: widget.firstFloor, replyItem: widget.firstFloor,
replyLevel: '2', replyLevel: '1',
), showReplyRow: false,
addReply: (replyItem) {
_videoReplyReplyController.replyList
.add(replyItem);
}),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: Divider( child: Divider(
@ -153,7 +157,13 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
child: ReplyItem( child: ReplyItem(
replyItem: _videoReplyReplyController replyItem: _videoReplyReplyController
.replyList[index], .replyList[index],
), replyLevel: '2',
showReplyRow: false,
addReply: (replyItem) {
_videoReplyReplyController
.replyList
.add(replyItem);
}),
); );
} }
}, },