From 7478f85bbbb81383b25c5dae2f9279941ff5ba45 Mon Sep 17 00:00:00 2001 From: CYH <13923927013@163.com> Date: Mon, 4 Dec 2023 19:21:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=8D=931.3.5=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- circle_app/android/app/build.gradle | 4 +- .../lib/app/chat/widget/chat_gift_pannel.dart | 181 ++++++----- circle_app/lib/app/chat/widget/gift.dart | 1 + circle_app/lib/app/dialog/UpdateDialog.dart | 4 +- circle_app/lib/app/home/logic.dart | 4 + circle_app/lib/app/msg/view.dart | 4 +- circle_app/lib/app/quick/view.dart | 118 +++---- circle_app/lib/app/userinfo/view.dart | 9 + .../common/Widgets/RechargeScreenDialog.dart | 16 +- circle_app/lib/main.dart | 6 +- circle_app/lib/network/api.dart | 4 +- circle_app/lib/view/notice.dart | 301 ++++++++++-------- 12 files changed, 356 insertions(+), 296 deletions(-) diff --git a/circle_app/android/app/build.gradle b/circle_app/android/app/build.gradle index 3b22b37..f666db0 100644 --- a/circle_app/android/app/build.gradle +++ b/circle_app/android/app/build.gradle @@ -71,8 +71,8 @@ android { // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion - versionCode 26 - versionName "1.3.3" + versionCode 27 + versionName "1.3.5" manifestPlaceholders = [ vivo_APPID: "105669716", vivo_APPKEY:"84f750207787376b310ca5b0d5969122", diff --git a/circle_app/lib/app/chat/widget/chat_gift_pannel.dart b/circle_app/lib/app/chat/widget/chat_gift_pannel.dart index f3e72ab..379ec69 100644 --- a/circle_app/lib/app/chat/widget/chat_gift_pannel.dart +++ b/circle_app/lib/app/chat/widget/chat_gift_pannel.dart @@ -59,97 +59,102 @@ class _ChatGiftPannelState extends State height: Get.height, child: Column( children: [ - Expanded(child: Container()), + Expanded(child:GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + Get.back(); + }, + child: Container())), Container( - // color: Color(0xFF423055), - child: SafeArea( - top: false, - child: Container( - decoration: BoxDecoration( - color: Color(0xFF423055), - borderRadius: BorderRadius.only(topLeft: Radius.circular(16.sp,),topRight: Radius.circular(16.sp)) - ), - width: Get.width, - height: 370.sp, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 5.sp,), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - height: 30.sp, - width:120.sp, - margin: EdgeInsets.only(left: 5.sp,), - child: TabBar( - isScrollable: false, - automaticIndicatorColorAdjustment: false, - labelPadding: EdgeInsets.symmetric(horizontal: 4.0.sp), - physics: NeverScrollableScrollPhysics(), - indicatorColor: AppColor.mainColor, - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - fontSize: 16.sp, - fontWeight: FontWeight.w500, + child: SafeArea( + top: false, + child: Container( + decoration: BoxDecoration( + color: Color(0xFF423055), + borderRadius: BorderRadius.only(topLeft: Radius.circular(16.sp,),topRight: Radius.circular(16.sp)) + ), + width: Get.width, + height: 370.sp, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 5.sp,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + height: 30.sp, + width:120.sp, + margin: EdgeInsets.only(left: 5.sp,), + child: TabBar( + isScrollable: false, + automaticIndicatorColorAdjustment: false, + labelPadding: EdgeInsets.symmetric(horizontal: 4.0.sp), + physics: NeverScrollableScrollPhysics(), + indicatorColor: AppColor.mainColor, + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + fontSize: 16.sp, + fontWeight: FontWeight.w500, + ), + unselectedLabelColor: Color(0xB3FFFFFF), + labelColor: AppColor.mainColor, + labelStyle: TextStyle( + fontSize: 16.sp, fontWeight: FontWeight.w500), + controller: tabController, + tabs: const [ + Tab( + text: '礼物', + ), + Tab( + text: '会员', + ), + ], ), - unselectedLabelColor: Color(0xB3FFFFFF), - labelColor: AppColor.mainColor, - labelStyle: TextStyle( - fontSize: 16.sp, fontWeight: FontWeight.w500), - controller: tabController, - tabs: const [ - Tab( - text: '礼物', - ), - Tab( - text: '会员', - ), - ], ), - ), - tabController.index == 0 ? Container( - margin: EdgeInsets.only(right: 15.sp), - child: InkWell( - onTap: () { - String toUserId = widget.accid!.split('_').last; - Get.toNamed(AppRoutes.GiftShopPage,arguments: toUserId); - }, - child: Container( - height:22.sp, - width: 62.sp, - decoration: BoxDecoration( - gradient: AppColor.mainVerLinearGradient, - borderRadius: BorderRadius.circular(11.sp) - ), - child: Stack( - alignment: Alignment.center, - children: [ - Container( - height:20.sp, - width: 60.sp, - decoration: BoxDecoration( - color: Color(0xFF423055), - borderRadius: BorderRadius.circular(10.sp) - )), - Text('礼物墙',style: TextStyle(color: Colors.white,fontSize: 14.sp),) - ], - ), - )), - ) : Container() - ], - ), - Expanded( - child: TabBarView( - controller: tabController, - children: [ - Gift(widget.accid,widget.giftId), - PartnerOption(accid: widget.accid), - ], - )) - ], - ), - ))) + tabController.index == 0 ? Container( + margin: EdgeInsets.only(right: 15.sp), + child: InkWell( + onTap: () { + String toUserId = widget.accid!.split('_').last; + Get.toNamed(AppRoutes.GiftShopPage,arguments: toUserId); + }, + child: Container( + height:22.sp, + width: 62.sp, + decoration: BoxDecoration( + gradient: AppColor.mainVerLinearGradient, + borderRadius: BorderRadius.circular(11.sp) + ), + child: Stack( + alignment: Alignment.center, + children: [ + Container( + height:20.sp, + width: 60.sp, + decoration: BoxDecoration( + color: Color(0xFF423055), + borderRadius: BorderRadius.circular(10.sp) + )), + Text('礼物墙',style: TextStyle(color: Colors.white,fontSize: 14.sp),) + ], + ), + )), + ) : Container() + ], + ), + Expanded( + child: TabBarView( + controller: tabController, + children: [ + Gift(widget.accid,widget.giftId), + PartnerOption(accid: widget.accid), + ], + )) + ], + ), + )), + ) ], ), ), diff --git a/circle_app/lib/app/chat/widget/gift.dart b/circle_app/lib/app/chat/widget/gift.dart index d2170e8..900bb71 100644 --- a/circle_app/lib/app/chat/widget/gift.dart +++ b/circle_app/lib/app/chat/widget/gift.dart @@ -263,6 +263,7 @@ class _GiftState extends State { if (info['name'] == '浪漫告白') { selectedIndex = i; giftId = info['id'].toString(); + tipStr = info['topHours'] != null ? info['topHours'].toString() : ''; } } diff --git a/circle_app/lib/app/dialog/UpdateDialog.dart b/circle_app/lib/app/dialog/UpdateDialog.dart index 0d6f247..ecd9b01 100644 --- a/circle_app/lib/app/dialog/UpdateDialog.dart +++ b/circle_app/lib/app/dialog/UpdateDialog.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -// import 'package:flutter_install_app/flutter_install_app.dart'; +import 'package:flutter_install_app/flutter_install_app.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -260,7 +260,7 @@ class _CustomDialogState extends State { // SmartDialog.dismiss(); print(error); }); - // await AppInstaller.installApk(filePath, actionRequired: false); + await AppInstaller.installApk(filePath, actionRequired: false); } } diff --git a/circle_app/lib/app/home/logic.dart b/circle_app/lib/app/home/logic.dart index 4c6fe74..ee5de48 100644 --- a/circle_app/lib/app/home/logic.dart +++ b/circle_app/lib/app/home/logic.dart @@ -23,6 +23,7 @@ import 'package:tencent_cloud_chat_uikit/data_services/message/message_services. import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart'; import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart'; +import '../../util/PaymentUtils.dart'; import '../../util/SharedPreferencesHelper.dart'; import '../../util/eventBus.dart'; import '../../view/notice.dart'; @@ -87,6 +88,9 @@ class HomeLogic extends GetxController with WidgetsBindingObserver { checkVersion(); loadMyCircleData(); + if (Platform.isAndroid) { + initWxApi(); + } } void addMsgListener() { diff --git a/circle_app/lib/app/msg/view.dart b/circle_app/lib/app/msg/view.dart index b3b5795..3688a2a 100644 --- a/circle_app/lib/app/msg/view.dart +++ b/circle_app/lib/app/msg/view.dart @@ -248,7 +248,7 @@ class _MsgPageState extends State with AutomaticKeepAliveClientMixin { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - '想要聊天的圈友', + '最近想要聊天的圈友', style: TextStyle( color: Colors.white, fontSize: 16.sp, @@ -270,7 +270,7 @@ class _MsgPageState extends State with AutomaticKeepAliveClientMixin { ).createShader(Offset.zero & bounds.size); }, child: Text( - '${ctr.total}人等您聊', + '${ctr.total}人在线等您聊', style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.w600, diff --git a/circle_app/lib/app/quick/view.dart b/circle_app/lib/app/quick/view.dart index f9f9791..fcc7f53 100644 --- a/circle_app/lib/app/quick/view.dart +++ b/circle_app/lib/app/quick/view.dart @@ -138,30 +138,12 @@ class QuickPage extends StatelessWidget { // height: 210.sp + (item.images.isNotEmpty ? 98.sp : 0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.sp), - border: GradientBoxBorder( - - gradient: - AppColor.mainVerLinearGradient, + border: Border.all( + color: AppColor.mainColor.withOpacity(0.2), width: 1.sp, ), ), - child: Stack( - children: [ - Container( - margin: EdgeInsets.only(top: 1.sp, left: 1.sp, right: 1.sp), - child: ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10.sp), - topRight: Radius.circular(10.sp), - ), - child: Image( - image: AssetImage(getCircleImage("icon_list_null")), - width: Get.width, - fit: BoxFit.fill, - height: 92.sp, - ) - ), - ), + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -171,10 +153,10 @@ class QuickPage extends StatelessWidget { children: [ Container( margin: EdgeInsets.only(top: 6.sp, left: 8.sp), - width: 88.sp, - height: 88.sp, + width: 61.sp, + height: 61.sp, decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8.0), + borderRadius: BorderRadius.circular(30.5.sp), gradient: const LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, @@ -187,51 +169,58 @@ class QuickPage extends StatelessWidget { ), padding: EdgeInsets.all(2.sp), child: ClipRRect( - borderRadius: BorderRadius.circular(8.0), + borderRadius: BorderRadius.circular(30.sp), child: Image.network(item.avatarThumb, - width: 88.sp, height: 88.sp, fit: BoxFit.cover), + width: 60.sp, height: 60.sp, fit: BoxFit.cover), ), ), + Expanded( + child: Column( + children: [ + Container( + margin: EdgeInsets.only(top: 6.sp, left: 9.sp), + child: Row( + children: [ + Text( + item.nickname, + style: TextStyle( + fontWeight: FontWeight.bold, + color: const Color.fromRGBO(247, 250, 250, 1.0), + fontSize: 16.sp, + ), + ), + SizedBox(width: 8.sp), + if (item.gender != null) + _buildInfoRow(item), + const Spacer(), + ], + ), + ), + Container( + // color: Colors.red, + // height: 55.sp, // 设置固定高度 + constraints: BoxConstraints( + maxHeight: 55.sp + ), + width: Get.width, + margin: EdgeInsets.symmetric(horizontal: 8.0), + child: Align( + alignment: Alignment.centerLeft, // 文本左对齐,垂直居中 + child: Text( + item.signature ?? '暂时还没有签名哦~', + maxLines: 2, + style: TextStyle(color: Colors.white, fontSize: 18.sp), + overflow: TextOverflow.ellipsis, + ), + ), + ), + ], + ), + ) ], ), ), - Container( - margin: EdgeInsets.only(top: 6.sp, left: 9.sp), - child: Row( - children: [ - Text( - item.nickname, - style: TextStyle( - fontWeight: FontWeight.bold, - color: const Color.fromRGBO(247, 250, 250, 1.0), - fontSize: 16.sp, - ), - ), - SizedBox(width: 8.sp), - if (item.gender != null) - _buildInfoRow(item), - const Spacer(), - ], - ), - ), - Container( - // color: Colors.red, - // height: 55.sp, // 设置固定高度 - constraints: BoxConstraints( - maxHeight: 55.sp - ), - width: Get.width, - margin: EdgeInsets.symmetric(horizontal: 8.0), - child: Align( - alignment: Alignment.centerLeft, // 文本左对齐,垂直居中 - child: Text( - item.signature ?? '暂时还没有签名哦~', - maxLines: 2, - style: TextStyle(color: Colors.white, fontSize: 18.sp), - overflow: TextOverflow.ellipsis, - ), - ), - ), + if (item.interests.isNotEmpty) Container( margin: EdgeInsets.only(left: 8.sp, right: 3.sp,bottom: 5.sp), @@ -262,8 +251,7 @@ class QuickPage extends StatelessWidget { ), ), ]), - ], - )), + ), ); } diff --git a/circle_app/lib/app/userinfo/view.dart b/circle_app/lib/app/userinfo/view.dart index e3607f4..895d011 100644 --- a/circle_app/lib/app/userinfo/view.dart +++ b/circle_app/lib/app/userinfo/view.dart @@ -106,6 +106,15 @@ class MyTabbedScreenState extends State @override void dispose() { _tabController.dispose(); + OverlayState? overlayState = Overlay.of(Get.context!); + if (mainOverlayEntry != null) { + if (overlayState.debugIsVisible(mainOverlayEntry!)) { + mainOverlayEntry!.remove(); + } + } + + // overlayState.insert(entry); + sub.cancel(); routeObserver.unsubscribe(this); super.dispose(); diff --git a/circle_app/lib/common/Widgets/RechargeScreenDialog.dart b/circle_app/lib/common/Widgets/RechargeScreenDialog.dart index 94bbc5a..3b3f62a 100644 --- a/circle_app/lib/common/Widgets/RechargeScreenDialog.dart +++ b/circle_app/lib/common/Widgets/RechargeScreenDialog.dart @@ -77,9 +77,11 @@ class _RechargeScreenDialogState extends State { if (isZfbPrice) { var data = await DioManager.instance.post( url: Api.postAliPayOrder, - params: {"itemId": itemId, "payType": 4}); - if (data['code'] == 10000) { - openAliPay(data['payUrl'], (isSuccess, errorMsg) { + params: {"product_id": itemId, "type": 4}); + var bean = BaseResponse.fromJson( + data, (data) => PayUrlBean.fromJson(data)); + if (bean.isSuccess()) { + openAliPay(bean.data.payUrl, (isSuccess, errorMsg) { if (isSuccess) { // 处理支付成功 showOKToast('充值成功'); @@ -95,12 +97,12 @@ class _RechargeScreenDialogState extends State { } else { var data = await DioManager.instance.post( url: Api.postWxOrder, - params: {"itemId": itemId, "payType": 4}); + params: {"product_id": itemId, "type": 4}); var bean = BaseResponse.fromJson( data, (data) => PaymentData.fromJson(data)); if (bean.isSuccess()) { // "wxPayAo" -> [_Map] - openWxPay(data['wxPayAo'], (bool isSuccess, String? errorMessage) { + openWxPay(bean.data, (bool isSuccess, String? errorMessage) { if (isSuccess) { // 处理支付成功 showOKToast('充值成功'); @@ -129,7 +131,7 @@ class _RechargeScreenDialogState extends State { Container( margin: EdgeInsets.only(left: 20.sp,right: 20.sp), padding: EdgeInsets.all(20.sp), - height: widget.isShowBalance ? 441.sp + (!Platform.isAndroid ? 0 : 50.sp) : 390.sp + (!Platform.isAndroid ? 0 : 50.sp), + height: widget.isShowBalance ? 441.sp + (!Platform.isAndroid ? 0 : 15.sp) : 390.sp + (!Platform.isAndroid ? 0 : 50.sp), decoration: BoxDecoration( color: const Color(0xFF393949), borderRadius: BorderRadius.circular(10.sp) @@ -296,7 +298,7 @@ class _RechargeScreenDialogState extends State { ), ), ), - SizedBox(height: 16.0.sp), + SizedBox(height: 10.0.sp), GestureDetector( behavior: HitTestBehavior.opaque, diff --git a/circle_app/lib/main.dart b/circle_app/lib/main.dart index 87d5bee..527d456 100644 --- a/circle_app/lib/main.dart +++ b/circle_app/lib/main.dart @@ -41,6 +41,8 @@ final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance(); final TUIChatSeparateViewModel chatSeparateViewModel = TUIChatSeparateViewModel(); +OverlayEntry? mainOverlayEntry; + void main() { FlutterBugly.postCatchedException(() async { // 如果需要 ensureInitialized,请在这里运行。 @@ -133,9 +135,7 @@ void uploadBuzIDAndToken() async { return; } - // if (Platform.isAndroid) { - initWxApi(); - // } + await ChannelPush.init((msg) {}); int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo); diff --git a/circle_app/lib/network/api.dart b/circle_app/lib/network/api.dart index 42255d3..04a691a 100644 --- a/circle_app/lib/network/api.dart +++ b/circle_app/lib/network/api.dart @@ -1,10 +1,10 @@ class Api { - // static const baseUrl = 'https://leyuan666.com/zuul-service/'; + static const baseUrl = 'https://leyuan666.com/zuul-service/'; - static const baseUrl = 'http://192.168.3.55:2000/'; + // static const baseUrl = 'http://192.168.3.55:2000/'; // 获取验证码 diff --git a/circle_app/lib/view/notice.dart b/circle_app/lib/view/notice.dart index 10d115a..79bebc8 100644 --- a/circle_app/lib/view/notice.dart +++ b/circle_app/lib/view/notice.dart @@ -1,180 +1,231 @@ import 'dart:async'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:circle_app/common/colors/app_color.dart'; +import 'package:event_bus/event_bus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; + +import '../main.dart'; typedef void NoticeCallback(); void showFloatingButtonOverlay( BuildContext context, String nickname, String ageMsg, String avatar,int event,NoticeCallback noticeCallback) { + + OverlayState? overlayState = Overlay.of(context); late OverlayEntry overlayEntry; bool showMessage = false; int countdownSeconds = 5; // 倒计时秒数 + + // 创建 Timer late Timer countdownTimer; // 创建 OverlayEntry overlayEntry = OverlayEntry( builder: (BuildContext context) { - return Positioned( - top: 30, + + return Stack( + alignment: Alignment.center, + children: [ + Positioned( + top: MediaQuery.of(context).padding.top, // right: 16, - child: AnimatedContainer( - duration: const Duration(milliseconds: 500), - curve: Curves.easeInOut, - height: showMessage ? 95 : 0, - child: Container( - width: Get.width - 16, - margin: EdgeInsets.all(10.sp), - padding: EdgeInsets.fromLTRB(16.sp, 16.sp, 16.sp, 0), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: const Color(0xFF353443), - ), - child: SingleChildScrollView( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ClipOval( - child: CachedNetworkImage( - fit: BoxFit.cover, - placeholder: null, - imageUrl: avatar, - width: 48.sp, - height: 48.sp, + child: AnimatedContainer( + duration: const Duration(milliseconds: 500), + curve: Curves.easeInOut, + height: showMessage ? 85 : 0, + child: Container( + width: Get.width - 16, + // margin: EdgeInsets.only(top:10.sp), + padding: EdgeInsets.fromLTRB(16.sp, 16.sp, 16.sp, 0), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color(0xFF353443), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipOval( + child: CachedNetworkImage( + fit: BoxFit.cover, + placeholder: null, + imageUrl: avatar, + width: 48.sp, + height: 48.sp, + ), ), - ), - const SizedBox(width: 8), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - // width: 70.sp, - child: Text( - nickname, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Color.fromRGBO(247, 250, 250, 1.0), - fontSize: 16.sp, + const SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + // width: 70.sp, + child: Text( + nickname, + overflow: TextOverflow.ellipsis, + style: TextStyle( + color: Color.fromRGBO(247, 250, 250, 1.0), + fontSize: 16.sp, + ), ), ), - ), - SizedBox(width: 8.sp), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(17), - gradient: const LinearGradient( - colors: [ - Color.fromRGBO(141, 255, 248, 1.0), - Color.fromRGBO(181, 211, 255, 1.0), - ], - begin: Alignment.centerLeft, - end: Alignment.centerRight, + SizedBox(width: 8.sp), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: const LinearGradient( + colors: [ + Color.fromRGBO(141, 255, 248, 1.0), + Color.fromRGBO(181, 211, 255, 1.0), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.only( + top: 2.sp, + bottom: 2.sp, + left: 10.sp, + right: 10.sp, + ), + child: Text( + ageMsg, + style: const TextStyle( + color: Colors.black, + fontSize: 10, + ), ), ), - padding: EdgeInsets.only( - top: 2.sp, - bottom: 2.sp, - left: 10.sp, - right: 10.sp, - ), - child: Text( - ageMsg, - style: const TextStyle( - color: Colors.black, - fontSize: 10, - ), - ), - ), - ], - ), - const SizedBox(height: 8), - Text( event == 0 - ? "看了这么久,给我点个喜欢呗~" - : event == 1 - ? "我喜欢了你,可以喜欢我一下吗?" - : event == 2 - ? "你喜欢的人上线啦,赶紧找他聊天吧!" - : "我也喜欢了你,一起聊聊呗~", - style: TextStyle( - color: Colors.grey, - fontSize: 14.sp, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ], - ), - const Spacer(), - GestureDetector( - onTap: () { - countdownTimer.cancel(); // 取消计时器 - overlayEntry!.remove(); - noticeCallback(); - - // logic.setLike(); - // logic.showMessage = false; - // logic.update(); - }, - child: Container( - margin: EdgeInsets.only(top: 6.sp), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(17), - gradient: const LinearGradient( - colors: [ - Color(0xFF06F9FA), - Color(0xFFDC5BFD), ], - begin: Alignment.centerLeft, - end: Alignment.centerRight, ), - ), - padding: EdgeInsets.symmetric( - horizontal: 16.sp, vertical: 6.sp), - child: Text( - event == 0 - ? "喜欢" + const SizedBox(height: 8), + Text( event == 0 + ? "看了这么久,给我点个喜欢呗~" : event == 1 - ? "回关" + ? "我喜欢了你,可以喜欢我一下吗?" : event == 2 - ? "私聊" - : "私聊", - style: TextStyle( - color: Colors.white, - fontSize: 14.sp, + ? "你喜欢的人上线啦,赶紧找他聊天吧!" + : "我也喜欢了你,一起聊聊呗~", + style: TextStyle( + color: Colors.grey, + fontSize: 14.sp, + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ], + ), + const Spacer(), + GestureDetector( + onTap: () { + countdownTimer.cancel(); + try { + overlayEntry!.remove(); + } catch (e) { + + } + mainOverlayEntry = null; + noticeCallback(); + + // logic.setLike(); + // logic.showMessage = false; + // logic.update(); + }, + child: Container( + margin: EdgeInsets.only(top: 6.sp), + height: 34, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(17), + gradient: const LinearGradient( + colors: [ + Color(0xFF06F9FA), + Color(0xFFDC5BFD), + ], + begin: Alignment.centerLeft, + end: Alignment.centerRight, + ), + ), + padding: EdgeInsets.symmetric( + horizontal: 16.sp, vertical: 6.sp), + child: Text( + event == 0 + ? "喜欢" + : event == 1 + ? "回关" + : event == 2 + ? "私聊" + : "私聊", + style: TextStyle( + color: Colors.white, + fontSize: 14.sp, + ), ), ), ), - ), - // ), - ], + // ), + ], + ), ), ), ), - ), + if (event == 0) + Positioned( + top: MediaQuery.of(context).padding.top, + right: 8, + child: GestureDetector( + onTap: () { + countdownTimer.cancel(); + // 取消计时器 + try { + overlayEntry!.remove(); + } catch (e) { + + } + mainOverlayEntry = null; + }, + child: Container( + height: 20, + width: 30, + decoration: BoxDecoration( + borderRadius: BorderRadius.only(topRight: Radius.circular(10),bottomLeft: Radius.circular(10)), + gradient: AppColor.mainVerLinearGradient + ), + alignment: Alignment.center, + child: Icon(Icons.close,size: 20,color: Colors.white,), + ), + )) + ], ); }, ); // setState(() {}); showMessage = true; + mainOverlayEntry = overlayEntry; countdownTimer = Timer.periodic(Duration(seconds: 1), (timer) { if (countdownSeconds > 0) { countdownSeconds--; // overlayEntry.markNeedsBuild(); // 刷新 OverlayEntry } else { - timer.cancel(); // 取消计时器 - overlayEntry!.remove(); + timer.cancel(); + + try { + overlayEntry!.remove(); + } catch (e) { + + } + mainOverlayEntry = null; } }); // 将 OverlayEntry 添加到 Overlay 中