From d45562486b53a27008b3857a0e3d2884e5e4a9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AD=90=E8=B4=A4?= Date: Wed, 31 Dec 2025 11:24:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/timeline_info_controller.dart | 12 +++ lib/pages/home/matchmaker_page.dart | 38 ++++++++ lib/pages/home/recommend_tab.dart | 11 +++ lib/pages/home/timeline_info.dart | 97 +++++++++++++------ 4 files changed, 126 insertions(+), 32 deletions(-) create mode 100644 lib/pages/home/matchmaker_page.dart diff --git a/lib/controller/home/timeline_info_controller.dart b/lib/controller/home/timeline_info_controller.dart index b2b13fe..25c238d 100644 --- a/lib/controller/home/timeline_info_controller.dart +++ b/lib/controller/home/timeline_info_controller.dart @@ -33,6 +33,8 @@ class TimelineInfoController extends GetxController { final message = ''.obs; final messageController = TextEditingController().obs; + final focusNode = FocusNode().obs; + @override void onInit() { super.onInit(); @@ -44,8 +46,16 @@ class TimelineInfoController extends GetxController { _homeApi = Get.find(); getPostData(); getCommentData(); + } + @override + void onClose() { + super.onClose(); + focusNode.value.dispose(); + } + + getPostData() async { try { final response = await _homeApi.userPagePostDetail(id: id); @@ -144,6 +154,8 @@ class TimelineInfoController extends GetxController { getPostData(); getCommentData(); showInput.value = false; + + FocusScope.of(Get.context!).unfocus(); parentId.value = "0"; message.value = ""; diff --git a/lib/pages/home/matchmaker_page.dart b/lib/pages/home/matchmaker_page.dart new file mode 100644 index 0000000..a488c80 --- /dev/null +++ b/lib/pages/home/matchmaker_page.dart @@ -0,0 +1,38 @@ +import 'package:dating_touchme_app/components/page_appbar.dart'; +import 'package:dating_touchme_app/controller/home/home_controller.dart'; +import 'package:dating_touchme_app/pages/home/nearby_tab.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +class MatchmakerPage extends StatefulWidget { + const MatchmakerPage({super.key}); + + @override + State createState() => _MatchmakerPageState(); +} + +class _MatchmakerPageState extends State with AutomaticKeepAliveClientMixin { + + + final HomeController controller = Get.find(); + + @override + Widget build(BuildContext context) { + super.build(context); + return Scaffold( + appBar: PageAppbar(title: "金牌红娘"), + body: Column( + children: [ + Expanded( + child: NearbyTab(), + ) + ], + ), + ); + } + + + @override + bool get wantKeepAlive => true; +} + diff --git a/lib/pages/home/recommend_tab.dart b/lib/pages/home/recommend_tab.dart index 8065793..1099316 100644 --- a/lib/pages/home/recommend_tab.dart +++ b/lib/pages/home/recommend_tab.dart @@ -3,6 +3,7 @@ import 'package:dating_touchme_app/extension/ex_widget.dart'; import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/pages/home/event_info.dart'; import 'package:dating_touchme_app/pages/home/matchmaker_item.dart'; +import 'package:dating_touchme_app/pages/home/matchmaker_page.dart'; import 'package:dating_touchme_app/pages/mine/open_webview.dart'; import 'package:easy_refresh/easy_refresh.dart'; import 'package:flutter/material.dart'; @@ -223,6 +224,16 @@ class _RecommendTabState extends State fontWeight: FontWeight.w700 ), ), + Text( + "查看更多", + style: TextStyle( + fontSize: 9.w, + color: const Color.fromRGBO(144, 144, 144, 1), + fontWeight: FontWeight.w500 + ), + ).onTap((){ + Get.to(() => MatchmakerPage()); + }) ], ), Wrap( diff --git a/lib/pages/home/timeline_info.dart b/lib/pages/home/timeline_info.dart index 4f39b21..6e5ce8d 100644 --- a/lib/pages/home/timeline_info.dart +++ b/lib/pages/home/timeline_info.dart @@ -7,6 +7,7 @@ import 'package:dating_touchme_app/model/home/post_comment_data.dart'; import 'package:dating_touchme_app/pages/home/report_page.dart'; import 'package:dating_touchme_app/pages/home/user_information_page.dart'; import 'package:easy_refresh/easy_refresh.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -45,6 +46,33 @@ class TimelineInfo extends StatelessWidget { color: const Color.fromRGBO(51, 51, 51, 1) ), ), + actions: [ + Container( + margin: EdgeInsets.only(right: 14.w), + child: PopupMenuButton( + tooltip: "", + padding: EdgeInsets.zero, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), + color: Colors.white, + elevation: 8, + offset: Offset(0, 32.w), // 相对按钮下移一点 + itemBuilder: (context) => [ + const PopupMenuItem(value: 'report', child: Text('举报')), + ], + onSelected: (v) { + if (v == 'report') { + print("举报"); + Get.to(() => ReportPage(id: id,)); + } + }, + child: Icon( + Icons.keyboard_control, + size: 24.w, + color: const Color.fromRGBO(51, 51, 51, 1), + ), // 你的小圆按钮 + ), + ) + ], ), body: Stack( children: [ @@ -138,28 +166,7 @@ class TimelineInfo extends StatelessWidget { ) ], ), - PopupMenuButton( - tooltip: "", - padding: EdgeInsets.zero, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), - color: Colors.white, - elevation: 8, - offset: Offset(0, 32.w), // 相对按钮下移一点 - itemBuilder: (context) => [ - const PopupMenuItem(value: 'report', child: Text('举报')), - ], - onSelected: (v) { - if (v == 'report') { - print("举报"); - Get.to(() => ReportPage(id: id,)); - } - }, - child: Icon( - Icons.keyboard_control, - size: 15.w, - color: const Color.fromRGBO(51, 51, 51, 1), - ), // 你的小圆按钮 - ), + ], ), Container( @@ -247,7 +254,9 @@ class TimelineInfo extends StatelessWidget { ) ], ).onTap((){ - controller.showInput.value = true; + controller.focusNode.value.requestFocus(); + + // controller.update(); }), ], @@ -271,15 +280,36 @@ class TimelineInfo extends StatelessWidget { ), ), ), - if(controller.showInput.value) Positioned.fill( - child: Container( - color: const Color.fromRGBO(0, 0, 0, .4), - ).onTap((){ - controller.showInput.value = false; + // if(controller.showInput.value) Positioned.fill( + // child: Container( + // color: const Color.fromRGBO(0, 0, 0, .4), + // ).onTap((){ + // controller.showInput.value = false; + // FocusScope.of(context).unfocus(); + // + // }), + // ), + ListenableBuilder( + listenable: controller.focusNode.value, // 直接监听焦点节点 + builder: (context, child) { + // 只有当焦点状态改变时,这段 builder 才会运行 + return Visibility( + visible: controller.focusNode.value.hasFocus, + child: GestureDetector( + onTap: () { - }), + FocusScope.of(context).unfocus(); + controller.parentId.value = "0"; + }, + child: Container( + color: const Color.fromRGBO(0, 0, 0, .4), + // 这里放遮罩层的内容 + ), + ), + ); + }, ), - if(controller.showInput.value) Positioned( + Positioned( left: 0, bottom: 0, child: Container( @@ -296,8 +326,8 @@ class TimelineInfo extends StatelessWidget { borderRadius: BorderRadius.all(Radius.circular(40.w)) ), child: TextField( + focusNode: controller.focusNode.value, controller: controller.messageController.value, - autofocus: true, style: TextStyle( fontSize: ScreenUtil().setWidth(14), height: 1 @@ -437,7 +467,10 @@ class _CommentItemState extends State { ), ).onTap((){ widget.controller.parentId.value = widget.item.id ?? "0"; - widget.controller.showInput.value = true; + + + widget.controller.focusNode.value.requestFocus(); + }), ], ),