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(
controller: _pageController,
physics: const NeverScrollableScrollPhysics(),
// physics: const NeverScrollableScrollPhysics(),
onPageChanged: (index) {
selectedIndex = index;
setState(() {});
@ -111,19 +111,17 @@ class _MainAppState extends State<MainApp> 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),
),
);
}

View File

@ -163,12 +163,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
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<VideoReplyPanel>
parent: 0,
);
},
).then((value) => {print('close ModalBottomSheet')});
).then((value) => {
// 完成评论,数据添加
_videoReplyController
.replyList.add(value['data'])
});
},
tooltip: '发表评论',
child: const Icon(Icons.reply),

View File

@ -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']),
}
});
},
),
),

View File

@ -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<VideoReplyNewDialog>
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<VideoReplyNewDialog>
);
if (result['status']) {
SmartDialog.showToast(result['data']['success_toast']);
Get.back(result: {
'data': ReplyItemModel.fromJson(result['data']['reply'], ''),
});
} else {}
}

View File

@ -104,9 +104,13 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
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<VideoReplyReplyPanel> {
} else {
return Material(
child: ReplyItem(
replyItem: _videoReplyReplyController
.replyList[index],
),
replyItem: _videoReplyReplyController
.replyList[index],
replyLevel: '2',
showReplyRow: false,
addReply: (replyItem) {
_videoReplyReplyController
.replyList
.add(replyItem);
}),
);
}
},