import 'dart:convert'; import 'package:extended_text/extended_text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:yumi/shared/data_sources/sources/local/user_manager.dart'; import 'package:marquee/marquee.dart'; import 'package:provider/provider.dart'; import 'package:yumi/app_localizations.dart'; import 'package:yumi/services/general/sc_app_general_manager.dart'; import 'package:yumi/ui_kit/components/sc_compontent.dart'; import 'package:yumi/ui_kit/components/text/sc_text.dart'; import 'package:yumi/ui_kit/components/sc_tts.dart'; import 'package:yumi/app/constants/sc_global_config.dart'; import '../../shared/business_logic/models/res/sc_system_invit_message_res.dart'; class SCSystemMessageUtils { static Widget buildAgentSendInviteHostMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, Function(String id) rejectOpt, Function(String id) acceptOpt, BuildContext context, ) { String expand = data["expand"] ?? ""; if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: Column( children: [ Row( children: [ head(url: bean.userAvatar ?? "", width: 65.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ netImage( url: Provider.of( context, listen: false, ) .findCountryByName( bean.countryName ?? "", ) ?.nationalFlag ?? "", borderRadius: BorderRadius.all( Radius.circular(3.w), ), width: 19.w, height: 14.w, ), SizedBox(width: 3.w), Container( constraints: BoxConstraints(maxWidth: 160.w), child: text( bean.userNickname ?? "", fontWeight: FontWeight.bold, textColor: Colors.white, fontSize: 16.sp, ), ), ], ), GestureDetector( child: Container( padding: EdgeInsets.symmetric(vertical: 8.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (bean.account != bean.actualAccount) ? "sc_images/general/sc_icon_special_id_bg.png" : "sc_images/general/sc_icon_id_bg.png", ), fit: BoxFit.fitWidth, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( bean.actualAccount ?? "", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "sc_images/room/sc_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), onTap: () { Clipboard.setData( ClipboardData(text: bean.actualAccount ?? ""), ); SCTts.show( SCAppLocalizations.of(context)!.copiedToClipboard, ); }, ), ], ), ], ), SizedBox(height: 3.w), Row( children: [ SizedBox(width: 10.w), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xffFF6464), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.reject, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { rejectOpt(expand); }, ), Spacer(), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xff7B64FF), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.accept, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { acceptOpt(expand); }, ), SizedBox(width: 10.w), ], ), Divider(color: Colors.black12, thickness: 0.5, height: 28.w), ExtendedText( SCAppLocalizations.of(context)!.inviteYouToBecomeHost, // specialTextSpanBuilder: MySpecialTextSpanBuilder(), style: TextStyle(fontSize: 14.sp, color: Colors.black54), ), SizedBox(height: 5.w), ], ), ), ); }, ); } return Container(); } static Widget buildBdSendInviteAgentMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, Function(String id) rejectOpt, Function(String id) acceptOpt, BuildContext context, ) { String expand = data["expand"] ?? ""; if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: Column( children: [ Row( children: [ head(url: bean.userAvatar ?? "", width: 65.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ netImage( url: Provider.of( context, listen: false, ) .findCountryByName( bean.countryName ?? "", ) ?.nationalFlag ?? "", borderRadius: BorderRadius.all( Radius.circular(3.w), ), width: 19.w, height: 14.w, ), SizedBox(width: 3.w), Container( constraints: BoxConstraints(maxWidth: 160.w), child: text( bean.userNickname ?? "", fontWeight: FontWeight.bold, textColor: Colors.black, fontSize: 16.sp, ), ), ], ), GestureDetector( child: Container( padding: EdgeInsets.symmetric(vertical: 8.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (bean.account != bean.actualAccount) ? "sc_images/general/sc_icon_special_id_bg.png" : "sc_images/general/sc_icon_id_bg.png", ), fit: BoxFit.fitWidth, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( bean.actualAccount ?? "", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "sc_images/room/sc_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), onTap: () { Clipboard.setData( ClipboardData(text: bean.actualAccount ?? ""), ); SCTts.show( SCAppLocalizations.of(context)!.copiedToClipboard, ); }, ), ], ), ], ), SizedBox(height: 3.w), Row( children: [ SizedBox(width: 10.w), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xffFF6464), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.reject, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { rejectOpt(expand); }, ), Spacer(), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xff7B64FF), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.accept, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { acceptOpt(expand); }, ), SizedBox(width: 10.w), ], ), Divider(color: Colors.black12, thickness: 0.5, height: 28.w), ExtendedText( SCAppLocalizations.of(context)!.inviteYouToBecomeAgent, // specialTextSpanBuilder: MySpecialTextSpanBuilder(), style: TextStyle(fontSize: 14.sp, color: Colors.black54), ), SizedBox(height: 5.w), ], ), ), ); }, ); } return Container(); } static Widget buildBdLeaderInviteBdMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, Function(String id) rejectOpt, Function(String id) acceptOpt, BuildContext context, ) { String expand = data["expand"] ?? ""; if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: Column( children: [ Row( children: [ head(url: bean.userAvatar ?? "", width: 65.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ netImage( url: Provider.of( context, listen: false, ) .findCountryByName( bean.countryName ?? "", ) ?.nationalFlag ?? "", borderRadius: BorderRadius.all( Radius.circular(3.w), ), width: 19.w, height: 14.w, ), SizedBox(width: 3.w), Container( constraints: BoxConstraints(maxWidth: 160.w), child: text( bean.userNickname ?? "", fontWeight: FontWeight.bold, textColor: Colors.black, fontSize: 16.sp, ), ), ], ), GestureDetector( child: Container( padding: EdgeInsets.symmetric(vertical: 8.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (bean.account != bean.actualAccount) ? "sc_images/general/sc_icon_special_id_bg.png" : "sc_images/general/sc_icon_id_bg.png", ), fit: BoxFit.fitWidth, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( bean.actualAccount ?? "", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "sc_images/room/sc_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), onTap: () { Clipboard.setData( ClipboardData(text: bean.actualAccount ?? ""), ); SCTts.show( SCAppLocalizations.of(context)!.copiedToClipboard, ); }, ), ], ), ], ), SizedBox(height: 3.w), Row( children: [ SizedBox(width: 10.w), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xffFF6464), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.reject, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { rejectOpt(expand); }, ), Spacer(), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xff7B64FF), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.accept, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { acceptOpt(expand); }, ), SizedBox(width: 10.w), ], ), Divider(color: Colors.black12, thickness: 0.5, height: 28.w), ExtendedText( SCAppLocalizations.of(context)!.inviteYouToBecomeBD, // specialTextSpanBuilder: MySpecialTextSpanBuilder(), style: TextStyle(fontSize: 14.sp, color: Colors.black54), ), SizedBox(height: 5.w), ], ), ), ); }, ); } return Container(); } static Widget buildBdLeaderInviteBdLeaderMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, Function(String id) rejectOpt, Function(String id) acceptOpt, BuildContext context, ) { String expand = data["expand"] ?? ""; if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: Column( children: [ Row( children: [ head(url: bean.userAvatar ?? "", width: 65.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ netImage( url: Provider.of( context, listen: false, ) .findCountryByName( bean.countryName ?? "", ) ?.nationalFlag ?? "", borderRadius: BorderRadius.all( Radius.circular(3.w), ), width: 19.w, height: 14.w, ), SizedBox(width: 3.w), Container( constraints: BoxConstraints(maxWidth: 160.w), child: text( bean.userNickname ?? "", fontWeight: FontWeight.bold, textColor: Colors.black, fontSize: 16.sp, ), ), ], ), GestureDetector( child: Container( padding: EdgeInsets.symmetric(vertical: 8.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (bean.account != bean.actualAccount) ? "sc_images/general/sc_icon_special_id_bg.png" : "sc_images/general/sc_icon_id_bg.png", ), fit: BoxFit.fitWidth, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( bean.actualAccount ?? "", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "sc_images/room/sc_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), onTap: () { Clipboard.setData( ClipboardData(text: bean.actualAccount ?? ""), ); SCTts.show( SCAppLocalizations.of(context)!.copiedToClipboard, ); }, ), ], ), ], ), SizedBox(height: 3.w), Row( children: [ SizedBox(width: 10.w), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xffFF6464), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.reject, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { rejectOpt(expand); }, ), Spacer(), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xff7B64FF), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.accept, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { acceptOpt(expand); }, ), SizedBox(width: 10.w), ], ), Divider(color: Colors.black12, thickness: 0.5, height: 28.w), ExtendedText( SCAppLocalizations.of( context, )!.bDLeaderInviteYouToBecomeBDLeader, // specialTextSpanBuilder: MySpecialTextSpanBuilder(), style: TextStyle(fontSize: 14.sp, color: Colors.black54), ), SizedBox(height: 5.w), ], ), ), ); }, ); } return Container(); } static Widget buildAdminInviteRechargeAgentMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, Function(String id) rejectOpt, Function(String id) acceptOpt, BuildContext context, ) { String expand = data["expand"] ?? ""; if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: Column( children: [ Row( children: [ head(url: bean.userAvatar ?? "", width: 65.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ netImage( url: Provider.of( context, listen: false, ) .findCountryByName( bean.countryName ?? "", ) ?.nationalFlag ?? "", borderRadius: BorderRadius.all( Radius.circular(3.w), ), width: 19.w, height: 14.w, ), SizedBox(width: 3.w), Container( constraints: BoxConstraints(maxWidth: 160.w), child: text( bean.userNickname ?? "", fontWeight: FontWeight.bold, textColor: Colors.black, fontSize: 16.sp, ), ), ], ), GestureDetector( child: Container( padding: EdgeInsets.symmetric(vertical: 8.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (bean.account != bean.actualAccount) ? "sc_images/general/sc_icon_special_id_bg.png" : "sc_images/general/sc_icon_id_bg.png", ), fit: BoxFit.fitWidth, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( bean.actualAccount ?? "", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "sc_images/room/sc_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), onTap: () { Clipboard.setData( ClipboardData(text: bean.actualAccount ?? ""), ); SCTts.show( SCAppLocalizations.of(context)!.copiedToClipboard, ); }, ), ], ), ], ), SizedBox(height: 3.w), Row( children: [ SizedBox(width: 10.w), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xffFF6464), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.reject, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { rejectOpt(expand); }, ), Spacer(), GestureDetector( child: Container( alignment: AlignmentDirectional.center, height: 25.w, width: 65.w, decoration: BoxDecoration( color: Color(0xff7B64FF), borderRadius: BorderRadius.all( Radius.circular(15.0), ), ), child: text( SCAppLocalizations.of(context)!.accept, fontSize: 14.sp, fontWeight: FontWeight.w600, textColor: Colors.white, ), ), onTap: () { acceptOpt(expand); }, ), SizedBox(width: 10.w), ], ), Divider(color: Colors.black12, thickness: 0.5, height: 28.w), ExtendedText( SCAppLocalizations.of(context)!.adminInviteRechargeAgent, // specialTextSpanBuilder: MySpecialTextSpanBuilder(), style: TextStyle(fontSize: 14.sp, color: Colors.black54), ), SizedBox(height: 5.w), ], ), ), ); }, ); } return Container(); } static Widget buildCPBuildMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, Function(String id) rejectOpt, Function(String id) acceptOpt, BuildContext context, ) { String expand = data["expand"] ?? ""; if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( height: 490.w, width: ScreenUtil().screenWidth * 0.8, decoration: BoxDecoration( image: DecorationImage( image: AssetImage( "sc_images/person/sc_icon_send_cp_requst_dialog_bg.png", ), fit: BoxFit.fill, ), ), child: Column( children: [ SizedBox(height: 58.w), Container( child: text( bean.applyType == "APPLY" ? SCAppLocalizations.of(context)!.cpRequest : SCAppLocalizations.of(context)!.reconcileInvitation, fontSize: 21.sp, textColor: Color(0xffDB5872), fontWeight: FontWeight.bold, ), ), Transform.translate( offset: Offset(0, -23), child: Stack( alignment: AlignmentDirectional.center, children: [ PositionedDirectional( top: 22.w, child: Row( mainAxisSize: MainAxisSize.min, children: [ head(url: bean.userAvatar ?? "", width: 80.w), SizedBox(width: 12.w), head( url: AccountStorage() .getCurrentUser() ?.userProfile ?.userAvatar ?? "", width: 80.w, ), ], ), ), Image.asset( "sc_images/person/sc_icon_send_cp_requst_dialog_head.png", height: 100.w, fit: BoxFit.fill, ), ], ), ), Transform.translate( offset: Offset(0, -23), child: Container( height: 25.w, width: ScreenUtil().screenWidth * 0.6, decoration: BoxDecoration( image: DecorationImage( image: AssetImage( "sc_images/person/sc_icon_send_cp_requst_username_bg.png", ), fit: BoxFit.fill, ), ), child: Row( children: [ Container( alignment: Alignment.center, width: 100.w, height: 15.w, child: (bean.userNickname?.length ?? 0) > 8 ? Marquee( text: bean.userNickname ?? "", style: TextStyle( fontSize: 10.sp, color: Colors.white, fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), scrollAxis: Axis.horizontal, crossAxisAlignment: CrossAxisAlignment.start, blankSpace: 20.0, velocity: 40.0, pauseAfterRound: Duration(seconds: 1), accelerationDuration: Duration( seconds: 1, ), accelerationCurve: Curves.easeOut, decelerationDuration: Duration( milliseconds: 500, ), decelerationCurve: Curves.easeOut, ) : Text( bean.userNickname ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 10.sp, color: Colors.white, fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), ), ), SizedBox(width: 20.w), Container( alignment: Alignment.center, width: 100.w, height: 15.w, child: (AccountStorage() .getCurrentUser() ?.userProfile ?.userNickname ?.length ?? 0) > 8 ? Marquee( text: AccountStorage() .getCurrentUser() ?.userProfile ?.userNickname ?? "", style: TextStyle( fontSize: 10.sp, color: Colors.white, fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), scrollAxis: Axis.horizontal, crossAxisAlignment: CrossAxisAlignment.start, blankSpace: 20.0, velocity: 40.0, pauseAfterRound: Duration(seconds: 1), accelerationDuration: Duration( seconds: 1, ), accelerationCurve: Curves.easeOut, decelerationDuration: Duration( milliseconds: 500, ), decelerationCurve: Curves.easeOut, ) : Text( AccountStorage() .getCurrentUser() ?.userProfile ?.userNickname ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 10.sp, color: Colors.white, fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), ), ), ], ), ), ), Container( padding: EdgeInsets.only(bottom: 12.w), margin: EdgeInsets.symmetric(horizontal: 18.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( "sc_images/person/sc_icon_send_cp_requst_dialog_content.png", ), fit: BoxFit.fill, ), ), child: Column( children: [ Container( margin: EdgeInsets.symmetric( horizontal: 35.w, ).copyWith(top: 40.w), child: text( bean.applyType == "APPLY" ? SCAppLocalizations.of( context, )!.areYouSureYouWantToSpend5( bean.userNickname ?? "", ) : SCAppLocalizations.of( context, )!.areYouSureYouWantToSpend6( bean.userNickname ?? "", ), fontWeight: FontWeight.w500, textColor: Color(0xffFF79A1), maxLines: 7, fontSize: 14.sp, ), ), ], ), ), SizedBox(height: 10.w), Row( mainAxisSize: MainAxisSize.min, children: [ GestureDetector( child: Container( padding: EdgeInsets.only(top: 7.w), alignment: AlignmentDirectional.center, width: 120.w, height: 45.w, decoration: BoxDecoration( image: DecorationImage( image: AssetImage( "sc_images/person/sc_icon_send_cp_requst_cancel_bg.png", ), fit: BoxFit.fill, ), ), child: text( SCAppLocalizations.of(context)!.reject, fontSize: 17.sp, fontWeight: FontWeight.bold, textColor: Colors.white, ), ), onTap: () { rejectOpt(expand); }, ), SizedBox(width: 25.w), GestureDetector( child: Container( padding: EdgeInsets.only(top: 7.w), alignment: AlignmentDirectional.center, width: 120.w, height: 45.w, decoration: BoxDecoration( image: DecorationImage( image: AssetImage( "sc_images/person/sc_icon_send_cp_requst_ok_bg.png", ), fit: BoxFit.fill, ), ), child: text( SCAppLocalizations.of(context)!.accept, fontSize: 17.sp, fontWeight: FontWeight.bold, textColor: Color(0xffDB5872), ), ), onTap: () { acceptOpt(expand); }, ), ], ), ], ), ), ); }, ); } return Container(); } static Widget buildCPLoveLetterMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, BuildContext context, ) { if (data["content"] != null) { var bean = SCSystemInvitMessageRes.fromJson(jsonDecode(data["content"])); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( height: 400.w, width: ScreenUtil().screenWidth * 0.8, decoration: BoxDecoration( image: DecorationImage( image: AssetImage("sc_images/msg/sc_icon_cp_lover_bg.png"), fit: BoxFit.fill, ), ), child: Column( children: [ SizedBox(height: 35.w), Image.asset( SCGlobalConfig.lang == "ar" ? "sc_images/msg/sc_icon_cp_lover_text_ar.png" : "sc_images/msg/sc_icon_cp_lover_text_en.png", width: 110.w, fit: BoxFit.fill, ), SizedBox(height: 45.w), Row( children: [ SizedBox(width: 55.w), netImage( url: bean.userAvatar ?? "", width: 45.w, height: 45.w, shape: BoxShape.circle, ), Column( children: [ Row( children: [ Container( alignment: Alignment.center, width: 100.w, height: 15.w, child: (bean.userNickname?.length ?? 0) > 8 ? Marquee( text: bean.userNickname ?? "", style: TextStyle( fontSize: 12.sp, color: Color(0xffDB5872), fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), scrollAxis: Axis.horizontal, crossAxisAlignment: CrossAxisAlignment.start, blankSpace: 20.0, velocity: 40.0, pauseAfterRound: Duration(seconds: 1), accelerationDuration: Duration( seconds: 1, ), accelerationCurve: Curves.easeOut, decelerationDuration: Duration( milliseconds: 500, ), decelerationCurve: Curves.easeOut, ) : Text( bean.userNickname ?? "", maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 12.sp, color: Color(0xffDB5872), fontWeight: FontWeight.w600, decoration: TextDecoration.none, ), ), ), ], ), GestureDetector( child: Container( padding: EdgeInsets.symmetric(vertical: 8.w), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (bean.account != bean.actualAccount) ? "sc_images/general/sc_icon_special_id_bg.png" : "sc_images/general/sc_icon_id_bg.png", ), fit: BoxFit.fitWidth, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( bean.actualAccount ?? "", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "sc_images/room/sc_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), onTap: () { Clipboard.setData( ClipboardData(text: bean.actualAccount ?? ""), ); SCTts.show( SCAppLocalizations.of(context)!.copiedToClipboard, ); }, ), ], ), ], ), SizedBox(height: 5.w), Container( height: 160.w, margin: EdgeInsets.symmetric(horizontal: 53.w), child: SingleChildScrollView( child: ExtendedText( bean.content ?? "", style: TextStyle( fontSize: 12.sp, color: Color(0xffDB5872), fontWeight: FontWeight.w600, ), ), ), ), ], ), ), ); }, ); } return Container(); } static Widget buildUserCoinsReceivedMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, BuildContext context, ) { if (data["content"] != null) { return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, ""); }, child: Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [BoxShadow(blurRadius: 2.w, color: Colors.black26)], borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: Column( children: [ text( SCAppLocalizations.of(context)!.coinsReceived, fontSize: 16.sp, textColor: Colors.black, fontWeight: FontWeight.bold, ), ExtendedText( data["content"], // specialTextSpanBuilder: MySpecialTextSpanBuilder(), style: TextStyle(fontSize: 14.sp, color: Colors.black54), ) ], ), ), ); }, ); } return Container(); } static Widget buildRegisterRewardGrantedMessage( data, Function(BuildContext ct, String content) showMsgItemMenu, BuildContext context, ) { final content = _registerRewardGrantedContent(data, context); return Builder( builder: (ct) { return GestureDetector( onLongPress: () { showMsgItemMenu(ct, content); }, child: Container( decoration: BoxDecoration( color: Colors.white, boxShadow: [BoxShadow(blurRadius: 2.w, color: Colors.black26)], borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(8.w), bottomLeft: Radius.circular(8.w), bottomRight: Radius.circular(8), ), ), padding: EdgeInsets.all(8.0.w), child: ExtendedText( content, style: TextStyle(fontSize: 14.sp, color: Colors.black54), ), ), ); }, ); } static String _registerRewardGrantedContent( dynamic data, BuildContext context, ) { final l10n = SCAppLocalizations.of(context)!; final rewards = _extractRegisterRewardItems(data) .map((item) => _registerRewardItemLabel(l10n, item)) .where((item) => item.isNotEmpty) .toList(); if (rewards.isNotEmpty) { return l10n.registerRewardReceived(rewards.join(', ')); } final plainContent = _plainRegisterRewardContent(data); if (plainContent.isNotEmpty) { return l10n.registerRewardReceived(plainContent); } return l10n.receiveSucc; } static List _extractRegisterRewardItems(dynamic value) { final decoded = _decodeJsonValue(value); if (decoded is List) { return decoded; } if (decoded is Map) { final nestedItems = _extractNestedRegisterRewardItems(decoded); if (nestedItems.isNotEmpty) { return nestedItems; } if (_looksLikeRewardItem(decoded)) { return [decoded]; } } return const []; } static String _registerRewardItemLabel( SCAppLocalizations l10n, dynamic item, ) { final decoded = _decodeJsonValue(item); if (decoded is! Map) { return _readPlainText(decoded); } if (!_looksLikeRewardItem(decoded)) { final nestedItems = _extractNestedRegisterRewardItems(decoded); if (nestedItems.isNotEmpty) { return nestedItems .map((item) => _registerRewardItemLabel(l10n, item)) .where((item) => item.isNotEmpty) .join(', '); } } final type = _readPlainText(decoded['type']).trim().toUpperCase(); final detailType = _readPlainText(decoded['detailType']).trim().toUpperCase(); final quantity = _rewardQuantity(decoded); if (type == 'GOLD' || type == 'COIN' || type == 'COINS' || detailType == 'GOLD' || detailType == 'COIN' || detailType == 'COINS') { return l10n.coins2(quantity.isEmpty ? '0' : quantity); } final name = _pickFirstNonEmpty([ _readPlainText(decoded['name']), _readPlainText(decoded['badgeName']), _readPlainText(decoded['remark']), _readPlainText(decoded['title']), _readPlainText(decoded['content']), detailType, type, ]); if (name.isEmpty) { return ''; } final count = _asInt(decoded['quantity']); if (count > 1) { return '$name x$count'; } return name; } static List _extractNestedRegisterRewardItems( Map value, ) { const nestedKeys = [ 'rewardItems', 'rewards', 'items', 'activityRewardProps', 'rewardConfig', 'propsGroup', 'propsGroups', 'data', 'content', ]; for (final key in nestedKeys) { final items = _extractRegisterRewardItems(value[key]); if (items.isNotEmpty) { return items; } } return const []; } static String _rewardQuantity(Map item) { final quantity = _asInt(item['quantity']); if (quantity > 0) { return quantity.toString(); } return _pickFirstNonEmpty([ _readPlainText(item['amount']), _readPlainText(item['content']), ]); } static String _plainRegisterRewardContent(dynamic data) { final decoded = _decodeJsonValue(data); if (decoded is Map) { return _pickFirstNonEmpty([ _readPlainText(decoded['message']), _readPlainText(decoded['title']), _readPlainText(decoded['content']), ]); } return _readPlainText(decoded); } static dynamic _decodeJsonValue(dynamic value) { if (value is! String) { return value; } final text = value.trim(); if (!_looksLikeStructuredText(text)) { return value; } try { return jsonDecode(text); } catch (_) { return value; } } static bool _looksLikeRewardItem(Map value) { const rewardKeys = [ 'type', 'detailType', 'name', 'quantity', 'amount', 'remark', 'badgeName', ]; return rewardKeys.any(value.containsKey); } static String _pickFirstNonEmpty(List values) { for (final value in values) { final text = value.trim(); if (text.isNotEmpty) { return text; } } return ''; } static String _readPlainText(dynamic value) { final text = _asString(value).trim(); if (text.isEmpty || _looksLikeStructuredText(text)) { return ''; } return text; } static bool _looksLikeStructuredText(String value) { final text = value.trimLeft(); return text.startsWith('{') || text.startsWith('['); } static String _asString(dynamic value) { if (value == null) { return ''; } return value.toString(); } static int _asInt(dynamic value) { if (value is int) { return value; } if (value is num) { return value.toInt(); } return int.tryParse(_asString(value)) ?? 0; } }